@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
package/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Anthropic, PBC (Original Memory MCP Server)
4
- Copyright (c) 2025 Daniel Simon Jr. (Phase 1-4 Enhancements)
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anthropic, PBC (Original Memory MCP Server)
4
+ Copyright (c) 2025 Daniel Simon Jr. (Phase 1-4 Enhancements)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -6,8 +6,16 @@
6
6
  *
7
7
  * @module core/EntityManager
8
8
  */
9
- import type { Entity, LongRunningOperationOptions } from '../types/index.js';
9
+ import type { Entity } from '../types/index.js';
10
10
  import type { GraphStorage } from './GraphStorage.js';
11
+ /**
12
+ * Minimum importance value (least important).
13
+ */
14
+ export declare const MIN_IMPORTANCE = 0;
15
+ /**
16
+ * Maximum importance value (most important).
17
+ */
18
+ export declare const MAX_IMPORTANCE = 10;
11
19
  /**
12
20
  * Manages entity operations with automatic timestamp handling.
13
21
  */
@@ -23,13 +31,9 @@ export declare class EntityManager {
23
31
  * - Normalizes all tags to lowercase for consistent searching
24
32
  * - Validates importance values (must be between 0-10)
25
33
  *
26
- * Phase 9B: Supports progress tracking and cancellation via LongRunningOperationOptions.
27
- *
28
34
  * @param entities - Array of entities to create. Each entity must have a unique name.
29
- * @param options - Optional progress/cancellation options (Phase 9B)
30
35
  * @returns Promise resolving to array of newly created entities (excludes duplicates)
31
36
  * @throws {InvalidImportanceError} If any entity has importance outside the valid range [0-10]
32
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
33
37
  *
34
38
  * @example
35
39
  * ```typescript
@@ -49,16 +53,9 @@ export declare class EntityManager {
49
53
  * { name: 'Bob', entityType: 'person', observations: [] },
50
54
  * { name: 'Charlie', entityType: 'person', observations: [] }
51
55
  * ]);
52
- *
53
- * // With progress tracking and cancellation (Phase 9B)
54
- * const controller = new AbortController();
55
- * const results = await manager.createEntities(largeEntityArray, {
56
- * signal: controller.signal,
57
- * onProgress: (p) => console.log(`${p.percentage}% complete`),
58
- * });
59
56
  * ```
60
57
  */
61
- createEntities(entities: Entity[], options?: LongRunningOperationOptions): Promise<Entity[]>;
58
+ createEntities(entities: Entity[]): Promise<Entity[]>;
62
59
  /**
63
60
  * Delete multiple entities by name in a single batch operation.
64
61
  *
@@ -228,8 +225,6 @@ export declare class EntityManager {
228
225
  /**
229
226
  * Add tags to multiple entities in a single operation.
230
227
  *
231
- * OPTIMIZED: Uses Map for O(1) entity lookups instead of O(n) find() per entity.
232
- *
233
228
  * @param entityNames - Names of entities to tag
234
229
  * @param tags - Tags to add to each entity
235
230
  * @returns Array of results showing which tags were added to each entity
@@ -1 +1 @@
1
- {"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../src/core/EntityManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyBtD;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,MAAM,EAAE,CAAC;IA+EpB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB1D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAuB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,WAAW,CACf,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,GACzD,OAAO,CAAC,MAAM,EAAE,CAAC;IAuCpB;;;;;;;;;OASG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAA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AAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAoC5G;;;;;;;;OAQG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBhH;;;;;;OAMG;IACG,yBAAyB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAiC9H;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBxG;;;;;;;;;;OAUG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAmCvH"}
@@ -7,18 +7,16 @@
7
7
  * @module core/EntityManager
8
8
  */
9
9
  import { EntityNotFoundError, InvalidImportanceError, ValidationError } from '../utils/errors.js';
10
- import { BatchCreateEntitiesSchema, UpdateEntitySchema, EntityNamesSchema, checkCancellation, createProgressReporter, createProgress, sanitizeObject, } from '../utils/index.js';
10
+ import { BatchCreateEntitiesSchema, UpdateEntitySchema, EntityNamesSchema } from '../utils/index.js';
11
11
  import { GRAPH_LIMITS } from '../utils/constants.js';
12
12
  /**
13
13
  * Minimum importance value (least important).
14
- * Note: Use IMPORTANCE_RANGE from constants.ts for external access.
15
14
  */
16
- const MIN_IMPORTANCE = 0;
15
+ export const MIN_IMPORTANCE = 0;
17
16
  /**
18
17
  * Maximum importance value (most important).
19
- * Note: Use IMPORTANCE_RANGE from constants.ts for external access.
20
18
  */
21
- const MAX_IMPORTANCE = 10;
19
+ export const MAX_IMPORTANCE = 10;
22
20
  /**
23
21
  * Manages entity operations with automatic timestamp handling.
24
22
  */
@@ -36,13 +34,9 @@ export class EntityManager {
36
34
  * - Normalizes all tags to lowercase for consistent searching
37
35
  * - Validates importance values (must be between 0-10)
38
36
  *
39
- * Phase 9B: Supports progress tracking and cancellation via LongRunningOperationOptions.
40
- *
41
37
  * @param entities - Array of entities to create. Each entity must have a unique name.
42
- * @param options - Optional progress/cancellation options (Phase 9B)
43
38
  * @returns Promise resolving to array of newly created entities (excludes duplicates)
44
39
  * @throws {InvalidImportanceError} If any entity has importance outside the valid range [0-10]
45
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
46
40
  *
47
41
  * @example
48
42
  * ```typescript
@@ -62,28 +56,15 @@ export class EntityManager {
62
56
  * { name: 'Bob', entityType: 'person', observations: [] },
63
57
  * { name: 'Charlie', entityType: 'person', observations: [] }
64
58
  * ]);
65
- *
66
- * // With progress tracking and cancellation (Phase 9B)
67
- * const controller = new AbortController();
68
- * const results = await manager.createEntities(largeEntityArray, {
69
- * signal: controller.signal,
70
- * onProgress: (p) => console.log(`${p.percentage}% complete`),
71
- * });
72
59
  * ```
73
60
  */
74
- async createEntities(entities, options) {
75
- // Check for early cancellation
76
- checkCancellation(options?.signal, 'createEntities');
61
+ async createEntities(entities) {
77
62
  // Validate input
78
63
  const validation = BatchCreateEntitiesSchema.safeParse(entities);
79
64
  if (!validation.success) {
80
65
  const errors = validation.error.issues.map((e) => `${e.path.join('.')}: ${e.message}`);
81
66
  throw new ValidationError('Invalid entity data', errors);
82
67
  }
83
- // Setup progress reporter
84
- const reportProgress = createProgressReporter(options?.onProgress);
85
- const total = entities.length;
86
- reportProgress?.(createProgress(0, total, 'createEntities'));
87
68
  // Use read-only graph for checking existing entities
88
69
  const readGraph = await this.storage.loadGraph();
89
70
  const timestamp = new Date().toISOString();
@@ -92,13 +73,8 @@ export class EntityManager {
92
73
  if (readGraph.entities.length + entitiesToAdd.length > GRAPH_LIMITS.MAX_ENTITIES) {
93
74
  throw new ValidationError('Graph size limit exceeded', [`Adding ${entitiesToAdd.length} entities would exceed maximum of ${GRAPH_LIMITS.MAX_ENTITIES} entities`]);
94
75
  }
95
- // Check for cancellation before processing
96
- checkCancellation(options?.signal, 'createEntities');
97
- const newEntities = [];
98
- let processed = 0;
99
- for (const e of entitiesToAdd) {
100
- // Check for cancellation periodically
101
- checkCancellation(options?.signal, 'createEntities');
76
+ const newEntities = entitiesToAdd
77
+ .map(e => {
102
78
  const entity = {
103
79
  ...e,
104
80
  createdAt: e.createdAt || timestamp,
@@ -115,10 +91,8 @@ export class EntityManager {
115
91
  }
116
92
  entity.importance = e.importance;
117
93
  }
118
- newEntities.push(entity);
119
- processed++;
120
- reportProgress?.(createProgress(processed, entitiesToAdd.length, 'createEntities'));
121
- }
94
+ return entity;
95
+ });
122
96
  // OPTIMIZED: Use append for single entity, bulk save for multiple
123
97
  // (N individual appends is slower than one bulk write)
124
98
  if (newEntities.length === 1) {
@@ -129,8 +103,6 @@ export class EntityManager {
129
103
  graph.entities.push(...newEntities);
130
104
  await this.storage.saveGraph(graph);
131
105
  }
132
- // Report completion
133
- reportProgress?.(createProgress(entitiesToAdd.length, entitiesToAdd.length, 'createEntities'));
134
106
  return newEntities;
135
107
  }
136
108
  /**
@@ -250,8 +222,8 @@ export class EntityManager {
250
222
  if (!entity) {
251
223
  throw new EntityNotFoundError(name);
252
224
  }
253
- // Apply updates (sanitized to prevent prototype pollution)
254
- Object.assign(entity, sanitizeObject(updates));
225
+ // Apply updates
226
+ Object.assign(entity, updates);
255
227
  entity.lastModified = new Date().toISOString();
256
228
  await this.storage.saveGraph(graph);
257
229
  return entity;
@@ -310,8 +282,8 @@ export class EntityManager {
310
282
  throw new EntityNotFoundError(name);
311
283
  }
312
284
  const entity = graph.entities[idx];
313
- // Apply updates (sanitized to prevent prototype pollution)
314
- Object.assign(entity, sanitizeObject(updateData));
285
+ // Apply updates
286
+ Object.assign(entity, updateData);
315
287
  entity.lastModified = timestamp;
316
288
  updatedEntities.push(entity);
317
289
  }
@@ -357,8 +329,9 @@ export class EntityManager {
357
329
  * @throws {EntityNotFoundError} If entity is not found
358
330
  */
359
331
  async removeTags(entityName, tags) {
360
- // OPTIMIZED: Use O(1) NameIndex lookup instead of loadGraph() + O(n) find()
361
- const entity = this.storage.getEntityByName(entityName);
332
+ const graph = await this.storage.getGraphForMutation();
333
+ const timestamp = new Date().toISOString();
334
+ const entity = graph.entities.find(e => e.name === entityName);
362
335
  if (!entity) {
363
336
  throw new EntityNotFoundError(entityName);
364
337
  }
@@ -371,13 +344,14 @@ export class EntityManager {
371
344
  // Capture existing tags (lowercase) BEFORE filtering to accurately track removals
372
345
  const existingTagsLower = entity.tags.map(t => t.toLowerCase());
373
346
  // Filter out the tags to remove
374
- const newTags = entity.tags.filter(tag => !normalizedTags.includes(tag.toLowerCase()));
347
+ entity.tags = entity.tags.filter(tag => !normalizedTags.includes(tag.toLowerCase()));
375
348
  // A tag was removed if it existed in the original tags
376
349
  const removedTags = normalizedTags.filter(tag => existingTagsLower.includes(tag));
377
- // Update entity via storage if tags were removed
378
- if (newTags.length < originalLength) {
379
- await this.storage.updateEntity(entityName, { tags: newTags });
350
+ // Update lastModified timestamp if tags were removed
351
+ if (entity.tags.length < originalLength) {
352
+ entity.lastModified = timestamp;
380
353
  }
354
+ await this.storage.saveGraph(graph);
381
355
  return { entityName, removedTags };
382
356
  }
383
357
  /**
@@ -406,8 +380,6 @@ export class EntityManager {
406
380
  /**
407
381
  * Add tags to multiple entities in a single operation.
408
382
  *
409
- * OPTIMIZED: Uses Map for O(1) entity lookups instead of O(n) find() per entity.
410
- *
411
383
  * @param entityNames - Names of entities to tag
412
384
  * @param tags - Tags to add to each entity
413
385
  * @returns Array of results showing which tags were added to each entity
@@ -417,13 +389,8 @@ export class EntityManager {
417
389
  const timestamp = new Date().toISOString();
418
390
  const normalizedTags = tags.map(tag => tag.toLowerCase());
419
391
  const results = [];
420
- // OPTIMIZED: Build Map for O(1) lookups instead of O(n) find() per entity
421
- const entityMap = new Map();
422
- for (const e of graph.entities) {
423
- entityMap.set(e.name, e);
424
- }
425
392
  for (const entityName of entityNames) {
426
- const entity = entityMap.get(entityName);
393
+ const entity = graph.entities.find(e => e.name === entityName);
427
394
  if (!entity) {
428
395
  continue; // Skip non-existent entities
429
396
  }
@@ -7,8 +7,6 @@
7
7
  * @module core/GraphStorage
8
8
  */
9
9
  import type { KnowledgeGraph, Entity, Relation, ReadonlyKnowledgeGraph, IGraphStorage, LowercaseData } from '../types/index.js';
10
- import { BatchTransaction } from './TransactionManager.js';
11
- import { GraphEventEmitter } from './GraphEventEmitter.js';
12
10
  /**
13
11
  * GraphStorage manages persistence of the knowledge graph to disk.
14
12
  *
@@ -74,38 +72,12 @@ export declare class GraphStorage implements IGraphStorage {
74
72
  * Maps words in observations to entity names.
75
73
  */
76
74
  private observationIndex;
77
- /**
78
- * Phase 10 Sprint 2: Event emitter for graph change notifications.
79
- * Allows external systems to subscribe to graph changes.
80
- */
81
- private eventEmitter;
82
75
  /**
83
76
  * Create a new GraphStorage instance.
84
77
  *
85
78
  * @param memoryFilePath - Absolute path to the JSONL file
86
79
  */
87
80
  constructor(memoryFilePath: string);
88
- /**
89
- * Get the event emitter for subscribing to graph changes.
90
- *
91
- * @returns GraphEventEmitter instance
92
- *
93
- * @example
94
- * ```typescript
95
- * const storage = new GraphStorage('/data/memory.jsonl');
96
- *
97
- * // Subscribe to entity creation events
98
- * storage.events.on('entity:created', (event) => {
99
- * console.log(`Entity ${event.entity.name} created`);
100
- * });
101
- *
102
- * // Subscribe to all events
103
- * storage.events.onAny((event) => {
104
- * console.log(`Graph event: ${event.type}`);
105
- * });
106
- * ```
107
- */
108
- get events(): GraphEventEmitter;
109
81
  /**
110
82
  * Write content to file with fsync for durability.
111
83
  *
@@ -368,28 +340,5 @@ export declare class GraphStorage implements IGraphStorage {
368
340
  wordCount: number;
369
341
  entityCount: number;
370
342
  };
371
- /**
372
- * Create a new batch transaction for atomic operations.
373
- *
374
- * Returns a BatchTransaction instance that can be used to queue multiple
375
- * operations and execute them atomically with a single save operation.
376
- *
377
- * @returns A new BatchTransaction instance
378
- *
379
- * @example
380
- * ```typescript
381
- * const storage = new GraphStorage('/data/memory.jsonl');
382
- *
383
- * // Create and execute a batch transaction
384
- * const result = await storage.transaction()
385
- * .createEntity({ name: 'Alice', entityType: 'person', observations: ['Developer'] })
386
- * .createEntity({ name: 'Bob', entityType: 'person', observations: ['Designer'] })
387
- * .createRelation({ from: 'Alice', to: 'Bob', relationType: 'knows' })
388
- * .execute();
389
- *
390
- * console.log(`Batch completed: ${result.operationsExecuted} operations`);
391
- * ```
392
- */
393
- transaction(): BatchTransaction;
394
343
  }
395
344
  //# sourceMappingURL=GraphStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphStorage.d.ts","sourceRoot":"","sources":["../../src/core/GraphStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIhI,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAa,YAAW,aAAa;IAqEpC,OAAO,CAAC,cAAc;IApElC;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAe;IAE5B;;;OAGG;IACH,OAAO,CAAC,KAAK,CAA+B;IAE5C;;;OAGG;IACH,OAAO,CAAC,cAAc,CAAa;IAEnC;;;;;;;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EAAE;IAI/C;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAMzC;;;;;;;;;OASG;IACH,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIvD;;;;;;;;OAQG;IACH,+BAA+B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;IAI7D;;;;;;;;OAQG;IACH,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;IAI9D;;;;OAIG;IACH,wBAAwB,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CAGvE"}
@@ -10,9 +10,6 @@ import { promises as fs } from 'fs';
10
10
  import { Mutex } from 'async-mutex';
11
11
  import { clearAllSearchCaches } from '../utils/searchCache.js';
12
12
  import { NameIndex, TypeIndex, LowercaseCache, RelationIndex, ObservationIndex } from '../utils/indexes.js';
13
- import { sanitizeObject } from '../utils/index.js';
14
- import { BatchTransaction } from './TransactionManager.js';
15
- import { GraphEventEmitter } from './GraphEventEmitter.js';
16
13
  /**
17
14
  * GraphStorage manages persistence of the knowledge graph to disk.
18
15
  *
@@ -80,11 +77,6 @@ export class GraphStorage {
80
77
  * Maps words in observations to entity names.
81
78
  */
82
79
  observationIndex = new ObservationIndex();
83
- /**
84
- * Phase 10 Sprint 2: Event emitter for graph change notifications.
85
- * Allows external systems to subscribe to graph changes.
86
- */
87
- eventEmitter = new GraphEventEmitter();
88
80
  /**
89
81
  * Create a new GraphStorage instance.
90
82
  *
@@ -93,30 +85,6 @@ export class GraphStorage {
93
85
  constructor(memoryFilePath) {
94
86
  this.memoryFilePath = memoryFilePath;
95
87
  }
96
- // ==================== Phase 10 Sprint 2: Event Emitter Access ====================
97
- /**
98
- * Get the event emitter for subscribing to graph changes.
99
- *
100
- * @returns GraphEventEmitter instance
101
- *
102
- * @example
103
- * ```typescript
104
- * const storage = new GraphStorage('/data/memory.jsonl');
105
- *
106
- * // Subscribe to entity creation events
107
- * storage.events.on('entity:created', (event) => {
108
- * console.log(`Entity ${event.entity.name} created`);
109
- * });
110
- *
111
- * // Subscribe to all events
112
- * storage.events.onAny((event) => {
113
- * console.log(`Graph event: ${event.type}`);
114
- * });
115
- * ```
116
- */
117
- get events() {
118
- return this.eventEmitter;
119
- }
120
88
  // ==================== Durable File Operations ====================
121
89
  /**
122
90
  * Write content to file with fsync for durability.
@@ -243,16 +211,12 @@ export class GraphStorage {
243
211
  // Build indexes from loaded data
244
212
  this.buildEntityIndexes(graph.entities);
245
213
  this.buildRelationIndex(graph.relations);
246
- // Phase 10 Sprint 2: Emit graph:loaded event
247
- this.eventEmitter.emitGraphLoaded(graph.entities.length, graph.relations.length);
248
214
  }
249
215
  catch (error) {
250
216
  // File doesn't exist - create empty graph
251
217
  if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
252
218
  this.cache = { entities: [], relations: [] };
253
219
  this.clearIndexes();
254
- // Phase 10 Sprint 2: Emit graph:loaded event for empty graph
255
- this.eventEmitter.emitGraphLoaded(0, 0);
256
220
  return;
257
221
  }
258
222
  throw error;
@@ -357,8 +321,6 @@ export class GraphStorage {
357
321
  this.pendingAppends++;
358
322
  // Clear search caches
359
323
  clearAllSearchCaches();
360
- // Phase 10 Sprint 2: Emit entity:created event
361
- this.eventEmitter.emitEntityCreated(entity);
362
324
  // Trigger compaction if threshold reached
363
325
  if (this.pendingAppends >= this.compactionThreshold) {
364
326
  await this.compactInternal();
@@ -407,8 +369,6 @@ export class GraphStorage {
407
369
  this.pendingAppends++;
408
370
  // Clear search caches
409
371
  clearAllSearchCaches();
410
- // Phase 10 Sprint 2: Emit relation:created event
411
- this.eventEmitter.emitRelationCreated(relation);
412
372
  // Trigger compaction if threshold reached
413
373
  if (this.pendingAppends >= this.compactionThreshold) {
414
374
  await this.compactInternal();
@@ -487,8 +447,6 @@ export class GraphStorage {
487
447
  this.pendingAppends = 0;
488
448
  // Clear all search caches since graph data has changed
489
449
  clearAllSearchCaches();
490
- // Phase 10 Sprint 2: Emit graph:saved event
491
- this.eventEmitter.emitGraphSaved(graph.entities.length, graph.relations.length);
492
450
  }
493
451
  /**
494
452
  * Get the current pending appends count.
@@ -521,13 +479,6 @@ export class GraphStorage {
521
479
  const entity = this.cache.entities[entityIndex];
522
480
  const oldType = entity.entityType;
523
481
  const timestamp = new Date().toISOString();
524
- // Phase 10 Sprint 2: Capture previous values for event
525
- const previousValues = {};
526
- for (const key of Object.keys(updates)) {
527
- if (key in entity) {
528
- previousValues[key] = entity[key];
529
- }
530
- }
531
482
  // Build the updated entity data for file write BEFORE modifying cache
532
483
  // This ensures cache consistency if file write fails
533
484
  const updatedEntity = {
@@ -563,8 +514,8 @@ export class GraphStorage {
563
514
  throw error;
564
515
  }
565
516
  }
566
- // File write succeeded - NOW update cache in-place (sanitized to prevent prototype pollution)
567
- Object.assign(entity, sanitizeObject(updates));
517
+ // File write succeeded - NOW update cache in-place
518
+ Object.assign(entity, updates);
568
519
  entity.lastModified = timestamp;
569
520
  // Update indexes
570
521
  this.nameIndex.add(entity); // Update reference
@@ -579,8 +530,6 @@ export class GraphStorage {
579
530
  this.pendingAppends++;
580
531
  // Clear search caches
581
532
  clearAllSearchCaches();
582
- // Phase 10 Sprint 2: Emit entity:updated event
583
- this.eventEmitter.emitEntityUpdated(entityName, updates, previousValues);
584
533
  // Trigger compaction if threshold reached
585
534
  if (this.pendingAppends >= this.compactionThreshold) {
586
535
  await this.compactInternal();
@@ -756,30 +705,4 @@ export class GraphStorage {
756
705
  getObservationIndexStats() {
757
706
  return this.observationIndex.getStats();
758
707
  }
759
- // ==================== Phase 10 Sprint 1: Transaction Factory ====================
760
- /**
761
- * Create a new batch transaction for atomic operations.
762
- *
763
- * Returns a BatchTransaction instance that can be used to queue multiple
764
- * operations and execute them atomically with a single save operation.
765
- *
766
- * @returns A new BatchTransaction instance
767
- *
768
- * @example
769
- * ```typescript
770
- * const storage = new GraphStorage('/data/memory.jsonl');
771
- *
772
- * // Create and execute a batch transaction
773
- * const result = await storage.transaction()
774
- * .createEntity({ name: 'Alice', entityType: 'person', observations: ['Developer'] })
775
- * .createEntity({ name: 'Bob', entityType: 'person', observations: ['Designer'] })
776
- * .createRelation({ from: 'Alice', to: 'Bob', relationType: 'knows' })
777
- * .execute();
778
- *
779
- * console.log(`Batch completed: ${result.operationsExecuted} operations`);
780
- * ```
781
- */
782
- transaction() {
783
- return new BatchTransaction(this);
784
- }
785
708
  }
@@ -60,18 +60,13 @@ export declare class GraphTraversal {
60
60
  /**
61
61
  * Find all paths between two entities up to a maximum depth.
62
62
  *
63
- * Phase 9B: Supports cancellation via AbortSignal in options.
64
- *
65
63
  * @param source - Source entity name
66
64
  * @param target - Target entity name
67
65
  * @param maxDepth - Maximum path length (default: 5)
68
- * @param options - Traversal options (includes signal for cancellation)
66
+ * @param options - Traversal options
69
67
  * @returns Array of PathResult objects for all found paths
70
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
71
68
  */
72
- findAllPaths(source: string, target: string, maxDepth?: number, options?: TraversalOptions & {
73
- signal?: AbortSignal;
74
- }): Promise<PathResult[]>;
69
+ findAllPaths(source: string, target: string, maxDepth?: number, options?: TraversalOptions): Promise<PathResult[]>;
75
70
  /**
76
71
  * Find all connected components in the graph.
77
72
  *
@@ -1 +1 @@
1
- {"version":3,"file":"GraphTraversal.d.ts","sourceRoot":"","sources":["../../src/core/GraphTraversal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAEV,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAatD;;;;;GAKG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAI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IA2BvB;;;;;;;;OAQG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAU,EACpB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,UAAU,EAAE,CAAC;IAiDxB;;;;;;OAMG;IACG,uBAAuB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IA0CnE;;;;;;;;;OASG;IACG,yBAAyB,CAC7B,SAAS,GAAE,IAAI,GAAG,KAAK,GAAG,MAAe,EACzC,IAAI,GAAE,MAAW,GAChB,OAAO,CAAC,gBAAgB,CAAC;IA+B5B;;;;;;;;;;;;;OAaG;IACG,8BAA8B,CAClC,OAAO,GAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QACxC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KAChB,GACL,OAAO,CAAC,gBAAgB,CAAC;IAiH5B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;;;;;;;;OAWG;IACG,iBAAiB,CACrB,aAAa,GAAE,MAAa,EAC5B,aAAa,GAAE,MAAY,EAC3B,SAAS,GAAE,MAAa,EACxB,IAAI,GAAE,MAAW,GAChB,OAAO,CAAC,gBAAgB,CAAC;IA0E5B;;OAEG;IACH,OAAO,CAAC,cAAc;CASvB"}
@@ -6,7 +6,6 @@
6
6
  *
7
7
  * @module core/GraphTraversal
8
8
  */
9
- import { checkCancellation } from '../utils/index.js';
10
9
  /**
11
10
  * Phase 4 Sprint 6: Default traversal options.
12
11
  */
@@ -226,41 +225,25 @@ export class GraphTraversal {
226
225
  /**
227
226
  * Find all paths between two entities up to a maximum depth.
228
227
  *
229
- * Phase 9B: Supports cancellation via AbortSignal in options.
230
- *
231
228
  * @param source - Source entity name
232
229
  * @param target - Target entity name
233
230
  * @param maxDepth - Maximum path length (default: 5)
234
- * @param options - Traversal options (includes signal for cancellation)
231
+ * @param options - Traversal options
235
232
  * @returns Array of PathResult objects for all found paths
236
- * @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
237
233
  */
238
234
  async findAllPaths(source, target, maxDepth = 5, options = {}) {
239
- // Check for early cancellation
240
- const { signal, ...traversalOptions } = options;
241
- checkCancellation(signal, 'findAllPaths');
242
235
  // Ensure graph is loaded to populate indexes
243
236
  await this.storage.loadGraph();
244
- // Check for cancellation after load
245
- checkCancellation(signal, 'findAllPaths');
246
237
  // Validate entities exist
247
238
  if (!this.storage.hasEntity(source) || !this.storage.hasEntity(target)) {
248
239
  return [];
249
240
  }
250
- const opts = { ...DEFAULT_OPTIONS, ...traversalOptions };
241
+ const opts = { ...DEFAULT_OPTIONS, ...options };
251
242
  const allPaths = [];
252
243
  const currentPath = [source];
253
244
  const currentRelations = [];
254
245
  const visited = new Set([source]);
255
- // Track iterations for periodic cancellation checks
256
- let iterationCount = 0;
257
- const CANCELLATION_CHECK_INTERVAL = 100;
258
246
  const dfsAllPaths = (current, depth) => {
259
- // Periodic cancellation check
260
- iterationCount++;
261
- if (iterationCount % CANCELLATION_CHECK_INTERVAL === 0) {
262
- checkCancellation(signal, 'findAllPaths');
263
- }
264
247
  if (depth > maxDepth)
265
248
  return;
266
249
  if (current === target && depth > 0) {
@@ -14,7 +14,6 @@ import { ObservationManager } from './ObservationManager.js';
14
14
  import { HierarchyManager } from './HierarchyManager.js';
15
15
  import { GraphTraversal } from './GraphTraversal.js';
16
16
  import { SearchManager } from '../search/SearchManager.js';
17
- import { RankedSearch } from '../search/RankedSearch.js';
18
17
  import { SemanticSearch } from '../search/index.js';
19
18
  import { IOManager } from '../features/IOManager.js';
20
19
  import { TagManager } from '../features/TagManager.js';
@@ -36,7 +35,6 @@ export declare class ManagerContext {
36
35
  private _graphTraversal?;
37
36
  private _searchManager?;
38
37
  private _semanticSearch?;
39
- private _rankedSearch?;
40
38
  private _ioManager?;
41
39
  private _tagManager?;
42
40
  private _analyticsManager?;
@@ -60,8 +58,6 @@ export declare class ManagerContext {
60
58
  * Returns null if no embedding provider is configured.
61
59
  */
62
60
  get semanticSearch(): SemanticSearch | null;
63
- /** RankedSearch - Phase 11: TF-IDF/BM25 ranked search for hybrid search */
64
- get rankedSearch(): RankedSearch;
65
61
  /** IOManager - Import, export, and backup operations */
66
62
  get ioManager(): IOManager;
67
63
  /** TagManager - Tag alias management */