@danielsimonjr/memory-mcp 0.48.0 → 9.8.0

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 (209) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +2000 -194
  3. package/dist/__tests__/file-path.test.js +7 -11
  4. package/dist/__tests__/knowledge-graph.test.js +3 -8
  5. package/dist/core/EntityManager.d.ts +266 -0
  6. package/dist/core/EntityManager.d.ts.map +1 -0
  7. package/dist/core/EntityManager.js +85 -133
  8. package/dist/core/GraphEventEmitter.d.ts +202 -0
  9. package/dist/core/GraphEventEmitter.d.ts.map +1 -0
  10. package/dist/core/GraphEventEmitter.js +346 -0
  11. package/dist/core/GraphStorage.d.ts +395 -0
  12. package/dist/core/GraphStorage.d.ts.map +1 -0
  13. package/dist/core/GraphStorage.js +643 -31
  14. package/dist/core/GraphTraversal.d.ts +141 -0
  15. package/dist/core/GraphTraversal.d.ts.map +1 -0
  16. package/dist/core/GraphTraversal.js +573 -0
  17. package/dist/core/HierarchyManager.d.ts +111 -0
  18. package/dist/core/HierarchyManager.d.ts.map +1 -0
  19. package/dist/{features → core}/HierarchyManager.js +14 -9
  20. package/dist/core/ManagerContext.d.ts +72 -0
  21. package/dist/core/ManagerContext.d.ts.map +1 -0
  22. package/dist/core/ManagerContext.js +118 -0
  23. package/dist/core/ObservationManager.d.ts +85 -0
  24. package/dist/core/ObservationManager.d.ts.map +1 -0
  25. package/dist/core/ObservationManager.js +51 -57
  26. package/dist/core/RelationManager.d.ts +131 -0
  27. package/dist/core/RelationManager.d.ts.map +1 -0
  28. package/dist/core/RelationManager.js +31 -7
  29. package/dist/core/SQLiteStorage.d.ts +354 -0
  30. package/dist/core/SQLiteStorage.d.ts.map +1 -0
  31. package/dist/core/SQLiteStorage.js +917 -0
  32. package/dist/core/StorageFactory.d.ts +45 -0
  33. package/dist/core/StorageFactory.d.ts.map +1 -0
  34. package/dist/core/StorageFactory.js +64 -0
  35. package/dist/core/TransactionManager.d.ts +464 -0
  36. package/dist/core/TransactionManager.d.ts.map +1 -0
  37. package/dist/core/TransactionManager.js +490 -13
  38. package/dist/core/index.d.ts +17 -0
  39. package/dist/core/index.d.ts.map +1 -0
  40. package/dist/core/index.js +12 -2
  41. package/dist/features/AnalyticsManager.d.ts +44 -0
  42. package/dist/features/AnalyticsManager.d.ts.map +1 -0
  43. package/dist/features/AnalyticsManager.js +3 -2
  44. package/dist/features/ArchiveManager.d.ts +133 -0
  45. package/dist/features/ArchiveManager.d.ts.map +1 -0
  46. package/dist/features/ArchiveManager.js +221 -14
  47. package/dist/features/CompressionManager.d.ts +117 -0
  48. package/dist/features/CompressionManager.d.ts.map +1 -0
  49. package/dist/features/CompressionManager.js +189 -20
  50. package/dist/features/IOManager.d.ts +225 -0
  51. package/dist/features/IOManager.d.ts.map +1 -0
  52. package/dist/features/IOManager.js +1041 -0
  53. package/dist/features/StreamingExporter.d.ts +123 -0
  54. package/dist/features/StreamingExporter.d.ts.map +1 -0
  55. package/dist/features/StreamingExporter.js +203 -0
  56. package/dist/features/TagManager.d.ts +147 -0
  57. package/dist/features/TagManager.d.ts.map +1 -0
  58. package/dist/features/index.d.ts +12 -0
  59. package/dist/features/index.d.ts.map +1 -0
  60. package/dist/features/index.js +5 -6
  61. package/dist/index.d.ts +9 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +10 -10
  64. package/dist/memory.jsonl +1 -26
  65. package/dist/search/BasicSearch.d.ts +51 -0
  66. package/dist/search/BasicSearch.d.ts.map +1 -0
  67. package/dist/search/BasicSearch.js +9 -3
  68. package/dist/search/BooleanSearch.d.ts +98 -0
  69. package/dist/search/BooleanSearch.d.ts.map +1 -0
  70. package/dist/search/BooleanSearch.js +156 -9
  71. package/dist/search/EmbeddingService.d.ts +178 -0
  72. package/dist/search/EmbeddingService.d.ts.map +1 -0
  73. package/dist/search/EmbeddingService.js +358 -0
  74. package/dist/search/FuzzySearch.d.ts +118 -0
  75. package/dist/search/FuzzySearch.d.ts.map +1 -0
  76. package/dist/search/FuzzySearch.js +241 -25
  77. package/dist/search/QueryCostEstimator.d.ts +111 -0
  78. package/dist/search/QueryCostEstimator.d.ts.map +1 -0
  79. package/dist/search/QueryCostEstimator.js +355 -0
  80. package/dist/search/RankedSearch.d.ts +71 -0
  81. package/dist/search/RankedSearch.d.ts.map +1 -0
  82. package/dist/search/RankedSearch.js +54 -6
  83. package/dist/search/SavedSearchManager.d.ts +79 -0
  84. package/dist/search/SavedSearchManager.d.ts.map +1 -0
  85. package/dist/search/SearchFilterChain.d.ts +120 -0
  86. package/dist/search/SearchFilterChain.d.ts.map +1 -0
  87. package/dist/search/SearchFilterChain.js +2 -4
  88. package/dist/search/SearchManager.d.ts +326 -0
  89. package/dist/search/SearchManager.d.ts.map +1 -0
  90. package/dist/search/SearchManager.js +148 -0
  91. package/dist/search/SearchSuggestions.d.ts +27 -0
  92. package/dist/search/SearchSuggestions.d.ts.map +1 -0
  93. package/dist/search/SearchSuggestions.js +1 -1
  94. package/dist/search/SemanticSearch.d.ts +149 -0
  95. package/dist/search/SemanticSearch.d.ts.map +1 -0
  96. package/dist/search/SemanticSearch.js +323 -0
  97. package/dist/search/TFIDFEventSync.d.ts +85 -0
  98. package/dist/search/TFIDFEventSync.d.ts.map +1 -0
  99. package/dist/search/TFIDFEventSync.js +133 -0
  100. package/dist/search/TFIDFIndexManager.d.ts +151 -0
  101. package/dist/search/TFIDFIndexManager.d.ts.map +1 -0
  102. package/dist/search/TFIDFIndexManager.js +232 -17
  103. package/dist/search/VectorStore.d.ts +235 -0
  104. package/dist/search/VectorStore.d.ts.map +1 -0
  105. package/dist/search/VectorStore.js +311 -0
  106. package/dist/search/index.d.ts +21 -0
  107. package/dist/search/index.d.ts.map +1 -0
  108. package/dist/search/index.js +12 -0
  109. package/dist/server/MCPServer.d.ts +21 -0
  110. package/dist/server/MCPServer.d.ts.map +1 -0
  111. package/dist/server/MCPServer.js +4 -4
  112. package/dist/server/responseCompressor.d.ts +94 -0
  113. package/dist/server/responseCompressor.d.ts.map +1 -0
  114. package/dist/server/responseCompressor.js +127 -0
  115. package/dist/server/toolDefinitions.d.ts +27 -0
  116. package/dist/server/toolDefinitions.d.ts.map +1 -0
  117. package/dist/server/toolDefinitions.js +188 -17
  118. package/dist/server/toolHandlers.d.ts +41 -0
  119. package/dist/server/toolHandlers.d.ts.map +1 -0
  120. package/dist/server/toolHandlers.js +467 -75
  121. package/dist/types/index.d.ts +13 -0
  122. package/dist/types/index.d.ts.map +1 -0
  123. package/dist/types/index.js +1 -1
  124. package/dist/types/types.d.ts +1654 -0
  125. package/dist/types/types.d.ts.map +1 -0
  126. package/dist/types/types.js +9 -0
  127. package/dist/utils/compressedCache.d.ts +192 -0
  128. package/dist/utils/compressedCache.d.ts.map +1 -0
  129. package/dist/utils/compressedCache.js +309 -0
  130. package/dist/utils/compressionUtil.d.ts +214 -0
  131. package/dist/utils/compressionUtil.d.ts.map +1 -0
  132. package/dist/utils/compressionUtil.js +247 -0
  133. package/dist/utils/constants.d.ts +245 -0
  134. package/dist/utils/constants.d.ts.map +1 -0
  135. package/dist/utils/constants.js +124 -0
  136. package/dist/utils/entityUtils.d.ts +321 -0
  137. package/dist/utils/entityUtils.d.ts.map +1 -0
  138. package/dist/utils/entityUtils.js +434 -4
  139. package/dist/utils/errors.d.ts +95 -0
  140. package/dist/utils/errors.d.ts.map +1 -0
  141. package/dist/utils/errors.js +24 -0
  142. package/dist/utils/formatters.d.ts +145 -0
  143. package/dist/utils/formatters.d.ts.map +1 -0
  144. package/dist/utils/{paginationUtils.js → formatters.js} +54 -3
  145. package/dist/utils/index.d.ts +23 -0
  146. package/dist/utils/index.d.ts.map +1 -0
  147. package/dist/utils/index.js +69 -31
  148. package/dist/utils/indexes.d.ts +270 -0
  149. package/dist/utils/indexes.d.ts.map +1 -0
  150. package/dist/utils/indexes.js +526 -0
  151. package/dist/utils/logger.d.ts +24 -0
  152. package/dist/utils/logger.d.ts.map +1 -0
  153. package/dist/utils/operationUtils.d.ts +124 -0
  154. package/dist/utils/operationUtils.d.ts.map +1 -0
  155. package/dist/utils/operationUtils.js +175 -0
  156. package/dist/utils/parallelUtils.d.ts +72 -0
  157. package/dist/utils/parallelUtils.d.ts.map +1 -0
  158. package/dist/utils/parallelUtils.js +169 -0
  159. package/dist/utils/schemas.d.ts +374 -0
  160. package/dist/utils/schemas.d.ts.map +1 -0
  161. package/dist/utils/schemas.js +302 -2
  162. package/dist/utils/searchAlgorithms.d.ts +99 -0
  163. package/dist/utils/searchAlgorithms.d.ts.map +1 -0
  164. package/dist/utils/searchAlgorithms.js +167 -0
  165. package/dist/utils/searchCache.d.ts +108 -0
  166. package/dist/utils/searchCache.d.ts.map +1 -0
  167. package/dist/utils/taskScheduler.d.ts +290 -0
  168. package/dist/utils/taskScheduler.d.ts.map +1 -0
  169. package/dist/utils/taskScheduler.js +466 -0
  170. package/dist/workers/index.d.ts +12 -0
  171. package/dist/workers/index.d.ts.map +1 -0
  172. package/dist/workers/index.js +9 -0
  173. package/dist/workers/levenshteinWorker.d.ts +60 -0
  174. package/dist/workers/levenshteinWorker.d.ts.map +1 -0
  175. package/dist/workers/levenshteinWorker.js +98 -0
  176. package/package.json +17 -4
  177. package/dist/__tests__/edge-cases/edge-cases.test.js +0 -406
  178. package/dist/__tests__/integration/workflows.test.js +0 -449
  179. package/dist/__tests__/performance/benchmarks.test.js +0 -413
  180. package/dist/__tests__/unit/core/EntityManager.test.js +0 -334
  181. package/dist/__tests__/unit/core/GraphStorage.test.js +0 -205
  182. package/dist/__tests__/unit/core/RelationManager.test.js +0 -274
  183. package/dist/__tests__/unit/features/CompressionManager.test.js +0 -350
  184. package/dist/__tests__/unit/search/BasicSearch.test.js +0 -311
  185. package/dist/__tests__/unit/search/BooleanSearch.test.js +0 -432
  186. package/dist/__tests__/unit/search/FuzzySearch.test.js +0 -448
  187. package/dist/__tests__/unit/search/RankedSearch.test.js +0 -379
  188. package/dist/__tests__/unit/utils/levenshtein.test.js +0 -77
  189. package/dist/core/KnowledgeGraphManager.js +0 -423
  190. package/dist/features/BackupManager.js +0 -311
  191. package/dist/features/ExportManager.js +0 -305
  192. package/dist/features/ImportExportManager.js +0 -50
  193. package/dist/features/ImportManager.js +0 -328
  194. package/dist/memory-saved-searches.jsonl +0 -0
  195. package/dist/memory-tag-aliases.jsonl +0 -0
  196. package/dist/types/analytics.types.js +0 -6
  197. package/dist/types/entity.types.js +0 -7
  198. package/dist/types/import-export.types.js +0 -7
  199. package/dist/types/search.types.js +0 -7
  200. package/dist/types/tag.types.js +0 -6
  201. package/dist/utils/dateUtils.js +0 -89
  202. package/dist/utils/filterUtils.js +0 -155
  203. package/dist/utils/levenshtein.js +0 -62
  204. package/dist/utils/pathUtils.js +0 -115
  205. package/dist/utils/responseFormatter.js +0 -55
  206. package/dist/utils/tagUtils.js +0 -107
  207. package/dist/utils/tfidf.js +0 -90
  208. package/dist/utils/validationHelper.js +0 -99
  209. package/dist/utils/validationUtils.js +0 -109
