@danielsimonjr/memory-mcp 11.0.1 → 11.1.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 (172) hide show
  1. package/LICENSE +22 -22
  2. package/dist/core/EntityManager.d.ts +10 -15
  3. package/dist/core/EntityManager.d.ts.map +1 -1
  4. package/dist/core/EntityManager.js +21 -54
  5. package/dist/core/GraphStorage.d.ts +0 -51
  6. package/dist/core/GraphStorage.d.ts.map +1 -1
  7. package/dist/core/GraphStorage.js +2 -79
  8. package/dist/core/GraphTraversal.d.ts +2 -7
  9. package/dist/core/GraphTraversal.d.ts.map +1 -1
  10. package/dist/core/GraphTraversal.js +2 -19
  11. package/dist/core/ManagerContext.d.ts +0 -4
  12. package/dist/core/ManagerContext.d.ts.map +1 -1
  13. package/dist/core/ManagerContext.js +2 -12
  14. package/dist/core/RelationManager.d.ts.map +1 -1
  15. package/dist/core/RelationManager.js +4 -5
  16. package/dist/core/SQLiteStorage.d.ts.map +1 -1
  17. package/dist/core/SQLiteStorage.js +2 -3
  18. package/dist/core/TransactionManager.d.ts +2 -207
  19. package/dist/core/TransactionManager.d.ts.map +1 -1
  20. package/dist/core/TransactionManager.js +6 -482
  21. package/dist/core/index.d.ts +1 -2
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +1 -3
  24. package/dist/features/ArchiveManager.d.ts +2 -14
  25. package/dist/features/ArchiveManager.d.ts.map +1 -1
  26. package/dist/features/ArchiveManager.js +3 -44
  27. package/dist/features/CompressionManager.d.ts +4 -14
  28. package/dist/features/CompressionManager.d.ts.map +1 -1
  29. package/dist/features/CompressionManager.js +9 -74
  30. package/dist/features/IOManager.d.ts +2 -6
  31. package/dist/features/IOManager.d.ts.map +1 -1
  32. package/dist/features/IOManager.js +10 -105
  33. package/dist/features/StreamingExporter.d.ts +4 -27
  34. package/dist/features/StreamingExporter.d.ts.map +1 -1
  35. package/dist/features/StreamingExporter.js +4 -65
  36. package/dist/features/index.d.ts +0 -2
  37. package/dist/features/index.d.ts.map +1 -1
  38. package/dist/features/index.js +0 -3
  39. package/dist/search/EmbeddingService.d.ts +9 -108
  40. package/dist/search/EmbeddingService.d.ts.map +1 -1
  41. package/dist/search/EmbeddingService.js +15 -187
  42. package/dist/search/FuzzySearch.js +1 -1
  43. package/dist/search/SavedSearchManager.d.ts.map +1 -1
  44. package/dist/search/SavedSearchManager.js +2 -3
  45. package/dist/search/SearchManager.d.ts +1 -42
  46. package/dist/search/SearchManager.d.ts.map +1 -1
  47. package/dist/search/SearchManager.js +0 -115
  48. package/dist/search/SemanticSearch.d.ts +1 -4
  49. package/dist/search/SemanticSearch.d.ts.map +1 -1
  50. package/dist/search/SemanticSearch.js +2 -12
  51. package/dist/search/TFIDFIndexManager.d.ts +0 -88
  52. package/dist/search/TFIDFIndexManager.d.ts.map +1 -1
  53. package/dist/search/TFIDFIndexManager.js +0 -217
  54. package/dist/search/index.d.ts +1 -18
  55. package/dist/search/index.d.ts.map +1 -1
  56. package/dist/search/index.js +1 -32
  57. package/dist/server/MCPServer.d.ts.map +1 -1
  58. package/dist/server/MCPServer.js +4 -1
  59. package/dist/server/responseCompressor.js +5 -5
  60. package/dist/server/toolDefinitions.d.ts.map +1 -1
  61. package/dist/server/toolDefinitions.js +5 -1
  62. package/dist/server/toolHandlers.d.ts +9 -5
  63. package/dist/server/toolHandlers.d.ts.map +1 -1
  64. package/dist/server/toolHandlers.js +23 -8
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/dist/types/types.d.ts +2 -579
  68. package/dist/types/types.d.ts.map +1 -1
  69. package/dist/utils/compressedCache.d.ts +0 -29
  70. package/dist/utils/compressedCache.d.ts.map +1 -1
  71. package/dist/utils/compressedCache.js +0 -39
  72. package/dist/utils/entityUtils.d.ts +1 -59
  73. package/dist/utils/entityUtils.d.ts.map +1 -1
  74. package/dist/utils/entityUtils.js +3 -113
  75. package/dist/utils/errors.d.ts +0 -18
  76. package/dist/utils/errors.d.ts.map +1 -1
  77. package/dist/utils/errors.js +0 -24
  78. package/dist/utils/index.d.ts +2 -6
  79. package/dist/utils/index.d.ts.map +1 -1
  80. package/dist/utils/index.js +2 -14
  81. package/dist/utils/logger.d.ts +0 -7
  82. package/dist/utils/logger.d.ts.map +1 -1
  83. package/dist/utils/logger.js +2 -9
  84. package/dist/utils/parallelUtils.d.ts +1 -5
  85. package/dist/utils/parallelUtils.d.ts.map +1 -1
  86. package/dist/utils/parallelUtils.js +1 -23
  87. package/dist/utils/schemas.d.ts +16 -16
  88. package/dist/utils/schemas.d.ts.map +1 -1
  89. package/dist/utils/schemas.js +12 -12
  90. package/dist/utils/taskScheduler.d.ts +0 -4
  91. package/dist/utils/taskScheduler.d.ts.map +1 -1
  92. package/dist/utils/taskScheduler.js +1 -21
  93. package/dist/workers/WorkerPool.d.ts +81 -0
  94. package/dist/workers/WorkerPool.d.ts.map +1 -0
  95. package/dist/workers/WorkerPool.js +121 -0
  96. package/dist/workers/index.d.ts +1 -1
  97. package/dist/workers/index.d.ts.map +1 -1
  98. package/dist/workers/levenshteinWorker.js +1 -1
  99. package/package.json +1 -4
  100. package/dist/__tests__/file-path.test.js +0 -119
  101. package/dist/__tests__/knowledge-graph.test.js +0 -318
  102. package/dist/core/GraphEventEmitter.d.ts +0 -202
  103. package/dist/core/GraphEventEmitter.d.ts.map +0 -1
  104. package/dist/core/GraphEventEmitter.js +0 -346
  105. package/dist/features/KeywordExtractor.d.ts +0 -61
  106. package/dist/features/KeywordExtractor.d.ts.map +0 -1
  107. package/dist/features/KeywordExtractor.js +0 -126
  108. package/dist/features/ObservationNormalizer.d.ts +0 -90
  109. package/dist/features/ObservationNormalizer.d.ts.map +0 -1
  110. package/dist/features/ObservationNormalizer.js +0 -193
  111. package/dist/memory.jsonl +0 -1
  112. package/dist/search/BM25Search.d.ts +0 -148
  113. package/dist/search/BM25Search.d.ts.map +0 -1
  114. package/dist/search/BM25Search.js +0 -339
  115. package/dist/search/EarlyTerminationManager.d.ts +0 -140
  116. package/dist/search/EarlyTerminationManager.d.ts.map +0 -1
  117. package/dist/search/EarlyTerminationManager.js +0 -279
  118. package/dist/search/EmbeddingCache.d.ts +0 -175
  119. package/dist/search/EmbeddingCache.d.ts.map +0 -1
  120. package/dist/search/EmbeddingCache.js +0 -246
  121. package/dist/search/HybridScorer.d.ts +0 -181
  122. package/dist/search/HybridScorer.d.ts.map +0 -1
  123. package/dist/search/HybridScorer.js +0 -257
  124. package/dist/search/HybridSearchManager.d.ts +0 -80
  125. package/dist/search/HybridSearchManager.d.ts.map +0 -1
  126. package/dist/search/HybridSearchManager.js +0 -187
  127. package/dist/search/IncrementalIndexer.d.ts +0 -201
  128. package/dist/search/IncrementalIndexer.d.ts.map +0 -1
  129. package/dist/search/IncrementalIndexer.js +0 -342
  130. package/dist/search/OptimizedInvertedIndex.d.ts +0 -163
  131. package/dist/search/OptimizedInvertedIndex.d.ts.map +0 -1
  132. package/dist/search/OptimizedInvertedIndex.js +0 -358
  133. package/dist/search/ParallelSearchExecutor.d.ts +0 -172
  134. package/dist/search/ParallelSearchExecutor.d.ts.map +0 -1
  135. package/dist/search/ParallelSearchExecutor.js +0 -309
  136. package/dist/search/QuantizedVectorStore.d.ts +0 -171
  137. package/dist/search/QuantizedVectorStore.d.ts.map +0 -1
  138. package/dist/search/QuantizedVectorStore.js +0 -307
  139. package/dist/search/QueryAnalyzer.d.ts +0 -76
  140. package/dist/search/QueryAnalyzer.d.ts.map +0 -1
  141. package/dist/search/QueryAnalyzer.js +0 -227
  142. package/dist/search/QueryCostEstimator.d.ts +0 -244
  143. package/dist/search/QueryCostEstimator.d.ts.map +0 -1
  144. package/dist/search/QueryCostEstimator.js +0 -652
  145. package/dist/search/QueryPlanCache.d.ts +0 -220
  146. package/dist/search/QueryPlanCache.d.ts.map +0 -1
  147. package/dist/search/QueryPlanCache.js +0 -379
  148. package/dist/search/QueryPlanner.d.ts +0 -58
  149. package/dist/search/QueryPlanner.d.ts.map +0 -1
  150. package/dist/search/QueryPlanner.js +0 -137
  151. package/dist/search/ReflectionManager.d.ts +0 -120
  152. package/dist/search/ReflectionManager.d.ts.map +0 -1
  153. package/dist/search/ReflectionManager.js +0 -231
  154. package/dist/search/SymbolicSearch.d.ts +0 -61
  155. package/dist/search/SymbolicSearch.d.ts.map +0 -1
  156. package/dist/search/SymbolicSearch.js +0 -163
  157. package/dist/search/TFIDFEventSync.d.ts +0 -85
  158. package/dist/search/TFIDFEventSync.d.ts.map +0 -1
  159. package/dist/search/TFIDFEventSync.js +0 -133
  160. package/dist/utils/BatchProcessor.d.ts +0 -271
  161. package/dist/utils/BatchProcessor.d.ts.map +0 -1
  162. package/dist/utils/BatchProcessor.js +0 -376
  163. package/dist/utils/MemoryMonitor.d.ts +0 -176
  164. package/dist/utils/MemoryMonitor.d.ts.map +0 -1
  165. package/dist/utils/MemoryMonitor.js +0 -305
  166. package/dist/utils/WorkerPoolManager.d.ts +0 -233
  167. package/dist/utils/WorkerPoolManager.d.ts.map +0 -1
  168. package/dist/utils/WorkerPoolManager.js +0 -420
  169. package/dist/utils/operationUtils.d.ts +0 -124
  170. package/dist/utils/operationUtils.d.ts.map +0 -1
  171. package/dist/utils/operationUtils.js +0 -175
  172. package/dist/vitest.config.js +0 -13
