@elizaos/plugin-memory 1.1.0 → 1.1.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/README.md +230 -330
- package/dist/actions/remember.d.ts +11 -0
- package/dist/browser/index.browser.js +205 -348
- package/dist/browser/index.browser.js.map +13 -23
- package/dist/cjs/index.node.cjs +936 -2193
- package/dist/cjs/index.node.js.map +13 -23
- package/dist/evaluators/long-term-extraction.d.ts +8 -0
- package/dist/evaluators/summarization.d.ts +25 -6
- package/dist/index.d.ts +32 -152
- package/dist/node/index.node.js +944 -2210
- package/dist/node/index.node.js.map +13 -23
- package/dist/providers/context-summary.d.ts +12 -0
- package/dist/providers/long-term-memory.d.ts +11 -18
- package/dist/schemas/index.d.ts +6 -16
- package/dist/schemas/long-term-memories.d.ts +70 -308
- package/dist/schemas/memory-access-logs.d.ts +154 -0
- package/dist/schemas/session-summaries.d.ts +283 -0
- package/dist/services/memory-service.d.ts +51 -95
- package/dist/types/index.d.ts +53 -298
- package/package.json +2 -84
- package/dist/evaluators/consolidation.d.ts +0 -19
- package/dist/prompts/consolidation.d.ts +0 -35
- package/dist/prompts/summarization.d.ts +0 -25
- package/dist/providers/action-results.d.ts +0 -2
- package/dist/providers/recent-conversation-summary.d.ts +0 -2
- package/dist/repositories/conversation-summary.d.ts +0 -33
- package/dist/repositories/index.d.ts +0 -17
- package/dist/repositories/long-term-memory.d.ts +0 -53
- package/dist/schemas/conversation-summaries.d.ts +0 -494
- package/dist/utils/db-mapping.d.ts +0 -20
- package/dist/utils/decay-scoring.d.ts +0 -41
- package/dist/utils/embedding.d.ts +0 -21
- package/dist/utils/formatting.d.ts +0 -17
- package/dist/utils/index.d.ts +0 -17
- package/dist/utils/search-merging.d.ts +0 -18
- package/dist/utils/token-counter.d.ts +0 -53
package/dist/types/index.d.ts
CHANGED
|
@@ -1,330 +1,85 @@
|
|
|
1
1
|
import type { UUID } from '@elizaos/core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type EmbeddingDimensionColumn = 'dim384' | 'dim512' | 'dim768' | 'dim1024' | 'dim1536' | 'dim3072';
|
|
6
|
-
/**
|
|
7
|
-
* Dimension map for dynamic embedding support
|
|
8
|
-
*/
|
|
9
|
-
export declare const MEMORY_DIMENSION_MAP: Record<number, EmbeddingDimensionColumn>;
|
|
10
|
-
/**
|
|
11
|
-
* Memory Type Taxonomy (Based on Cognitive Science)
|
|
3
|
+
* Categories of long-term memory based on cognitive science
|
|
12
4
|
*
|
|
13
|
-
*
|
|
14
|
-
* - EPISODIC:
|
|
15
|
-
* - SEMANTIC: Facts and knowledge
|
|
16
|
-
* - PROCEDURAL:
|
|
5
|
+
* Following the widely accepted classification of human long-term memory:
|
|
6
|
+
* - EPISODIC: Personal experiences and events (what happened, when, where)
|
|
7
|
+
* - SEMANTIC: Facts, concepts, and knowledge (what things mean)
|
|
8
|
+
* - PROCEDURAL: Skills and how-to knowledge (how to do things)
|
|
17
9
|
*/
|
|
18
|
-
export declare enum
|
|
19
|
-
EPISODIC = "
|
|
20
|
-
SEMANTIC = "
|
|
21
|
-
PROCEDURAL = "
|
|
10
|
+
export declare enum LongTermMemoryCategory {
|
|
11
|
+
EPISODIC = "episodic",// Specific events, experiences, and interactions (e.g., "User worked on bug #123 last Tuesday")
|
|
12
|
+
SEMANTIC = "semantic",// General facts, concepts, and knowledge (e.g., "User is a Python developer", "User prefers async/await")
|
|
13
|
+
PROCEDURAL = "procedural"
|
|
22
14
|
}
|
|
23
15
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Research: Section 4.2 "Mathematical Model for Memory Decay"
|
|
27
|
-
* - EXPONENTIAL: Standard forgetting curve (Ebbinghaus)
|
|
28
|
-
* - LINEAR: Simple time-based decay
|
|
29
|
-
* - NONE: Core facts that never decay (identity, core preferences)
|
|
16
|
+
* Long-term memory entry
|
|
30
17
|
*/
|
|
31
|
-
export
|
|
32
|
-
EXPONENTIAL = "EXPONENTIAL",
|
|
33
|
-
LINEAR = "LINEAR",
|
|
34
|
-
NONE = "NONE"
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Conversation Summary - Hierarchical Conversation Summarization
|
|
38
|
-
*
|
|
39
|
-
* Research: Section 5.1.2 "Hierarchical Conversation Summarization"
|
|
40
|
-
*
|
|
41
|
-
* This implements recursive, multi-level summarization for long conversations:
|
|
42
|
-
* - Level 1: Summary of 50-100 messages
|
|
43
|
-
* - Level 2+: Summary of lower-level summaries (recursive)
|
|
44
|
-
*
|
|
45
|
-
* Benefits:
|
|
46
|
-
* - 10x token compression for very long conversations
|
|
47
|
-
* - Maintains narrative flow without exploding context window
|
|
48
|
-
* - Enables efficient retrieval of past conversation context
|
|
49
|
-
*/
|
|
50
|
-
export interface ConversationSummary {
|
|
51
|
-
/** Unique identifier */
|
|
18
|
+
export interface LongTermMemory {
|
|
52
19
|
id: UUID;
|
|
53
|
-
/** Agent this summary belongs to */
|
|
54
20
|
agentId: UUID;
|
|
55
|
-
/** Entity (user) this summary is about */
|
|
56
21
|
entityId: UUID;
|
|
57
|
-
|
|
58
|
-
roomId: UUID;
|
|
59
|
-
/**
|
|
60
|
-
* Hierarchical level
|
|
61
|
-
* - 1: Direct summarization of messages
|
|
62
|
-
* - 2+: Summarization of lower-level summaries
|
|
63
|
-
*/
|
|
64
|
-
level: number;
|
|
65
|
-
/**
|
|
66
|
-
* Parent summary ID (for tree structure)
|
|
67
|
-
* - null for Level 1 (summarizes messages)
|
|
68
|
-
* - UUID for Level 2+ (summarizes summaries)
|
|
69
|
-
*/
|
|
70
|
-
parentSummaryId?: UUID;
|
|
71
|
-
/** The summary content (human-readable paragraph) */
|
|
22
|
+
category: LongTermMemoryCategory;
|
|
72
23
|
content: string;
|
|
73
|
-
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
74
25
|
embedding?: number[];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/** Time range this summary covers */
|
|
78
|
-
startTime: Date;
|
|
79
|
-
endTime: Date;
|
|
80
|
-
/**
|
|
81
|
-
* Number of source items summarized
|
|
82
|
-
* - Level 1: message count
|
|
83
|
-
* - Level 2+: summary count
|
|
84
|
-
*/
|
|
85
|
-
sourceCount: number;
|
|
86
|
-
/** IDs of source items (messages or summaries) */
|
|
87
|
-
sourceIds: UUID[];
|
|
88
|
-
/** When this summary was created */
|
|
26
|
+
confidence?: number;
|
|
27
|
+
source?: string;
|
|
89
28
|
createdAt: Date;
|
|
90
|
-
|
|
91
|
-
lastAccessedAt
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/** Flexible metadata (topics, sentiment, etc.) */
|
|
95
|
-
metadata: Record<string, unknown>;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
lastAccessedAt?: Date;
|
|
31
|
+
accessCount?: number;
|
|
32
|
+
similarity?: number;
|
|
96
33
|
}
|
|
97
34
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* Research: Section 4.1 "The SOTA Memory Schema"
|
|
101
|
-
* This interface represents a single unit of long-term memory with all necessary metadata
|
|
102
|
-
* for cognitive processing, including decay, confidence, and provenance tracking.
|
|
35
|
+
* Short-term memory session summary
|
|
103
36
|
*/
|
|
104
|
-
export interface
|
|
105
|
-
/** Unique identifier for this memory */
|
|
37
|
+
export interface SessionSummary {
|
|
106
38
|
id: UUID;
|
|
107
|
-
/** Agent this memory belongs to */
|
|
108
39
|
agentId: UUID;
|
|
109
|
-
|
|
110
|
-
entityId
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* Research: Section 3.2.1 "Contextual Embeddings"
|
|
120
|
-
* Example: "[User preference regarding programming]: I prefer Python over JavaScript"
|
|
121
|
-
*/
|
|
122
|
-
embeddingContext: string;
|
|
123
|
-
/** Vector embedding of embeddingContext */
|
|
124
|
-
embedding: number[];
|
|
125
|
-
/**
|
|
126
|
-
* Confidence score (0.0 to 1.0)
|
|
127
|
-
* Research: Section 4.1 - Track certainty of extracted facts
|
|
128
|
-
* - 1.0: User explicitly stated or verified
|
|
129
|
-
* - < 1.0: LLM inferred or uncertain
|
|
130
|
-
*/
|
|
131
|
-
confidence: number;
|
|
132
|
-
/**
|
|
133
|
-
* Decay rate (lambda λ) for exponential decay
|
|
134
|
-
* Research: Section 4.2.2 "Implementation Strategy"
|
|
135
|
-
* - ~0: Core facts (name, identity) - very slow decay
|
|
136
|
-
* - 0.01: Mid-term facts (current projects) - fade over weeks
|
|
137
|
-
* - 0.5+: Transient facts (lunch plans) - fade over days
|
|
138
|
-
*/
|
|
139
|
-
decayRate: number;
|
|
140
|
-
/** Type of decay function to use */
|
|
141
|
-
decayFunction: DecayFunction;
|
|
142
|
-
/** When this memory was created */
|
|
40
|
+
roomId: UUID;
|
|
41
|
+
entityId?: UUID;
|
|
42
|
+
summary: string;
|
|
43
|
+
messageCount: number;
|
|
44
|
+
lastMessageOffset: number;
|
|
45
|
+
startTime: Date;
|
|
46
|
+
endTime: Date;
|
|
47
|
+
topics?: string[];
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
embedding?: number[];
|
|
143
50
|
createdAt: Date;
|
|
144
|
-
|
|
145
|
-
lastAccessedAt: Date | null;
|
|
146
|
-
/**
|
|
147
|
-
* How many times this memory has been retrieved
|
|
148
|
-
* Research: Section 4.2.2 - High count = stronger memory (slower decay)
|
|
149
|
-
*/
|
|
150
|
-
accessCount: number;
|
|
151
|
-
/**
|
|
152
|
-
* Soft delete flag for contradiction handling
|
|
153
|
-
* Research: Section 4.3 "Handling Contradictions"
|
|
154
|
-
* When a contradiction is found, old memory is marked inactive
|
|
155
|
-
*/
|
|
156
|
-
isActive: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Provenance: Source tracking
|
|
159
|
-
* Research: Section 4.1 "Provenance / Lineage"
|
|
160
|
-
*/
|
|
161
|
-
source: {
|
|
162
|
-
/** ID of the session where this was extracted */
|
|
163
|
-
sessionId?: string;
|
|
164
|
-
/** ID of the specific message that generated this fact */
|
|
165
|
-
messageId?: string;
|
|
166
|
-
/** Raw text snippet that triggered extraction */
|
|
167
|
-
textSnippet?: string;
|
|
168
|
-
/** Who provided the info (user ID or agent ID) */
|
|
169
|
-
authorId?: string;
|
|
170
|
-
/** Extraction model used (e.g., "gpt-4-turbo") */
|
|
171
|
-
extractionModel?: string;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Flexible metadata for future extensions
|
|
175
|
-
* Can store: tags, categories, relationships, etc.
|
|
176
|
-
*/
|
|
177
|
-
metadata: Record<string, unknown>;
|
|
178
|
-
/**
|
|
179
|
-
* Optional: ID of memory this one supersedes (for contradiction resolution)
|
|
180
|
-
* Research: Section 4.3.1 "Resolution Strategies"
|
|
181
|
-
*/
|
|
182
|
-
supersedesId?: UUID;
|
|
51
|
+
updatedAt: Date;
|
|
183
52
|
}
|
|
184
53
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* Research: Section 6 "Implementation Strategy"
|
|
188
|
-
* Simplified configuration focusing on key parameters
|
|
54
|
+
* Configuration for memory plugin
|
|
189
55
|
*/
|
|
190
|
-
export interface
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
minConfidence: number;
|
|
203
|
-
/**
|
|
204
|
-
* Enable vector search (requires embedding model)
|
|
205
|
-
* Research: Section 3 "RAG Strategy"
|
|
206
|
-
*/
|
|
207
|
-
enableVectorSearch: boolean;
|
|
208
|
-
/**
|
|
209
|
-
* Enable BM25 keyword search
|
|
210
|
-
* Research: Section 3.2.1 - Combines with vector for Contextual Retrieval
|
|
211
|
-
*/
|
|
212
|
-
enableBM25: boolean;
|
|
213
|
-
/**
|
|
214
|
-
* Number of memories to retrieve during RAG
|
|
215
|
-
* Research: Section 5.1.3 "Tier 3: Just-In-Time Injection"
|
|
216
|
-
*/
|
|
217
|
-
retrievalLimit: number;
|
|
218
|
-
/**
|
|
219
|
-
* Token budget for memory context injection
|
|
220
|
-
* Research: Section 5.1.3 - Only highest-scoring memories within budget
|
|
221
|
-
*/
|
|
222
|
-
tokenBudget: number;
|
|
223
|
-
/**
|
|
224
|
-
* Default decay rates for different memory types
|
|
225
|
-
* Research: Section 4.2.2 "Implementation Strategy"
|
|
226
|
-
*/
|
|
227
|
-
defaultDecayRates: {
|
|
228
|
-
[MemoryType.EPISODIC]: number;
|
|
229
|
-
[MemoryType.SEMANTIC]: number;
|
|
230
|
-
[MemoryType.PROCEDURAL]: number;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* Enable contradiction detection and resolution
|
|
234
|
-
* Research: Section 4.3 "Handling Contradictions"
|
|
235
|
-
*/
|
|
236
|
-
enableContradictionDetection: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Hierarchical Summarization Configuration (GAP 3 fix)
|
|
239
|
-
* Research: Section 5.1.2 "Hierarchical Episodic Summarization"
|
|
240
|
-
*/
|
|
241
|
-
summarization?: {
|
|
242
|
-
/** Enable hierarchical summarization */
|
|
243
|
-
enabled: boolean;
|
|
244
|
-
/** Number of messages before triggering Level 1 summary */
|
|
245
|
-
messagesPerSummary: number;
|
|
246
|
-
/** Number of Level N summaries before creating Level N+1 summary */
|
|
247
|
-
summariesPerLevel: number;
|
|
248
|
-
/** Maximum hierarchical depth (prevents infinite recursion) */
|
|
249
|
-
maxDepth: number;
|
|
250
|
-
/** Token budget for summary retrieval */
|
|
251
|
-
summaryTokenBudget: number;
|
|
252
|
-
};
|
|
56
|
+
export interface MemoryConfig {
|
|
57
|
+
shortTermSummarizationThreshold: number;
|
|
58
|
+
shortTermRetainRecent: number;
|
|
59
|
+
shortTermSummarizationInterval: number;
|
|
60
|
+
longTermExtractionEnabled: boolean;
|
|
61
|
+
longTermVectorSearchEnabled: boolean;
|
|
62
|
+
longTermConfidenceThreshold: number;
|
|
63
|
+
longTermExtractionThreshold: number;
|
|
64
|
+
longTermExtractionInterval: number;
|
|
65
|
+
summaryModelType?: string;
|
|
66
|
+
summaryMaxTokens?: number;
|
|
67
|
+
summaryMaxNewMessages?: number;
|
|
253
68
|
}
|
|
254
69
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* Research: Section 2.2.2 "Proposed Extraction Prompt Structure"
|
|
70
|
+
* Memory extraction result from evaluator
|
|
258
71
|
*/
|
|
259
|
-
export interface
|
|
260
|
-
|
|
261
|
-
type: MemoryType;
|
|
262
|
-
/** The extracted content */
|
|
72
|
+
export interface MemoryExtraction {
|
|
73
|
+
category: LongTermMemoryCategory;
|
|
263
74
|
content: string;
|
|
264
|
-
/** Confidence score (0-1) */
|
|
265
75
|
confidence: number;
|
|
266
|
-
/** Whether this contradicts an existing memory */
|
|
267
|
-
isContradiction: boolean;
|
|
268
|
-
/** ID of the source message */
|
|
269
|
-
sourceMessageId?: string;
|
|
270
|
-
/**
|
|
271
|
-
* Optional: Entity extraction for graph
|
|
272
|
-
* Research: Section 3.1.2 "Graph Advantages"
|
|
273
|
-
*/
|
|
274
|
-
entities?: {
|
|
275
|
-
subject: string;
|
|
276
|
-
predicate: string;
|
|
277
|
-
object: string;
|
|
278
|
-
};
|
|
279
|
-
/** Additional metadata */
|
|
280
76
|
metadata?: Record<string, unknown>;
|
|
281
77
|
}
|
|
282
78
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
* Research: Section 2.2.2 "OUTPUT FORMAT"
|
|
286
|
-
*/
|
|
287
|
-
export interface ConsolidationResult {
|
|
288
|
-
/** Reasoning trace for debugging */
|
|
289
|
-
reasoningTrace: string;
|
|
290
|
-
/** Brief summary of transient events (for episodic log) */
|
|
291
|
-
transientSummary: string;
|
|
292
|
-
/** Extracted persistent long-term memories */
|
|
293
|
-
extractedMemories: ExtractedLongTermMemory[];
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Long-Term Memory Retrieval Result (with decay-adjusted scoring)
|
|
297
|
-
*
|
|
298
|
-
* Research: Section 4.2 "Mathematical Model for Memory Decay"
|
|
79
|
+
* Summary generation result
|
|
299
80
|
*/
|
|
300
|
-
export interface
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
activationScore: number;
|
|
305
|
-
/** Final composite score (relevance * decay * confidence) */
|
|
306
|
-
finalScore: number;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Long-Term Memory Search Query Parameters
|
|
310
|
-
*/
|
|
311
|
-
export interface LongTermMemorySearchParams {
|
|
312
|
-
/** Entity to search memories for */
|
|
313
|
-
entityId: UUID;
|
|
314
|
-
/** Optional room context filter */
|
|
315
|
-
roomId?: UUID;
|
|
316
|
-
/** Query text */
|
|
317
|
-
query: string;
|
|
318
|
-
/** Optional memory type filter */
|
|
319
|
-
type?: MemoryType;
|
|
320
|
-
/** Maximum results to return */
|
|
321
|
-
limit?: number;
|
|
322
|
-
/** Minimum confidence threshold (default: 0.7) */
|
|
323
|
-
minConfidence?: number;
|
|
324
|
-
/** Minimum similarity threshold for vector search (default: 0.3) */
|
|
325
|
-
similarityThreshold?: number;
|
|
326
|
-
/** Whether to include inactive (superseded) memories */
|
|
327
|
-
includeInactive?: boolean;
|
|
328
|
-
/** Token budget for this retrieval (overrides config default) */
|
|
329
|
-
tokenBudget?: number;
|
|
81
|
+
export interface SummaryResult {
|
|
82
|
+
summary: string;
|
|
83
|
+
topics: string[];
|
|
84
|
+
keyPoints: string[];
|
|
330
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-memory",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Advanced memory management plugin with short-term summarization and long-term persistent memory",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.node.cjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@elizaos/core": "latest",
|
|
51
|
-
"drizzle-orm": "^0.
|
|
51
|
+
"drizzle-orm": "^0.45.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/bun": "latest",
|
|
@@ -66,87 +66,5 @@
|
|
|
66
66
|
"license": "MIT",
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
|
-
},
|
|
70
|
-
"agentConfig": {
|
|
71
|
-
"pluginType": "elizaos:plugin:1.0.0",
|
|
72
|
-
"pluginParameters": {
|
|
73
|
-
"MEMORY_CONSOLIDATION_THRESHOLD": {
|
|
74
|
-
"type": "number",
|
|
75
|
-
"description": "Number of messages to buffer before triggering memory consolidation.",
|
|
76
|
-
"required": false,
|
|
77
|
-
"default": 10,
|
|
78
|
-
"sensitive": false
|
|
79
|
-
},
|
|
80
|
-
"MEMORY_MIN_CONFIDENCE": {
|
|
81
|
-
"type": "number",
|
|
82
|
-
"description": "Minimum confidence score (0-1) required to store extracted facts.",
|
|
83
|
-
"required": false,
|
|
84
|
-
"default": 0.7,
|
|
85
|
-
"sensitive": false
|
|
86
|
-
},
|
|
87
|
-
"MEMORY_ENABLE_VECTOR_SEARCH": {
|
|
88
|
-
"type": "boolean",
|
|
89
|
-
"description": "Enable semantic similarity search using embeddings.",
|
|
90
|
-
"required": false,
|
|
91
|
-
"default": true,
|
|
92
|
-
"sensitive": false
|
|
93
|
-
},
|
|
94
|
-
"MEMORY_ENABLE_BM25": {
|
|
95
|
-
"type": "boolean",
|
|
96
|
-
"description": "Enable keyword-based search with stemming for exact term matching.",
|
|
97
|
-
"required": false,
|
|
98
|
-
"default": true,
|
|
99
|
-
"sensitive": false
|
|
100
|
-
},
|
|
101
|
-
"MEMORY_RETRIEVAL_LIMIT": {
|
|
102
|
-
"type": "number",
|
|
103
|
-
"description": "Maximum number of memories to retrieve per query.",
|
|
104
|
-
"required": false,
|
|
105
|
-
"default": 5,
|
|
106
|
-
"sensitive": false
|
|
107
|
-
},
|
|
108
|
-
"MEMORY_TOKEN_BUDGET": {
|
|
109
|
-
"type": "number",
|
|
110
|
-
"description": "Maximum tokens to use for memory context in prompts.",
|
|
111
|
-
"required": false,
|
|
112
|
-
"default": 1000,
|
|
113
|
-
"sensitive": false
|
|
114
|
-
},
|
|
115
|
-
"MEMORY_SUMMARY_ENABLED": {
|
|
116
|
-
"type": "boolean",
|
|
117
|
-
"description": "Enable hierarchical conversation summarization to reduce token usage.",
|
|
118
|
-
"required": false,
|
|
119
|
-
"default": true,
|
|
120
|
-
"sensitive": false
|
|
121
|
-
},
|
|
122
|
-
"MEMORY_MESSAGES_PER_SUMMARY": {
|
|
123
|
-
"type": "number",
|
|
124
|
-
"description": "How many messages to include in each Level 1 summary.",
|
|
125
|
-
"required": false,
|
|
126
|
-
"default": 15,
|
|
127
|
-
"sensitive": false
|
|
128
|
-
},
|
|
129
|
-
"MEMORY_SUMMARIES_PER_LEVEL": {
|
|
130
|
-
"type": "number",
|
|
131
|
-
"description": "How many summaries to accumulate before creating the next level.",
|
|
132
|
-
"required": false,
|
|
133
|
-
"default": 5,
|
|
134
|
-
"sensitive": false
|
|
135
|
-
},
|
|
136
|
-
"MEMORY_SUMMARY_MAX_DEPTH": {
|
|
137
|
-
"type": "number",
|
|
138
|
-
"description": "Maximum depth of the summary hierarchy (1=direct summaries, 2=summaries of summaries, etc).",
|
|
139
|
-
"required": false,
|
|
140
|
-
"default": 3,
|
|
141
|
-
"sensitive": false
|
|
142
|
-
},
|
|
143
|
-
"MEMORY_SUMMARY_TOKEN_BUDGET": {
|
|
144
|
-
"type": "number",
|
|
145
|
-
"description": "Maximum tokens to use for conversation summaries in context.",
|
|
146
|
-
"required": false,
|
|
147
|
-
"default": 500,
|
|
148
|
-
"sensitive": false
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
69
|
}
|
|
152
70
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Evaluator } from '@elizaos/core';
|
|
2
|
-
/**
|
|
3
|
-
* Memory Consolidation Evaluator
|
|
4
|
-
*
|
|
5
|
-
* Research: Section 2.3 "Consolidation Pipeline"
|
|
6
|
-
*
|
|
7
|
-
* This evaluator implements the full consolidation flow:
|
|
8
|
-
* 1. Buffers conversation messages
|
|
9
|
-
* 2. Validates when threshold is reached
|
|
10
|
-
* 3. Extracts persistent facts using LLM
|
|
11
|
-
* 4. Stores memories via service
|
|
12
|
-
*
|
|
13
|
-
* Architecture Design:
|
|
14
|
-
* - Evaluator owns the consolidation logic and prompts
|
|
15
|
-
* - Service handles storage/retrieval only
|
|
16
|
-
* - System prompt is temporarily swapped during consolidation
|
|
17
|
-
* - Non-blocking: Doesn't wait for consolidation to complete
|
|
18
|
-
*/
|
|
19
|
-
export declare const consolidationEvaluator: Evaluator;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Consolidation Prompts
|
|
3
|
-
*
|
|
4
|
-
* Research: Section 2.2.2 "Proposed Extraction Prompt Structure"
|
|
5
|
-
*
|
|
6
|
-
* This module contains all prompts used for memory consolidation.
|
|
7
|
-
* Prompts are structured to use Chain-of-Thought (CoT) reasoning to
|
|
8
|
-
* distinguish transient events from persistent facts.
|
|
9
|
-
*
|
|
10
|
-
* Key Principles:
|
|
11
|
-
* - Clear mission statement
|
|
12
|
-
* - Explicit definitions (transient vs persistent)
|
|
13
|
-
* - Strict extraction rules
|
|
14
|
-
* - Structured XML output (more reliable than JSON for LLMs)
|
|
15
|
-
* - CoT examples for few-shot learning
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* System prompt for the consolidation engine
|
|
19
|
-
*
|
|
20
|
-
* This replaces runtime.character.system temporarily during consolidation
|
|
21
|
-
*/
|
|
22
|
-
export declare const CONSOLIDATION_SYSTEM_PROMPT = "You are the \"Cortex\" \u2014 an advanced Memory Extraction Engine.\nYour function is to parse conversation logs and extract persistent facts into a structured database format.\n\n# CORE DIRECTIVE: \"Subject-First\" Extraction\nYou must rephrase memories to focus on the *topic*, not the user. This optimizes vector retrieval.\n- BAD: \"User likes to trade Bitcoin.\" (Too generic)\n- GOOD: \"Bitcoin (BTC) is a preferred trading asset.\" (Topic-focused)\n\n# COMPRESSION RULES (CRITICAL)\n1. **Aggressive Filtering**: Most user chatter is noise. If it won't be relevant in 30 days, DO NOT extract it.\n2. **Merge & Dedupe**: Do not create three separate memories for one topic. Combine them.\n - *Input:* \"I like Red. I also like Blue. And Green.\"\n - *Output:* \"Red, Blue, and Green are the preferred colors.\"\n3. **Conflict Resolution**: If a new fact contradicts an old one, mark 'isContradiction' as true.\n\n# OUTPUT FORMAT\nPhase 1: [ANALYSIS]\n- List extracted points.\n- MARK items as [TRANSIENT] (Ignore) or [MERGE] (Combine).\n- Refine the final wording.\n\nPhase 2: [MEMORIES]\nFormat: `MEM|TYPE|CATEGORY|CONFIDENCE|IS_CONTRADICTION|CONTENT`\n\nTypes: EPISODIC, SEMANTIC, PROCEDURAL\nCategories: bio, health, finance, preferences, relationships, skills, work\n";
|
|
23
|
-
export declare function buildExtractionPrompt(conversationLog: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Contradiction detection prompt
|
|
26
|
-
*
|
|
27
|
-
* Research: Section 4.3.1 "Detection Logic"
|
|
28
|
-
*
|
|
29
|
-
* Used to determine if a new memory contradicts existing memories
|
|
30
|
-
*/
|
|
31
|
-
export declare function buildContradictionPrompt(newMemoryContent: string, existingMemories: Array<{
|
|
32
|
-
content: string;
|
|
33
|
-
confidence: number;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
}>): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hierarchical Summarization Prompts
|
|
3
|
-
*
|
|
4
|
-
* Research: Section 5.1.2 "Hierarchical Episodic Summarization"
|
|
5
|
-
*
|
|
6
|
-
* These prompts implement recursive, multi-level summarization:
|
|
7
|
-
* - Level 1: Summarize raw messages into narrative paragraphs
|
|
8
|
-
* - Level 2+: Summarize lower-level summaries into higher-level abstractions
|
|
9
|
-
*
|
|
10
|
-
* Goal: Achieve 10x token compression while preserving conversational narrative
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* System prompt for Level 1 summarization (messages → summary)
|
|
14
|
-
*/
|
|
15
|
-
export declare const SUMMARIZATION_SYSTEM_PROMPT = "You are \"Chronos\", a master summarizer.\nYour function is to condense conversation logs into concise, subject-first narrative summaries.\n\n# CORE DIRECTIVE: \"Subject-First\" Summarization\nYou must rephrase the narrative to focus on the *topic*, not the user. This optimizes vector retrieval.\n- BAD: \"User asked about Python.\" (Too generic)\n- GOOD: \"Python programming inquiries were addressed.\" (Topic-focused)\n\n# COMPRESSION RULES\n1. **Be Concise**: Target 2-4 sentences. Maximum 100 words.\n2. **Be Factual**: No interpretation, no speculation. Only what actually happened.\n3. **Be Narrative**: Write as a story, not a bullet list.\n4. **Preserve Key Facts**: If the user revealed important information (preferences, identity, needs), include it.\n5. **Exclude Trivia**: Skip greetings, acknowledgments, and filler conversation.\n\n# OUTPUT FORMAT\nPhase 1: [ANALYSIS]\n- Identify key topics.\n- Draft the summary.\n- Refine wording to be subject-first.\n\nPhase 2: [RESULT]\nFormat: `SUMM|TAGS|CONTENT`\n- TAGS: Comma-separated list of key topics (lowercase)\n- CONTENT: The narrative summary text (must be a single line, no newlines)\n";
|
|
16
|
-
export declare function buildLevel1SummaryPrompt(formattedMessages: string, previousSummary?: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* System prompt for Level 2+ summarization (summaries → meta-summary)
|
|
19
|
-
*/
|
|
20
|
-
export declare const HIGHER_LEVEL_SUMMARIZATION_SYSTEM_PROMPT = "You are \"Chronos\", a Meta-Summarization Agent.\nYour task is to compress multiple conversation summaries into a single, higher-level summary.\n\n# MISSION\nTransform a list of conversation summaries into one concise meta-summary that captures:\n1. **Overarching themes** across the summaries\n2. **Key events or milestones** (e.g., \"User onboarded\", \"Project completed\")\n3. **Evolving context** (e.g., \"User's preferences shifted from X to Y\")\n\n# RULES\n- **Subject-First**: Focus on the topic, not the user.\n- **Abstract Higher**: Don't repeat specifics from each summary. Find the pattern.\n- **Chronological Flow**: Maintain temporal order if it matters.\n- **Preserve Critical Facts**: If summaries mention important identity or preferences, keep them.\n\n# OUTPUT FORMAT\nPhase 1: [ANALYSIS]\n- Identify themes and milestones.\n- Combine related points.\n- Refine to subject-first.\n\nPhase 2: [RESULT]\nFormat: `SUMM|TAGS|CONTENT`\n- TAGS: Comma-separated list of key topics (lowercase)\n- CONTENT: The meta-summary text (must be a single line, no newlines)\n";
|
|
21
|
-
export declare function buildHigherLevelSummaryPrompt(formattedSummaries: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Estimate token count from text (used as fallback)
|
|
24
|
-
*/
|
|
25
|
-
export declare function estimateTokensInSummary(text: string): number;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { IAgentRuntime, UUID } from '@elizaos/core';
|
|
2
|
-
import { type ConversationSummary, type EmbeddingDimensionColumn } from '../types/index';
|
|
3
|
-
/**
|
|
4
|
-
* Conversation Summary Repository
|
|
5
|
-
*
|
|
6
|
-
* Research: Section 5.1.2 "Hierarchical Conversation Summarization"
|
|
7
|
-
* Handles database operations for conversation summaries
|
|
8
|
-
*/
|
|
9
|
-
export declare class ConversationSummaryRepository {
|
|
10
|
-
private runtime;
|
|
11
|
-
private embeddingDimension?;
|
|
12
|
-
constructor(runtime: IAgentRuntime, embeddingDimension?: EmbeddingDimensionColumn);
|
|
13
|
-
/**
|
|
14
|
-
* Get database instance with health check
|
|
15
|
-
*/
|
|
16
|
-
private getDb;
|
|
17
|
-
/**
|
|
18
|
-
* Insert a new summary
|
|
19
|
-
*/
|
|
20
|
-
insert(summary: Omit<ConversationSummary, 'id' | 'createdAt' | 'lastAccessedAt' | 'accessCount'>, embedding?: number[]): Promise<ConversationSummary>;
|
|
21
|
-
/**
|
|
22
|
-
* Find summaries by level
|
|
23
|
-
*/
|
|
24
|
-
findByLevel(roomId: UUID, level: number): Promise<ConversationSummary[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Vector search for summaries
|
|
27
|
-
*/
|
|
28
|
-
vectorSearch(entityId: UUID, roomId: UUID, queryEmbedding: number[], limit?: number): Promise<ConversationSummary[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Update access metadata for summaries
|
|
31
|
-
*/
|
|
32
|
-
updateAccessMetadata(summaryIds: UUID[]): Promise<void>;
|
|
33
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository Layer for Memory Plugin
|
|
3
|
-
*
|
|
4
|
-
* This module provides data access repositories that encapsulate
|
|
5
|
-
* all database operations for the memory system.
|
|
6
|
-
*
|
|
7
|
-
* Repositories handle:
|
|
8
|
-
* - Database connection management
|
|
9
|
-
* - CRUD operations
|
|
10
|
-
* - Query building
|
|
11
|
-
* - Transaction management
|
|
12
|
-
* - Health checks for long-running operations
|
|
13
|
-
*
|
|
14
|
-
* Research: Clean Architecture - Separation of data access from business logic
|
|
15
|
-
*/
|
|
16
|
-
export * from './long-term-memory';
|
|
17
|
-
export * from './conversation-summary';
|