@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
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { IAgentRuntime, UUID } from '@elizaos/core';
|
|
2
|
-
import { type LongTermMemory, type LongTermMemoryRetrievalResult, type LongTermMemorySearchParams, type EmbeddingDimensionColumn, MemoryType } from '../types/index';
|
|
3
|
-
/**
|
|
4
|
-
* Long-Term Memory Repository
|
|
5
|
-
*
|
|
6
|
-
* Handles all database operations for long-term memories
|
|
7
|
-
* Provides clean data access layer separated from business logic
|
|
8
|
-
*/
|
|
9
|
-
export declare class LongTermMemoryRepository {
|
|
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 memory into database
|
|
19
|
-
*/
|
|
20
|
-
insert(memory: Omit<LongTermMemory, 'id' | 'createdAt' | 'lastAccessedAt' | 'accessCount' | 'isActive' | 'embedding'>, embedding?: number[]): Promise<LongTermMemory>;
|
|
21
|
-
/**
|
|
22
|
-
* Find memory by ID
|
|
23
|
-
*/
|
|
24
|
-
findById(id: UUID): Promise<LongTermMemory | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Update existing memory
|
|
27
|
-
*/
|
|
28
|
-
update(id: UUID, updates: Partial<LongTermMemory>, newEmbedding?: number[]): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Delete memory (hard delete)
|
|
31
|
-
*/
|
|
32
|
-
delete(id: UUID): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Find memories by entity with optional filters
|
|
35
|
-
*/
|
|
36
|
-
findByEntity(entityId: UUID, type?: MemoryType, limit?: number, includeInactive?: boolean): Promise<LongTermMemory[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Vector search for memories
|
|
39
|
-
*/
|
|
40
|
-
vectorSearch(params: LongTermMemorySearchParams, queryEmbedding: number[], similarityThreshold?: number): Promise<LongTermMemoryRetrievalResult[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Fetch all active memories for BM25 indexing
|
|
43
|
-
*/
|
|
44
|
-
fetchAllActive(): Promise<Array<{
|
|
45
|
-
id: UUID;
|
|
46
|
-
content: string;
|
|
47
|
-
embeddingContext: string;
|
|
48
|
-
}>>;
|
|
49
|
-
/**
|
|
50
|
-
* Update access metadata (lastAccessedAt and accessCount)
|
|
51
|
-
*/
|
|
52
|
-
updateAccessMetadata(memoryIds: UUID[]): Promise<void>;
|
|
53
|
-
}
|
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conversation Summaries Table - Hierarchical Summarization
|
|
3
|
-
*
|
|
4
|
-
* Research: Section 5.1.2 "Hierarchical Episodic Summarization"
|
|
5
|
-
*
|
|
6
|
-
* This table implements recursive, multi-level summarization for long conversations:
|
|
7
|
-
* - Level 0: Raw messages (stored elsewhere)
|
|
8
|
-
* - Level 1: Summary of 50-100 messages
|
|
9
|
-
* - Level 2: Summary of 5-10 Level 1 summaries
|
|
10
|
-
* - Level 3+: Recursive summarization for very long sessions
|
|
11
|
-
*
|
|
12
|
-
* Benefits:
|
|
13
|
-
* - Dramatic token reduction (10x compression)
|
|
14
|
-
* - Better context management for 100+ message sessions
|
|
15
|
-
* - Preserves conversational narrative without exploding context window
|
|
16
|
-
*
|
|
17
|
-
* Design Philosophy:
|
|
18
|
-
* - Summaries reference other summaries (parentSummaryId for tree structure)
|
|
19
|
-
* - Each summary has a level (depth in the hierarchy)
|
|
20
|
-
* - Token count tracked for precise budget management
|
|
21
|
-
* - Time ranges tracked for temporal queries
|
|
22
|
-
*
|
|
23
|
-
* Note: "Conversation Summaries" provide narrative context, distinct from "Facts" which are discrete knowledge units.
|
|
24
|
-
*/
|
|
25
|
-
export declare const conversationSummaries: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
26
|
-
name: "conversation_summaries";
|
|
27
|
-
schema: undefined;
|
|
28
|
-
columns: {
|
|
29
|
-
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
30
|
-
name: "id";
|
|
31
|
-
tableName: "conversation_summaries";
|
|
32
|
-
dataType: "string";
|
|
33
|
-
columnType: "PgVarchar";
|
|
34
|
-
data: string;
|
|
35
|
-
driverParam: string;
|
|
36
|
-
notNull: true;
|
|
37
|
-
hasDefault: false;
|
|
38
|
-
isPrimaryKey: true;
|
|
39
|
-
isAutoincrement: false;
|
|
40
|
-
hasRuntimeDefault: false;
|
|
41
|
-
enumValues: [string, ...string[]];
|
|
42
|
-
baseColumn: never;
|
|
43
|
-
identity: undefined;
|
|
44
|
-
generated: undefined;
|
|
45
|
-
}, {}, {
|
|
46
|
-
length: 36;
|
|
47
|
-
}>;
|
|
48
|
-
agentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
49
|
-
name: "agent_id";
|
|
50
|
-
tableName: "conversation_summaries";
|
|
51
|
-
dataType: "string";
|
|
52
|
-
columnType: "PgVarchar";
|
|
53
|
-
data: string;
|
|
54
|
-
driverParam: string;
|
|
55
|
-
notNull: true;
|
|
56
|
-
hasDefault: false;
|
|
57
|
-
isPrimaryKey: false;
|
|
58
|
-
isAutoincrement: false;
|
|
59
|
-
hasRuntimeDefault: false;
|
|
60
|
-
enumValues: [string, ...string[]];
|
|
61
|
-
baseColumn: never;
|
|
62
|
-
identity: undefined;
|
|
63
|
-
generated: undefined;
|
|
64
|
-
}, {}, {
|
|
65
|
-
length: 36;
|
|
66
|
-
}>;
|
|
67
|
-
entityId: import("drizzle-orm/pg-core").PgColumn<{
|
|
68
|
-
name: "entity_id";
|
|
69
|
-
tableName: "conversation_summaries";
|
|
70
|
-
dataType: "string";
|
|
71
|
-
columnType: "PgVarchar";
|
|
72
|
-
data: string;
|
|
73
|
-
driverParam: string;
|
|
74
|
-
notNull: true;
|
|
75
|
-
hasDefault: false;
|
|
76
|
-
isPrimaryKey: false;
|
|
77
|
-
isAutoincrement: false;
|
|
78
|
-
hasRuntimeDefault: false;
|
|
79
|
-
enumValues: [string, ...string[]];
|
|
80
|
-
baseColumn: never;
|
|
81
|
-
identity: undefined;
|
|
82
|
-
generated: undefined;
|
|
83
|
-
}, {}, {
|
|
84
|
-
length: 36;
|
|
85
|
-
}>;
|
|
86
|
-
roomId: import("drizzle-orm/pg-core").PgColumn<{
|
|
87
|
-
name: "room_id";
|
|
88
|
-
tableName: "conversation_summaries";
|
|
89
|
-
dataType: "string";
|
|
90
|
-
columnType: "PgVarchar";
|
|
91
|
-
data: string;
|
|
92
|
-
driverParam: string;
|
|
93
|
-
notNull: true;
|
|
94
|
-
hasDefault: false;
|
|
95
|
-
isPrimaryKey: false;
|
|
96
|
-
isAutoincrement: false;
|
|
97
|
-
hasRuntimeDefault: false;
|
|
98
|
-
enumValues: [string, ...string[]];
|
|
99
|
-
baseColumn: never;
|
|
100
|
-
identity: undefined;
|
|
101
|
-
generated: undefined;
|
|
102
|
-
}, {}, {
|
|
103
|
-
length: 36;
|
|
104
|
-
}>;
|
|
105
|
-
level: import("drizzle-orm/pg-core").PgColumn<{
|
|
106
|
-
name: "level";
|
|
107
|
-
tableName: "conversation_summaries";
|
|
108
|
-
dataType: "number";
|
|
109
|
-
columnType: "PgInteger";
|
|
110
|
-
data: number;
|
|
111
|
-
driverParam: string | number;
|
|
112
|
-
notNull: true;
|
|
113
|
-
hasDefault: true;
|
|
114
|
-
isPrimaryKey: false;
|
|
115
|
-
isAutoincrement: false;
|
|
116
|
-
hasRuntimeDefault: false;
|
|
117
|
-
enumValues: undefined;
|
|
118
|
-
baseColumn: never;
|
|
119
|
-
identity: undefined;
|
|
120
|
-
generated: undefined;
|
|
121
|
-
}, {}, {}>;
|
|
122
|
-
parentSummaryId: import("drizzle-orm/pg-core").PgColumn<{
|
|
123
|
-
name: "parent_summary_id";
|
|
124
|
-
tableName: "conversation_summaries";
|
|
125
|
-
dataType: "string";
|
|
126
|
-
columnType: "PgVarchar";
|
|
127
|
-
data: string;
|
|
128
|
-
driverParam: string;
|
|
129
|
-
notNull: false;
|
|
130
|
-
hasDefault: false;
|
|
131
|
-
isPrimaryKey: false;
|
|
132
|
-
isAutoincrement: false;
|
|
133
|
-
hasRuntimeDefault: false;
|
|
134
|
-
enumValues: [string, ...string[]];
|
|
135
|
-
baseColumn: never;
|
|
136
|
-
identity: undefined;
|
|
137
|
-
generated: undefined;
|
|
138
|
-
}, {}, {
|
|
139
|
-
length: 36;
|
|
140
|
-
}>;
|
|
141
|
-
content: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
-
name: "content";
|
|
143
|
-
tableName: "conversation_summaries";
|
|
144
|
-
dataType: "string";
|
|
145
|
-
columnType: "PgText";
|
|
146
|
-
data: string;
|
|
147
|
-
driverParam: string;
|
|
148
|
-
notNull: true;
|
|
149
|
-
hasDefault: false;
|
|
150
|
-
isPrimaryKey: false;
|
|
151
|
-
isAutoincrement: false;
|
|
152
|
-
hasRuntimeDefault: false;
|
|
153
|
-
enumValues: [string, ...string[]];
|
|
154
|
-
baseColumn: never;
|
|
155
|
-
identity: undefined;
|
|
156
|
-
generated: undefined;
|
|
157
|
-
}, {}, {}>;
|
|
158
|
-
tokenCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
-
name: "token_count";
|
|
160
|
-
tableName: "conversation_summaries";
|
|
161
|
-
dataType: "number";
|
|
162
|
-
columnType: "PgInteger";
|
|
163
|
-
data: number;
|
|
164
|
-
driverParam: string | number;
|
|
165
|
-
notNull: true;
|
|
166
|
-
hasDefault: false;
|
|
167
|
-
isPrimaryKey: false;
|
|
168
|
-
isAutoincrement: false;
|
|
169
|
-
hasRuntimeDefault: false;
|
|
170
|
-
enumValues: undefined;
|
|
171
|
-
baseColumn: never;
|
|
172
|
-
identity: undefined;
|
|
173
|
-
generated: undefined;
|
|
174
|
-
}, {}, {}>;
|
|
175
|
-
startTime: import("drizzle-orm/pg-core").PgColumn<{
|
|
176
|
-
name: "start_time";
|
|
177
|
-
tableName: "conversation_summaries";
|
|
178
|
-
dataType: "date";
|
|
179
|
-
columnType: "PgTimestamp";
|
|
180
|
-
data: Date;
|
|
181
|
-
driverParam: string;
|
|
182
|
-
notNull: true;
|
|
183
|
-
hasDefault: false;
|
|
184
|
-
isPrimaryKey: false;
|
|
185
|
-
isAutoincrement: false;
|
|
186
|
-
hasRuntimeDefault: false;
|
|
187
|
-
enumValues: undefined;
|
|
188
|
-
baseColumn: never;
|
|
189
|
-
identity: undefined;
|
|
190
|
-
generated: undefined;
|
|
191
|
-
}, {}, {}>;
|
|
192
|
-
endTime: import("drizzle-orm/pg-core").PgColumn<{
|
|
193
|
-
name: "end_time";
|
|
194
|
-
tableName: "conversation_summaries";
|
|
195
|
-
dataType: "date";
|
|
196
|
-
columnType: "PgTimestamp";
|
|
197
|
-
data: Date;
|
|
198
|
-
driverParam: string;
|
|
199
|
-
notNull: true;
|
|
200
|
-
hasDefault: false;
|
|
201
|
-
isPrimaryKey: false;
|
|
202
|
-
isAutoincrement: false;
|
|
203
|
-
hasRuntimeDefault: false;
|
|
204
|
-
enumValues: undefined;
|
|
205
|
-
baseColumn: never;
|
|
206
|
-
identity: undefined;
|
|
207
|
-
generated: undefined;
|
|
208
|
-
}, {}, {}>;
|
|
209
|
-
sourceCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
210
|
-
name: "source_count";
|
|
211
|
-
tableName: "conversation_summaries";
|
|
212
|
-
dataType: "number";
|
|
213
|
-
columnType: "PgInteger";
|
|
214
|
-
data: number;
|
|
215
|
-
driverParam: string | number;
|
|
216
|
-
notNull: true;
|
|
217
|
-
hasDefault: false;
|
|
218
|
-
isPrimaryKey: false;
|
|
219
|
-
isAutoincrement: false;
|
|
220
|
-
hasRuntimeDefault: false;
|
|
221
|
-
enumValues: undefined;
|
|
222
|
-
baseColumn: never;
|
|
223
|
-
identity: undefined;
|
|
224
|
-
generated: undefined;
|
|
225
|
-
}, {}, {}>;
|
|
226
|
-
sourceIds: import("drizzle-orm/pg-core").PgColumn<{
|
|
227
|
-
name: "source_ids";
|
|
228
|
-
tableName: "conversation_summaries";
|
|
229
|
-
dataType: "json";
|
|
230
|
-
columnType: "PgJsonb";
|
|
231
|
-
data: unknown;
|
|
232
|
-
driverParam: unknown;
|
|
233
|
-
notNull: true;
|
|
234
|
-
hasDefault: true;
|
|
235
|
-
isPrimaryKey: false;
|
|
236
|
-
isAutoincrement: false;
|
|
237
|
-
hasRuntimeDefault: false;
|
|
238
|
-
enumValues: undefined;
|
|
239
|
-
baseColumn: never;
|
|
240
|
-
identity: undefined;
|
|
241
|
-
generated: undefined;
|
|
242
|
-
}, {}, {}>;
|
|
243
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
244
|
-
name: "created_at";
|
|
245
|
-
tableName: "conversation_summaries";
|
|
246
|
-
dataType: "date";
|
|
247
|
-
columnType: "PgTimestamp";
|
|
248
|
-
data: Date;
|
|
249
|
-
driverParam: string;
|
|
250
|
-
notNull: true;
|
|
251
|
-
hasDefault: true;
|
|
252
|
-
isPrimaryKey: false;
|
|
253
|
-
isAutoincrement: false;
|
|
254
|
-
hasRuntimeDefault: false;
|
|
255
|
-
enumValues: undefined;
|
|
256
|
-
baseColumn: never;
|
|
257
|
-
identity: undefined;
|
|
258
|
-
generated: undefined;
|
|
259
|
-
}, {}, {}>;
|
|
260
|
-
lastAccessedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
261
|
-
name: "last_accessed_at";
|
|
262
|
-
tableName: "conversation_summaries";
|
|
263
|
-
dataType: "date";
|
|
264
|
-
columnType: "PgTimestamp";
|
|
265
|
-
data: Date;
|
|
266
|
-
driverParam: string;
|
|
267
|
-
notNull: false;
|
|
268
|
-
hasDefault: false;
|
|
269
|
-
isPrimaryKey: false;
|
|
270
|
-
isAutoincrement: false;
|
|
271
|
-
hasRuntimeDefault: false;
|
|
272
|
-
enumValues: undefined;
|
|
273
|
-
baseColumn: never;
|
|
274
|
-
identity: undefined;
|
|
275
|
-
generated: undefined;
|
|
276
|
-
}, {}, {}>;
|
|
277
|
-
accessCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
278
|
-
name: "access_count";
|
|
279
|
-
tableName: "conversation_summaries";
|
|
280
|
-
dataType: "number";
|
|
281
|
-
columnType: "PgInteger";
|
|
282
|
-
data: number;
|
|
283
|
-
driverParam: string | number;
|
|
284
|
-
notNull: true;
|
|
285
|
-
hasDefault: true;
|
|
286
|
-
isPrimaryKey: false;
|
|
287
|
-
isAutoincrement: false;
|
|
288
|
-
hasRuntimeDefault: false;
|
|
289
|
-
enumValues: undefined;
|
|
290
|
-
baseColumn: never;
|
|
291
|
-
identity: undefined;
|
|
292
|
-
generated: undefined;
|
|
293
|
-
}, {}, {}>;
|
|
294
|
-
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
295
|
-
name: "metadata";
|
|
296
|
-
tableName: "conversation_summaries";
|
|
297
|
-
dataType: "json";
|
|
298
|
-
columnType: "PgJsonb";
|
|
299
|
-
data: unknown;
|
|
300
|
-
driverParam: unknown;
|
|
301
|
-
notNull: true;
|
|
302
|
-
hasDefault: true;
|
|
303
|
-
isPrimaryKey: false;
|
|
304
|
-
isAutoincrement: false;
|
|
305
|
-
hasRuntimeDefault: false;
|
|
306
|
-
enumValues: undefined;
|
|
307
|
-
baseColumn: never;
|
|
308
|
-
identity: undefined;
|
|
309
|
-
generated: undefined;
|
|
310
|
-
}, {}, {}>;
|
|
311
|
-
};
|
|
312
|
-
dialect: "pg";
|
|
313
|
-
}>;
|
|
314
|
-
/**
|
|
315
|
-
* Conversation Summary Embeddings Table
|
|
316
|
-
* Stores vector embeddings for semantic search of summaries with dynamic dimension support
|
|
317
|
-
* Research: Section 5.1.2 "Hierarchical Episodic Summarization" + Section 3 "RAG Strategy"
|
|
318
|
-
*/
|
|
319
|
-
export declare const conversationSummaryEmbeddings: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
320
|
-
name: "conversation_summary_embeddings";
|
|
321
|
-
schema: undefined;
|
|
322
|
-
columns: {
|
|
323
|
-
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
324
|
-
name: "id";
|
|
325
|
-
tableName: "conversation_summary_embeddings";
|
|
326
|
-
dataType: "string";
|
|
327
|
-
columnType: "PgVarchar";
|
|
328
|
-
data: string;
|
|
329
|
-
driverParam: string;
|
|
330
|
-
notNull: true;
|
|
331
|
-
hasDefault: false;
|
|
332
|
-
isPrimaryKey: true;
|
|
333
|
-
isAutoincrement: false;
|
|
334
|
-
hasRuntimeDefault: false;
|
|
335
|
-
enumValues: [string, ...string[]];
|
|
336
|
-
baseColumn: never;
|
|
337
|
-
identity: undefined;
|
|
338
|
-
generated: undefined;
|
|
339
|
-
}, {}, {
|
|
340
|
-
length: 36;
|
|
341
|
-
}>;
|
|
342
|
-
summaryId: import("drizzle-orm/pg-core").PgColumn<{
|
|
343
|
-
name: "summary_id";
|
|
344
|
-
tableName: "conversation_summary_embeddings";
|
|
345
|
-
dataType: "string";
|
|
346
|
-
columnType: "PgVarchar";
|
|
347
|
-
data: string;
|
|
348
|
-
driverParam: string;
|
|
349
|
-
notNull: true;
|
|
350
|
-
hasDefault: false;
|
|
351
|
-
isPrimaryKey: false;
|
|
352
|
-
isAutoincrement: false;
|
|
353
|
-
hasRuntimeDefault: false;
|
|
354
|
-
enumValues: [string, ...string[]];
|
|
355
|
-
baseColumn: never;
|
|
356
|
-
identity: undefined;
|
|
357
|
-
generated: undefined;
|
|
358
|
-
}, {}, {
|
|
359
|
-
length: 36;
|
|
360
|
-
}>;
|
|
361
|
-
dim384: import("drizzle-orm/pg-core").PgColumn<{
|
|
362
|
-
name: "dim_384";
|
|
363
|
-
tableName: "conversation_summary_embeddings";
|
|
364
|
-
dataType: "array";
|
|
365
|
-
columnType: "PgVector";
|
|
366
|
-
data: number[];
|
|
367
|
-
driverParam: string;
|
|
368
|
-
notNull: false;
|
|
369
|
-
hasDefault: false;
|
|
370
|
-
isPrimaryKey: false;
|
|
371
|
-
isAutoincrement: false;
|
|
372
|
-
hasRuntimeDefault: false;
|
|
373
|
-
enumValues: undefined;
|
|
374
|
-
baseColumn: never;
|
|
375
|
-
identity: undefined;
|
|
376
|
-
generated: undefined;
|
|
377
|
-
}, {}, {
|
|
378
|
-
dimensions: 384;
|
|
379
|
-
}>;
|
|
380
|
-
dim512: import("drizzle-orm/pg-core").PgColumn<{
|
|
381
|
-
name: "dim_512";
|
|
382
|
-
tableName: "conversation_summary_embeddings";
|
|
383
|
-
dataType: "array";
|
|
384
|
-
columnType: "PgVector";
|
|
385
|
-
data: number[];
|
|
386
|
-
driverParam: string;
|
|
387
|
-
notNull: false;
|
|
388
|
-
hasDefault: false;
|
|
389
|
-
isPrimaryKey: false;
|
|
390
|
-
isAutoincrement: false;
|
|
391
|
-
hasRuntimeDefault: false;
|
|
392
|
-
enumValues: undefined;
|
|
393
|
-
baseColumn: never;
|
|
394
|
-
identity: undefined;
|
|
395
|
-
generated: undefined;
|
|
396
|
-
}, {}, {
|
|
397
|
-
dimensions: 512;
|
|
398
|
-
}>;
|
|
399
|
-
dim768: import("drizzle-orm/pg-core").PgColumn<{
|
|
400
|
-
name: "dim_768";
|
|
401
|
-
tableName: "conversation_summary_embeddings";
|
|
402
|
-
dataType: "array";
|
|
403
|
-
columnType: "PgVector";
|
|
404
|
-
data: number[];
|
|
405
|
-
driverParam: string;
|
|
406
|
-
notNull: false;
|
|
407
|
-
hasDefault: false;
|
|
408
|
-
isPrimaryKey: false;
|
|
409
|
-
isAutoincrement: false;
|
|
410
|
-
hasRuntimeDefault: false;
|
|
411
|
-
enumValues: undefined;
|
|
412
|
-
baseColumn: never;
|
|
413
|
-
identity: undefined;
|
|
414
|
-
generated: undefined;
|
|
415
|
-
}, {}, {
|
|
416
|
-
dimensions: 768;
|
|
417
|
-
}>;
|
|
418
|
-
dim1024: import("drizzle-orm/pg-core").PgColumn<{
|
|
419
|
-
name: "dim_1024";
|
|
420
|
-
tableName: "conversation_summary_embeddings";
|
|
421
|
-
dataType: "array";
|
|
422
|
-
columnType: "PgVector";
|
|
423
|
-
data: number[];
|
|
424
|
-
driverParam: string;
|
|
425
|
-
notNull: false;
|
|
426
|
-
hasDefault: false;
|
|
427
|
-
isPrimaryKey: false;
|
|
428
|
-
isAutoincrement: false;
|
|
429
|
-
hasRuntimeDefault: false;
|
|
430
|
-
enumValues: undefined;
|
|
431
|
-
baseColumn: never;
|
|
432
|
-
identity: undefined;
|
|
433
|
-
generated: undefined;
|
|
434
|
-
}, {}, {
|
|
435
|
-
dimensions: 1024;
|
|
436
|
-
}>;
|
|
437
|
-
dim1536: import("drizzle-orm/pg-core").PgColumn<{
|
|
438
|
-
name: "dim_1536";
|
|
439
|
-
tableName: "conversation_summary_embeddings";
|
|
440
|
-
dataType: "array";
|
|
441
|
-
columnType: "PgVector";
|
|
442
|
-
data: number[];
|
|
443
|
-
driverParam: string;
|
|
444
|
-
notNull: false;
|
|
445
|
-
hasDefault: false;
|
|
446
|
-
isPrimaryKey: false;
|
|
447
|
-
isAutoincrement: false;
|
|
448
|
-
hasRuntimeDefault: false;
|
|
449
|
-
enumValues: undefined;
|
|
450
|
-
baseColumn: never;
|
|
451
|
-
identity: undefined;
|
|
452
|
-
generated: undefined;
|
|
453
|
-
}, {}, {
|
|
454
|
-
dimensions: 1536;
|
|
455
|
-
}>;
|
|
456
|
-
dim3072: import("drizzle-orm/pg-core").PgColumn<{
|
|
457
|
-
name: "dim_3072";
|
|
458
|
-
tableName: "conversation_summary_embeddings";
|
|
459
|
-
dataType: "array";
|
|
460
|
-
columnType: "PgVector";
|
|
461
|
-
data: number[];
|
|
462
|
-
driverParam: string;
|
|
463
|
-
notNull: false;
|
|
464
|
-
hasDefault: false;
|
|
465
|
-
isPrimaryKey: false;
|
|
466
|
-
isAutoincrement: false;
|
|
467
|
-
hasRuntimeDefault: false;
|
|
468
|
-
enumValues: undefined;
|
|
469
|
-
baseColumn: never;
|
|
470
|
-
identity: undefined;
|
|
471
|
-
generated: undefined;
|
|
472
|
-
}, {}, {
|
|
473
|
-
dimensions: 3072;
|
|
474
|
-
}>;
|
|
475
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
476
|
-
name: "created_at";
|
|
477
|
-
tableName: "conversation_summary_embeddings";
|
|
478
|
-
dataType: "date";
|
|
479
|
-
columnType: "PgTimestamp";
|
|
480
|
-
data: Date;
|
|
481
|
-
driverParam: string;
|
|
482
|
-
notNull: true;
|
|
483
|
-
hasDefault: true;
|
|
484
|
-
isPrimaryKey: false;
|
|
485
|
-
isAutoincrement: false;
|
|
486
|
-
hasRuntimeDefault: false;
|
|
487
|
-
enumValues: undefined;
|
|
488
|
-
baseColumn: never;
|
|
489
|
-
identity: undefined;
|
|
490
|
-
generated: undefined;
|
|
491
|
-
}, {}, {}>;
|
|
492
|
-
};
|
|
493
|
-
dialect: "pg";
|
|
494
|
-
}>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type LongTermMemory, type ConversationSummary } from '../types/index';
|
|
2
|
-
/**
|
|
3
|
-
* Database Row Mapping Utilities
|
|
4
|
-
*
|
|
5
|
-
* Maps raw database rows to strongly-typed domain objects
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Map database row to LongTermMemory object
|
|
9
|
-
*
|
|
10
|
-
* @param row - Raw database row
|
|
11
|
-
* @returns Typed LongTermMemory object
|
|
12
|
-
*/
|
|
13
|
-
export declare function mapDbRowToLongTermMemory(row: any): LongTermMemory;
|
|
14
|
-
/**
|
|
15
|
-
* Map database row to ConversationSummary object
|
|
16
|
-
*
|
|
17
|
-
* @param row - Raw database row
|
|
18
|
-
* @returns Typed ConversationSummary object
|
|
19
|
-
*/
|
|
20
|
-
export declare function mapDbRowToConversationSummary(row: any): ConversationSummary;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { DecayFunction, type LongTermMemoryRetrievalResult } from '../types/index';
|
|
2
|
-
/**
|
|
3
|
-
* Decay Scoring Utilities
|
|
4
|
-
*
|
|
5
|
-
* Research: Section 4.2 "Mathematical Model for Memory Decay"
|
|
6
|
-
*
|
|
7
|
-
* Implements exponential and linear decay functions to model natural
|
|
8
|
-
* forgetting curves inspired by cognitive science research (Ebbinghaus forgetting curve)
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Calculate decay factor based on decay function type
|
|
12
|
-
*
|
|
13
|
-
* Research: Section 4.2 "Mathematical Model for Memory Decay"
|
|
14
|
-
* Formula: Score = Relevance * Confidence * exp(-λ * (t_now - t_last))
|
|
15
|
-
*
|
|
16
|
-
* @param decayFunction - Type of decay function (EXPONENTIAL, LINEAR, NONE)
|
|
17
|
-
* @param decayRate - Decay rate (lambda λ)
|
|
18
|
-
* @param timeDeltaDays - Time since last access in days
|
|
19
|
-
* @returns Decay factor (0.0 to 1.0)
|
|
20
|
-
*/
|
|
21
|
-
export declare function calculateDecayFactor(decayFunction: DecayFunction, decayRate: number, timeDeltaDays: number): number;
|
|
22
|
-
/**
|
|
23
|
-
* Calculate access boost factor from access count
|
|
24
|
-
*
|
|
25
|
-
* Research: Section 4.2.2 "Reinforcement"
|
|
26
|
-
* More accesses = stronger memory
|
|
27
|
-
*
|
|
28
|
-
* @param accessCount - Number of times memory has been accessed
|
|
29
|
-
* @returns Boost factor (>= 1.0)
|
|
30
|
-
*/
|
|
31
|
-
export declare function calculateAccessBoost(accessCount: number): number;
|
|
32
|
-
/**
|
|
33
|
-
* Apply decay scoring to a set of memories
|
|
34
|
-
*
|
|
35
|
-
* Research: Section 4.2 "Mathematical Model for Memory Decay"
|
|
36
|
-
* Calculates activation score and final score for each memory
|
|
37
|
-
*
|
|
38
|
-
* @param memories - Array of memory retrieval results
|
|
39
|
-
* @returns Array with decay scores applied
|
|
40
|
-
*/
|
|
41
|
-
export declare function applyDecayScoring(memories: LongTermMemoryRetrievalResult[]): LongTermMemoryRetrievalResult[];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type IAgentRuntime } from '@elizaos/core';
|
|
2
|
-
/**
|
|
3
|
-
* Embedding Generation Utility
|
|
4
|
-
*
|
|
5
|
-
* Research: Section 3.2.1 "Contextual Embeddings"
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Generate embedding for text using the runtime's embedding model
|
|
9
|
-
*
|
|
10
|
-
* @param runtime - Agent runtime instance
|
|
11
|
-
* @param text - Text to generate embedding for
|
|
12
|
-
* @returns Embedding vector
|
|
13
|
-
*/
|
|
14
|
-
export declare function generateEmbedding(runtime: IAgentRuntime, text: string): Promise<number[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Clean and normalize an embedding vector
|
|
17
|
-
*
|
|
18
|
-
* @param embedding - Raw embedding vector
|
|
19
|
-
* @returns Cleaned vector with finite numbers and fixed precision
|
|
20
|
-
*/
|
|
21
|
-
export declare function cleanEmbedding(embedding: number[]): number[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type LongTermMemoryRetrievalResult } from '../types/index';
|
|
2
|
-
/**
|
|
3
|
-
* Memory Formatting Utilities
|
|
4
|
-
*
|
|
5
|
-
* Research: Section 5.1.3 "Tier 3: Just-In-Time Injection"
|
|
6
|
-
* Formats memories for LLM context in a human-readable format
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Format memories for context injection
|
|
10
|
-
*
|
|
11
|
-
* Research: Section 5.1.3 "Tier 3: Just-In-Time Injection"
|
|
12
|
-
* Groups by type and formats in a human-readable markdown format
|
|
13
|
-
*
|
|
14
|
-
* @param memories - Array of memories to format
|
|
15
|
-
* @returns Formatted string for LLM context
|
|
16
|
-
*/
|
|
17
|
-
export declare function formatMemoriesForContext(memories: LongTermMemoryRetrievalResult[]): string;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility Functions for Memory Plugin
|
|
3
|
-
*
|
|
4
|
-
* This module exports reusable utility functions for:
|
|
5
|
-
* - Embedding generation and cleaning
|
|
6
|
-
* - Decay scoring calculations
|
|
7
|
-
* - Search result merging
|
|
8
|
-
* - Memory formatting
|
|
9
|
-
* - Database row mapping
|
|
10
|
-
* - Token counting and budget enforcement
|
|
11
|
-
*/
|
|
12
|
-
export * from './embedding';
|
|
13
|
-
export * from './decay-scoring';
|
|
14
|
-
export * from './search-merging';
|
|
15
|
-
export * from './formatting';
|
|
16
|
-
export * from './db-mapping';
|
|
17
|
-
export * from './token-counter';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { LongTermMemoryRetrievalResult } from '../types/index';
|
|
2
|
-
/**
|
|
3
|
-
* Search Result Merging Utilities
|
|
4
|
-
*
|
|
5
|
-
* Research: Section 3.2.1 "Contextual Retrieval"
|
|
6
|
-
* Combines multiple ranking methods (Vector + BM25) for superior retrieval
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Merge vector and BM25 search results
|
|
10
|
-
*
|
|
11
|
-
* Research: Section 3.2.1 "Contextual Retrieval"
|
|
12
|
-
* When a memory appears in both result sets, average their scores
|
|
13
|
-
*
|
|
14
|
-
* @param vectorResults - Results from vector search
|
|
15
|
-
* @param bm25Results - Results from BM25 search
|
|
16
|
-
* @returns Merged results with combined scores
|
|
17
|
-
*/
|
|
18
|
-
export declare function mergeSearchResults(vectorResults: LongTermMemoryRetrievalResult[], bm25Results: LongTermMemoryRetrievalResult[]): LongTermMemoryRetrievalResult[];
|