@@ -12,7 +12,6 @@ import { BooleanSearch } from './BooleanSearch.js';
12
12
  import { FuzzySearch } from './FuzzySearch.js';
13
13
  import { SearchSuggestions } from './SearchSuggestions.js';
14
14
  import { SavedSearchManager } from './SavedSearchManager.js';
15
- import { QueryCostEstimator } from './QueryCostEstimator.js';
16
15
  /**
17
16
  * Unified search manager providing access to all search types.
18
17
  *
@@ -25,17 +24,13 @@ export class SearchManager {
25
24
  fuzzySearcher;
26
25
  searchSuggestions;
27
26
  savedSearchManager;
28
- storage;
29
- queryEstimator;
30
27
  constructor(storage, savedSearchesFilePath) {
31
- this.storage = storage;
32
28
  this.basicSearch = new BasicSearch(storage);
33
29
  this.rankedSearch = new RankedSearch(storage);
34
30
  this.booleanSearcher = new BooleanSearch(storage);
35
31
  this.fuzzySearcher = new FuzzySearch(storage);
36
32
  this.searchSuggestions = new SearchSuggestions(storage);
37
33
  this.savedSearchManager = new SavedSearchManager(savedSearchesFilePath, this.basicSearch);
38
- this.queryEstimator = new QueryCostEstimator();
39
34
  }
40
35
  // ==================== Cache Management (Phase 4 Sprint 5) ====================
41
36
  /**
@@ -340,114 +335,4 @@ export class SearchManager {
340
335
  async updateSavedSearch(name, updates) {
341
336
  return this.savedSearchManager.updateSavedSearch(name, updates);
342
337
  }
343
- // ==================== Phase 10 Sprint 4: Automatic Search ====================
344
- /**
345
- * Phase 10 Sprint 4: Automatically select and execute the best search method.
346
- *
347
- * Analyzes the query and graph size to determine the optimal search method,
348
- * then executes it and returns both the results and the selection reasoning.
349
- *
350
- * @param query - The search query
351
- * @param limit - Maximum number of results (default: 10)
352
- * @returns AutoSearchResult with selected method, results, and estimates
353
- *
354
- * @example
355
- * ```typescript
356
- * const manager = new SearchManager(storage, savedSearchesPath);
357
- *
358
- * // Let the system choose the best search method
359
- * const result = await manager.autoSearch('software engineer skills');
360
- *
361
- * console.log(`Used ${result.selectedMethod} because: ${result.selectionReason}`);
362
- * console.log(`Found ${result.results.length} results in ${result.executionTimeMs}ms`);
363
- * ```
364
- */
365
- async autoSearch(query, limit = 10) {
366
- const startTime = Date.now();
367
- // Get entity count from graph
368
- const graph = await this.storage.loadGraph();
369
- const entityCount = graph.entities.length;
370
- // Get cost estimates for all methods
371
- const estimates = this.queryEstimator.estimateAllMethods(query, entityCount);
372
- // Get the recommended method
373
- const recommendation = this.queryEstimator.recommendMethod(query, entityCount);
374
- const selectedMethod = recommendation.method;
375
- const selectionReason = recommendation.reason;
376
- // Execute the selected search method
377
- let results;
378
- switch (selectedMethod) {
379
- case 'basic': {
380
- const basicResult = await this.basicSearch.searchNodes(query);
381
- results = basicResult.entities.map((e, idx) => ({
382
- entity: e,
383
- score: 1.0 - idx * 0.01, // Rank by position
384
- matchedFields: { name: true, observations: e.observations },
385
- }));
386
- break;
387
- }
388
- case 'ranked': {
389
- results = await this.rankedSearch.searchNodesRanked(query, undefined, undefined, undefined, limit);
390
- break;
391
- }
392
- case 'boolean': {
393
- const booleanResult = await this.booleanSearcher.booleanSearch(query);
394
- results = booleanResult.entities.map((e, idx) => ({
395
- entity: e,
396
- score: 1.0 - idx * 0.01, // Rank by position
397
- matchedFields: { name: true, observations: e.observations },
398
- }));
399
- break;
400
- }
401
- case 'fuzzy': {
402
- const fuzzyResult = await this.fuzzySearcher.fuzzySearch(query);
403
- results = fuzzyResult.entities.map((e, idx) => ({
404
- entity: e,
405
- score: 1.0 - idx * 0.01, // Rank by position
406
- matchedFields: { name: true, observations: e.observations },
407
- }));
408
- break;
409
- }
410
- case 'semantic': {
411
- // Semantic search not available through SearchManager
412
- // Fall back to ranked search
413
- results = await this.rankedSearch.searchNodesRanked(query, undefined, undefined, undefined, limit);
414
- break;
415
- }
416
- default: {
417
- const _exhaustiveCheck = selectedMethod;
418
- throw new Error(`Unknown search method: ${_exhaustiveCheck}`);
419
- }
420
- }
421
- // Limit results
422
- const limitedResults = results.slice(0, limit);
423
- return {
424
- selectedMethod,
425
- selectionReason,
426
- estimates,
427
- results: limitedResults,
428
- executionTimeMs: Date.now() - startTime,
429
- };
430
- }
431
- /**
432
- * Phase 10 Sprint 4: Get cost estimates for all search methods.
433
- *
434
- * Useful for clients that want to display cost information or
435
- * make their own method selection decisions.
436
- *
437
- * @param query - The search query
438
- * @returns Array of cost estimates for all methods
439
- */
440
- async getSearchCostEstimates(query) {
441
- const graph = await this.storage.loadGraph();
442
- const entityCount = graph.entities.length;
443
- return this.queryEstimator.estimateAllMethods(query, entityCount);
444
- }
445
- /**
446
- * Phase 10 Sprint 4: Get the query cost estimator instance.
447
- *
448
- * @returns The QueryCostEstimator instance
449
- */
450
- getQueryEstimator() {
451
- return this.queryEstimator;
452
- }
453
338
  }
