@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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +450 -0
  3. package/dist/chunk-GACX3FPR.js +1402 -0
  4. package/dist/chunk-M44NB53O.js +1226 -0
  5. package/dist/chunk-MQDWBPZU.js +972 -0
  6. package/dist/chunk-TPC7MYWK.js +1495 -0
  7. package/dist/chunk-XD2CQGSD.js +1540 -0
  8. package/dist/chunk-YI7RPDEV.js +1215 -0
  9. package/dist/core.types-lkxKv-bW.d.cts +242 -0
  10. package/dist/core.types-lkxKv-bW.d.ts +242 -0
  11. package/dist/debug/index.cjs +1248 -0
  12. package/dist/debug/index.d.cts +3 -0
  13. package/dist/debug/index.d.ts +3 -0
  14. package/dist/debug/index.js +20 -0
  15. package/dist/index-7SsAJ4et.d.ts +525 -0
  16. package/dist/index-BGxYqpFb.d.cts +601 -0
  17. package/dist/index-BX62efZu.d.ts +565 -0
  18. package/dist/index-Bbc3COw0.d.cts +748 -0
  19. package/dist/index-Bczz1Eyk.d.ts +637 -0
  20. package/dist/index-C7pEiT8L.d.cts +637 -0
  21. package/dist/index-CHetLTb0.d.ts +389 -0
  22. package/dist/index-CloeiFyx.d.ts +748 -0
  23. package/dist/index-DNOhq-3y.d.cts +525 -0
  24. package/dist/index-Da-M8FOV.d.cts +389 -0
  25. package/dist/index-Dy8UjRFz.d.cts +565 -0
  26. package/dist/index-aVcITW0B.d.ts +601 -0
  27. package/dist/index.cjs +8554 -0
  28. package/dist/index.d.cts +293 -0
  29. package/dist/index.d.ts +293 -0
  30. package/dist/index.js +742 -0
  31. package/dist/processing/index.cjs +1575 -0
  32. package/dist/processing/index.d.cts +2 -0
  33. package/dist/processing/index.d.ts +2 -0
  34. package/dist/processing/index.js +24 -0
  35. package/dist/retrieval/index.cjs +1262 -0
  36. package/dist/retrieval/index.d.cts +2 -0
  37. package/dist/retrieval/index.d.ts +2 -0
  38. package/dist/retrieval/index.js +26 -0
  39. package/dist/sharing/index.cjs +1003 -0
  40. package/dist/sharing/index.d.cts +3 -0
  41. package/dist/sharing/index.d.ts +3 -0
  42. package/dist/sharing/index.js +16 -0
  43. package/dist/stores/index.cjs +1445 -0
  44. package/dist/stores/index.d.cts +2 -0
  45. package/dist/stores/index.d.ts +2 -0
  46. package/dist/stores/index.js +20 -0
  47. package/dist/structures/index.cjs +1530 -0
  48. package/dist/structures/index.d.cts +3 -0
  49. package/dist/structures/index.d.ts +3 -0
  50. package/dist/structures/index.js +24 -0
  51. package/package.json +141 -0
