@smyslenny/agent-memory 5.0.1 → 5.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/.github/workflows/test.yml +1 -1
- package/.pnpm-approve-builds.json +1 -0
- package/CHANGELOG.md +153 -0
- package/README.md +52 -15
- package/dist/bin/agent-memory.js +285 -27
- package/dist/bin/agent-memory.js.map +1 -1
- package/dist/index.d.ts +77 -3
- package/dist/index.js +354 -26
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +604 -13997
- package/dist/mcp/server.js.map +1 -1
- package/docs/README-zh.md +132 -15
- package/docs/architecture.md +1 -1
- package/docs/integrations/generic.md +43 -3
- package/docs/integrations/openclaw.md +48 -8
- package/docs/migration-v3-v4.md +15 -0
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"better-sqlite3@11.10.0": true, "esbuild@0.27.4": true}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.1.0 (2026-03-20)
|
|
4
|
+
|
|
5
|
+
### ✨ Features
|
|
6
|
+
|
|
7
|
+
#### Archive on Eviction (淘汰归档)
|
|
8
|
+
|
|
9
|
+
- Memories evicted by governance are now **archived** to `memory_archive` instead
|
|
10
|
+
of permanently deleted. Only memories with `vitality ≥ 0.1` are archived;
|
|
11
|
+
lower-vitality memories (decayed noise) are still directly deleted.
|
|
12
|
+
- New schema v8: adds `memory_archive` table (migration `v7 → v8` runs
|
|
13
|
+
automatically on startup).
|
|
14
|
+
- New core functions: `archiveMemory()`, `restoreMemory()`, `listArchivedMemories()`,
|
|
15
|
+
`purgeArchive()`.
|
|
16
|
+
- New MCP tool **`archive`**: `list` / `restore` / `purge` actions for managing
|
|
17
|
+
archived memories.
|
|
18
|
+
- `GovernResult` now includes `archived` (count of memories actually written to
|
|
19
|
+
the archive table) and `evictedByType` breakdown.
|
|
20
|
+
|
|
21
|
+
#### Tiered Capacity (分层容量)
|
|
22
|
+
|
|
23
|
+
- Governance now enforces **per-type capacity limits** before the global cap.
|
|
24
|
+
Defaults: `identity: unlimited`, `emotion: 50`, `knowledge: 250`, `event: 50`,
|
|
25
|
+
`total: 350`.
|
|
26
|
+
- Configurable via environment variables: `AGENT_MEMORY_MAX_IDENTITY`,
|
|
27
|
+
`AGENT_MEMORY_MAX_EMOTION`, `AGENT_MEMORY_MAX_KNOWLEDGE`,
|
|
28
|
+
`AGENT_MEMORY_MAX_EVENT`, `AGENT_MEMORY_MAX_MEMORIES`.
|
|
29
|
+
- `status` MCP tool now returns a `capacity` object showing per-type counts and
|
|
30
|
+
limits.
|
|
31
|
+
- Identity memories (P0) are **never evicted** unless an explicit
|
|
32
|
+
`AGENT_MEMORY_MAX_IDENTITY` is set.
|
|
33
|
+
|
|
34
|
+
### ♻️ Notes
|
|
35
|
+
|
|
36
|
+
- Tidy phase (`runTidy`) still deletes low-vitality memories directly — no
|
|
37
|
+
archiving. Only govern-phase evictions (capacity-based) go to the archive.
|
|
38
|
+
- All new parameters have defaults; upgrading from 5.0.x requires no config
|
|
39
|
+
changes. Schema migration is automatic.
|
|
40
|
+
|
|
41
|
+
## 5.0.1 (2026-03-20)
|
|
42
|
+
|
|
43
|
+
### 🐛 Fixes
|
|
44
|
+
|
|
45
|
+
- **auto-ingest**: Daily log files (`YYYY-MM-DD.md`) are now skipped by default.
|
|
46
|
+
Only `MEMORY.md` (curated memory) is watched and ingested. Daily logs are raw
|
|
47
|
+
journals that often contain noise — they should be processed through the
|
|
48
|
+
memory-sync cron pipeline instead.
|
|
49
|
+
- New environment variable `AGENT_MEMORY_AUTO_INGEST_DAILY=1` restores the
|
|
50
|
+
previous behavior of ingesting all `.md` files in the `memory/` directory.
|
|
51
|
+
|
|
52
|
+
## 5.0.0 (2026-03-20)
|
|
53
|
+
|
|
54
|
+
### 🧠 Memory Intelligence
|
|
55
|
+
|
|
56
|
+
v5 is a major feature release that adds six intelligence capabilities to the
|
|
57
|
+
memory layer. All features are backward-compatible with v4 workflows.
|
|
58
|
+
|
|
59
|
+
Design document: see the v5 feature table in [README.md](README.md).
|
|
60
|
+
|
|
61
|
+
#### F1: Memory Links (记忆关联)
|
|
62
|
+
|
|
63
|
+
- Automatic link creation during `syncOne()`: after a successful `add` or
|
|
64
|
+
`merge`, candidates with `dedup_score ∈ [0.45, 0.82)` are saved as `related`
|
|
65
|
+
links (up to 5 per memory)
|
|
66
|
+
- `recall` and `surface` accept a new `related: boolean` parameter. When true,
|
|
67
|
+
top-K results are expanded with linked memories from the `links` table
|
|
68
|
+
(capped at `limit * 1.5`, with score scaled by `original_score * link_weight * 0.6`)
|
|
69
|
+
- Related memories are tagged with `match_type: 'related'` and
|
|
70
|
+
`related_source_id` in results so the agent knows why they appeared
|
|
71
|
+
- New MCP tool **`link`**: manually create or remove associations
|
|
72
|
+
(`relation`: `related` | `supersedes` | `contradicts`, with optional `weight`)
|
|
73
|
+
|
|
74
|
+
#### F2: Conflict Detection (冲突检测)
|
|
75
|
+
|
|
76
|
+
- Write Guard (`guard.ts`) now iterates over multiple candidates instead of
|
|
77
|
+
only the top-1 match
|
|
78
|
+
- Three conflict signal types detected between incoming content and existing
|
|
79
|
+
candidates:
|
|
80
|
+
- **Negation**: one side contains negation words the other does not
|
|
81
|
+
- **Value**: same entity with different numeric values (IPs, ports, versions)
|
|
82
|
+
- **Status**: one side marked done/cancelled while the other is in-progress
|
|
83
|
+
- Conflict score (0–1) is computed from weighted signals. Conflicts above 0.5
|
|
84
|
+
are reported in `GuardResult.conflicts` and propagated to `SyncResult`
|
|
85
|
+
- **Conflict Override rule**: when `dedup_score ≥ 0.93` and a `status` or
|
|
86
|
+
`value` conflict is detected, the guard action is forced from `skip` to
|
|
87
|
+
`update` — preventing legitimate state changes (e.g. TODO → DONE) from being
|
|
88
|
+
silently deduplicated. `negation` conflicts do not trigger override (higher
|
|
89
|
+
false-positive rate)
|
|
90
|
+
- Writes are never blocked by conflict detection — the agent decides what to do
|
|
91
|
+
|
|
92
|
+
#### F3: Temporal Recall (时间维度召回)
|
|
93
|
+
|
|
94
|
+
- `recall` and `surface` accept new optional parameters:
|
|
95
|
+
- `after` / `before` (ISO 8601) — time-range filter at the SQL layer for
|
|
96
|
+
both BM25 and vector search paths
|
|
97
|
+
- `recency_boost` (0–1) — blends a recency decay signal into the fusion
|
|
98
|
+
score: `final = (1 - boost) * base + boost * e^(-days/30)`
|
|
99
|
+
- BM25 and vector search functions (`searchBM25`, `searchByVector`) extended
|
|
100
|
+
with `after` / `before` filter support
|
|
101
|
+
|
|
102
|
+
#### F4: Passive Feedback (被动反馈)
|
|
103
|
+
|
|
104
|
+
- `FeedbackSource` type extended to `"recall" | "surface" | "passive"`
|
|
105
|
+
- When `recall` records access, the top-3 results automatically receive a
|
|
106
|
+
positive passive feedback event (value 0.7, vs 1.0 for explicit feedback)
|
|
107
|
+
- Rate-limited: max 3 passive feedback events per memory per 24-hour window
|
|
108
|
+
- Anti-N+1: deduplication check uses a single batch `WHERE memory_id IN (...)`
|
|
109
|
+
query instead of per-memory `SELECT COUNT(*)`
|
|
110
|
+
|
|
111
|
+
#### F5: Semantic Decay (语义衰减)
|
|
112
|
+
|
|
113
|
+
- New `isStaleContent(content, type)` function in `tidy.ts` detects
|
|
114
|
+
temporally-stale content via keyword pattern matching
|
|
115
|
+
- Pattern sets are scoped by memory type:
|
|
116
|
+
- `event`: broad matching (e.g. `正在`, `in progress`, `TODO`, `just now`)
|
|
117
|
+
- `knowledge`: anchored-start-only patterns (e.g. `^TODO:`, `^WIP:`) to
|
|
118
|
+
avoid false positives on knowledge descriptions containing those words
|
|
119
|
+
- `identity` and `emotion`: exempt from semantic decay
|
|
120
|
+
- Age thresholds: `in_progress` > 7d, `pending` > 14d, `ephemeral` > 3d
|
|
121
|
+
- Matched memories have their `vitality` multiplied by the pattern's
|
|
122
|
+
`decay_factor`
|
|
123
|
+
- `TidyResult` now includes `staleDecayed` count
|
|
124
|
+
|
|
125
|
+
#### F6: Memory Provenance (记忆溯源)
|
|
126
|
+
|
|
127
|
+
- Schema migration v6 → v7: three new nullable columns on `memories`:
|
|
128
|
+
- `source_session` — originating session ID
|
|
129
|
+
- `source_context` — trigger context (≤200 chars)
|
|
130
|
+
- `observed_at` — when the event actually happened (distinct from write time)
|
|
131
|
+
- `Memory` interface and `CreateMemoryInput` updated with provenance fields
|
|
132
|
+
- MCP `remember` tool accepts `session_id`, `context`, `observed_at`
|
|
133
|
+
- `recall` / `surface` results include provenance fields when present
|
|
134
|
+
- `guard.ts` `timeProximity()` now prefers `observed_at` over regex-guessed
|
|
135
|
+
timestamps from content/URI/source
|
|
136
|
+
|
|
137
|
+
### 🧰 Tooling
|
|
138
|
+
|
|
139
|
+
- MCP toolset expanded from **10 → 11 tools** (added `link`)
|
|
140
|
+
- MCP server version string updated to `5.0.0`
|
|
141
|
+
|
|
142
|
+
### ✅ Tests
|
|
143
|
+
|
|
144
|
+
- Added `tests/v5/intelligence.test.ts` with **25 new test cases** covering
|
|
145
|
+
all six v5 features
|
|
146
|
+
- Total test count: **96** (up from 69 in v4.2)
|
|
147
|
+
|
|
148
|
+
### 📦 Schema
|
|
149
|
+
|
|
150
|
+
- Database schema version: **7** (from 6)
|
|
151
|
+
- Migration is additive (nullable columns only) — safe to upgrade in place
|
|
152
|
+
- Rollback: ignore new columns, delete new link/feedback rows by type
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
3
156
|
## 4.2.0 (2026-03-19)
|
|
4
157
|
|
|
5
158
|
### 🛡️ Anti-Noise Hardening
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/@smyslenny/agent-memory"><img src="https://img.shields.io/npm/v/@smyslenny/agent-memory" alt="npm" /></a>
|
|
11
11
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a>
|
|
12
12
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-%E2%89%A518-green.svg" alt="Node.js" /></a>
|
|
13
|
-
<a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-
|
|
13
|
+
<a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-11_tools-orange.svg" alt="MCP" /></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
**English** | [简体中文说明](docs/README-zh.md)
|
|
@@ -22,7 +22,7 @@ AgentMemory is a SQLite-first memory layer for AI agents. It lets an agent:
|
|
|
22
22
|
- **maintain** them over time with `reflect`, `reindex`, and feedback signals
|
|
23
23
|
- **integrate** through **CLI**, **MCP stdio**, or **HTTP/SSE**
|
|
24
24
|
|
|
25
|
-
Current release: **`
|
|
25
|
+
Current release: **`5.0.2`**.
|
|
26
26
|
|
|
27
27
|
Without an embedding provider, AgentMemory still works in **BM25-only mode**.
|
|
28
28
|
With one configured, it adds **hybrid recall** and **semantic dedup**.
|
|
@@ -40,16 +40,36 @@ That means it is designed around the things agent runtimes actually need:
|
|
|
40
40
|
- a lifecycle path for decay, governance, reindexing, and recovery-friendly jobs
|
|
41
41
|
- a local-first deployment model that stays useful even without extra infra
|
|
42
42
|
|
|
43
|
-
Core building blocks
|
|
43
|
+
Core building blocks:
|
|
44
44
|
|
|
45
45
|
- **Typed memories**: `identity`, `emotion`, `knowledge`, `event`
|
|
46
46
|
- **URI paths** for stable addressing
|
|
47
|
-
- **Write Guard** with semantic dedup + typed merge policy
|
|
47
|
+
- **Write Guard** with semantic dedup + typed merge policy + conflict detection
|
|
48
48
|
- **Hybrid retrieval**: BM25 first, optional vector search
|
|
49
|
+
- **Memory links** with automatic association and related-memory expansion
|
|
50
|
+
- **Temporal recall** with time filtering and recency boost
|
|
49
51
|
- **Context-aware surfacing** for task/recent-turn driven context injection
|
|
52
|
+
- **Passive feedback** that records usage signals automatically
|
|
53
|
+
- **Semantic decay** that detects stale content beyond pure time-based Ebbinghaus
|
|
54
|
+
- **Memory provenance** for tracking where and when each memory originated
|
|
50
55
|
- **Lifecycle jobs**: `reflect`, `reindex`, job checkpoints, feedback signals
|
|
51
56
|
- **Three transport modes**: CLI, MCP stdio, HTTP/SSE
|
|
52
57
|
|
|
58
|
+
### New in v5: Memory Intelligence
|
|
59
|
+
|
|
60
|
+
v5 adds six features that turn agent-memory from a durable store into an
|
|
61
|
+
intelligent memory layer. All features are backward-compatible — existing
|
|
62
|
+
v4 workflows continue to work unchanged.
|
|
63
|
+
|
|
64
|
+
| Feature | What it does |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| **F1 Memory Links** | Automatically detects semantically related memories during write and builds lightweight associations. `recall` and `surface` support `related` expansion to pull in linked memories. A new `link` tool allows manual link management. |
|
|
67
|
+
| **F2 Conflict Detection** | Write Guard now scans candidates for contradictions (negation, value changes, status changes). Conflicts are reported in the sync result without blocking writes. A **Conflict Override** rule ensures status updates (e.g. TODO → DONE) are not incorrectly deduplicated. |
|
|
68
|
+
| **F3 Temporal Recall** | `recall` and `surface` accept `after`, `before`, and `recency_boost` parameters. Time filtering happens at the SQL layer for both BM25 and vector paths. Recency boost blends a time-decay signal into the fusion score. |
|
|
69
|
+
| **F4 Passive Feedback** | When `recall` returns results and records access, positive feedback is automatically logged for the top-3 hits. Rate-limited to 3 passive events per memory per 24 hours. |
|
|
70
|
+
| **F5 Semantic Decay** | The `tidy` phase now detects stale content through keyword pattern matching (e.g. "in progress", "TODO:", "just now"). Patterns are scoped by memory type — `event` uses broad matching, `knowledge` uses anchored-start-only patterns. `identity` and `emotion` are exempt. |
|
|
71
|
+
| **F6 Memory Provenance** | Memories can carry `source_session`, `source_context`, and `observed_at` metadata. This tracks where and when a memory originated, separate from its write timestamp. Schema migrated from v6 → v7. |
|
|
72
|
+
|
|
53
73
|
## 2) How is it different from a vector DB, a RAG pipeline, or memory summaries?
|
|
54
74
|
|
|
55
75
|
| Thing | Good at | What AgentMemory adds |
|
|
@@ -177,18 +197,19 @@ npx agent-memory reflect all
|
|
|
177
197
|
}
|
|
178
198
|
```
|
|
179
199
|
|
|
180
|
-
Available MCP tools
|
|
200
|
+
Available MCP tools:
|
|
181
201
|
|
|
182
|
-
- `remember`
|
|
183
|
-
- `recall`
|
|
184
|
-
- `recall_path`
|
|
185
|
-
- `boot`
|
|
186
|
-
- `forget`
|
|
187
|
-
- `reflect`
|
|
188
|
-
- `status`
|
|
189
|
-
- `ingest`
|
|
190
|
-
- `reindex`
|
|
191
|
-
- `surface`
|
|
202
|
+
- `remember` — store a memory (supports provenance: `session_id`, `context`, `observed_at`)
|
|
203
|
+
- `recall` — hybrid search (supports `related`, `after`, `before`, `recency_boost`)
|
|
204
|
+
- `recall_path` — read or list memories by URI
|
|
205
|
+
- `boot` — load startup memories (narrative or JSON)
|
|
206
|
+
- `forget` — soft-decay or hard-delete a memory
|
|
207
|
+
- `reflect` — run sleep cycle phases (decay, tidy, govern)
|
|
208
|
+
- `status` — memory system statistics
|
|
209
|
+
- `ingest` — extract structured memories from markdown
|
|
210
|
+
- `reindex` — rebuild BM25 index and optional embeddings
|
|
211
|
+
- `surface` — context-aware readonly surfacing (supports `related`, `after`, `before`, `recency_boost`)
|
|
212
|
+
- `link` — manually create or remove associations between memories
|
|
192
213
|
|
|
193
214
|
### C. HTTP API
|
|
194
215
|
|
|
@@ -274,6 +295,22 @@ export AGENT_MEMORY_EMBEDDING_API_KEY=your-api-key
|
|
|
274
295
|
Or use `AGENT_MEMORY_EMBEDDING_PROVIDER=local-http` for a local HTTP embedding
|
|
275
296
|
service. If no provider is configured, AgentMemory falls back to BM25-only.
|
|
276
297
|
|
|
298
|
+
## Environment variables
|
|
299
|
+
|
|
300
|
+
| Variable | Default | Description |
|
|
301
|
+
| --- | --- | --- |
|
|
302
|
+
| `AGENT_MEMORY_DB` | `./agent-memory.db` | SQLite database path |
|
|
303
|
+
| `AGENT_MEMORY_AGENT_ID` | `default` | Agent scope for multi-agent setups |
|
|
304
|
+
| `AGENT_MEMORY_MAX_MEMORIES` | `200` | Maximum memories retained during `reflect govern` |
|
|
305
|
+
| `AGENT_MEMORY_AUTO_INGEST` | `1` | Set to `0` to disable the auto-ingest file watcher |
|
|
306
|
+
| `AGENT_MEMORY_AUTO_INGEST_DAILY` | _(unset)_ | Set to `1` to include daily log files (`YYYY-MM-DD.md`) in auto-ingest. By default, only `MEMORY.md` is watched. |
|
|
307
|
+
| `AGENT_MEMORY_WORKSPACE` | `~/.openclaw/workspace` | Workspace directory for the auto-ingest watcher |
|
|
308
|
+
| `AGENT_MEMORY_EMBEDDING_PROVIDER` | _(unset)_ | `openai-compatible` or `local-http` |
|
|
309
|
+
| `AGENT_MEMORY_EMBEDDING_BASE_URL` | _(unset)_ | Base URL for the embedding endpoint |
|
|
310
|
+
| `AGENT_MEMORY_EMBEDDING_MODEL` | _(unset)_ | Embedding model name |
|
|
311
|
+
| `AGENT_MEMORY_EMBEDDING_DIMENSION` | _(unset)_ | Embedding vector dimension |
|
|
312
|
+
| `AGENT_MEMORY_EMBEDDING_API_KEY` | _(unset)_ | API key for the embedding provider |
|
|
313
|
+
|
|
277
314
|
## Documentation map
|
|
278
315
|
|
|
279
316
|
- [Architecture](docs/architecture.md)
|