@@ -53,12 +53,9 @@ export declare class SemanticSearch {
53
53
  * Generates embeddings for all entities and stores them in the vector store.
54
54
  * Can be called incrementally - only indexes entities that aren't already indexed.
55
55
  *
56
- * Phase 9B: Supports cancellation via AbortSignal in options.
57
- *
58
56
  * @param graph - Knowledge graph to index
59
- * @param options - Indexing options (includes signal for cancellation)
57
+ * @param options - Indexing options
60
58
  * @returns Index statistics
61
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
62
59
  */
63
60
  indexAll(graph: ReadonlyKnowledgeGraph, options?: SemanticIndexOptions): Promise<{
64
61
  indexed: number;
@@ -1 +1 @@
1
- {"version":3,"file":"SemanticSearch.d.ts","sourceRoot":"","sources":["../../src/search/SemanticSearch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAkBnD;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IACzB,+CAA+C;IAC/C,OAAO,CAAC,gBAAgB,CAAmB;IAE3C,wDAAwD;IACxD,OAAO,CAAC,WAAW,CAAe;IAElC,2CAA2C;IAC3C,OAAO,CAAC,OAAO,CAAS;IAExB,2CAA2C;IAC3C,OAAO,CAAC,YAAY,CAAK;IAEzB;;;;;OAKG;gBACS,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,YAAY;IAK1E;;;;;;;;;;;;OAYG;IACG,QAAQ,CACZ,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAwEhE;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM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AC,OAAO,CAAC;IAIrC;;;;OAIG;IACH,QAAQ,IAAI;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB;CASF"}
@@ -8,7 +8,6 @@
8
8
  */
9
9
  import { InMemoryVectorStore } from './VectorStore.js';
10
10
  import { EMBEDDING_DEFAULTS, SEMANTIC_SEARCH_LIMITS } from '../utils/constants.js';
11
- import { checkCancellation } from '../utils/index.js';
12
11
  /**
13
12
  * Convert an entity to a text representation for embedding.
14
13
  *
@@ -72,17 +71,12 @@ export class SemanticSearch {
72
71
  * Generates embeddings for all entities and stores them in the vector store.
73
72
  * Can be called incrementally - only indexes entities that aren't already indexed.
74
73
  *
75
- * Phase 9B: Supports cancellation via AbortSignal in options.
76
- *
77
74
  * @param graph - Knowledge graph to index
78
- * @param options - Indexing options (includes signal for cancellation)
75
+ * @param options - Indexing options
79
76
  * @returns Index statistics
80
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
81
77
  */
82
78
  async indexAll(graph, options = {}) {
83
- const { forceReindex = false, onProgress, batchSize = EMBEDDING_DEFAULTS.DEFAULT_BATCH_SIZE, signal, } = options;
84
- // Check for early cancellation
85
- checkCancellation(signal, 'indexAll');
79
+ const { forceReindex = false, onProgress, batchSize = EMBEDDING_DEFAULTS.DEFAULT_BATCH_SIZE, } = options;
86
80
  let indexed = 0;
87
81
  let skipped = 0;
88
82
  let errors = 0;
@@ -100,8 +94,6 @@ export class SemanticSearch {
100
94
  }
101
95
  // Process in batches
102
96
  for (let i = 0; i < toIndex.length; i += batchSize) {
103
- // Check for cancellation between batches
104
- checkCancellation(signal, 'indexAll');
105
97
  const batch = toIndex.slice(i, i + batchSize);
106
98
  const texts = batch.map(entityToText);
107
99
  try {
@@ -114,8 +106,6 @@ export class SemanticSearch {
114
106
  catch (error) {
115
107
  // Try individual embeddings on batch failure
116
108
  for (const entity of batch) {
117
- // Check for cancellation during fallback
118
- checkCancellation(signal, 'indexAll');
119
109
  try {
120
110
  const text = entityToText(entity);
121
111
  const embedding = await this.embeddingService.embed(text);
@@ -59,93 +59,5 @@ export declare class TFIDFIndexManager {
59
59
  * @returns True if index should be rebuilt
60
60
  */
61
61
  needsRebuild(graph: KnowledgeGraph): boolean;
62
- /**
63
- * Phase 10 Sprint 3: Add a single document to the index incrementally.
64
- *
65
- * More efficient than rebuilding the entire index for single entity additions.
66
- * Updates TF for the new document and recalculates IDF for affected terms.
67
- *
68
- * @param entity - The entity to add
69
- *
70
- * @example
71
- * ```typescript
72
- * const indexManager = new TFIDFIndexManager('/data');
73
- * await indexManager.loadIndex();
74
- *
75
- * // Add new entity
76
- * indexManager.addDocument({
77
- * name: 'NewEntity',
78
- * entityType: 'person',
79
- * observations: ['Software engineer']
80
- * });
81
- * ```
82
- */
83
- addDocument(entity: {
84
- name: string;
85
- entityType: string;
86
- observations: string[];
87
- }): void;
88
- /**
89
- * Phase 10 Sprint 3: Remove a single document from the index incrementally.
90
- *
91
- * More efficient than rebuilding the entire index for single entity deletions.
92
- * Recalculates IDF for terms that were in the removed document.
93
- *
94
- * @param entityName - Name of the entity to remove
95
- *
96
- * @example
97
- * ```typescript
98
- * indexManager.removeDocument('DeletedEntity');
99
- * ```
100
- */
101
- removeDocument(entityName: string): void;
102
- /**
103
- * Phase 10 Sprint 3: Update a single document in the index incrementally.
104
- *
105
- * More efficient than rebuilding the entire index for single entity updates.
106
- * Handles both term changes and observation updates.
107
- *
108
- * @param entity - The updated entity
109
- *
110
- * @example
111
- * ```typescript
112
- * indexManager.updateDocument({
113
- * name: 'ExistingEntity',
114
- * entityType: 'person',
115
- * observations: ['Updated observations']
116
- * });
117
- * ```
118
- */
119
- updateDocument(entity: {
120
- name: string;
121
- entityType: string;
122
- observations: string[];
123
- }): void;
124
- /**
125
- * Phase 10 Sprint 3: Recalculate IDF scores for a set of terms.
126
- *
127
- * @param terms - Set of terms to recalculate IDF for
128
- * @private
129
- */
130
- private recalculateIDFForTerms;
131
- /**
132
- * Phase 10 Sprint 3: Recalculate IDF scores for ALL terms in the index.
133
- *
134
- * Called when the total document count changes (add/remove document).
135
- * @private
136
- */
137
- private recalculateAllIDF;
138
- /**
139
- * Phase 10 Sprint 3: Check if the index is loaded/initialized.
140
- *
141
- * @returns True if index is available
142
- */
143
- isInitialized(): boolean;
144
- /**
145
- * Phase 10 Sprint 3: Get the number of documents in the index.
146
- *
147
- * @returns Document count or 0 if not initialized
148
- */
149
- getDocumentCount(): number;
150
62
  }
151
63
  //# sourceMappingURL=TFIDFIndexManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TFIDFIndexManager.d.ts","sourceRoot":"","sources":["../../src/search/TFIDFIndexManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAkB,cAAc,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAgB5G;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAA2B;gBAE5B,UAAU,EAAE,MAAM;IAI9B;;;;;OAKG;IACG,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;IAgDpE;;;;;;;OAOG;IACG,WAAW,CAAC,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAgEtG;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmB7C;;;;OAIG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBlD;;;;OAIG;IACH,QAAQ,IAAI,UAAU,GAAG,IAAI;IAI7B;;OAEG;IACG,UAAU,IAAI,OAAO,CA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;IAgEtG;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmB7C;;;;OAIG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBlD;;;;OAIG;IACH,QAAQ,IAAI,UAAU,GAAG,IAAI;IAI7B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;CAmB7C"}
@@ -212,221 +212,4 @@ export class TFIDFIndexManager {
212
212
  }
213
213
  return false;
214
214
  }
215
- // ==================== Phase 10 Sprint 3: Incremental Index Updates ====================
216
- /**
217
- * Phase 10 Sprint 3: Add a single document to the index incrementally.
218
- *
219
- * More efficient than rebuilding the entire index for single entity additions.
220
- * Updates TF for the new document and recalculates IDF for affected terms.
221
- *
222
- * @param entity - The entity to add
223
- *
224
- * @example
225
- * ```typescript
226
- * const indexManager = new TFIDFIndexManager('/data');
227
- * await indexManager.loadIndex();
228
- *
229
- * // Add new entity
230
- * indexManager.addDocument({
231
- * name: 'NewEntity',
232
- * entityType: 'person',
233
- * observations: ['Software engineer']
234
- * });
235
- * ```
236
- */
237
- addDocument(entity) {
238
- if (!this.index) {
239
- // Can't add to non-existent index
240
- return;
241
- }
242
- // Build document text and tokens
243
- const documentText = [entity.name, entity.entityType, ...entity.observations].join(' ');
244
- const tokens = tokenize(documentText);
245
- // Calculate term frequencies
246
- const termFreq = {};
247
- for (const term of tokens) {
248
- termFreq[term] = (termFreq[term] || 0) + 1;
249
- }
250
- // Add to documents map
251
- this.index.documents.set(entity.name, {
252
- entityName: entity.name,
253
- terms: termFreq,
254
- documentText,
255
- });
256
- // Update IDF for ALL terms because N changed (total document count)
257
- // IDF = log(N/df), and N has increased
258
- this.recalculateAllIDF();
259
- // Update timestamp
260
- this.index.lastUpdated = new Date().toISOString();
261
- }
262
- /**
263
- * Phase 10 Sprint 3: Remove a single document from the index incrementally.
264
- *
265
- * More efficient than rebuilding the entire index for single entity deletions.
266
- * Recalculates IDF for terms that were in the removed document.
267
- *
268
- * @param entityName - Name of the entity to remove
269
- *
270
- * @example
271
- * ```typescript
272
- * indexManager.removeDocument('DeletedEntity');
273
- * ```
274
- */
275
- removeDocument(entityName) {
276
- if (!this.index) {
277
- return;
278
- }
279
- const document = this.index.documents.get(entityName);
280
- if (!document) {
281
- return;
282
- }
283
- // Remove from documents map
284
- this.index.documents.delete(entityName);
285
- // Update IDF for ALL terms because N changed (total document count)
286
- // IDF = log(N/df), and N has decreased
287
- this.recalculateAllIDF();
288
- // Update timestamp
289
- this.index.lastUpdated = new Date().toISOString();
290
- }
291
- /**
292
- * Phase 10 Sprint 3: Update a single document in the index incrementally.
293
- *
294
- * More efficient than rebuilding the entire index for single entity updates.
295
- * Handles both term changes and observation updates.
296
- *
297
- * @param entity - The updated entity
298
- *
299
- * @example
300
- * ```typescript
301
- * indexManager.updateDocument({
302
- * name: 'ExistingEntity',
303
- * entityType: 'person',
304
- * observations: ['Updated observations']
305
- * });
306
- * ```
307
- */
308
- updateDocument(entity) {
309
- if (!this.index) {
310
- return;
311
- }
312
- const oldDocument = this.index.documents.get(entity.name);
313
- const oldTerms = oldDocument ? new Set(Object.keys(oldDocument.terms)) : new Set();
314
- // Build new document
315
- const documentText = [entity.name, entity.entityType, ...entity.observations].join(' ');
316
- const tokens = tokenize(documentText);
317
- const newTerms = new Set(tokens);
318
- // Calculate term frequencies
319
- const termFreq = {};
320
- for (const term of tokens) {
321
- termFreq[term] = (termFreq[term] || 0) + 1;
322
- }
323
- // Update documents map
324
- this.index.documents.set(entity.name, {
325
- entityName: entity.name,
326
- terms: termFreq,
327
- documentText,
328
- });
329
- // Find terms that changed (added or removed)
330
- const changedTerms = new Set();
331
- for (const term of oldTerms) {
332
- if (!newTerms.has(term)) {
333
- changedTerms.add(term);
334
- }
335
- }
336
- for (const term of newTerms) {
337
- if (!oldTerms.has(term)) {
338
- changedTerms.add(term);
339
- }
340
- }
341
- // Recalculate IDF for changed terms
342
- if (changedTerms.size > 0) {
343
- this.recalculateIDFForTerms(changedTerms);
344
- }
345
- // Update timestamp
346
- this.index.lastUpdated = new Date().toISOString();
347
- }
348
- /**
349
- * Phase 10 Sprint 3: Recalculate IDF scores for a set of terms.
350
- *
351
- * @param terms - Set of terms to recalculate IDF for
352
- * @private
353
- */
354
- recalculateIDFForTerms(terms) {
355
- if (!this.index) {
356
- return;
357
- }
358
- const totalDocs = this.index.documents.size;
359
- if (totalDocs === 0) {
360
- // No documents, clear all IDF for these terms
361
- for (const term of terms) {
362
- this.index.idf.delete(term);
363
- }
364
- return;
365
- }
366
- // Count documents containing each term
367
- for (const term of terms) {
368
- let docCount = 0;
369
- for (const doc of this.index.documents.values()) {
370
- if (term in doc.terms) {
371
- docCount++;
372
- }
373
- }
374
- if (docCount > 0) {
375
- // IDF = log(N / df) where N = total docs, df = doc frequency
376
- const idfScore = Math.log(totalDocs / docCount);
377
- this.index.idf.set(term, idfScore);
378
- }
379
- else {
380
- // Term no longer exists in any document
381
- this.index.idf.delete(term);
382
- }
383
- }
384
- }
385
- /**
386
- * Phase 10 Sprint 3: Recalculate IDF scores for ALL terms in the index.
387
- *
388
- * Called when the total document count changes (add/remove document).
389
- * @private
390
- */
391
- recalculateAllIDF() {
392
- if (!this.index) {
393
- return;
394
- }
395
- const totalDocs = this.index.documents.size;
396
- if (totalDocs === 0) {
397
- // No documents, clear all IDF
398
- this.index.idf.clear();
399
- return;
400
- }
401
- // Build term -> document count map
402
- const termDocCounts = new Map();
403
- for (const doc of this.index.documents.values()) {
404
- for (const term of Object.keys(doc.terms)) {
405
- termDocCounts.set(term, (termDocCounts.get(term) ?? 0) + 1);
406
- }
407
- }
408
- // Clear old IDF and recalculate
409
- this.index.idf.clear();
410
- for (const [term, docCount] of termDocCounts) {
411
- // IDF = log(N / df) where N = total docs, df = doc frequency
412
- const idfScore = Math.log(totalDocs / docCount);
413
- this.index.idf.set(term, idfScore);
414
- }
415
- }
416
- /**
417
- * Phase 10 Sprint 3: Check if the index is loaded/initialized.
418
- *
419
- * @returns True if index is available
420
- */
421
- isInitialized() {
422
- return this.index !== null;
423
- }
424
- /**
425
- * Phase 10 Sprint 3: Get the number of documents in the index.
426
- *
427
- * @returns Document count or 0 if not initialized
428
- */
429
- getDocumentCount() {
430
- return this.index?.documents.size ?? 0;
431
- }
432
215
  }
@@ -12,24 +12,7 @@ export { SearchSuggestions } from './SearchSuggestions.js';
12
12
  export { SavedSearchManager } from './SavedSearchManager.js';
13
13
  export { SearchManager } from './SearchManager.js';
14
14
  export { SearchFilterChain, type SearchFilters, type ValidatedPagination } from './SearchFilterChain.js';
15
- export { OpenAIEmbeddingService, LocalEmbeddingService, MockEmbeddingService, createEmbeddingService, l2Normalize, QUERY_PREFIX, DOCUMENT_PREFIX, type EmbeddingProgressCallback, } from './EmbeddingService.js';
16
- export { EmbeddingCache, DEFAULT_EMBEDDING_CACHE_OPTIONS, type EmbeddingCacheStats, type EmbeddingCacheOptions, } from './EmbeddingCache.js';
17
- export { IncrementalIndexer, DEFAULT_INDEXER_OPTIONS, type IndexOperationType, type IndexOperation, type IncrementalIndexerOptions, type FlushResult, } from './IncrementalIndexer.js';
15
+ export { OpenAIEmbeddingService, LocalEmbeddingService, MockEmbeddingService, createEmbeddingService, } from './EmbeddingService.js';
18
16
  export { InMemoryVectorStore, SQLiteVectorStore, createVectorStore, cosineSimilarity, type SQLiteStorageWithEmbeddings, } from './VectorStore.js';
19
17
  export { SemanticSearch, entityToText, } from './SemanticSearch.js';
20
- export { TFIDFIndexManager } from './TFIDFIndexManager.js';
21
- export { TFIDFEventSync } from './TFIDFEventSync.js';
22
- export { QueryCostEstimator, type SearchLayer, type ExtendedQueryCostEstimate, type LayerRecommendationOptions, type TokenEstimationOptions, type AdaptiveDepthConfig, } from './QueryCostEstimator.js';
23
- export { SymbolicSearch, type SymbolicResult } from './SymbolicSearch.js';
24
- export { HybridSearchManager, DEFAULT_HYBRID_WEIGHTS } from './HybridSearchManager.js';
25
- export { QueryAnalyzer } from './QueryAnalyzer.js';
26
- export { QueryPlanner } from './QueryPlanner.js';
27
- export { ReflectionManager, type ReflectionOptions, type ReflectionResult, type RefinementHistoryEntry, } from './ReflectionManager.js';
28
- export { BM25Search, STOPWORDS, DEFAULT_BM25_CONFIG, type BM25DocumentEntry, type BM25Index, type BM25Config, } from './BM25Search.js';
29
- export { OptimizedInvertedIndex, type IndexMemoryUsage, type PostingListResult, } from './OptimizedInvertedIndex.js';
30
- export { HybridScorer, DEFAULT_SCORER_WEIGHTS, type SemanticSearchResult, type LexicalSearchResult, type SymbolicSearchResult, type ScoredResult, type HybridWeights, type HybridScorerOptions, } from './HybridScorer.js';
31
- export { ParallelSearchExecutor, type LayerTiming, type ParallelSearchResult, type ParallelSearchOptions, } from './ParallelSearchExecutor.js';
32
- export { EarlyTerminationManager, type AdequacyCheck, type EarlyTerminationOptions, type EarlyTerminationResult, } from './EarlyTerminationManager.js';
33
- export { QueryPlanCache, type CachedQueryEntry, type QueryPlanCacheStats, type QueryPlanCacheOptions, } from './QueryPlanCache.js';
34
- export { QuantizedVectorStore, type QuantizationParams, type QuantizedVectorStoreStats, type QuantizedSearchResult, type QuantizedVectorStoreOptions, } from './QuantizedVectorStore.js';
35
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO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OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGzG,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,2BAA2B,GACjC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAC"}
@@ -14,39 +14,8 @@ export { SearchManager } from './SearchManager.js';
14
14
  // Sprint 2: Search Filter Chain utilities
15
15
  export { SearchFilterChain } from './SearchFilterChain.js';
16
16
  // Phase 4 Sprint 10: Embedding Service for semantic search
17
- // Phase 12 Sprint 5: Added l2Normalize, prefixes, and progress callback
18
- export { OpenAIEmbeddingService, LocalEmbeddingService, MockEmbeddingService, createEmbeddingService, l2Normalize, QUERY_PREFIX, DOCUMENT_PREFIX, } from './EmbeddingService.js';
19
- // Phase 12 Sprint 5: Embedding Cache with LRU eviction
20
- export { EmbeddingCache, DEFAULT_EMBEDDING_CACHE_OPTIONS, } from './EmbeddingCache.js';
21
- // Phase 12 Sprint 5: Incremental Indexer for batch updates
22
- export { IncrementalIndexer, DEFAULT_INDEXER_OPTIONS, } from './IncrementalIndexer.js';
17
+ export { OpenAIEmbeddingService, LocalEmbeddingService, MockEmbeddingService, createEmbeddingService, } from './EmbeddingService.js';
23
18
  // Phase 4 Sprint 11: Vector Store for semantic search
24
19
  export { InMemoryVectorStore, SQLiteVectorStore, createVectorStore, cosineSimilarity, } from './VectorStore.js';
25
20
  // Phase 4 Sprint 12: Semantic Search Manager
26
21
  export { SemanticSearch, entityToText, } from './SemanticSearch.js';
27
- // Phase 10 Sprint 3: TF-IDF Index Manager and Event Sync
28
- export { TFIDFIndexManager } from './TFIDFIndexManager.js';
29
- export { TFIDFEventSync } from './TFIDFEventSync.js';
30
- // Phase 10 Sprint 4: Query Cost Estimation
31
- // Phase 12 Sprint 4: Enhanced with adaptive depth, token estimation, layer recommendations
32
- export { QueryCostEstimator, } from './QueryCostEstimator.js';
33
- // Phase 11 Sprint 1: Hybrid Search
34
- export { SymbolicSearch } from './SymbolicSearch.js';
35
- export { HybridSearchManager, DEFAULT_HYBRID_WEIGHTS } from './HybridSearchManager.js';
36
- // Phase 11 Sprint 3: Query Analysis
37
- export { QueryAnalyzer } from './QueryAnalyzer.js';
38
- export { QueryPlanner } from './QueryPlanner.js';
39
- // Phase 11 Sprint 4: Reflection-based Retrieval
40
- // Phase 12 Sprint 4: Enhanced with progressive limits, focused refinement, history tracking
41
- export { ReflectionManager, } from './ReflectionManager.js';
42
- // Phase 12 Sprint 3: Search Algorithm Optimization
43
- export { BM25Search, STOPWORDS, DEFAULT_BM25_CONFIG, } from './BM25Search.js';
44
- export { OptimizedInvertedIndex, } from './OptimizedInvertedIndex.js';
45
- export { HybridScorer, DEFAULT_SCORER_WEIGHTS, } from './HybridScorer.js';
46
- // Phase 12 Sprint 2: Parallel Search Execution
47
- export { ParallelSearchExecutor, } from './ParallelSearchExecutor.js';
48
- // Phase 12 Sprint 4: Query Execution Optimization
49
- export { EarlyTerminationManager, } from './EarlyTerminationManager.js';
50
- export { QueryPlanCache, } from './QueryPlanCache.js';
51
- // Phase 12 Sprint 6: Quantized Vector Store
52
- export { QuantizedVectorStore, } from './QuantizedVectorStore.js';
@@ -1 +1 @@
1
- {"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAItE;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;gBAEhB,GAAG,EAAE,cAAc;IAiB/B,OAAO,CAAC,oBAAoB;IAetB,KAAK;CAKZ"}
1
+ {"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOtE;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;gBAEhB,GAAG,EAAE,cAAc;IAiB/B,OAAO,CAAC,oBAAoB;IAetB,KAAK;CAKZ"}
@@ -6,12 +6,15 @@
6
6
  *
7
7
  * @module server/MCPServer
8
8
  */
9
+ import { createRequire } from 'node:module';
9
10
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
10
11
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
12
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
12
13
  import { logger } from '@danielsimonjr/memoryjs';
13
14
  import { toolDefinitions } from './toolDefinitions.js';
14
15
  import { handleToolCall } from './toolHandlers.js';
16
+ const require = createRequire(import.meta.url);
17
+ const { version } = require('../../package.json');
15
18
  /**
16
19
  * MCP Server for Knowledge Graph operations.
17
20
  * Exposes tools for entity/relation management, search, and analysis.
@@ -23,7 +26,7 @@ export class MCPServer {
23
26
  this.ctx = ctx;
24
27
  this.server = new Server({
25
28
  name: "memory-server",
26
- version: "11.0.0",
29
+ version,
27
30
  }, {
28
31
  capabilities: {
29
32
  tools: {},
@@ -111,16 +111,16 @@ export function estimateCompressionRatio(content) {
111
111
  const jsonIndicators = (content.match(/[{}\[\]":,]/g) || []).length;
112
112
  const jsonRatio = jsonIndicators / size;
113
113
  if (jsonRatio > 0.1) {
114
- // Highly JSON-like, expect 60-75% compression
115
- return 0.25 + (0.1 * Math.random());
114
+ // Highly JSON-like, expect ~70% compression
115
+ return 0.3;
116
116
  }
117
117
  // Check for repetitive content
118
118
  const uniqueChars = new Set(content).size;
119
119
  const repetitionRatio = uniqueChars / Math.min(size, 256);
120
120
  if (repetitionRatio < 0.3) {
121
- // Very repetitive, expect 50-70% compression
122
- return 0.3 + (0.15 * Math.random());
121
+ // Very repetitive, expect ~60% compression
122
+ return 0.4;
123
123
  }
124
124
  // Default estimate for mixed content
125
- return 0.5 + (0.2 * Math.random());
125
+ return 0.6;
126
126
  }