@danielsimonjr/memory-mcp 12.2.3 → 12.5.2

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 (158) hide show
  1. package/README.md +88 -102
  2. package/dist/index.js +6 -0
  3. package/dist/server/toolDefinitions.d.ts.map +1 -1
  4. package/dist/server/toolDefinitions.js +745 -3
  5. package/dist/server/toolHandlers.d.ts +1 -9
  6. package/dist/server/toolHandlers.d.ts.map +1 -1
  7. package/dist/server/toolHandlers.js +859 -11
  8. package/package.json +9 -6
  9. package/dist/core/EntityManager.d.ts +0 -263
  10. package/dist/core/EntityManager.d.ts.map +0 -1
  11. package/dist/core/EntityManager.js +0 -478
  12. package/dist/core/GraphStorage.d.ts +0 -344
  13. package/dist/core/GraphStorage.d.ts.map +0 -1
  14. package/dist/core/GraphStorage.js +0 -708
  15. package/dist/core/GraphTraversal.d.ts +0 -136
  16. package/dist/core/GraphTraversal.d.ts.map +0 -1
  17. package/dist/core/GraphTraversal.js +0 -556
  18. package/dist/core/HierarchyManager.d.ts +0 -111
  19. package/dist/core/HierarchyManager.d.ts.map +0 -1
  20. package/dist/core/HierarchyManager.js +0 -224
  21. package/dist/core/ManagerContext.d.ts +0 -72
  22. package/dist/core/ManagerContext.d.ts.map +0 -1
  23. package/dist/core/ManagerContext.js +0 -118
  24. package/dist/core/ObservationManager.d.ts +0 -85
  25. package/dist/core/ObservationManager.d.ts.map +0 -1
  26. package/dist/core/ObservationManager.js +0 -123
  27. package/dist/core/RelationManager.d.ts +0 -131
  28. package/dist/core/RelationManager.d.ts.map +0 -1
  29. package/dist/core/RelationManager.js +0 -210
  30. package/dist/core/SQLiteStorage.d.ts +0 -354
  31. package/dist/core/SQLiteStorage.d.ts.map +0 -1
  32. package/dist/core/SQLiteStorage.js +0 -917
  33. package/dist/core/StorageFactory.d.ts +0 -45
  34. package/dist/core/StorageFactory.d.ts.map +0 -1
  35. package/dist/core/StorageFactory.js +0 -64
  36. package/dist/core/TransactionManager.d.ts +0 -259
  37. package/dist/core/TransactionManager.d.ts.map +0 -1
  38. package/dist/core/TransactionManager.js +0 -392
  39. package/dist/core/index.d.ts +0 -16
  40. package/dist/core/index.d.ts.map +0 -1
  41. package/dist/core/index.js +0 -17
  42. package/dist/features/AnalyticsManager.d.ts +0 -44
  43. package/dist/features/AnalyticsManager.d.ts.map +0 -1
  44. package/dist/features/AnalyticsManager.js +0 -223
  45. package/dist/features/ArchiveManager.d.ts +0 -121
  46. package/dist/features/ArchiveManager.d.ts.map +0 -1
  47. package/dist/features/ArchiveManager.js +0 -240
  48. package/dist/features/CompressionManager.d.ts +0 -109
  49. package/dist/features/CompressionManager.d.ts.map +0 -1
  50. package/dist/features/CompressionManager.js +0 -404
  51. package/dist/features/IOManager.d.ts +0 -221
  52. package/dist/features/IOManager.d.ts.map +0 -1
  53. package/dist/features/IOManager.js +0 -997
  54. package/dist/features/StreamingExporter.d.ts +0 -105
  55. package/dist/features/StreamingExporter.d.ts.map +0 -1
  56. package/dist/features/StreamingExporter.js +0 -150
  57. package/dist/features/TagManager.d.ts +0 -147
  58. package/dist/features/TagManager.d.ts.map +0 -1
  59. package/dist/features/TagManager.js +0 -210
  60. package/dist/features/index.d.ts +0 -12
  61. package/dist/features/index.d.ts.map +0 -1
  62. package/dist/features/index.js +0 -11
  63. package/dist/search/BasicSearch.d.ts +0 -51
  64. package/dist/search/BasicSearch.d.ts.map +0 -1
  65. package/dist/search/BasicSearch.js +0 -137
  66. package/dist/search/BooleanSearch.d.ts +0 -98
  67. package/dist/search/BooleanSearch.d.ts.map +0 -1
  68. package/dist/search/BooleanSearch.js +0 -430
  69. package/dist/search/EmbeddingService.d.ts +0 -178
  70. package/dist/search/EmbeddingService.d.ts.map +0 -1
  71. package/dist/search/EmbeddingService.js +0 -358
  72. package/dist/search/FuzzySearch.d.ts +0 -118
  73. package/dist/search/FuzzySearch.d.ts.map +0 -1
  74. package/dist/search/FuzzySearch.js +0 -312
  75. package/dist/search/RankedSearch.d.ts +0 -71
  76. package/dist/search/RankedSearch.d.ts.map +0 -1
  77. package/dist/search/RankedSearch.js +0 -238
  78. package/dist/search/SavedSearchManager.d.ts +0 -79
  79. package/dist/search/SavedSearchManager.d.ts.map +0 -1
  80. package/dist/search/SavedSearchManager.js +0 -145
  81. package/dist/search/SearchFilterChain.d.ts +0 -120
  82. package/dist/search/SearchFilterChain.d.ts.map +0 -1
  83. package/dist/search/SearchFilterChain.js +0 -185
  84. package/dist/search/SearchManager.d.ts +0 -285
  85. package/dist/search/SearchManager.d.ts.map +0 -1
  86. package/dist/search/SearchManager.js +0 -338
  87. package/dist/search/SearchSuggestions.d.ts +0 -27
  88. package/dist/search/SearchSuggestions.d.ts.map +0 -1
  89. package/dist/search/SearchSuggestions.js +0 -57
  90. package/dist/search/SemanticSearch.d.ts +0 -146
  91. package/dist/search/SemanticSearch.d.ts.map +0 -1
  92. package/dist/search/SemanticSearch.js +0 -313
  93. package/dist/search/TFIDFIndexManager.d.ts +0 -63
  94. package/dist/search/TFIDFIndexManager.d.ts.map +0 -1
  95. package/dist/search/TFIDFIndexManager.js +0 -215
  96. package/dist/search/VectorStore.d.ts +0 -235
  97. package/dist/search/VectorStore.d.ts.map +0 -1
  98. package/dist/search/VectorStore.js +0 -311
  99. package/dist/search/index.d.ts +0 -18
  100. package/dist/search/index.d.ts.map +0 -1
  101. package/dist/search/index.js +0 -21
  102. package/dist/types/index.d.ts +0 -13
  103. package/dist/types/index.d.ts.map +0 -1
  104. package/dist/types/index.js +0 -12
  105. package/dist/types/types.d.ts +0 -1234
  106. package/dist/types/types.d.ts.map +0 -1
  107. package/dist/types/types.js +0 -9
  108. package/dist/utils/compressedCache.d.ts +0 -192
  109. package/dist/utils/compressedCache.d.ts.map +0 -1
  110. package/dist/utils/compressedCache.js +0 -309
  111. package/dist/utils/compressionUtil.d.ts +0 -214
  112. package/dist/utils/compressionUtil.d.ts.map +0 -1
  113. package/dist/utils/compressionUtil.js +0 -247
  114. package/dist/utils/constants.d.ts +0 -245
  115. package/dist/utils/constants.d.ts.map +0 -1
  116. package/dist/utils/constants.js +0 -252
  117. package/dist/utils/entityUtils.d.ts +0 -321
  118. package/dist/utils/entityUtils.d.ts.map +0 -1
  119. package/dist/utils/entityUtils.js +0 -538
  120. package/dist/utils/errors.d.ts +0 -77
  121. package/dist/utils/errors.d.ts.map +0 -1
  122. package/dist/utils/errors.js +0 -121
  123. package/dist/utils/formatters.d.ts +0 -145
  124. package/dist/utils/formatters.d.ts.map +0 -1
  125. package/dist/utils/formatters.js +0 -132
  126. package/dist/utils/index.d.ts +0 -22
  127. package/dist/utils/index.d.ts.map +0 -1
  128. package/dist/utils/index.js +0 -75
  129. package/dist/utils/indexes.d.ts +0 -270
  130. package/dist/utils/indexes.d.ts.map +0 -1
  131. package/dist/utils/indexes.js +0 -526
  132. package/dist/utils/logger.d.ts +0 -24
  133. package/dist/utils/logger.d.ts.map +0 -1
  134. package/dist/utils/logger.js +0 -33
  135. package/dist/utils/parallelUtils.d.ts +0 -72
  136. package/dist/utils/parallelUtils.d.ts.map +0 -1
  137. package/dist/utils/parallelUtils.js +0 -169
  138. package/dist/utils/schemas.d.ts +0 -374
  139. package/dist/utils/schemas.d.ts.map +0 -1
  140. package/dist/utils/schemas.js +0 -484
  141. package/dist/utils/searchAlgorithms.d.ts +0 -99
  142. package/dist/utils/searchAlgorithms.d.ts.map +0 -1
  143. package/dist/utils/searchAlgorithms.js +0 -167
  144. package/dist/utils/searchCache.d.ts +0 -108
  145. package/dist/utils/searchCache.d.ts.map +0 -1
  146. package/dist/utils/searchCache.js +0 -209
  147. package/dist/utils/taskScheduler.d.ts +0 -290
  148. package/dist/utils/taskScheduler.d.ts.map +0 -1
  149. package/dist/utils/taskScheduler.js +0 -466
  150. package/dist/workers/WorkerPool.d.ts +0 -81
  151. package/dist/workers/WorkerPool.d.ts.map +0 -1
  152. package/dist/workers/WorkerPool.js +0 -121
  153. package/dist/workers/index.d.ts +0 -12
  154. package/dist/workers/index.d.ts.map +0 -1
  155. package/dist/workers/index.js +0 -9
  156. package/dist/workers/levenshteinWorker.d.ts +0 -60
  157. package/dist/workers/levenshteinWorker.d.ts.map +0 -1
  158. package/dist/workers/levenshteinWorker.js +0 -98
