@smyslenny/agent-memory 2.1.0 → 3.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/CHANGELOG.md +51 -27
- package/README.en.md +153 -0
- package/README.md +95 -122
- package/dist/bin/agent-memory.js +28 -485
- package/dist/bin/agent-memory.js.map +1 -1
- package/dist/index.d.ts +53 -143
- package/dist/index.js +289 -574
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +585 -631
- package/dist/mcp/server.js.map +1 -1
- package/docs/design/0004-agent-memory-integration.md +316 -0
- package/docs/design/0005-reranker-api-integration.md +276 -0
- package/docs/design/0006-multi-provider-embedding.md +196 -0
- package/docs/design/0014-memory-core-dedup.md +722 -0
- package/docs/design/TEMPLATE.md +67 -0
- package/docs/roadmap/integration-plan-v1.md +139 -0
- package/docs/roadmap/memory-architecture.md +168 -0
- package/docs/roadmap/warm-boot.md +135 -0
- package/package.json +2 -3
- package/README.zh-CN.md +0 -170
package/dist/index.d.ts
CHANGED
|
@@ -77,51 +77,6 @@ declare function getPathsByDomain(db: Database.Database, domain: string, agent_i
|
|
|
77
77
|
declare function getPathsByPrefix(db: Database.Database, prefix: string, agent_id?: string): Path[];
|
|
78
78
|
declare function deletePath(db: Database.Database, id: string): boolean;
|
|
79
79
|
|
|
80
|
-
type RelationType = "related" | "caused" | "reminds" | "evolved" | "contradicts";
|
|
81
|
-
interface Link {
|
|
82
|
-
agent_id: string;
|
|
83
|
-
source_id: string;
|
|
84
|
-
target_id: string;
|
|
85
|
-
relation: RelationType;
|
|
86
|
-
weight: number;
|
|
87
|
-
created_at: string;
|
|
88
|
-
}
|
|
89
|
-
declare function createLink(db: Database.Database, sourceId: string, targetId: string, relation: RelationType, weight?: number, agent_id?: string): Link;
|
|
90
|
-
declare function getLinks(db: Database.Database, memoryId: string, agent_id?: string): Link[];
|
|
91
|
-
declare function getOutgoingLinks(db: Database.Database, sourceId: string, agent_id?: string): Link[];
|
|
92
|
-
/**
|
|
93
|
-
* Multi-hop traversal: find all memories reachable within N hops
|
|
94
|
-
* Inspired by PowerMem's knowledge graph traversal
|
|
95
|
-
*/
|
|
96
|
-
declare function traverse(db: Database.Database, startId: string, maxHops?: number, agent_id?: string): Array<{
|
|
97
|
-
id: string;
|
|
98
|
-
hop: number;
|
|
99
|
-
relation: string;
|
|
100
|
-
}>;
|
|
101
|
-
declare function deleteLink(db: Database.Database, sourceId: string, targetId: string, agent_id?: string): boolean;
|
|
102
|
-
|
|
103
|
-
type SnapshotAction = "create" | "update" | "delete" | "merge";
|
|
104
|
-
interface Snapshot {
|
|
105
|
-
id: string;
|
|
106
|
-
memory_id: string;
|
|
107
|
-
content: string;
|
|
108
|
-
changed_by: string | null;
|
|
109
|
-
action: SnapshotAction;
|
|
110
|
-
created_at: string;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a snapshot before modifying a memory.
|
|
114
|
-
* Call this BEFORE any update/delete operation.
|
|
115
|
-
*/
|
|
116
|
-
declare function createSnapshot(db: Database.Database, memoryId: string, action: SnapshotAction, changedBy?: string): Snapshot;
|
|
117
|
-
declare function getSnapshots(db: Database.Database, memoryId: string): Snapshot[];
|
|
118
|
-
declare function getSnapshot(db: Database.Database, id: string): Snapshot | null;
|
|
119
|
-
/**
|
|
120
|
-
* Rollback a memory to a specific snapshot.
|
|
121
|
-
* Creates a new snapshot of the current state before rolling back.
|
|
122
|
-
*/
|
|
123
|
-
declare function rollback(db: Database.Database, snapshotId: string): boolean;
|
|
124
|
-
|
|
125
80
|
type GuardAction = "add" | "update" | "skip" | "merge";
|
|
126
81
|
interface GuardResult {
|
|
127
82
|
action: GuardAction;
|
|
@@ -177,102 +132,62 @@ declare function searchBM25(db: Database.Database, query: string, opts?: {
|
|
|
177
132
|
*/
|
|
178
133
|
declare function tokenize(text: string): string[];
|
|
179
134
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
confidence: number;
|
|
135
|
+
interface IngestBlock {
|
|
136
|
+
title: string;
|
|
137
|
+
content: string;
|
|
184
138
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Get search strategy based on intent
|
|
193
|
-
*/
|
|
194
|
-
declare function getStrategy(intent: SearchIntent): {
|
|
195
|
-
boostRecent: boolean;
|
|
196
|
-
boostPriority: boolean;
|
|
197
|
-
limit: number;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Rerank search results based on intent strategy and priority weighting.
|
|
202
|
-
*/
|
|
203
|
-
declare function rerank(results: SearchResult[], opts: {
|
|
204
|
-
intent?: SearchIntent;
|
|
205
|
-
boostRecent: boolean;
|
|
206
|
-
boostPriority: boolean;
|
|
207
|
-
limit: number;
|
|
208
|
-
}): SearchResult[];
|
|
209
|
-
|
|
210
|
-
interface EmbeddingProvider {
|
|
211
|
-
id: string;
|
|
212
|
-
model: string;
|
|
213
|
-
dimension?: number;
|
|
214
|
-
embed(text: string): Promise<number[]>;
|
|
139
|
+
interface IngestExtractedItem {
|
|
140
|
+
index: number;
|
|
141
|
+
title: string;
|
|
142
|
+
content: string;
|
|
143
|
+
type: MemoryType;
|
|
144
|
+
uri: string;
|
|
215
145
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}): EmbeddingProvider;
|
|
222
|
-
declare function createDashScopeProvider(opts: {
|
|
223
|
-
apiKey: string;
|
|
224
|
-
model: string;
|
|
225
|
-
baseUrl?: string;
|
|
226
|
-
}): EmbeddingProvider;
|
|
227
|
-
|
|
228
|
-
interface HybridSearchOptions {
|
|
229
|
-
agent_id?: string;
|
|
230
|
-
limit?: number;
|
|
231
|
-
bm25CandidateMultiplier?: number;
|
|
232
|
-
semanticCandidates?: number;
|
|
233
|
-
rrfK?: number;
|
|
234
|
-
embeddingProvider?: EmbeddingProvider | null;
|
|
235
|
-
embeddingModel?: string;
|
|
146
|
+
interface IngestDryRunDetail {
|
|
147
|
+
index: number;
|
|
148
|
+
type: MemoryType;
|
|
149
|
+
uri: string;
|
|
150
|
+
preview: string;
|
|
236
151
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
vector: Float32Array;
|
|
245
|
-
created_at: string;
|
|
246
|
-
updated_at: string;
|
|
152
|
+
interface IngestWriteDetail {
|
|
153
|
+
index: number;
|
|
154
|
+
type: MemoryType;
|
|
155
|
+
uri: string;
|
|
156
|
+
action: "added" | "updated" | "merged" | "skipped";
|
|
157
|
+
reason: string;
|
|
158
|
+
memoryId?: string;
|
|
247
159
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
160
|
+
interface IngestResult {
|
|
161
|
+
extracted: number;
|
|
162
|
+
written: number;
|
|
163
|
+
skipped: number;
|
|
164
|
+
dry_run: boolean;
|
|
165
|
+
details: Array<IngestDryRunDetail | IngestWriteDetail>;
|
|
166
|
+
}
|
|
167
|
+
interface IngestRunOptions {
|
|
168
|
+
text: string;
|
|
169
|
+
source?: string;
|
|
170
|
+
dryRun?: boolean;
|
|
171
|
+
agentId?: string;
|
|
172
|
+
}
|
|
173
|
+
declare function slugify(input: string): string;
|
|
174
|
+
declare function classifyIngestType(text: string): MemoryType;
|
|
175
|
+
declare function splitIngestBlocks(text: string): IngestBlock[];
|
|
176
|
+
declare function extractIngestItems(text: string, source?: string): IngestExtractedItem[];
|
|
177
|
+
declare function ingestText(db: Database.Database, options: IngestRunOptions): IngestResult;
|
|
261
178
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
scanned: number;
|
|
275
|
-
}>;
|
|
179
|
+
interface AutoIngestWatcherOptions {
|
|
180
|
+
db: Database.Database;
|
|
181
|
+
workspaceDir: string;
|
|
182
|
+
agentId: string;
|
|
183
|
+
debounceMs?: number;
|
|
184
|
+
initialScan?: boolean;
|
|
185
|
+
logger?: Pick<Console, "log" | "warn" | "error">;
|
|
186
|
+
}
|
|
187
|
+
interface AutoIngestWatcher {
|
|
188
|
+
close: () => void;
|
|
189
|
+
}
|
|
190
|
+
declare function runAutoIngestWatcher(options: AutoIngestWatcherOptions): AutoIngestWatcher;
|
|
276
191
|
|
|
277
192
|
/**
|
|
278
193
|
* Calculate vitality using Ebbinghaus forgetting curve.
|
|
@@ -333,30 +248,25 @@ declare function syncBatch(db: Database.Database, inputs: SyncInput[]): SyncResu
|
|
|
333
248
|
interface TidyResult {
|
|
334
249
|
archived: number;
|
|
335
250
|
orphansCleaned: number;
|
|
336
|
-
snapshotsPruned: number;
|
|
337
251
|
}
|
|
338
252
|
/**
|
|
339
253
|
* Run the tidy (deep sleep) cycle:
|
|
340
254
|
* 1. Archive decayed P3 memories (vitality < threshold)
|
|
341
255
|
* 2. Clean orphan paths (paths with no memory)
|
|
342
|
-
* 3. Prune old snapshots (keep last N per memory)
|
|
343
256
|
*/
|
|
344
257
|
declare function runTidy(db: Database.Database, opts?: {
|
|
345
258
|
vitalityThreshold?: number;
|
|
346
|
-
maxSnapshotsPerMemory?: number;
|
|
347
259
|
agent_id?: string;
|
|
348
260
|
}): TidyResult;
|
|
349
261
|
|
|
350
262
|
interface GovernResult {
|
|
351
263
|
orphanPaths: number;
|
|
352
|
-
orphanLinks: number;
|
|
353
264
|
emptyMemories: number;
|
|
354
265
|
}
|
|
355
266
|
/**
|
|
356
267
|
* Run governance checks and cleanup:
|
|
357
268
|
* 1. Remove orphan paths (no parent memory)
|
|
358
|
-
* 2. Remove
|
|
359
|
-
* 3. Remove empty memories (blank content)
|
|
269
|
+
* 2. Remove empty memories (blank content)
|
|
360
270
|
*/
|
|
361
271
|
declare function runGovern(db: Database.Database, opts?: {
|
|
362
272
|
agent_id?: string;
|
|
@@ -375,4 +285,4 @@ declare function boot(db: Database.Database, opts?: {
|
|
|
375
285
|
corePaths?: string[];
|
|
376
286
|
}): BootResult;
|
|
377
287
|
|
|
378
|
-
export { type
|
|
288
|
+
export { type AutoIngestWatcher, type AutoIngestWatcherOptions, type BootResult, type CreateMemoryInput, type ExportResult, type GovernResult, type GuardAction, type GuardResult, type IngestExtractedItem, type IngestResult, type IngestRunOptions, type Memory, type MemoryType, type Path, type Priority, type SearchResult, type SyncInput, type SyncResult, type TidyResult, type UpdateMemoryInput, boot, calculateVitality, classifyIngestType, contentHash, countMemories, createMemory, createPath, deleteMemory, deletePath, exportMemories, extractIngestItems, getDecayedMemories, getMemory, getPath, getPathByUri, getPathsByDomain, getPathsByMemory, getPathsByPrefix, guard, ingestText, listMemories, parseUri, recordAccess, runAutoIngestWatcher, runDecay, runGovern, runTidy, searchBM25, slugify, splitIngestBlocks, syncBatch, syncOne, tokenize, updateMemory };
|