@@ -38,14 +38,10 @@ describe('ensureMemoryFilePath', () => {
38
38
  });
39
39
  describe('with MEMORY_FILE_PATH environment variable', () => {
40
40
  it('should return absolute path when MEMORY_FILE_PATH is absolute', async () => {
41
- // Use platform-appropriate absolute path
42
- const absolutePath = process.platform === 'win32'
43
- ? 'C:\\tmp\\custom-memory.jsonl'
44
- : '/tmp/custom-memory.jsonl';
41
+ const absolutePath = '/tmp/custom-memory.jsonl';
45
42
  process.env.MEMORY_FILE_PATH = absolutePath;
46
43
  const result = await ensureMemoryFilePath();
47
- // Path may be normalized (backslashes on Windows)
48
- expect(path.normalize(result)).toBe(path.normalize(absolutePath));
44
+ expect(result).toBe(absolutePath);
49
45
  });
50
46
  it('should convert relative path to absolute when MEMORY_FILE_PATH is relative', async () => {
51
47
  const relativePath = 'custom-memory.jsonl';
@@ -75,7 +71,7 @@ describe('ensureMemoryFilePath', () => {
75
71
  it('should migrate from memory.json to memory.jsonl when only old file exists', async () => {
76
72
  // Create old memory.json file
77
73
  await fs.writeFile(oldMemoryPath, '{"test":"data"}');
78
- const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
74
+ const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
79
75
  const result = await ensureMemoryFilePath();
80
76
  expect(result).toBe(defaultMemoryPath);
81
77
  // Verify migration happened
@@ -83,10 +79,10 @@ describe('ensureMemoryFilePath', () => {
83
79
  const oldFileExists = await fs.access(oldMemoryPath).then(() => true).catch(() => false);
84
80
  expect(newFileExists).toBe(true);
85
81
  expect(oldFileExists).toBe(false);
86
- // Verify console messages (now using console.log instead of console.error)
87
- expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('[INFO] Found legacy memory.json file'));
88
- expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('[INFO] Successfully migrated'));
89
- consoleLogSpy.mockRestore();
82
+ // Verify console messages
83
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining('DETECTED: Found legacy memory.json file'));
84
+ expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining('COMPLETED: Successfully migrated'));
85
+ consoleErrorSpy.mockRestore();
90
86
  });
91
87
  it('should use new file when both old and new files exist', async () => {
92
88
  // Create both files
@@ -28,9 +28,7 @@ describe('KnowledgeGraphManager', () => {
28
28
  ];
29
29
  const newEntities = await manager.createEntities(entities);
30
30
  expect(newEntities).toHaveLength(2);
31
- // Entities now have timestamps, so check core fields
32
- expect(newEntities[0].name).toBe(entities[0].name);
33
- expect(newEntities[1].name).toBe(entities[1].name);
31
+ expect(newEntities).toEqual(entities);
34
32
  const graph = await manager.readGraph();
35
33
  expect(graph.entities).toHaveLength(2);
36
34
  });
@@ -60,10 +58,7 @@ describe('KnowledgeGraphManager', () => {
60
58
  ];
61
59
  const newRelations = await manager.createRelations(relations);
62
60
  expect(newRelations).toHaveLength(1);
63
- // Relations now have timestamps, so check core fields
64
- expect(newRelations[0].from).toBe(relations[0].from);
65
- expect(newRelations[0].to).toBe(relations[0].to);
66
- expect(newRelations[0].relationType).toBe(relations[0].relationType);
61
+ expect(newRelations).toEqual(relations);
67
62
  const graph = await manager.readGraph();
68
63
  expect(graph.relations).toHaveLength(1);
69
64
  });
@@ -120,7 +115,7 @@ describe('KnowledgeGraphManager', () => {
120
115
  it('should throw error for non-existent entity', async () => {
121
116
  await expect(manager.addObservations([
122
117
  { entityName: 'NonExistent', contents: ['some observation'] },
123
- ])).rejects.toThrow('Entity "NonExistent" not found');
118
+ ])).rejects.toThrow('Entity with name NonExistent not found');
124
119
  });
125
120
  });
126
121
  describe('deleteEntities', () => {
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Entity Manager
3
+ *
4
+ * Handles CRUD operations for entities in the knowledge graph.
5
+ * Focused on core entity and tag operations only (Phase 4: Consolidate God Objects).
6
+ *
7
+ * @module core/EntityManager
8
+ */
9
+ import type { Entity, LongRunningOperationOptions } from '../types/index.js';
10
+ import type { GraphStorage } from './GraphStorage.js';
11
+ /**
12
+ * Manages entity operations with automatic timestamp handling.
13
+ */
14
+ export declare class EntityManager {
15
+ private storage;
16
+ constructor(storage: GraphStorage);
17
+ /**
18
+ * Create multiple entities in a single batch operation.
19
+ *
20
+ * This method performs the following operations:
21
+ * - Filters out entities that already exist (duplicate names)
22
+ * - Automatically adds createdAt and lastModified timestamps
23
+ * - Normalizes all tags to lowercase for consistent searching
24
+ * - Validates importance values (must be between 0-10)
25
+ *
26
+ * Phase 9B: Supports progress tracking and cancellation via LongRunningOperationOptions.
27
+ *
28
+ * @param entities - Array of entities to create. Each entity must have a unique name.
29
+ * @param options - Optional progress/cancellation options (Phase 9B)
30
+ * @returns Promise resolving to array of newly created entities (excludes duplicates)
31
+ * @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
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const manager = new EntityManager(storage);
37
+ *
38
+ * // Create single entity
39
+ * const results = await manager.createEntities([{
40
+ * name: 'Alice',
41
+ * entityType: 'person',
42
+ * observations: ['Works as engineer', 'Lives in Seattle'],
43
+ * importance: 7,
44
+ * tags: ['Team', 'Engineering']
45
+ * }]);
46
+ *
47
+ * // Create multiple entities at once
48
+ * const users = await manager.createEntities([
49
+ * { name: 'Bob', entityType: 'person', observations: [] },
50
+ * { name: 'Charlie', entityType: 'person', observations: [] }
51
+ * ]);
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
+ * ```
60
+ */
61
+ createEntities(entities: Entity[], options?: LongRunningOperationOptions): Promise<Entity[]>;
62
+ /**
63
+ * Delete multiple entities by name in a single batch operation.
64
+ *
65
+ * This method performs cascading deletion:
66
+ * - Removes all specified entities from the graph
67
+ * - Automatically removes all relations where these entities are source or target
68
+ * - Silently ignores entity names that don't exist (no error thrown)
69
+ *
70
+ * @param entityNames - Array of entity names to delete
71
+ * @returns Promise that resolves when deletion is complete
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const manager = new EntityManager(storage);
76
+ *
77
+ * // Delete single entity
78
+ * await manager.deleteEntities(['Alice']);
79
+ *
80
+ * // Delete multiple entities at once
81
+ * await manager.deleteEntities(['Bob', 'Charlie', 'Dave']);
82
+ *
83
+ * // Safe to delete non-existent entities (no error)
84
+ * await manager.deleteEntities(['NonExistent']); // No error thrown
85
+ * ```
86
+ */
87
+ deleteEntities(entityNames: string[]): Promise<void>;
88
+ /**
89
+ * Retrieve a single entity by its unique name.
90
+ *
91
+ * This is a read-only operation that does not modify the graph.
92
+ * Entity names are case-sensitive.
93
+ *
94
+ * @param name - The unique name of the entity to retrieve
95
+ * @returns Promise resolving to the Entity object if found, or null if not found
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const manager = new EntityManager(storage);
100
+ *
101
+ * // Get an existing entity
102
+ * const alice = await manager.getEntity('Alice');
103
+ * if (alice) {
104
+ * console.log(alice.observations);
105
+ * console.log(alice.importance);
106
+ * }
107
+ *
108
+ * // Handle non-existent entity
109
+ * const missing = await manager.getEntity('NonExistent');
110
+ * console.log(missing); // null
111
+ * ```
112
+ */
113
+ getEntity(name: string): Promise<Entity | null>;
114
+ /**
115
+ * Update one or more fields of an existing entity.
116
+ *
117
+ * This method allows partial updates - only the fields specified in the updates
118
+ * object will be changed. All other fields remain unchanged.
119
+ * The lastModified timestamp is automatically updated.
120
+ *
121
+ * @param name - The unique name of the entity to update
122
+ * @param updates - Partial entity object containing only the fields to update
123
+ * @returns Promise resolving to the fully updated Entity object
124
+ * @throws {EntityNotFoundError} If no entity with the given name exists
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const manager = new EntityManager(storage);
129
+ *
130
+ * // Update importance only
131
+ * const updated = await manager.updateEntity('Alice', {
132
+ * importance: 9
133
+ * });
134
+ *
135
+ * // Update multiple fields
136
+ * await manager.updateEntity('Bob', {
137
+ * entityType: 'senior_engineer',
138
+ * tags: ['leadership', 'architecture'],
139
+ * observations: ['Led project X', 'Designed system Y']
140
+ * });
141
+ *
142
+ * // Add observations (requires reading existing entity first)
143
+ * const entity = await manager.getEntity('Charlie');
144
+ * if (entity) {
145
+ * await manager.updateEntity('Charlie', {
146
+ * observations: [...entity.observations, 'New observation']
147
+ * });
148
+ * }
149
+ * ```
150
+ */
151
+ updateEntity(name: string, updates: Partial<Entity>): Promise<Entity>;
152
+ /**
153
+ * Update multiple entities in a single batch operation.
154
+ *
155
+ * This method is more efficient than calling updateEntity multiple times
156
+ * as it loads and saves the graph only once. All updates are applied atomically.
157
+ * The lastModified timestamp is automatically updated for all entities.
158
+ *
159
+ * @param updates - Array of updates, each containing entity name and changes
160
+ * @returns Promise resolving to array of updated entities
161
+ * @throws {EntityNotFoundError} If any entity is not found
162
+ * @throws {ValidationError} If any update data is invalid
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const manager = new EntityManager(storage);
167
+ *
168
+ * // Update multiple entities at once
169
+ * const updated = await manager.batchUpdate([
170
+ * { name: 'Alice', updates: { importance: 9 } },
171
+ * { name: 'Bob', updates: { importance: 8, tags: ['senior'] } },
172
+ * { name: 'Charlie', updates: { entityType: 'lead_engineer' } }
173
+ * ]);
174
+ *
175
+ * console.log(`Updated ${updated.length} entities`);
176
+ *
177
+ * // Efficiently update many entities (single graph load/save)
178
+ * const massUpdate = employees.map(name => ({
179
+ * name,
180
+ * updates: { tags: ['team-2024'] }
181
+ * }));
182
+ * await manager.batchUpdate(massUpdate);
183
+ * ```
184
+ */
185
+ batchUpdate(updates: Array<{
186
+ name: string;
187
+ updates: Partial<Entity>;
188
+ }>): Promise<Entity[]>;
189
+ /**
190
+ * Add tags to an entity.
191
+ *
192
+ * Tags are normalized to lowercase and duplicates are filtered out.
193
+ *
194
+ * @param entityName - Name of the entity
195
+ * @param tags - Tags to add
196
+ * @returns Result with entity name and added tags
197
+ * @throws {EntityNotFoundError} If entity is not found
198
+ */
199
+ addTags(entityName: string, tags: string[]): Promise<{
200
+ entityName: string;
201
+ addedTags: string[];
202
+ }>;
203
+ /**
204
+ * Remove tags from an entity.
205
+ *
206
+ * @param entityName - Name of the entity
207
+ * @param tags - Tags to remove
208
+ * @returns Result with entity name and removed tags
209
+ * @throws {EntityNotFoundError} If entity is not found
210
+ */
211
+ removeTags(entityName: string, tags: string[]): Promise<{
212
+ entityName: string;
213
+ removedTags: string[];
214
+ }>;
215
+ /**
216
+ * Set importance level for an entity.
217
+ *
218
+ * @param entityName - Name of the entity
219
+ * @param importance - Importance level (0-10)
220
+ * @returns Result with entity name and importance
221
+ * @throws {EntityNotFoundError} If entity is not found
222
+ * @throws {Error} If importance is out of range
223
+ */
224
+ setImportance(entityName: string, importance: number): Promise<{
225
+ entityName: string;
226
+ importance: number;
227
+ }>;
228
+ /**
229
+ * Add tags to multiple entities in a single operation.
230
+ *
231
+ * @param entityNames - Names of entities to tag
232
+ * @param tags - Tags to add to each entity
233
+ * @returns Array of results showing which tags were added to each entity
234
+ */
235
+ addTagsToMultipleEntities(entityNames: string[], tags: string[]): Promise<{
236
+ entityName: string;
237
+ addedTags: string[];
238
+ }[]>;
239
+ /**
240
+ * Replace a tag with a new tag across all entities (rename tag).
241
+ *
242
+ * @param oldTag - Tag to replace
243
+ * @param newTag - New tag value
244
+ * @returns Result with affected entities and count
245
+ */
246
+ replaceTag(oldTag: string, newTag: string): Promise<{
247
+ affectedEntities: string[];
248
+ count: number;
249
+ }>;
250
+ /**
251
+ * Merge two tags into one target tag across all entities.
252
+ *
253
+ * Combines tag1 and tag2 into targetTag. Any entity with either tag1 or tag2
254
+ * will have both removed and targetTag added (if not already present).
255
+ *
256
+ * @param tag1 - First tag to merge
257
+ * @param tag2 - Second tag to merge
258
+ * @param targetTag - Target tag to merge into
259
+ * @returns Object with affected entity names and count
260
+ */
261
+ mergeTags(tag1: string, tag2: string, targetTag: string): Promise<{
262
+ affectedEntities: string[];
263
+ count: number;
264
+ }>;
265
+ }
266
+ //# sourceMappingURL=EntityManager.d.ts.map
@@ -0,0 +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;AAwBtD;;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,C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