@@ -0,0 +1,637 @@
1
+ import { j as MemoryType, i as MemoryStoreInterface, c as MemoryEntry } from './core.types-lkxKv-bW.js';
2
+ import { EventEmitter } from 'eventemitter3';
3
+
4
+ /**
5
+ * Debug Types
6
+ *
7
+ * Types for memory debugging and inspection.
8
+ */
9
+
10
+ /**
11
+ * Warning thresholds for inspector
12
+ */
13
+ interface WarningThresholds {
14
+ lowImportance?: number;
15
+ highEntryCount?: number;
16
+ oldAge?: number;
17
+ }
18
+ /**
19
+ * Inspector configuration
20
+ */
21
+ interface InspectorConfig {
22
+ includeEmbeddings?: boolean;
23
+ samplingRate?: number;
24
+ maxEntriesForAnalysis?: number;
25
+ warningThresholds?: WarningThresholds;
26
+ }
27
+ /**
28
+ * Timeline configuration
29
+ */
30
+ interface TimelineConfig {
31
+ timeRange?: {
32
+ start: number;
33
+ end: number;
34
+ };
35
+ groupBy?: 'hour' | 'day' | 'week' | 'month';
36
+ showTypes?: boolean;
37
+ showNamespaces?: boolean;
38
+ maxEvents?: number;
39
+ autoTrack?: boolean;
40
+ segmentSize?: 'hour' | 'day' | 'week';
41
+ }
42
+ /**
43
+ * Retrieval debug options
44
+ */
45
+ interface RetrievalDebugOptions {
46
+ query: string;
47
+ expectedMemories?: string[];
48
+ context?: Record<string, unknown>;
49
+ verbose?: boolean;
50
+ candidateMultiplier?: number;
51
+ limit?: number;
52
+ types?: string[];
53
+ namespace?: string;
54
+ minScore?: number;
55
+ }
56
+ /**
57
+ * Export format
58
+ */
59
+ type ExportFormat$1 = 'json' | 'csv' | 'jsonl' | 'training';
60
+ /**
61
+ * Export options
62
+ */
63
+ interface ExportOptions {
64
+ format?: ExportFormat$1;
65
+ includeEmbeddings?: boolean;
66
+ includeMetadata?: boolean;
67
+ filter?: {
68
+ types?: MemoryType[];
69
+ namespaces?: string[];
70
+ timeRange?: {
71
+ start?: number;
72
+ end?: number;
73
+ };
74
+ };
75
+ namespace?: string;
76
+ types?: string[];
77
+ startTime?: number;
78
+ endTime?: number;
79
+ ids?: string[];
80
+ pretty?: boolean;
81
+ }
82
+
83
+ /**
84
+ * Inspector
85
+ *
86
+ * Memory inspection and analysis tools.
87
+ */
88
+
89
+ /**
90
+ * Memory statistics
91
+ */
92
+ interface MemoryStats {
93
+ totalEntries: number;
94
+ totalSize: number;
95
+ avgContentLength: number;
96
+ avgImportance: number;
97
+ avgAccessCount: number;
98
+ typeDistribution: Record<string, number>;
99
+ namespaceDistribution: Record<string, number>;
100
+ timeRange: {
101
+ oldest: number;
102
+ newest: number;
103
+ } | null;
104
+ entriesWithEmbeddings: number;
105
+ expiredEntries: number;
106
+ }
107
+ /**
108
+ * Memory health report
109
+ */
110
+ interface HealthReport {
111
+ score: number;
112
+ issues: HealthIssue[];
113
+ recommendations: string[];
114
+ }
115
+ /**
116
+ * Health issue
117
+ */
118
+ interface HealthIssue {
119
+ type: 'warning' | 'error' | 'info';
120
+ message: string;
121
+ affectedEntries?: number;
122
+ suggestion?: string;
123
+ }
124
+ /**
125
+ * Inspection result
126
+ */
127
+ interface InspectionResult {
128
+ entry: MemoryEntry;
129
+ analysis: {
130
+ contentLength: number;
131
+ wordCount: number;
132
+ hasEmbedding: boolean;
133
+ embeddingDimensions?: number;
134
+ metadataKeys: string[];
135
+ age: number;
136
+ accessRate: number;
137
+ isExpired: boolean;
138
+ importancePercentile?: number;
139
+ };
140
+ }
141
+ /**
142
+ * Memory inspector
143
+ */
144
+ declare class Inspector {
145
+ private store;
146
+ private config;
147
+ constructor(store: MemoryStoreInterface, config?: InspectorConfig);
148
+ /**
149
+ * Get comprehensive memory statistics
150
+ */
151
+ getStats(): Promise<MemoryStats>;
152
+ /**
153
+ * Inspect a specific entry
154
+ */
155
+ inspect(id: string): Promise<InspectionResult | null>;
156
+ /**
157
+ * Get memory health report
158
+ */
159
+ getHealthReport(): Promise<HealthReport>;
160
+ /**
161
+ * Find duplicate entries
162
+ */
163
+ findDuplicates(threshold?: number): Promise<Array<[MemoryEntry, MemoryEntry]>>;
164
+ /**
165
+ * Find orphaned entries (no parent, but has parentId)
166
+ */
167
+ findOrphans(): Promise<MemoryEntry[]>;
168
+ /**
169
+ * Find low-value entries
170
+ */
171
+ findLowValueEntries(options?: {
172
+ maxImportance?: number;
173
+ maxAccessCount?: number;
174
+ minAge?: number;
175
+ }): Promise<MemoryEntry[]>;
176
+ /**
177
+ * Get entry distribution over time
178
+ */
179
+ getTimeDistribution(bucketSize?: 'hour' | 'day' | 'week' | 'month'): Promise<Map<string, number>>;
180
+ /**
181
+ * Calculate similarity between two entries
182
+ */
183
+ private calculateSimilarity;
184
+ /**
185
+ * Cosine similarity
186
+ */
187
+ private cosineSimilarity;
188
+ /**
189
+ * Text similarity (Jaccard)
190
+ */
191
+ private textSimilarity;
192
+ }
193
+ /**
194
+ * Create inspector instance
195
+ */
196
+ declare function createInspector(store: MemoryStoreInterface, config?: InspectorConfig): Inspector;
197
+
198
+ /**
199
+ * Timeline
200
+ *
201
+ * Memory timeline visualization and analysis.
202
+ */
203
+
204
+ /**
205
+ * Timeline event
206
+ */
207
+ interface TimelineEvent {
208
+ id: string;
209
+ type: 'add' | 'update' | 'delete' | 'access' | 'consolidate';
210
+ entryId: string;
211
+ timestamp: number;
212
+ details?: Record<string, unknown>;
213
+ }
214
+ /**
215
+ * Timeline segment
216
+ */
217
+ interface TimelineSegment {
218
+ start: number;
219
+ end: number;
220
+ entries: MemoryEntry[];
221
+ events: TimelineEvent[];
222
+ summary?: string;
223
+ }
224
+ /**
225
+ * Timeline marker
226
+ */
227
+ interface TimelineMarker {
228
+ timestamp: number;
229
+ label: string;
230
+ type: 'milestone' | 'annotation' | 'warning';
231
+ metadata?: Record<string, unknown>;
232
+ }
233
+ /**
234
+ * Memory timeline
235
+ */
236
+ declare class Timeline {
237
+ private store;
238
+ private config;
239
+ private events;
240
+ private markers;
241
+ constructor(store: MemoryStoreInterface, config?: TimelineConfig);
242
+ /**
243
+ * Record a timeline event
244
+ */
245
+ recordEvent(event: Omit<TimelineEvent, 'id'>): void;
246
+ /**
247
+ * Add a marker to the timeline
248
+ */
249
+ addMarker(marker: Omit<TimelineMarker, 'timestamp'> & {
250
+ timestamp?: number;
251
+ }): void;
252
+ /**
253
+ * Get timeline segments
254
+ */
255
+ getSegments(startTime: number, endTime: number): Promise<TimelineSegment[]>;
256
+ /**
257
+ * Get timeline for a specific entry
258
+ */
259
+ getEntryTimeline(entryId: string): Promise<{
260
+ entry: MemoryEntry | null;
261
+ events: TimelineEvent[];
262
+ createdAt: number;
263
+ lastModified: number;
264
+ accessHistory: number[];
265
+ }>;
266
+ /**
267
+ * Get activity heatmap data
268
+ */
269
+ getActivityHeatmap(startTime: number, endTime: number, bucketSize?: 'hour' | 'day'): Promise<Map<string, {
270
+ entries: number;
271
+ events: number;
272
+ }>>;
273
+ /**
274
+ * Get markers in time range
275
+ */
276
+ getMarkers(startTime: number, endTime: number): TimelineMarker[];
277
+ /**
278
+ * Get recent activity summary
279
+ */
280
+ getRecentActivity(windowMs?: number): {
281
+ newEntries: number;
282
+ updatedEntries: number;
283
+ deletedEntries: number;
284
+ totalAccesses: number;
285
+ topAccessed: Array<{
286
+ entryId: string;
287
+ accessCount: number;
288
+ }>;
289
+ };
290
+ /**
291
+ * Get memory growth over time
292
+ */
293
+ getGrowthChart(startTime: number, endTime: number, bucketSize?: 'hour' | 'day' | 'week'): Promise<Array<{
294
+ time: string;
295
+ cumulativeCount: number;
296
+ newCount: number;
297
+ }>>;
298
+ /**
299
+ * Find gaps in timeline (periods with no activity)
300
+ */
301
+ findGaps(startTime: number, endTime: number, minGapSize?: number): Promise<Array<{
302
+ start: number;
303
+ end: number;
304
+ durationMs: number;
305
+ }>>;
306
+ /**
307
+ * Clear events
308
+ */
309
+ clearEvents(): void;
310
+ /**
311
+ * Clear markers
312
+ */
313
+ clearMarkers(): void;
314
+ /**
315
+ * Export timeline data
316
+ */
317
+ exportData(): {
318
+ events: TimelineEvent[];
319
+ markers: TimelineMarker[];
320
+ exportedAt: number;
321
+ };
322
+ /**
323
+ * Import timeline data
324
+ */
325
+ importData(data: {
326
+ events: TimelineEvent[];
327
+ markers: TimelineMarker[];
328
+ }): void;
329
+ /**
330
+ * Get segment size in milliseconds
331
+ */
332
+ private getSegmentSizeMs;
333
+ /**
334
+ * Get bucket key for timestamp
335
+ */
336
+ private getBucketKey;
337
+ }
338
+ /**
339
+ * Create timeline instance
340
+ */
341
+ declare function createTimeline(store: MemoryStoreInterface, config?: TimelineConfig): Timeline;
342
+
343
+ /**
344
+ * Debugger
345
+ *
346
+ * Memory debugging and tracing tools.
347
+ */
348
+
349
+ /**
350
+ * Debug trace entry
351
+ */
352
+ interface DebugTrace {
353
+ id: string;
354
+ operation: string;
355
+ timestamp: number;
356
+ duration: number;
357
+ input: unknown;
358
+ output: unknown;
359
+ metadata?: Record<string, unknown>;
360
+ }
361
+ /**
362
+ * Retrieval debug info
363
+ */
364
+ interface RetrievalDebugInfo {
365
+ query: string;
366
+ totalCandidates: number;
367
+ returnedCount: number;
368
+ strategyUsed: string;
369
+ filteringSteps: Array<{
370
+ name: string;
371
+ inputCount: number;
372
+ outputCount: number;
373
+ durationMs: number;
374
+ }>;
375
+ scoringDetails: Array<{
376
+ entryId: string;
377
+ scores: Record<string, number>;
378
+ finalScore: number;
379
+ }>;
380
+ timing: {
381
+ total: number;
382
+ embedding?: number;
383
+ search?: number;
384
+ filtering?: number;
385
+ ranking?: number;
386
+ };
387
+ }
388
+ /**
389
+ * Breakpoint
390
+ */
391
+ interface Breakpoint {
392
+ id: string;
393
+ condition: (entry: MemoryEntry, operation: string) => boolean;
394
+ enabled: boolean;
395
+ hitCount: number;
396
+ }
397
+ /**
398
+ * Debug events
399
+ */
400
+ interface DebuggerEvents {
401
+ trace: (trace: DebugTrace) => void;
402
+ breakpointHit: (breakpoint: Breakpoint, entry: MemoryEntry, operation: string) => void;
403
+ warning: (message: string, data?: unknown) => void;
404
+ }
405
+ /**
406
+ * Memory debugger
407
+ */
408
+ declare class Debugger extends EventEmitter<DebuggerEvents> {
409
+ private store;
410
+ private traces;
411
+ private breakpoints;
412
+ private enabled;
413
+ private maxTraces;
414
+ constructor(store: MemoryStoreInterface);
415
+ /**
416
+ * Enable debugging
417
+ */
418
+ enable(): void;
419
+ /**
420
+ * Disable debugging
421
+ */
422
+ disable(): void;
423
+ /**
424
+ * Check if debugging is enabled
425
+ */
426
+ isEnabled(): boolean;
427
+ /**
428
+ * Trace an operation
429
+ */
430
+ trace(operation: string, input: unknown, output: unknown, durationMs: number, metadata?: Record<string, unknown>): void;
431
+ /**
432
+ * Wrap a function with tracing
433
+ */
434
+ wrapWithTrace<T extends (...args: unknown[]) => Promise<unknown>>(operation: string, fn: T): T;
435
+ /**
436
+ * Add a breakpoint
437
+ */
438
+ addBreakpoint(condition: (entry: MemoryEntry, operation: string) => boolean, id?: string): string;
439
+ /**
440
+ * Remove a breakpoint
441
+ */
442
+ removeBreakpoint(id: string): boolean;
443
+ /**
444
+ * Enable/disable a breakpoint
445
+ */
446
+ toggleBreakpoint(id: string, enabled: boolean): boolean;
447
+ /**
448
+ * Check breakpoints for an entry/operation
449
+ */
450
+ checkBreakpoints(entry: MemoryEntry, operation: string): void;
451
+ /**
452
+ * Debug a retrieval operation
453
+ */
454
+ debugRetrieval(query: string, embedFn: (text: string) => Promise<number[]>, options?: RetrievalDebugOptions): Promise<RetrievalDebugInfo>;
455
+ /**
456
+ * Get recent traces
457
+ */
458
+ getTraces(options?: {
459
+ operation?: string;
460
+ limit?: number;
461
+ startTime?: number;
462
+ endTime?: number;
463
+ }): DebugTrace[];
464
+ /**
465
+ * Get operation statistics
466
+ */
467
+ getOperationStats(): Map<string, {
468
+ count: number;
469
+ avgDuration: number;
470
+ maxDuration: number;
471
+ minDuration: number;
472
+ }>;
473
+ /**
474
+ * Get all breakpoints
475
+ */
476
+ getBreakpoints(): Breakpoint[];
477
+ /**
478
+ * Clear traces
479
+ */
480
+ clearTraces(): void;
481
+ /**
482
+ * Clear all breakpoints
483
+ */
484
+ clearBreakpoints(): void;
485
+ /**
486
+ * Create a snapshot of current debug state
487
+ */
488
+ createSnapshot(): {
489
+ traces: DebugTrace[];
490
+ breakpoints: Array<{
491
+ id: string;
492
+ enabled: boolean;
493
+ hitCount: number;
494
+ }>;
495
+ stats: Map<string, {
496
+ count: number;
497
+ avgDuration: number;
498
+ maxDuration: number;
499
+ minDuration: number;
500
+ }>;
501
+ timestamp: number;
502
+ };
503
+ }
504
+ /**
505
+ * Create debugger instance
506
+ */
507
+ declare function createDebugger(store: MemoryStoreInterface): Debugger;
508
+
509
+ /**
510
+ * Exporter
511
+ *
512
+ * Export and import memory data in various formats.
513
+ */
514
+
515
+ /**
516
+ * Export format
517
+ */
518
+ type ExportFormat = 'json' | 'jsonl' | 'csv' | 'training';
519
+ /**
520
+ * Export result
521
+ */
522
+ interface ExportResult {
523
+ data: string;
524
+ format: ExportFormat;
525
+ entryCount: number;
526
+ exportedAt: number;
527
+ checksum: string;
528
+ }
529
+ /**
530
+ * Import result
531
+ */
532
+ interface ImportResult {
533
+ imported: number;
534
+ skipped: number;
535
+ errors: Array<{
536
+ entry: unknown;
537
+ error: string;
538
+ }>;
539
+ }
540
+ /**
541
+ * Memory exporter
542
+ */
543
+ declare class Exporter {
544
+ private store;
545
+ constructor(store: MemoryStoreInterface);
546
+ /**
547
+ * Export memories to string
548
+ */
549
+ export(options?: ExportOptions): Promise<ExportResult>;
550
+ /**
551
+ * Export to JSON file content
552
+ */
553
+ private toJSON;
554
+ /**
555
+ * Export to JSON Lines format
556
+ */
557
+ private toJSONL;
558
+ /**
559
+ * Export to CSV format
560
+ */
561
+ private toCSV;
562
+ /**
563
+ * Escape CSV value
564
+ */
565
+ private escapeCSV;
566
+ /**
567
+ * Import memories from string
568
+ */
569
+ import(data: string, format?: ExportFormat, options?: {
570
+ overwrite?: boolean;
571
+ namespace?: string;
572
+ validateOnly?: boolean;
573
+ }): Promise<ImportResult>;
574
+ /**
575
+ * Parse JSON export
576
+ */
577
+ private fromJSON;
578
+ /**
579
+ * Parse JSONL export
580
+ */
581
+ private fromJSONL;
582
+ /**
583
+ * Parse CSV export
584
+ */
585
+ private fromCSV;
586
+ /**
587
+ * Parse a CSV line
588
+ */
589
+ private parseCSVLine;
590
+ /**
591
+ * Validate entry
592
+ */
593
+ private validateEntry;
594
+ /**
595
+ * Calculate simple checksum
596
+ */
597
+ private calculateChecksum;
598
+ /**
599
+ * Create backup
600
+ */
601
+ createBackup(name?: string): Promise<{
602
+ name: string;
603
+ data: ExportResult;
604
+ createdAt: number;
605
+ }>;
606
+ /**
607
+ * Restore from backup
608
+ */
609
+ restoreBackup(backup: {
610
+ data: ExportResult;
611
+ }, options?: {
612
+ clearExisting?: boolean;
613
+ }): Promise<ImportResult>;
614
+ /**
615
+ * Get export size estimate
616
+ */
617
+ estimateExportSize(options?: ExportOptions): Promise<{
618
+ entryCount: number;
619
+ estimatedSizeBytes: number;
620
+ withEmbeddingsBytes?: number;
621
+ }>;
622
+ /**
623
+ * Diff two exports
624
+ */
625
+ diffExports(export1: ExportResult, export2: ExportResult): {
626
+ added: string[];
627
+ removed: string[];
628
+ modified: string[];
629
+ unchanged: string[];
630
+ };
631
+ }
632
+ /**
633
+ * Create exporter instance
634
+ */
635
+ declare function createExporter(store: MemoryStoreInterface): Exporter;
636
+
637
+ export { type Breakpoint as B, Debugger as D, type ExportOptions as E, type HealthReport as H, type InspectorConfig as I, type MemoryStats as M, type RetrievalDebugOptions as R, type TimelineConfig as T, Inspector as a, Timeline as b, createInspector as c, createTimeline as d, createDebugger as e, Exporter as f, createExporter as g, type HealthIssue as h, type InspectionResult as i, type TimelineEvent as j, type TimelineSegment as k, type TimelineMarker as l, type DebugTrace as m, type RetrievalDebugInfo as n, type DebuggerEvents as o, type ExportFormat as p, type ExportResult as q, type ImportResult as r };