@smyslenny/agent-memory 5.0.0 → 5.0.2
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/.github/workflows/test.yml +1 -1
- package/.pnpm-approve-builds.json +1 -0
- package/CHANGELOG.md +115 -0
- package/README.md +52 -15
- package/dist/bin/agent-memory.js +88 -16
- package/dist/bin/agent-memory.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +93 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +174 -13884
- package/dist/mcp/server.js.map +1 -1
- package/docs/README-zh.md +133 -15
- package/docs/architecture.md +1 -1
- package/docs/integrations/openclaw.md +1 -1
- package/package.json +4 -3
package/docs/README-zh.md
CHANGED
|
@@ -1,23 +1,141 @@
|
|
|
1
|
-
# AgentMemory
|
|
1
|
+
# AgentMemory 简体中文说明
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 面向 AI Agent 的记忆层,支持 CLI / MCP / HTTP,SQLite 优先,零外部依赖即可运行。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**完整文档请参阅 [README.md](../README.md)(英文)**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
当前版本:**v5.0.1**
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
> 检索质量,以及生命周期管理(decay / govern / reindex / feedback)。
|
|
9
|
+
---
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
## 一句话定位
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- [OpenClaw integration](integrations/openclaw.md)
|
|
17
|
-
- [Architecture overview](architecture.md)
|
|
13
|
+
AgentMemory 是一个 **agent 原生的记忆层**,不是向量数据库,不是 RAG 框架。
|
|
14
|
+
它专注于:写入质量控制、结构化检索、生命周期管理(衰减 / 治理 / 反馈)。
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
## v5.0 新特性:Memory Intelligence
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
v5 是重大特性版本,新增 6 项智能能力,全部向下兼容 v4:
|
|
19
|
+
|
|
20
|
+
| 特性 | 说明 |
|
|
21
|
+
|------|------|
|
|
22
|
+
| **F1 记忆关联** | 写入时自动检测语义相关记忆并建立轻量关联,召回时可展开相关记忆 |
|
|
23
|
+
| **F2 冲突检测** | 写入时检测与已有记忆的否定词/数值/状态冲突,报告但不阻止写入 |
|
|
24
|
+
| **F3 时间维度召回** | `recall`/`surface` 支持 `after`/`before` 时间过滤 + `recency_boost` |
|
|
25
|
+
| **F4 被动反馈** | `recall` 返回结果自动记录正面反馈(24h 防重复,无需主动调用) |
|
|
26
|
+
| **F5 语义衰减** | `reflect` 阶段识别过时内容(进行中/待办/临时),加速衰减 |
|
|
27
|
+
| **F6 记忆溯源** | 每条记忆携带来源元数据(session_id、触发上下文、实际发生时间) |
|
|
28
|
+
|
|
29
|
+
### 冲突否决规则(v5 亮点)
|
|
30
|
+
|
|
31
|
+
当两条记忆高度相似(dedup_score ≥ 0.93)但检测到状态或数值冲突时,
|
|
32
|
+
系统会强制将 `skip`(跳过)降级为 `update`(更新),防止状态变更被去重吞掉。
|
|
33
|
+
|
|
34
|
+
例:旧记忆 "TODO: 修复 bug" → 新写入 "DONE: 修复 bug",不会被当作重复跳过。
|
|
35
|
+
|
|
36
|
+
## 核心概念
|
|
37
|
+
|
|
38
|
+
- **四种记忆类型**:`identity`(身份)、`emotion`(情感)、`knowledge`(知识)、`event`(事件)
|
|
39
|
+
- **URI 路径**:稳定寻址(如 `core://user/name`、`emotion://2026-03-20/happy`)
|
|
40
|
+
- **Write Guard**:语义去重 + 类型化合并策略 + 四准则门控 + 冲突检测
|
|
41
|
+
- **双路召回**:BM25(必选)+ 向量搜索(可选),支持关联展开和时间过滤
|
|
42
|
+
- **上下文感知 Surface**:基于 task/recent_turns/intent 的主动记忆浮现
|
|
43
|
+
- **生命周期管理**:Ebbinghaus 衰减 + 语义衰减 + 治理 + 反馈信号
|
|
44
|
+
|
|
45
|
+
## 快速开始
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @smyslenny/agent-memory
|
|
49
|
+
|
|
50
|
+
export AGENT_MEMORY_DB=./agent-memory.db
|
|
51
|
+
export AGENT_MEMORY_AGENT_ID=my-agent
|
|
52
|
+
|
|
53
|
+
# 写入记忆
|
|
54
|
+
npx agent-memory remember "小心喜欢低饱和风格的 UI" --type knowledge
|
|
55
|
+
|
|
56
|
+
# 召回记忆
|
|
57
|
+
npx agent-memory recall "UI 风格偏好" --limit 5
|
|
58
|
+
|
|
59
|
+
# 启动记忆(加载身份+核心记忆)
|
|
60
|
+
npx agent-memory boot
|
|
61
|
+
|
|
62
|
+
# 运行维护周期(衰减+清理+治理)
|
|
63
|
+
npx agent-memory reflect all
|
|
64
|
+
|
|
65
|
+
# 查看状态
|
|
66
|
+
npx agent-memory status
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## MCP 集成(11 个工具)
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"agent-memory": {
|
|
75
|
+
"command": "node",
|
|
76
|
+
"args": ["./node_modules/@smyslenny/agent-memory/dist/mcp/server.js"],
|
|
77
|
+
"env": {
|
|
78
|
+
"AGENT_MEMORY_DB": "./agent-memory.db",
|
|
79
|
+
"AGENT_MEMORY_AGENT_ID": "my-agent"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| 工具 | 说明 |
|
|
87
|
+
|------|------|
|
|
88
|
+
| `remember` | 写入记忆(经 Write Guard 去重),支持 `session_id`/`context`/`observed_at` 溯源 |
|
|
89
|
+
| `recall` | 双路召回,支持 `after`/`before`/`recency_boost`/`related` 参数 |
|
|
90
|
+
| `recall_path` | 按 URI 路径精确查找或前缀列表 |
|
|
91
|
+
| `surface` | 上下文感知记忆浮现(query + task + recent_turns + intent) |
|
|
92
|
+
| `boot` | 启动加载(叙事格式或 JSON) |
|
|
93
|
+
| `forget` | 软衰减或硬删除 |
|
|
94
|
+
| `reflect` | 运行维护周期(decay / tidy / govern / all) |
|
|
95
|
+
| `status` | 记忆系统统计 |
|
|
96
|
+
| `ingest` | 从 Markdown 文本提取结构化记忆 |
|
|
97
|
+
| `reindex` | 重建 BM25 索引和(可选的)向量嵌入 |
|
|
98
|
+
| `link` | **v5 新增** — 手动创建/删除记忆关联 |
|
|
99
|
+
|
|
100
|
+
## 环境变量
|
|
101
|
+
|
|
102
|
+
| 变量 | 默认值 | 说明 |
|
|
103
|
+
|------|--------|------|
|
|
104
|
+
| `AGENT_MEMORY_DB` | `./agent-memory.db` | SQLite 数据库路径 |
|
|
105
|
+
| `AGENT_MEMORY_AGENT_ID` | `default` | Agent 作用域 ID |
|
|
106
|
+
| `AGENT_MEMORY_MAX_MEMORIES` | `200` | 治理引擎的记忆上限,超出时按 eviction score 淘汰 |
|
|
107
|
+
| `AGENT_MEMORY_AUTO_INGEST` | `1` | 是否启用 auto-ingest 文件监听 |
|
|
108
|
+
| `AGENT_MEMORY_AUTO_INGEST_DAILY` | `0` | 是否监听日记文件(YYYY-MM-DD.md),默认只监听 MEMORY.md |
|
|
109
|
+
| `AGENT_MEMORY_EMBEDDING_PROVIDER` | _(空)_ | 嵌入提供者(`openai-compatible` / `gemini` / `local-http`) |
|
|
110
|
+
| `AGENT_MEMORY_EMBEDDING_MODEL` | _(空)_ | 嵌入模型名称 |
|
|
111
|
+
| `AGENT_MEMORY_EMBEDDING_BASE_URL` | _(空)_ | 嵌入 API 地址 |
|
|
112
|
+
| `AGENT_MEMORY_EMBEDDING_API_KEY` | _(空)_ | 嵌入 API 密钥 |
|
|
113
|
+
| `AGENT_MEMORY_EMBEDDING_DIMENSION` | _(空)_ | 嵌入向量维度 |
|
|
114
|
+
|
|
115
|
+
## 推荐架构
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
日记写入(实时)
|
|
119
|
+
│
|
|
120
|
+
├─ MEMORY.md ←── auto-ingest 监听(兜底)
|
|
121
|
+
│
|
|
122
|
+
└─ memory/YYYY-MM-DD.md
|
|
123
|
+
│
|
|
124
|
+
├─ memory-sync cron (14:00/22:00)
|
|
125
|
+
│ └─ LLM 清洗 → 精选 → remember 写入 agent-memory
|
|
126
|
+
│
|
|
127
|
+
└─ memory-tidy cron (03:00)
|
|
128
|
+
└─ 压缩旧日记 → 蒸馏 MEMORY.md → reflect 维护
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 更多文档
|
|
132
|
+
|
|
133
|
+
- [架构概览](architecture.md)
|
|
134
|
+
- [通用运行时集成](integrations/generic.md)
|
|
135
|
+
- [OpenClaw 集成](integrations/openclaw.md)
|
|
136
|
+
- [v3 → v4 迁移指南](migration-v3-v4.md)
|
|
137
|
+
- [v5 设计文档 (DD-0018)](design/0018-v5-memory-intelligence.md)
|
|
138
|
+
|
|
139
|
+
## 许可证
|
|
140
|
+
|
|
141
|
+
MIT
|
package/docs/architecture.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<img src="assets/architecture-diagram.jpg" alt="AgentMemory Architecture" width="800" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
AgentMemory
|
|
7
|
+
AgentMemory v5 is a **SQLite-first, agent-native memory layer** with three
|
|
8
8
|
independent but connected paths:
|
|
9
9
|
|
|
10
10
|
1. **Write path** — capture durable memories safely
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
OpenClaw is a **good host example**, not a requirement for AgentMemory.
|
|
4
4
|
|
|
5
|
-
If you are using OpenClaw, this guide shows how to integrate AgentMemory
|
|
5
|
+
If you are using OpenClaw, this guide shows how to integrate AgentMemory v5
|
|
6
6
|
without making OpenClaw-specific assumptions part of the product definition.
|
|
7
7
|
|
|
8
8
|
## When to use this guide
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smyslenny/agent-memory",
|
|
3
|
-
"version": "5.0.
|
|
4
|
-
"description": "Agent-native memory layer with lifecycle management for AI agents
|
|
3
|
+
"version": "5.0.2",
|
|
4
|
+
"description": "Agent-native memory layer with lifecycle management for AI agents — SQLite-first, Write Guard, hybrid recall, MCP, CLI, and HTTP API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
54
54
|
"@node-rs/jieba": "^2.0.1",
|
|
55
55
|
"better-sqlite3": "^11.8.1",
|
|
56
|
-
"uuid": "^11.1.0"
|
|
56
|
+
"uuid": "^11.1.0",
|
|
57
|
+
"zod": "^4.3.6"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/better-sqlite3": "^7.6.13",
|