@smyslenny/agent-memory 3.1.0 → 4.0.0-alpha.1
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/CHANGELOG.md +122 -4
- package/README.md +229 -84
- package/dist/bin/agent-memory.js +2458 -313
- package/dist/bin/agent-memory.js.map +1 -1
- package/dist/index.d.ts +513 -76
- package/dist/index.js +2519 -357
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +2250 -684
- package/dist/mcp/server.js.map +1 -1
- package/docs/README-zh.md +23 -0
- package/docs/architecture.md +239 -0
- package/docs/assets/architecture-diagram.jpg +0 -0
- package/docs/assets/banner.jpg +0 -0
- package/docs/assets/icon.jpg +0 -0
- package/docs/assets/npm-badge.jpg +0 -0
- package/docs/assets/social-preview.jpg +0 -0
- package/docs/design/0015-v4-overhaul.md +631 -0
- package/docs/integrations/generic.md +293 -0
- package/docs/integrations/openclaw.md +148 -0
- package/docs/migration-v3-v4.md +236 -0
- package/package.json +11 -4
- package/README.en.md +0 -153
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# AgentMemory 中文说明
|
|
2
|
+
|
|
3
|
+
AgentMemory 的主 README 已统一为英文:
|
|
4
|
+
|
|
5
|
+
- [README.md](../README.md)
|
|
6
|
+
|
|
7
|
+
v4 的一句话定位:
|
|
8
|
+
|
|
9
|
+
> 面向 AI agent 的 memory layer,支持 CLI / MCP / HTTP,强调写入质量、
|
|
10
|
+
> 检索质量,以及生命周期管理(decay / govern / reindex / feedback)。
|
|
11
|
+
|
|
12
|
+
如果你是从 v3 或 OpenClaw 场景过来的,建议先看:
|
|
13
|
+
|
|
14
|
+
- [v3 → v4 migration guide](migration-v3-v4.md)
|
|
15
|
+
- [Generic runtime integration](integrations/generic.md)
|
|
16
|
+
- [OpenClaw integration](integrations/openclaw.md)
|
|
17
|
+
- [Architecture overview](architecture.md)
|
|
18
|
+
|
|
19
|
+
说明:
|
|
20
|
+
|
|
21
|
+
- v4 不再默认假设你使用 OpenClaw
|
|
22
|
+
- `memory/*.md + MEMORY.md` 现在是 **optional workflow**,不是产品定义
|
|
23
|
+
- OpenClaw 仍然支持,但被下沉为一个实践良好的宿主示例
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/architecture-diagram.jpg" alt="AgentMemory Architecture" width="800" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
AgentMemory v4 is a **SQLite-first, agent-native memory layer** with three
|
|
8
|
+
independent but connected paths:
|
|
9
|
+
|
|
10
|
+
1. **Write path** — capture durable memories safely
|
|
11
|
+
2. **Read path** — retrieve or surface the right memories at the right time
|
|
12
|
+
3. **Lifecycle path** — keep the memory store healthy over time
|
|
13
|
+
|
|
14
|
+
The same application core is exposed through **CLI**, **MCP stdio**, and
|
|
15
|
+
**HTTP/SSE**.
|
|
16
|
+
|
|
17
|
+
## System overview
|
|
18
|
+
|
|
19
|
+
```mermaid
|
|
20
|
+
flowchart LR
|
|
21
|
+
subgraph Transport[Transport layer]
|
|
22
|
+
CLI[CLI]
|
|
23
|
+
MCP[MCP stdio]
|
|
24
|
+
HTTP[HTTP / SSE]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
subgraph Core[Application core]
|
|
28
|
+
REM[remember / ingest]
|
|
29
|
+
REC[recall / surface / boot]
|
|
30
|
+
LIFE[reflect / reindex / feedback]
|
|
31
|
+
GUARD[Write Guard]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
subgraph Store[SQLite-first storage]
|
|
35
|
+
MEM[(memories)]
|
|
36
|
+
PATH[(paths)]
|
|
37
|
+
FTS[(FTS / BM25)]
|
|
38
|
+
EMB[(embeddings, optional)]
|
|
39
|
+
JOB[(maintenance_jobs)]
|
|
40
|
+
FB[(feedback_events)]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
CLI --> REM
|
|
44
|
+
CLI --> REC
|
|
45
|
+
CLI --> LIFE
|
|
46
|
+
MCP --> REM
|
|
47
|
+
MCP --> REC
|
|
48
|
+
MCP --> LIFE
|
|
49
|
+
HTTP --> REM
|
|
50
|
+
HTTP --> REC
|
|
51
|
+
HTTP --> LIFE
|
|
52
|
+
|
|
53
|
+
REM --> GUARD
|
|
54
|
+
GUARD --> MEM
|
|
55
|
+
GUARD --> PATH
|
|
56
|
+
GUARD --> FTS
|
|
57
|
+
GUARD --> EMB
|
|
58
|
+
|
|
59
|
+
REC --> MEM
|
|
60
|
+
REC --> PATH
|
|
61
|
+
REC --> FTS
|
|
62
|
+
REC --> EMB
|
|
63
|
+
|
|
64
|
+
LIFE --> MEM
|
|
65
|
+
LIFE --> FTS
|
|
66
|
+
LIFE --> EMB
|
|
67
|
+
LIFE --> JOB
|
|
68
|
+
LIFE --> FB
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Write path
|
|
72
|
+
|
|
73
|
+
The write path exists to answer a hard question safely:
|
|
74
|
+
|
|
75
|
+
> Should this become memory at all, and if yes, should it create, merge, or be
|
|
76
|
+
> rejected?
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
flowchart TD
|
|
80
|
+
A[Runtime event / durable fact] --> B[remember or ingest]
|
|
81
|
+
B --> C[Normalize input]
|
|
82
|
+
C --> D[Write Guard]
|
|
83
|
+
D -->|reject| E[No write]
|
|
84
|
+
D -->|create| F[New memory row]
|
|
85
|
+
D -->|merge| G[Typed merge policy]
|
|
86
|
+
F --> H[Update path index]
|
|
87
|
+
G --> H
|
|
88
|
+
H --> I[Update BM25 / FTS]
|
|
89
|
+
H --> J[Mark embedding pending if provider configured]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### What happens here
|
|
93
|
+
|
|
94
|
+
- **Typed memory model** maps memories into `identity`, `emotion`, `knowledge`,
|
|
95
|
+
and `event`
|
|
96
|
+
- **URI paths** give you stable addressing like
|
|
97
|
+
`knowledge://users/alice/preferences/theme`
|
|
98
|
+
- **Write Guard** checks for duplicates and near-duplicates before writing
|
|
99
|
+
- **Typed merge policy** decides whether similar memories should be updated,
|
|
100
|
+
merged, or left alone
|
|
101
|
+
- **Embeddings are optional** — memory creation does not depend on them
|
|
102
|
+
|
|
103
|
+
### Why this matters
|
|
104
|
+
|
|
105
|
+
A memory system that only appends will eventually become noisy. The write path
|
|
106
|
+
in v4 is built to improve **memory quality at insertion time**, not only at
|
|
107
|
+
query time.
|
|
108
|
+
|
|
109
|
+
## Read path
|
|
110
|
+
|
|
111
|
+
The read path supports three different retrieval behaviors:
|
|
112
|
+
|
|
113
|
+
- **`boot`** — load startup identity and pinned context
|
|
114
|
+
- **`recall`** — explicit search when the agent is asking a memory question
|
|
115
|
+
- **`surface`** — proactive, task-aware context surfacing before a response or
|
|
116
|
+
planning step
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
flowchart TD
|
|
120
|
+
A[Startup / query / task] --> B{Operation}
|
|
121
|
+
B -->|boot| C[Load identity + boot paths]
|
|
122
|
+
B -->|recall| D[BM25 retrieval]
|
|
123
|
+
B -->|surface| E[Task-aware candidate selection]
|
|
124
|
+
D --> F{Embedding provider configured?}
|
|
125
|
+
E --> G[Recent turns / intent / type filters]
|
|
126
|
+
F -->|no| H[BM25-only ranking]
|
|
127
|
+
F -->|yes| I[Vector search + fusion]
|
|
128
|
+
G --> J[Priority + vitality + feedback scoring]
|
|
129
|
+
I --> K[Ranked results]
|
|
130
|
+
H --> K
|
|
131
|
+
J --> L[Surfaced context]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Recall
|
|
135
|
+
|
|
136
|
+
`recall` is for explicit lookup:
|
|
137
|
+
|
|
138
|
+
- BM25 is always available
|
|
139
|
+
- vector search is added only when an embedding provider is configured
|
|
140
|
+
- fusion keeps the system useful even in partial or degraded environments
|
|
141
|
+
|
|
142
|
+
### Surface
|
|
143
|
+
|
|
144
|
+
`surface` is for proactive context:
|
|
145
|
+
|
|
146
|
+
- it can use `task`, `query`, `recent_turns`, `intent`, and `types`
|
|
147
|
+
- it is **readonly** and does **not** record access by default
|
|
148
|
+
- it uses feedback signals and memory priors to bias what gets surfaced
|
|
149
|
+
|
|
150
|
+
### Boot
|
|
151
|
+
|
|
152
|
+
`boot` is the startup path:
|
|
153
|
+
|
|
154
|
+
- load high-priority identity memories
|
|
155
|
+
- optionally load URI paths referenced by `system://boot`
|
|
156
|
+
- give the agent a stable self/context seed at session start
|
|
157
|
+
|
|
158
|
+
## Lifecycle path
|
|
159
|
+
|
|
160
|
+
AgentMemory is not just a write/read cache. It has a maintenance path for
|
|
161
|
+
keeping memory healthy across time.
|
|
162
|
+
|
|
163
|
+
```mermaid
|
|
164
|
+
flowchart TD
|
|
165
|
+
A[Scheduler / operator / runtime] --> B{Lifecycle operation}
|
|
166
|
+
B -->|reflect| C[decay -> tidy -> govern]
|
|
167
|
+
B -->|reindex| D[Rebuild FTS + embeddings]
|
|
168
|
+
B -->|feedback| E[Record usefulness]
|
|
169
|
+
|
|
170
|
+
C --> F[(maintenance_jobs)]
|
|
171
|
+
D --> F
|
|
172
|
+
E --> G[(feedback_events)]
|
|
173
|
+
|
|
174
|
+
C --> H[(memories)]
|
|
175
|
+
D --> I[(FTS / embeddings)]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Reflect
|
|
179
|
+
|
|
180
|
+
`reflect` runs lifecycle maintenance phases:
|
|
181
|
+
|
|
182
|
+
- **decay** — lower vitality over time with type-aware priors
|
|
183
|
+
- **tidy** — consolidate or normalize where appropriate
|
|
184
|
+
- **govern** — enforce quotas and clean low-value memory over time
|
|
185
|
+
|
|
186
|
+
In v4, reflect jobs are tracked through **maintenance checkpoints**, which makes
|
|
187
|
+
longer jobs more observable and more recovery-friendly.
|
|
188
|
+
|
|
189
|
+
### Reindex
|
|
190
|
+
|
|
191
|
+
`reindex` is the maintenance bridge between storage and retrieval:
|
|
192
|
+
|
|
193
|
+
- rebuilds BM25 / FTS state
|
|
194
|
+
- fills or refreshes embeddings when a provider is configured
|
|
195
|
+
- supports incremental backfill or full rebuild
|
|
196
|
+
|
|
197
|
+
### Feedback
|
|
198
|
+
|
|
199
|
+
`feedback` closes the loop:
|
|
200
|
+
|
|
201
|
+
- record whether a surfaced or recalled memory was useful
|
|
202
|
+
- let future surfacing/ranking be influenced by actual utility
|
|
203
|
+
|
|
204
|
+
## Optional Markdown workflow
|
|
205
|
+
|
|
206
|
+
AgentMemory no longer assumes a specific host workflow, but it still supports a
|
|
207
|
+
human-editable file layer when you want it.
|
|
208
|
+
|
|
209
|
+
Typical options:
|
|
210
|
+
|
|
211
|
+
- use `migrate` to import an existing `MEMORY.md` / journal directory
|
|
212
|
+
- use `ingest` to extract structured memories from markdown text
|
|
213
|
+
- use watcher-based ingest only when your runtime provides a real workspace to
|
|
214
|
+
watch
|
|
215
|
+
|
|
216
|
+
This keeps Markdown as an **optional integration choice**, not the definition of
|
|
217
|
+
what AgentMemory is.
|
|
218
|
+
|
|
219
|
+
## Transport choices
|
|
220
|
+
|
|
221
|
+
| Transport | Best for | Notes |
|
|
222
|
+
| --- | --- | --- |
|
|
223
|
+
| CLI | local scripts, cron jobs, shell workflows | simplest operational path |
|
|
224
|
+
| MCP stdio | tool-using LLM runtimes | great when your host already speaks MCP |
|
|
225
|
+
| HTTP/SSE | long-lived services, polyglot runtimes | avoids per-call process spawn overhead |
|
|
226
|
+
|
|
227
|
+
## Design principles
|
|
228
|
+
|
|
229
|
+
- **SQLite-first**: local-first, low-friction deployment
|
|
230
|
+
- **Optional semantics**: BM25-only remains valid without embeddings
|
|
231
|
+
- **Shared application core**: transports do not duplicate memory logic
|
|
232
|
+
- **Lifecycle-aware**: memory quality is managed over time, not left to drift
|
|
233
|
+
- **Agent-native**: typed memories, boot, surface, and feedback are first-class
|
|
234
|
+
|
|
235
|
+
## Related docs
|
|
236
|
+
|
|
237
|
+
- [Generic integration guide](integrations/generic.md)
|
|
238
|
+
- [OpenClaw integration guide](integrations/openclaw.md)
|
|
239
|
+
- [Migration guide: v3 → v4](migration-v3-v4.md)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|