@@ -1,111 +0,0 @@
1
- /**
2
- * Hierarchy Manager
3
- *
4
- * Handles entity hierarchy operations (parent-child relationships).
5
- * Extracted from EntityManager (Phase 4: Consolidate God Objects).
6
- *
7
- * @module core/HierarchyManager
8
- */
9
- import type { Entity, KnowledgeGraph } from '../types/index.js';
10
- import type { GraphStorage } from './GraphStorage.js';
11
- /**
12
- * Manages hierarchical relationships between entities.
13
- */
14
- export declare class HierarchyManager {
15
- private storage;
16
- constructor(storage: GraphStorage);
17
- /**
18
- * Set the parent of an entity.
19
- *
20
- * Validates:
21
- * - Entity and parent exist
22
- * - Setting parent won't create a cycle
23
- *
24
- * @param entityName - Entity to set parent for
25
- * @param parentName - Parent entity name (null to remove parent)
26
- * @returns Updated entity
27
- * @throws {EntityNotFoundError} If entity or parent not found
28
- * @throws {CycleDetectedError} If setting parent would create a cycle
29
- */
30
- setEntityParent(entityName: string, parentName: string | null): Promise<Entity>;
31
- /**
32
- * Check if setting a parent would create a cycle in the hierarchy.
33
- *
34
- * @param graph - Knowledge graph
35
- * @param entityName - Entity to set parent for
36
- * @param parentName - Proposed parent
37
- * @returns True if cycle would be created
38
- */
39
- private wouldCreateCycle;
40
- /**
41
- * Get the immediate children of an entity.
42
- *
43
- * @param entityName - Parent entity name
44
- * @returns Array of child entities
45
- * @throws {EntityNotFoundError} If entity not found
46
- */
47
- getChildren(entityName: string): Promise<Entity[]>;
48
- /**
49
- * Get the parent of an entity.
50
- *
51
- * @param entityName - Entity name
52
- * @returns Parent entity or null if no parent
53
- * @throws {EntityNotFoundError} If entity not found
54
- */
55
- getParent(entityName: string): Promise<Entity | null>;
56
- /**
57
- * Get all ancestors of an entity (parent, grandparent, etc.).
58
- *
59
- * @param entityName - Entity name
60
- * @returns Array of ancestor entities (ordered from immediate parent to root)
61
- * @throws {EntityNotFoundError} If entity not found
62
- */
63
- getAncestors(entityName: string): Promise<Entity[]>;
64
- /**
65
- * Get all descendants of an entity (children, grandchildren, etc.).
66
- *
67
- * Uses breadth-first traversal.
68
- *
69
- * @param entityName - Entity name
70
- * @returns Array of descendant entities
71
- * @throws {EntityNotFoundError} If entity not found
72
- */
73
- getDescendants(entityName: string): Promise<Entity[]>;
74
- /**
75
- * Get the entire subtree rooted at an entity (entity + all descendants).
76
- *
77
- * Includes relations between entities in the subtree.
78
- *
79
- * @param entityName - Root entity name
80
- * @returns Knowledge graph containing subtree
81
- * @throws {EntityNotFoundError} If entity not found
82
- */
83
- getSubtree(entityName: string): Promise<KnowledgeGraph>;
84
- /**
85
- * Get root entities (entities with no parent).
86
- *
87
- * @returns Array of root entities
88
- */
89
- getRootEntities(): Promise<Entity[]>;
90
- /**
91
- * Get the depth of an entity in the hierarchy.
92
- *
93
- * Root entities have depth 0, their children depth 1, etc.
94
- *
95
- * @param entityName - Entity name
96
- * @returns Depth (number of ancestors)
97
- * @throws {EntityNotFoundError} If entity not found
98
- */
99
- getEntityDepth(entityName: string): Promise<number>;
100
- /**
101
- * Move an entity to a new parent (maintaining its descendants).
102
- *
103
- * Alias for setEntityParent.
104
- *
105
- * @param entityName - Entity to move
106
- * @param newParentName - New parent name (null to make root)
107
- * @returns Updated entity
108
- */
109
- moveEntity(entityName: string, newParentName: string | null): Promise<Entity>;
110
- }
111
- //# sourceMappingURL=HierarchyManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HierarchyManager.d.ts","sourceRoot":"","sources":["../../src/core/HierarchyManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAA0B,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;GAEG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCrF;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAwBxB;;;;;;OAMG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAWxD;;;;;;OAMG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgB3D;;;;;;OAMG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmBzD;;;;;;;;OAQG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwB3D;;;;;;;;OAQG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAuB7D;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAK1C;;;;;;;;OAQG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKzD;;;;;;;;OAQG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAGpF"}
@@ -1,224 +0,0 @@
1
- /**
2
- * Hierarchy Manager
3
- *
4
- * Handles entity hierarchy operations (parent-child relationships).
5
- * Extracted from EntityManager (Phase 4: Consolidate God Objects).
6
- *
7
- * @module core/HierarchyManager
8
- */
9
- import { EntityNotFoundError, CycleDetectedError } from '../utils/errors.js';
10
- /**
11
- * Manages hierarchical relationships between entities.
12
- */
13
- export class HierarchyManager {
14
- storage;
15
- constructor(storage) {
16
- this.storage = storage;
17
- }
18
- /**
19
- * Set the parent of an entity.
20
- *
21
- * Validates:
22
- * - Entity and parent exist
23
- * - Setting parent won't create a cycle
24
- *
25
- * @param entityName - Entity to set parent for
26
- * @param parentName - Parent entity name (null to remove parent)
27
- * @returns Updated entity
28
- * @throws {EntityNotFoundError} If entity or parent not found
29
- * @throws {CycleDetectedError} If setting parent would create a cycle
30
- */
31
- async setEntityParent(entityName, parentName) {
32
- // Use read-only graph for validation checks
33
- const readGraph = await this.storage.loadGraph();
34
- const entityExists = readGraph.entities.find(e => e.name === entityName);
35
- if (!entityExists) {
36
- throw new EntityNotFoundError(entityName);
37
- }
38
- // If setting a parent, validate it exists and doesn't create a cycle
39
- if (parentName !== null) {
40
- const parent = readGraph.entities.find(e => e.name === parentName);
41
- if (!parent) {
42
- throw new EntityNotFoundError(parentName);
43
- }
44
- // Check for cycles
45
- if (this.wouldCreateCycle(readGraph, entityName, parentName)) {
46
- throw new CycleDetectedError(entityName, parentName);
47
- }
48
- }
49
- // Get mutable copy for write operation
50
- const graph = await this.storage.getGraphForMutation();
51
- const entity = graph.entities.find(e => e.name === entityName);
52
- entity.parentId = parentName || undefined;
53
- entity.lastModified = new Date().toISOString();
54
- await this.storage.saveGraph(graph);
55
- return entity;
56
- }
57
- /**
58
- * Check if setting a parent would create a cycle in the hierarchy.
59
- *
60
- * @param graph - Knowledge graph
61
- * @param entityName - Entity to set parent for
62
- * @param parentName - Proposed parent
63
- * @returns True if cycle would be created
64
- */
65
- wouldCreateCycle(graph, entityName, parentName) {
66
- const visited = new Set();
67
- let current = parentName;
68
- while (current) {
69
- if (visited.has(current)) {
70
- return true; // Cycle detected in existing hierarchy
71
- }
72
- if (current === entityName) {
73
- return true; // Would create a cycle
74
- }
75
- visited.add(current);
76
- const currentEntity = graph.entities.find(e => e.name === current);
77
- current = currentEntity?.parentId;
78
- }
79
- return false;
80
- }
81
- /**
82
- * Get the immediate children of an entity.
83
- *
84
- * @param entityName - Parent entity name
85
- * @returns Array of child entities
86
- * @throws {EntityNotFoundError} If entity not found
87
- */
88
- async getChildren(entityName) {
89
- const graph = await this.storage.loadGraph();
90
- // Verify entity exists
91
- if (!graph.entities.find(e => e.name === entityName)) {
92
- throw new EntityNotFoundError(entityName);
93
- }
94
- return graph.entities.filter(e => e.parentId === entityName);
95
- }
96
- /**
97
- * Get the parent of an entity.
98
- *
99
- * @param entityName - Entity name
100
- * @returns Parent entity or null if no parent
101
- * @throws {EntityNotFoundError} If entity not found
102
- */
103
- async getParent(entityName) {
104
- const graph = await this.storage.loadGraph();
105
- const entity = graph.entities.find(e => e.name === entityName);
106
- if (!entity) {
107
- throw new EntityNotFoundError(entityName);
108
- }
109
- if (!entity.parentId) {
110
- return null;
111
- }
112
- const parent = graph.entities.find(e => e.name === entity.parentId);
113
- return parent || null;
114
- }
115
- /**
116
- * Get all ancestors of an entity (parent, grandparent, etc.).
117
- *
118
- * @param entityName - Entity name
119
- * @returns Array of ancestor entities (ordered from immediate parent to root)
120
- * @throws {EntityNotFoundError} If entity not found
121
- */
122
- async getAncestors(entityName) {
123
- const graph = await this.storage.loadGraph();
124
- const ancestors = [];
125
- let current = graph.entities.find(e => e.name === entityName);
126
- if (!current) {
127
- throw new EntityNotFoundError(entityName);
128
- }
129
- while (current.parentId) {
130
- const parent = graph.entities.find(e => e.name === current.parentId);
131
- if (!parent)
132
- break;
133
- ancestors.push(parent);
134
- current = parent;
135
- }
136
- return ancestors;
137
- }
138
- /**
139
- * Get all descendants of an entity (children, grandchildren, etc.).
140
- *
141
- * Uses breadth-first traversal.
142
- *
143
- * @param entityName - Entity name
144
- * @returns Array of descendant entities
145
- * @throws {EntityNotFoundError} If entity not found
146
- */
147
- async getDescendants(entityName) {
148
- const graph = await this.storage.loadGraph();
149
- // Verify entity exists
150
- if (!graph.entities.find(e => e.name === entityName)) {
151
- throw new EntityNotFoundError(entityName);
152
- }
153
- const descendants = [];
154
- const toProcess = [entityName];
155
- while (toProcess.length > 0) {
156
- const current = toProcess.shift();
157
- const children = graph.entities.filter(e => e.parentId === current);
158
- for (const child of children) {
159
- descendants.push(child);
160
- toProcess.push(child.name);
161
- }
162
- }
163
- return descendants;
164
- }
165
- /**
166
- * Get the entire subtree rooted at an entity (entity + all descendants).
167
- *
168
- * Includes relations between entities in the subtree.
169
- *
170
- * @param entityName - Root entity name
171
- * @returns Knowledge graph containing subtree
172
- * @throws {EntityNotFoundError} If entity not found
173
- */
174
- async getSubtree(entityName) {
175
- const graph = await this.storage.loadGraph();
176
- const entity = graph.entities.find(e => e.name === entityName);
177
- if (!entity) {
178
- throw new EntityNotFoundError(entityName);
179
- }
180
- const descendants = await this.getDescendants(entityName);
181
- const subtreeEntities = [entity, ...descendants];
182
- const subtreeEntityNames = new Set(subtreeEntities.map(e => e.name));
183
- // Include relations between entities in the subtree
184
- const subtreeRelations = graph.relations.filter(r => subtreeEntityNames.has(r.from) && subtreeEntityNames.has(r.to));
185
- return {
186
- entities: subtreeEntities,
187
- relations: subtreeRelations,
188
- };
189
- }
190
- /**
191
- * Get root entities (entities with no parent).
192
- *
193
- * @returns Array of root entities
194
- */
195
- async getRootEntities() {
196
- const graph = await this.storage.loadGraph();
197
- return graph.entities.filter(e => !e.parentId);
198
- }
199
- /**
200
- * Get the depth of an entity in the hierarchy.
201
- *
202
- * Root entities have depth 0, their children depth 1, etc.
203
- *
204
- * @param entityName - Entity name
205
- * @returns Depth (number of ancestors)
206
- * @throws {EntityNotFoundError} If entity not found
207
- */
208
- async getEntityDepth(entityName) {
209
- const ancestors = await this.getAncestors(entityName);
210
- return ancestors.length;
211
- }
212
- /**
213
- * Move an entity to a new parent (maintaining its descendants).
214
- *
215
- * Alias for setEntityParent.
216
- *
217
- * @param entityName - Entity to move
218
- * @param newParentName - New parent name (null to make root)
219
- * @returns Updated entity
220
- */
221
- async moveEntity(entityName, newParentName) {
222
- return await this.setEntityParent(entityName, newParentName);
223
- }
224
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Manager Context
3
- *
4
- * Central context holding all manager instances with lazy initialization.
5
- * Provides direct manager access for toolHandlers.
6
- * Phase 4: Removed convenience methods - use managers directly.
7
- *
8
- * @module core/ManagerContext
9
- */
10
- import { GraphStorage } from './GraphStorage.js';
11
- import { EntityManager } from './EntityManager.js';
12
- import { RelationManager } from './RelationManager.js';
13
- import { ObservationManager } from './ObservationManager.js';
14
- import { HierarchyManager } from './HierarchyManager.js';
15
- import { GraphTraversal } from './GraphTraversal.js';
16
- import { SearchManager } from '../search/SearchManager.js';
17
- import { SemanticSearch } from '../search/index.js';
18
- import { IOManager } from '../features/IOManager.js';
19
- import { TagManager } from '../features/TagManager.js';
20
- import { AnalyticsManager } from '../features/AnalyticsManager.js';
21
- import { CompressionManager } from '../features/CompressionManager.js';
22
- import { ArchiveManager } from '../features/ArchiveManager.js';
23
- /**
24
- * Context holding all manager instances with lazy initialization.
25
- * Provides direct manager access for toolHandlers.
26
- */
27
- export declare class ManagerContext {
28
- readonly storage: GraphStorage;
29
- private readonly savedSearchesFilePath;
30
- private readonly tagAliasesFilePath;
31
- private _entityManager?;
32
- private _relationManager?;
33
- private _observationManager?;
34
- private _hierarchyManager?;
35
- private _graphTraversal?;
36
- private _searchManager?;
37
- private _semanticSearch?;
38
- private _ioManager?;
39
- private _tagManager?;
40
- private _analyticsManager?;
41
- private _compressionManager?;
42
- private _archiveManager?;
43
- constructor(memoryFilePath: string);
44
- /** EntityManager - Entity CRUD and tag operations */
45
- get entityManager(): EntityManager;
46
- /** RelationManager - Relation CRUD */
47
- get relationManager(): RelationManager;
48
- /** ObservationManager - Observation CRUD */
49
- get observationManager(): ObservationManager;
50
- /** HierarchyManager - Entity hierarchy operations */
51
- get hierarchyManager(): HierarchyManager;
52
- /** GraphTraversal - Phase 4 Sprint 6-8: Graph traversal algorithms */
53
- get graphTraversal(): GraphTraversal;
54
- /** SearchManager - All search operations */
55
- get searchManager(): SearchManager;
56
- /**
57
- * SemanticSearch - Phase 4 Sprint 12: Semantic similarity search.
58
- * Returns null if no embedding provider is configured.
59
- */
60
- get semanticSearch(): SemanticSearch | null;
61
- /** IOManager - Import, export, and backup operations */
62
- get ioManager(): IOManager;
63
- /** TagManager - Tag alias management */
64
- get tagManager(): TagManager;
65
- /** AnalyticsManager - Graph statistics and validation */
66
- get analyticsManager(): AnalyticsManager;
67
- /** CompressionManager - Duplicate detection and entity merging */
68
- get compressionManager(): CompressionManager;
69
- /** ArchiveManager - Entity archival operations */
70
- get archiveManager(): ArchiveManager;
71
- }
72
- //# sourceMappingURL=ManagerContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ManagerContext.d.ts","sourceRoot":"","sources":["../../src/core/ManagerContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAA6C,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D;;;GAGG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAG5C,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,mBAAmB,CAAC,CAAqB;IACjD,OAAO,CAAC,iBAAiB,CAAC,CAAmB;IAC7C,OAAO,CAAC,eAAe,CAAC,CAAiB;IACzC,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,eAAe,CAAC,CAAwB;IAChD,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,iBAAiB,CAAC,CAAmB;IAC7C,OAAO,CAAC,mBAAmB,CAAC,CAAqB;IACjD,OAAO,CAAC,eAAe,CAAC,CAAiB;gBAE7B,cAAc,EAAE,MAAM;IAYlC,qDAAqD;IACrD,IAAI,aAAa,IAAI,aAAa,CAEjC;IAED,sCAAsC;IACtC,IAAI,eAAe,IAAI,eAAe,CAErC;IAED,4CAA4C;IAC5C,IAAI,kBAAkB,IAAI,kBAAkB,CAE3C;IAED,qDAAqD;IACrD,IAAI,gBAAgB,IAAI,gBAAgB,CAEvC;IAED,sEAAsE;IACtE,IAAI,cAAc,IAAI,cAAc,CAEnC;IAED,4CAA4C;IAC5C,IAAI,aAAa,IAAI,aAAa,CAEjC;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,cAAc,GAAG,IAAI,CAa1C;IAED,wDAAwD;IACxD,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,wCAAwC;IACxC,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED,yDAAyD;IACzD,IAAI,gBAAgB,IAAI,gBAAgB,CAEvC;IAED,kEAAkE;IAClE,IAAI,kBAAkB,IAAI,kBAAkB,CAE3C;IAED,kDAAkD;IAClD,IAAI,cAAc,IAAI,cAAc,CAEnC;CACF"}
@@ -1,118 +0,0 @@
1
- /**
2
- * Manager Context
3
- *
4
- * Central context holding all manager instances with lazy initialization.
5
- * Provides direct manager access for toolHandlers.
6
- * Phase 4: Removed convenience methods - use managers directly.
7
- *
8
- * @module core/ManagerContext
9
- */
10
- import path from 'path';
11
- import { GraphStorage } from './GraphStorage.js';
12
- import { EntityManager } from './EntityManager.js';
13
- import { RelationManager } from './RelationManager.js';
14
- import { ObservationManager } from './ObservationManager.js';
15
- import { HierarchyManager } from './HierarchyManager.js';
16
- import { GraphTraversal } from './GraphTraversal.js';
17
- import { SearchManager } from '../search/SearchManager.js';
18
- import { SemanticSearch, createEmbeddingService, createVectorStore } from '../search/index.js';
19
- import { IOManager } from '../features/IOManager.js';
20
- import { TagManager } from '../features/TagManager.js';
21
- import { AnalyticsManager } from '../features/AnalyticsManager.js';
22
- import { CompressionManager } from '../features/CompressionManager.js';
23
- import { ArchiveManager } from '../features/ArchiveManager.js';
24
- import { getEmbeddingConfig } from '../utils/constants.js';
25
- /**
26
- * Context holding all manager instances with lazy initialization.
27
- * Provides direct manager access for toolHandlers.
28
- */
29
- export class ManagerContext {
30
- storage;
31
- savedSearchesFilePath;
32
- tagAliasesFilePath;
33
- // Lazy-initialized managers
34
- _entityManager;
35
- _relationManager;
36
- _observationManager;
37
- _hierarchyManager;
38
- _graphTraversal;
39
- _searchManager;
40
- _semanticSearch;
41
- _ioManager;
42
- _tagManager;
43
- _analyticsManager;
44
- _compressionManager;
45
- _archiveManager;
46
- constructor(memoryFilePath) {
47
- // Derive paths for saved searches and tag aliases
48
- const dir = path.dirname(memoryFilePath);
49
- const basename = path.basename(memoryFilePath, path.extname(memoryFilePath));
50
- this.savedSearchesFilePath = path.join(dir, `${basename}-saved-searches.jsonl`);
51
- this.tagAliasesFilePath = path.join(dir, `${basename}-tag-aliases.jsonl`);
52
- this.storage = new GraphStorage(memoryFilePath);
53
- }
54
- // ==================== MANAGER ACCESSORS ====================
55
- // Use these for direct manager access in toolHandlers
56
- /** EntityManager - Entity CRUD and tag operations */
57
- get entityManager() {
58
- return (this._entityManager ??= new EntityManager(this.storage));
59
- }
60
- /** RelationManager - Relation CRUD */
61
- get relationManager() {
62
- return (this._relationManager ??= new RelationManager(this.storage));
63
- }
64
- /** ObservationManager - Observation CRUD */
65
- get observationManager() {
66
- return (this._observationManager ??= new ObservationManager(this.storage));
67
- }
68
- /** HierarchyManager - Entity hierarchy operations */
69
- get hierarchyManager() {
70
- return (this._hierarchyManager ??= new HierarchyManager(this.storage));
71
- }
72
- /** GraphTraversal - Phase 4 Sprint 6-8: Graph traversal algorithms */
73
- get graphTraversal() {
74
- return (this._graphTraversal ??= new GraphTraversal(this.storage));
75
- }
76
- /** SearchManager - All search operations */
77
- get searchManager() {
78
- return (this._searchManager ??= new SearchManager(this.storage, this.savedSearchesFilePath));
79
- }
80
- /**
81
- * SemanticSearch - Phase 4 Sprint 12: Semantic similarity search.
82
- * Returns null if no embedding provider is configured.
83
- */
84
- get semanticSearch() {
85
- if (this._semanticSearch === undefined) {
86
- const config = getEmbeddingConfig();
87
- const embeddingService = createEmbeddingService(config);
88
- if (embeddingService) {
89
- const vectorStore = createVectorStore('jsonl'); // Use in-memory for now
90
- this._semanticSearch = new SemanticSearch(embeddingService, vectorStore);
91
- }
92
- else {
93
- this._semanticSearch = null;
94
- }
95
- }
96
- return this._semanticSearch;
97
- }
98
- /** IOManager - Import, export, and backup operations */
99
- get ioManager() {
100
- return (this._ioManager ??= new IOManager(this.storage));
101
- }
102
- /** TagManager - Tag alias management */
103
- get tagManager() {
104
- return (this._tagManager ??= new TagManager(this.tagAliasesFilePath));
105
- }
106
- /** AnalyticsManager - Graph statistics and validation */
107
- get analyticsManager() {
108
- return (this._analyticsManager ??= new AnalyticsManager(this.storage));
109
- }
110
- /** CompressionManager - Duplicate detection and entity merging */
111
- get compressionManager() {
112
- return (this._compressionManager ??= new CompressionManager(this.storage));
113
- }
114
- /** ArchiveManager - Entity archival operations */
115
- get archiveManager() {
116
- return (this._archiveManager ??= new ArchiveManager(this.storage));
117
- }
118
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * Observation Manager
3
- *
4
- * Handles observation CRUD operations for entities.
5
- * Extracted from EntityManager (Phase 4: Consolidate God Objects).
6
- *
7
- * @module core/ObservationManager
8
- */
9
- import type { GraphStorage } from './GraphStorage.js';
10
- /**
11
- * Manages observation operations for entities in the knowledge graph.
12
- */
13
- export declare class ObservationManager {
14
- private storage;
15
- constructor(storage: GraphStorage);
16
- /**
17
- * Add observations to multiple entities in a single batch operation.
18
- *
19
- * This method performs the following operations:
20
- * - Adds new observations to specified entities
21
- * - Filters out duplicate observations (already present)
22
- * - Updates lastModified timestamp only if new observations were added
23
- * - ATOMIC: All updates are saved in a single operation
24
- *
25
- * @param observations - Array of entity names and observations to add
26
- * @returns Promise resolving to array of results showing which observations were added
27
- * @throws {EntityNotFoundError} If any entity is not found
28
- *
29
- * @example
30
- * ```typescript
31
- * const manager = new ObservationManager(storage);
32
- *
33
- * // Add observations to multiple entities
34
- * const results = await manager.addObservations([
35
- * { entityName: 'Alice', contents: ['Completed project X', 'Started project Y'] },
36
- * { entityName: 'Bob', contents: ['Joined team meeting'] }
37
- * ]);
38
- *
39
- * // Check what was added (duplicates are filtered out)
40
- * results.forEach(r => {
41
- * console.log(`${r.entityName}: added ${r.addedObservations.length} new observations`);
42
- * });
43
- * ```
44
- */
45
- addObservations(observations: {
46
- entityName: string;
47
- contents: string[];
48
- }[]): Promise<{
49
- entityName: string;
50
- addedObservations: string[];
51
- }[]>;
52
- /**
53
- * Delete observations from multiple entities in a single batch operation.
54
- *
55
- * This method performs the following operations:
56
- * - Removes specified observations from entities
57
- * - Updates lastModified timestamp only if observations were deleted
58
- * - Silently ignores entities that don't exist (no error thrown)
59
- * - ATOMIC: All deletions are saved in a single operation
60
- *
61
- * @param deletions - Array of entity names and observations to delete
62
- * @returns Promise that resolves when deletion is complete
63
- *
64
- * @example
65
- * ```typescript
66
- * const manager = new ObservationManager(storage);
67
- *
68
- * // Delete observations from multiple entities
69
- * await manager.deleteObservations([
70
- * { entityName: 'Alice', observations: ['Old observation 1', 'Old observation 2'] },
71
- * { entityName: 'Bob', observations: ['Outdated info'] }
72
- * ]);
73
- *
74
- * // Safe to delete from non-existent entities (no error)
75
- * await manager.deleteObservations([
76
- * { entityName: 'NonExistent', observations: ['Some text'] }
77
- * ]); // No error thrown
78
- * ```
79
- */
80
- deleteObservations(deletions: {
81
- entityName: string;
82
- observations: string[];
83
- }[]): Promise<void>;
84
- }
85
- //# sourceMappingURL=ObservationManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ObservationManager.d.ts","sourceRoot":"","sources":["../../src/core/ObservationManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;GAEG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,eAAe,CACnB,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,GACzD,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAiCjE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,kBAAkB,CACtB,SAAS,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,GAC1D,OAAO,CAAC,IAAI,CAAC;CAyBjB"}