@lov3kaizen/agentsea-memory 0.5.1
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/LICENSE +21 -0
- package/README.md +450 -0
- package/dist/chunk-GACX3FPR.js +1402 -0
- package/dist/chunk-M44NB53O.js +1226 -0
- package/dist/chunk-MQDWBPZU.js +972 -0
- package/dist/chunk-TPC7MYWK.js +1495 -0
- package/dist/chunk-XD2CQGSD.js +1540 -0
- package/dist/chunk-YI7RPDEV.js +1215 -0
- package/dist/core.types-lkxKv-bW.d.cts +242 -0
- package/dist/core.types-lkxKv-bW.d.ts +242 -0
- package/dist/debug/index.cjs +1248 -0
- package/dist/debug/index.d.cts +3 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.js +20 -0
- package/dist/index-7SsAJ4et.d.ts +525 -0
- package/dist/index-BGxYqpFb.d.cts +601 -0
- package/dist/index-BX62efZu.d.ts +565 -0
- package/dist/index-Bbc3COw0.d.cts +748 -0
- package/dist/index-Bczz1Eyk.d.ts +637 -0
- package/dist/index-C7pEiT8L.d.cts +637 -0
- package/dist/index-CHetLTb0.d.ts +389 -0
- package/dist/index-CloeiFyx.d.ts +748 -0
- package/dist/index-DNOhq-3y.d.cts +525 -0
- package/dist/index-Da-M8FOV.d.cts +389 -0
- package/dist/index-Dy8UjRFz.d.cts +565 -0
- package/dist/index-aVcITW0B.d.ts +601 -0
- package/dist/index.cjs +8554 -0
- package/dist/index.d.cts +293 -0
- package/dist/index.d.ts +293 -0
- package/dist/index.js +742 -0
- package/dist/processing/index.cjs +1575 -0
- package/dist/processing/index.d.cts +2 -0
- package/dist/processing/index.d.ts +2 -0
- package/dist/processing/index.js +24 -0
- package/dist/retrieval/index.cjs +1262 -0
- package/dist/retrieval/index.d.cts +2 -0
- package/dist/retrieval/index.d.ts +2 -0
- package/dist/retrieval/index.js +26 -0
- package/dist/sharing/index.cjs +1003 -0
- package/dist/sharing/index.d.cts +3 -0
- package/dist/sharing/index.d.ts +3 -0
- package/dist/sharing/index.js +16 -0
- package/dist/stores/index.cjs +1445 -0
- package/dist/stores/index.d.cts +2 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/index.js +20 -0
- package/dist/structures/index.cjs +1530 -0
- package/dist/structures/index.d.cts +3 -0
- package/dist/structures/index.d.ts +3 -0
- package/dist/structures/index.js +24 -0
- package/package.json +141 -0
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
import { L as LLMProviderInterface, c as MemoryEntry, i as MemoryStoreInterface } from './core.types-lkxKv-bW.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Processing Types
|
|
5
|
+
*
|
|
6
|
+
* Types for memory processing utilities.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Summarization strategy
|
|
11
|
+
*/
|
|
12
|
+
type SummarizationStrategy = 'hierarchical' | 'incremental' | 'abstractive' | 'extractive';
|
|
13
|
+
/**
|
|
14
|
+
* Summarizer configuration
|
|
15
|
+
*/
|
|
16
|
+
interface SummarizerConfig {
|
|
17
|
+
provider?: LLMProviderInterface;
|
|
18
|
+
model?: string;
|
|
19
|
+
strategy?: SummarizationStrategy;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
preserveEntities?: boolean;
|
|
22
|
+
focusPrompt?: string;
|
|
23
|
+
maxSummaryLength?: number;
|
|
24
|
+
minEntriesForSummary?: number;
|
|
25
|
+
preserveKeyEntities?: boolean;
|
|
26
|
+
summaryStyle?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compression strategy
|
|
30
|
+
*/
|
|
31
|
+
type CompressionStrategy = 'importance-weighted' | 'recency' | 'semantic-clustering' | 'hybrid';
|
|
32
|
+
/**
|
|
33
|
+
* Compressor configuration
|
|
34
|
+
*/
|
|
35
|
+
interface CompressorConfig {
|
|
36
|
+
targetRatio?: number;
|
|
37
|
+
preserveImportant?: boolean;
|
|
38
|
+
strategy?: CompressionStrategy;
|
|
39
|
+
minImportance?: number;
|
|
40
|
+
minContentLength?: number;
|
|
41
|
+
removeEmbeddings?: boolean;
|
|
42
|
+
truncateMetadata?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Merge strategy for consolidation
|
|
46
|
+
*/
|
|
47
|
+
type MergeStrategy = 'newest-wins' | 'confidence-weighted' | 'union' | 'intersection';
|
|
48
|
+
/**
|
|
49
|
+
* Consolidator configuration
|
|
50
|
+
*/
|
|
51
|
+
interface ConsolidatorConfig {
|
|
52
|
+
similarityThreshold?: number;
|
|
53
|
+
mergeStrategy?: MergeStrategy;
|
|
54
|
+
extractRelations?: boolean;
|
|
55
|
+
maxBatchSize?: number;
|
|
56
|
+
minGroupSize?: number;
|
|
57
|
+
maxGroupSize?: number;
|
|
58
|
+
groupingStrategy?: 'semantic' | 'temporal' | 'type';
|
|
59
|
+
preserveOriginals?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Retention policy
|
|
63
|
+
*/
|
|
64
|
+
interface RetentionPolicy {
|
|
65
|
+
critical?: number;
|
|
66
|
+
high?: number;
|
|
67
|
+
medium?: number;
|
|
68
|
+
low?: number;
|
|
69
|
+
trivial?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Forgetter configuration
|
|
73
|
+
*/
|
|
74
|
+
interface ForgetterConfig {
|
|
75
|
+
retentionPolicy?: RetentionPolicy;
|
|
76
|
+
importanceThreshold?: number;
|
|
77
|
+
maxAge?: number;
|
|
78
|
+
preserveTypes?: string[];
|
|
79
|
+
curve?: 'exponential' | 'power' | 'ebbinghaus';
|
|
80
|
+
halfLife?: number;
|
|
81
|
+
minRetention?: number;
|
|
82
|
+
accessBoost?: number;
|
|
83
|
+
importanceWeight?: number;
|
|
84
|
+
forgetThreshold?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Extraction type
|
|
88
|
+
*/
|
|
89
|
+
type ExtractionType = 'person' | 'organization' | 'location' | 'date' | 'preference' | 'fact' | 'intent' | 'sentiment' | 'topic' | 'custom';
|
|
90
|
+
/**
|
|
91
|
+
* Extractor configuration
|
|
92
|
+
*/
|
|
93
|
+
interface ExtractorConfig {
|
|
94
|
+
provider?: LLMProviderInterface;
|
|
95
|
+
model?: string;
|
|
96
|
+
extractTypes?: ExtractionType[];
|
|
97
|
+
customPrompt?: string;
|
|
98
|
+
confidence?: number;
|
|
99
|
+
extractEntities?: boolean;
|
|
100
|
+
extractRelations?: boolean;
|
|
101
|
+
extractKeywords?: boolean;
|
|
102
|
+
extractSentiment?: boolean;
|
|
103
|
+
minConfidence?: number;
|
|
104
|
+
maxEntitiesPerEntry?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Summarizer
|
|
109
|
+
*
|
|
110
|
+
* Summarizes memory entries using LLM or heuristic methods.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Summary result
|
|
115
|
+
*/
|
|
116
|
+
interface SummaryResult {
|
|
117
|
+
summary: string;
|
|
118
|
+
keyPoints: string[];
|
|
119
|
+
sourceCount: number;
|
|
120
|
+
compressionRatio: number;
|
|
121
|
+
metadata: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Summary function type (for LLM integration)
|
|
125
|
+
*/
|
|
126
|
+
type SummaryFunction = (entries: MemoryEntry[], options?: {
|
|
127
|
+
maxLength?: number;
|
|
128
|
+
style?: string;
|
|
129
|
+
}) => Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Memory summarizer
|
|
132
|
+
*/
|
|
133
|
+
declare class Summarizer {
|
|
134
|
+
private config;
|
|
135
|
+
private summaryFn?;
|
|
136
|
+
constructor(config?: SummarizerConfig);
|
|
137
|
+
/**
|
|
138
|
+
* Set custom summary function (for LLM integration)
|
|
139
|
+
*/
|
|
140
|
+
setSummaryFunction(fn: SummaryFunction): void;
|
|
141
|
+
/**
|
|
142
|
+
* Summarize a collection of memories
|
|
143
|
+
*/
|
|
144
|
+
summarize(entries: MemoryEntry[]): Promise<SummaryResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Summarize memories by time period
|
|
147
|
+
*/
|
|
148
|
+
summarizeByPeriod(entries: MemoryEntry[], period: 'hour' | 'day' | 'week'): Promise<Map<string, SummaryResult>>;
|
|
149
|
+
/**
|
|
150
|
+
* Summarize memories by topic/type
|
|
151
|
+
*/
|
|
152
|
+
summarizeByTopic(entries: MemoryEntry[]): Promise<Map<string, SummaryResult>>;
|
|
153
|
+
/**
|
|
154
|
+
* Create incremental summary (add to existing summary)
|
|
155
|
+
*/
|
|
156
|
+
incrementalSummarize(existingSummary: string, newEntries: MemoryEntry[]): Promise<SummaryResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Heuristic-based summarization
|
|
159
|
+
*/
|
|
160
|
+
private heuristicSummarize;
|
|
161
|
+
/**
|
|
162
|
+
* Create simple summary for few entries
|
|
163
|
+
*/
|
|
164
|
+
private createSimpleSummary;
|
|
165
|
+
/**
|
|
166
|
+
* Extract key points from entries
|
|
167
|
+
*/
|
|
168
|
+
private extractKeyPoints;
|
|
169
|
+
/**
|
|
170
|
+
* Group entries by time period
|
|
171
|
+
*/
|
|
172
|
+
private groupByPeriod;
|
|
173
|
+
/**
|
|
174
|
+
* Group entries by topic/type
|
|
175
|
+
*/
|
|
176
|
+
private groupByTopic;
|
|
177
|
+
/**
|
|
178
|
+
* Get time range description
|
|
179
|
+
*/
|
|
180
|
+
private getTimeRange;
|
|
181
|
+
/**
|
|
182
|
+
* Calculate compression ratio
|
|
183
|
+
*/
|
|
184
|
+
private calculateCompressionRatio;
|
|
185
|
+
/**
|
|
186
|
+
* Deduplicate similar strings
|
|
187
|
+
*/
|
|
188
|
+
private deduplicateStrings;
|
|
189
|
+
/**
|
|
190
|
+
* Simple string similarity (Jaccard)
|
|
191
|
+
*/
|
|
192
|
+
private stringSimilarity;
|
|
193
|
+
/**
|
|
194
|
+
* Update configuration
|
|
195
|
+
*/
|
|
196
|
+
configure(config: Partial<SummarizerConfig>): void;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Create summarizer instance
|
|
200
|
+
*/
|
|
201
|
+
declare function createSummarizer(config?: SummarizerConfig): Summarizer;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Compressor
|
|
205
|
+
*
|
|
206
|
+
* Compresses memory entries to save space while preserving key information.
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Compression result
|
|
211
|
+
*/
|
|
212
|
+
interface CompressionResult {
|
|
213
|
+
compressed: MemoryEntry;
|
|
214
|
+
originalSize: number;
|
|
215
|
+
compressedSize: number;
|
|
216
|
+
ratio: number;
|
|
217
|
+
preservedFields: string[];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Batch compression result
|
|
221
|
+
*/
|
|
222
|
+
interface BatchCompressionResult {
|
|
223
|
+
entries: MemoryEntry[];
|
|
224
|
+
totalOriginalSize: number;
|
|
225
|
+
totalCompressedSize: number;
|
|
226
|
+
avgRatio: number;
|
|
227
|
+
removedCount: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Memory compressor
|
|
231
|
+
*/
|
|
232
|
+
declare class Compressor {
|
|
233
|
+
private config;
|
|
234
|
+
constructor(config?: CompressorConfig);
|
|
235
|
+
/**
|
|
236
|
+
* Compress a single memory entry
|
|
237
|
+
*/
|
|
238
|
+
compress(entry: MemoryEntry): CompressionResult;
|
|
239
|
+
/**
|
|
240
|
+
* Compress multiple entries
|
|
241
|
+
*/
|
|
242
|
+
compressBatch(entries: MemoryEntry[]): BatchCompressionResult;
|
|
243
|
+
/**
|
|
244
|
+
* Compress entries to target size
|
|
245
|
+
*/
|
|
246
|
+
compressToSize(entries: MemoryEntry[], targetSize: number): BatchCompressionResult;
|
|
247
|
+
/**
|
|
248
|
+
* Deduplicate and compress similar entries
|
|
249
|
+
*/
|
|
250
|
+
deduplicateAndCompress(entries: MemoryEntry[]): BatchCompressionResult;
|
|
251
|
+
/**
|
|
252
|
+
* Truncate content based on importance
|
|
253
|
+
*/
|
|
254
|
+
private truncateContent;
|
|
255
|
+
/**
|
|
256
|
+
* Truncate metadata
|
|
257
|
+
*/
|
|
258
|
+
private truncateMetadata;
|
|
259
|
+
/**
|
|
260
|
+
* Aggressive compression for tight space constraints
|
|
261
|
+
*/
|
|
262
|
+
private aggressiveCompress;
|
|
263
|
+
/**
|
|
264
|
+
* Get deduplication key for entry
|
|
265
|
+
*/
|
|
266
|
+
private getDedupeKey;
|
|
267
|
+
/**
|
|
268
|
+
* Calculate approximate size of entry in bytes
|
|
269
|
+
*/
|
|
270
|
+
private calculateSize;
|
|
271
|
+
/**
|
|
272
|
+
* Update configuration
|
|
273
|
+
*/
|
|
274
|
+
configure(config: Partial<CompressorConfig>): void;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Create compressor instance
|
|
278
|
+
*/
|
|
279
|
+
declare function createCompressor(config?: CompressorConfig): Compressor;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Consolidator
|
|
283
|
+
*
|
|
284
|
+
* Merges similar or related memories into consolidated entries.
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Consolidation group
|
|
289
|
+
*/
|
|
290
|
+
interface ConsolidationGroup {
|
|
291
|
+
id: string;
|
|
292
|
+
entries: MemoryEntry[];
|
|
293
|
+
similarity: number;
|
|
294
|
+
groupKey: string;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Consolidation result
|
|
298
|
+
*/
|
|
299
|
+
interface ConsolidationResult {
|
|
300
|
+
consolidated: MemoryEntry;
|
|
301
|
+
sourceIds: string[];
|
|
302
|
+
groupKey: string;
|
|
303
|
+
avgImportance: number;
|
|
304
|
+
timeSpan: {
|
|
305
|
+
start: number;
|
|
306
|
+
end: number;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Memory consolidator
|
|
311
|
+
*/
|
|
312
|
+
declare class Consolidator {
|
|
313
|
+
private config;
|
|
314
|
+
private summarizer;
|
|
315
|
+
private embedFn?;
|
|
316
|
+
constructor(config?: ConsolidatorConfig);
|
|
317
|
+
/**
|
|
318
|
+
* Set embedding function for semantic grouping
|
|
319
|
+
*/
|
|
320
|
+
setEmbeddingFunction(fn: (text: string) => Promise<number[]>): void;
|
|
321
|
+
/**
|
|
322
|
+
* Set summarizer function
|
|
323
|
+
*/
|
|
324
|
+
setSummarizerFunction(fn: (entries: MemoryEntry[], options?: {
|
|
325
|
+
maxLength?: number;
|
|
326
|
+
}) => Promise<string>): void;
|
|
327
|
+
/**
|
|
328
|
+
* Find and consolidate similar memories
|
|
329
|
+
*/
|
|
330
|
+
consolidate(entries: MemoryEntry[], store?: MemoryStoreInterface): Promise<ConsolidationResult[]>;
|
|
331
|
+
/**
|
|
332
|
+
* Group similar entries
|
|
333
|
+
*/
|
|
334
|
+
groupSimilar(entries: MemoryEntry[]): Promise<ConsolidationGroup[]>;
|
|
335
|
+
/**
|
|
336
|
+
* Group by semantic similarity
|
|
337
|
+
*/
|
|
338
|
+
private groupBySemantic;
|
|
339
|
+
/**
|
|
340
|
+
* Group by text similarity (fallback)
|
|
341
|
+
*/
|
|
342
|
+
private groupByTextSimilarity;
|
|
343
|
+
/**
|
|
344
|
+
* Group by temporal proximity
|
|
345
|
+
*/
|
|
346
|
+
private groupByTemporal;
|
|
347
|
+
/**
|
|
348
|
+
* Group by memory type
|
|
349
|
+
*/
|
|
350
|
+
private groupByType;
|
|
351
|
+
/**
|
|
352
|
+
* Consolidate a group into a single entry
|
|
353
|
+
*/
|
|
354
|
+
private consolidateGroup;
|
|
355
|
+
/**
|
|
356
|
+
* Calculate cosine similarity
|
|
357
|
+
*/
|
|
358
|
+
private cosineSimilarity;
|
|
359
|
+
/**
|
|
360
|
+
* Calculate text similarity (Jaccard)
|
|
361
|
+
*/
|
|
362
|
+
private textSimilarity;
|
|
363
|
+
/**
|
|
364
|
+
* Calculate average similarity within a group
|
|
365
|
+
*/
|
|
366
|
+
private calculateGroupSimilarity;
|
|
367
|
+
/**
|
|
368
|
+
* Generate unique ID
|
|
369
|
+
*/
|
|
370
|
+
private generateId;
|
|
371
|
+
/**
|
|
372
|
+
* Update configuration
|
|
373
|
+
*/
|
|
374
|
+
configure(config: Partial<ConsolidatorConfig>): void;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Create consolidator instance
|
|
378
|
+
*/
|
|
379
|
+
declare function createConsolidator(config?: ConsolidatorConfig): Consolidator;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Forgetter
|
|
383
|
+
*
|
|
384
|
+
* Implements forgetting curves and memory decay for realistic memory behavior.
|
|
385
|
+
*/
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Forgetting curve type
|
|
389
|
+
*/
|
|
390
|
+
type ForgettingCurve = 'exponential' | 'power' | 'ebbinghaus';
|
|
391
|
+
/**
|
|
392
|
+
* Retention score for a memory
|
|
393
|
+
*/
|
|
394
|
+
interface RetentionScore {
|
|
395
|
+
entryId: string;
|
|
396
|
+
retention: number;
|
|
397
|
+
ageMs: number;
|
|
398
|
+
accessCount: number;
|
|
399
|
+
importance: number;
|
|
400
|
+
shouldForget: boolean;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Forgetting result
|
|
404
|
+
*/
|
|
405
|
+
interface ForgettingResult {
|
|
406
|
+
forgotten: string[];
|
|
407
|
+
decayed: Array<{
|
|
408
|
+
id: string;
|
|
409
|
+
oldImportance: number;
|
|
410
|
+
newImportance: number;
|
|
411
|
+
}>;
|
|
412
|
+
retained: string[];
|
|
413
|
+
avgRetention: number;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Memory forgetter with configurable decay
|
|
417
|
+
*/
|
|
418
|
+
declare class Forgetter {
|
|
419
|
+
private config;
|
|
420
|
+
constructor(config?: ForgetterConfig);
|
|
421
|
+
/**
|
|
422
|
+
* Calculate retention score for a memory
|
|
423
|
+
*/
|
|
424
|
+
calculateRetention(entry: MemoryEntry, now?: number): RetentionScore;
|
|
425
|
+
/**
|
|
426
|
+
* Calculate base retention using the configured curve
|
|
427
|
+
*/
|
|
428
|
+
private calculateBaseRetention;
|
|
429
|
+
/**
|
|
430
|
+
* Apply forgetting to memories in a store
|
|
431
|
+
*/
|
|
432
|
+
applyForgetting(store: MemoryStoreInterface): Promise<ForgettingResult>;
|
|
433
|
+
/**
|
|
434
|
+
* Simulate forgetting over time (for testing/visualization)
|
|
435
|
+
*/
|
|
436
|
+
simulateForgetting(entries: MemoryEntry[], timePeriodMs: number, steps?: number): Array<{
|
|
437
|
+
time: number;
|
|
438
|
+
avgRetention: number;
|
|
439
|
+
forgottenCount: number;
|
|
440
|
+
}>;
|
|
441
|
+
/**
|
|
442
|
+
* Get memories at risk of being forgotten
|
|
443
|
+
*/
|
|
444
|
+
getAtRiskMemories(store: MemoryStoreInterface, threshold?: number): Promise<Array<{
|
|
445
|
+
entry: MemoryEntry;
|
|
446
|
+
retention: number;
|
|
447
|
+
}>>;
|
|
448
|
+
/**
|
|
449
|
+
* Reinforce a memory (simulate rehearsal)
|
|
450
|
+
*/
|
|
451
|
+
reinforce(store: MemoryStoreInterface, id: string, boost?: number): Promise<boolean>;
|
|
452
|
+
/**
|
|
453
|
+
* Batch reinforce multiple memories
|
|
454
|
+
*/
|
|
455
|
+
reinforceBatch(store: MemoryStoreInterface, ids: string[], boost?: number): Promise<number>;
|
|
456
|
+
/**
|
|
457
|
+
* Calculate optimal review schedule for a memory
|
|
458
|
+
*/
|
|
459
|
+
calculateReviewSchedule(entry: MemoryEntry, targetRetention?: number): number[];
|
|
460
|
+
/**
|
|
461
|
+
* Get statistics about memory retention
|
|
462
|
+
*/
|
|
463
|
+
getRetentionStats(store: MemoryStoreInterface): Promise<{
|
|
464
|
+
avgRetention: number;
|
|
465
|
+
atRiskCount: number;
|
|
466
|
+
forgettableCount: number;
|
|
467
|
+
healthyCount: number;
|
|
468
|
+
distribution: Record<string, number>;
|
|
469
|
+
}>;
|
|
470
|
+
/**
|
|
471
|
+
* Update configuration
|
|
472
|
+
*/
|
|
473
|
+
configure(config: Partial<ForgetterConfig>): void;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Create forgetter instance
|
|
477
|
+
*/
|
|
478
|
+
declare function createForgetter(config?: ForgetterConfig): Forgetter;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Extractor
|
|
482
|
+
*
|
|
483
|
+
* Extracts entities, relations, and structured information from memories.
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Extracted entity
|
|
488
|
+
*/
|
|
489
|
+
interface ExtractedEntity {
|
|
490
|
+
text: string;
|
|
491
|
+
type: 'person' | 'organization' | 'location' | 'date' | 'concept' | 'number' | 'other';
|
|
492
|
+
confidence: number;
|
|
493
|
+
position: {
|
|
494
|
+
start: number;
|
|
495
|
+
end: number;
|
|
496
|
+
};
|
|
497
|
+
metadata?: Record<string, unknown>;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Extracted relation
|
|
501
|
+
*/
|
|
502
|
+
interface ExtractedRelation {
|
|
503
|
+
subject: string;
|
|
504
|
+
predicate: string;
|
|
505
|
+
object: string;
|
|
506
|
+
confidence: number;
|
|
507
|
+
sourceText: string;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Extraction result
|
|
511
|
+
*/
|
|
512
|
+
interface ExtractionResult {
|
|
513
|
+
entities: ExtractedEntity[];
|
|
514
|
+
relations: ExtractedRelation[];
|
|
515
|
+
keywords: string[];
|
|
516
|
+
sentiment?: {
|
|
517
|
+
score: number;
|
|
518
|
+
label: 'positive' | 'negative' | 'neutral';
|
|
519
|
+
};
|
|
520
|
+
topics?: string[];
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* LLM extraction function type
|
|
524
|
+
*/
|
|
525
|
+
type ExtractionFunction = (content: string, options?: {
|
|
526
|
+
extractRelations?: boolean;
|
|
527
|
+
extractSentiment?: boolean;
|
|
528
|
+
}) => Promise<ExtractionResult>;
|
|
529
|
+
/**
|
|
530
|
+
* Memory content extractor
|
|
531
|
+
*/
|
|
532
|
+
declare class Extractor {
|
|
533
|
+
private config;
|
|
534
|
+
private extractFn?;
|
|
535
|
+
constructor(config?: ExtractorConfig);
|
|
536
|
+
/**
|
|
537
|
+
* Set custom extraction function (for LLM integration)
|
|
538
|
+
*/
|
|
539
|
+
setExtractionFunction(fn: ExtractionFunction): void;
|
|
540
|
+
/**
|
|
541
|
+
* Extract information from a memory entry
|
|
542
|
+
*/
|
|
543
|
+
extract(entry: MemoryEntry): Promise<ExtractionResult>;
|
|
544
|
+
/**
|
|
545
|
+
* Extract from multiple entries
|
|
546
|
+
*/
|
|
547
|
+
extractBatch(entries: MemoryEntry[]): Promise<Map<string, ExtractionResult>>;
|
|
548
|
+
/**
|
|
549
|
+
* Extract and aggregate across multiple entries
|
|
550
|
+
*/
|
|
551
|
+
extractAggregate(entries: MemoryEntry[]): Promise<{
|
|
552
|
+
allEntities: Map<string, {
|
|
553
|
+
entity: ExtractedEntity;
|
|
554
|
+
count: number;
|
|
555
|
+
}>;
|
|
556
|
+
allRelations: ExtractedRelation[];
|
|
557
|
+
topKeywords: Array<{
|
|
558
|
+
keyword: string;
|
|
559
|
+
count: number;
|
|
560
|
+
}>;
|
|
561
|
+
avgSentiment: number | null;
|
|
562
|
+
}>;
|
|
563
|
+
/**
|
|
564
|
+
* Heuristic-based extraction (fallback)
|
|
565
|
+
*/
|
|
566
|
+
private heuristicExtract;
|
|
567
|
+
/**
|
|
568
|
+
* Extract entities using patterns
|
|
569
|
+
*/
|
|
570
|
+
private extractEntities;
|
|
571
|
+
/**
|
|
572
|
+
* Extract relations using patterns
|
|
573
|
+
*/
|
|
574
|
+
private extractRelations;
|
|
575
|
+
/**
|
|
576
|
+
* Extract keywords
|
|
577
|
+
*/
|
|
578
|
+
private extractKeywords;
|
|
579
|
+
/**
|
|
580
|
+
* Extract sentiment
|
|
581
|
+
*/
|
|
582
|
+
private extractSentiment;
|
|
583
|
+
/**
|
|
584
|
+
* Check if text is a sentence starter
|
|
585
|
+
*/
|
|
586
|
+
private isSentenceStarter;
|
|
587
|
+
/**
|
|
588
|
+
* Guess entity type from text
|
|
589
|
+
*/
|
|
590
|
+
private guessEntityType;
|
|
591
|
+
/**
|
|
592
|
+
* Update configuration
|
|
593
|
+
*/
|
|
594
|
+
configure(config: Partial<ExtractorConfig>): void;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Create extractor instance
|
|
598
|
+
*/
|
|
599
|
+
declare function createExtractor(config?: ExtractorConfig): Extractor;
|
|
600
|
+
|
|
601
|
+
export { type BatchCompressionResult as B, type CompressorConfig as C, type ExtractorConfig as E, type ForgetterConfig as F, type RetentionScore as R, type SummarizerConfig as S, type ConsolidatorConfig as a, Summarizer as b, createSummarizer as c, Compressor as d, createCompressor as e, Consolidator as f, createConsolidator as g, Forgetter as h, createForgetter as i, Extractor as j, createExtractor as k, type SummaryResult as l, type SummaryFunction as m, type CompressionResult as n, type ConsolidationGroup as o, type ConsolidationResult as p, type ForgettingCurve as q, type ForgettingResult as r, type ExtractedEntity as s, type ExtractedRelation as t, type ExtractionResult as u, type ExtractionFunction as v };
|