@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.
- package/LICENSE +22 -22
- package/dist/core/EntityManager.d.ts +10 -15
- package/dist/core/EntityManager.d.ts.map +1 -1
- package/dist/core/EntityManager.js +21 -54
- package/dist/core/GraphStorage.d.ts +0 -51
- package/dist/core/GraphStorage.d.ts.map +1 -1
- package/dist/core/GraphStorage.js +2 -79
- package/dist/core/GraphTraversal.d.ts +2 -7
- package/dist/core/GraphTraversal.d.ts.map +1 -1
- package/dist/core/GraphTraversal.js +2 -19
- package/dist/core/ManagerContext.d.ts +0 -4
- package/dist/core/ManagerContext.d.ts.map +1 -1
- package/dist/core/ManagerContext.js +2 -12
- package/dist/core/RelationManager.d.ts.map +1 -1
- package/dist/core/RelationManager.js +4 -5
- package/dist/core/SQLiteStorage.d.ts.map +1 -1
- package/dist/core/SQLiteStorage.js +2 -3
- package/dist/core/TransactionManager.d.ts +2 -207
- package/dist/core/TransactionManager.d.ts.map +1 -1
- package/dist/core/TransactionManager.js +6 -482
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -3
- package/dist/features/ArchiveManager.d.ts +2 -14
- package/dist/features/ArchiveManager.d.ts.map +1 -1
- package/dist/features/ArchiveManager.js +3 -44
- package/dist/features/CompressionManager.d.ts +4 -14
- package/dist/features/CompressionManager.d.ts.map +1 -1
- package/dist/features/CompressionManager.js +9 -74
- package/dist/features/IOManager.d.ts +2 -6
- package/dist/features/IOManager.d.ts.map +1 -1
- package/dist/features/IOManager.js +10 -105
- package/dist/features/StreamingExporter.d.ts +4 -27
- package/dist/features/StreamingExporter.d.ts.map +1 -1
- package/dist/features/StreamingExporter.js +4 -65
- package/dist/features/index.d.ts +0 -2
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +0 -3
- package/dist/search/EmbeddingService.d.ts +9 -108
- package/dist/search/EmbeddingService.d.ts.map +1 -1
- package/dist/search/EmbeddingService.js +15 -187
- package/dist/search/FuzzySearch.js +1 -1
- package/dist/search/SavedSearchManager.d.ts.map +1 -1
- package/dist/search/SavedSearchManager.js +2 -3
- package/dist/search/SearchManager.d.ts +1 -42
- package/dist/search/SearchManager.d.ts.map +1 -1
- package/dist/search/SearchManager.js +0 -115
- package/dist/search/SemanticSearch.d.ts +1 -4
- package/dist/search/SemanticSearch.d.ts.map +1 -1
- package/dist/search/SemanticSearch.js +2 -12
- package/dist/search/TFIDFIndexManager.d.ts +0 -88
- package/dist/search/TFIDFIndexManager.d.ts.map +1 -1
- package/dist/search/TFIDFIndexManager.js +0 -217
- package/dist/search/index.d.ts +1 -18
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -32
- package/dist/server/MCPServer.d.ts.map +1 -1
- package/dist/server/MCPServer.js +4 -1
- package/dist/server/responseCompressor.js +5 -5
- package/dist/server/toolDefinitions.d.ts.map +1 -1
- package/dist/server/toolDefinitions.js +5 -1
- package/dist/server/toolHandlers.d.ts +9 -5
- package/dist/server/toolHandlers.d.ts.map +1 -1
- package/dist/server/toolHandlers.js +23 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -579
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils/compressedCache.d.ts +0 -29
- package/dist/utils/compressedCache.d.ts.map +1 -1
- package/dist/utils/compressedCache.js +0 -39
- package/dist/utils/entityUtils.d.ts +1 -59
- package/dist/utils/entityUtils.d.ts.map +1 -1
- package/dist/utils/entityUtils.js +3 -113
- package/dist/utils/errors.d.ts +0 -18
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +0 -24
- package/dist/utils/index.d.ts +2 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -14
- package/dist/utils/logger.d.ts +0 -7
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +2 -9
- package/dist/utils/parallelUtils.d.ts +1 -5
- package/dist/utils/parallelUtils.d.ts.map +1 -1
- package/dist/utils/parallelUtils.js +1 -23
- package/dist/utils/schemas.d.ts +16 -16
- package/dist/utils/schemas.d.ts.map +1 -1
- package/dist/utils/schemas.js +12 -12
- package/dist/utils/taskScheduler.d.ts +0 -4
- package/dist/utils/taskScheduler.d.ts.map +1 -1
- package/dist/utils/taskScheduler.js +1 -21
- package/dist/workers/WorkerPool.d.ts +81 -0
- package/dist/workers/WorkerPool.d.ts.map +1 -0
- package/dist/workers/WorkerPool.js +121 -0
- package/dist/workers/index.d.ts +1 -1
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/levenshteinWorker.js +1 -1
- package/package.json +1 -4
- package/dist/__tests__/file-path.test.js +0 -119
- package/dist/__tests__/knowledge-graph.test.js +0 -318
- package/dist/core/GraphEventEmitter.d.ts +0 -202
- package/dist/core/GraphEventEmitter.d.ts.map +0 -1
- package/dist/core/GraphEventEmitter.js +0 -346
- package/dist/features/KeywordExtractor.d.ts +0 -61
- package/dist/features/KeywordExtractor.d.ts.map +0 -1
- package/dist/features/KeywordExtractor.js +0 -126
- package/dist/features/ObservationNormalizer.d.ts +0 -90
- package/dist/features/ObservationNormalizer.d.ts.map +0 -1
- package/dist/features/ObservationNormalizer.js +0 -193
- package/dist/memory.jsonl +0 -1
- package/dist/search/BM25Search.d.ts +0 -148
- package/dist/search/BM25Search.d.ts.map +0 -1
- package/dist/search/BM25Search.js +0 -339
- package/dist/search/EarlyTerminationManager.d.ts +0 -140
- package/dist/search/EarlyTerminationManager.d.ts.map +0 -1
- package/dist/search/EarlyTerminationManager.js +0 -279
- package/dist/search/EmbeddingCache.d.ts +0 -175
- package/dist/search/EmbeddingCache.d.ts.map +0 -1
- package/dist/search/EmbeddingCache.js +0 -246
- package/dist/search/HybridScorer.d.ts +0 -181
- package/dist/search/HybridScorer.d.ts.map +0 -1
- package/dist/search/HybridScorer.js +0 -257
- package/dist/search/HybridSearchManager.d.ts +0 -80
- package/dist/search/HybridSearchManager.d.ts.map +0 -1
- package/dist/search/HybridSearchManager.js +0 -187
- package/dist/search/IncrementalIndexer.d.ts +0 -201
- package/dist/search/IncrementalIndexer.d.ts.map +0 -1
- package/dist/search/IncrementalIndexer.js +0 -342
- package/dist/search/OptimizedInvertedIndex.d.ts +0 -163
- package/dist/search/OptimizedInvertedIndex.d.ts.map +0 -1
- package/dist/search/OptimizedInvertedIndex.js +0 -358
- package/dist/search/ParallelSearchExecutor.d.ts +0 -172
- package/dist/search/ParallelSearchExecutor.d.ts.map +0 -1
- package/dist/search/ParallelSearchExecutor.js +0 -309
- package/dist/search/QuantizedVectorStore.d.ts +0 -171
- package/dist/search/QuantizedVectorStore.d.ts.map +0 -1
- package/dist/search/QuantizedVectorStore.js +0 -307
- package/dist/search/QueryAnalyzer.d.ts +0 -76
- package/dist/search/QueryAnalyzer.d.ts.map +0 -1
- package/dist/search/QueryAnalyzer.js +0 -227
- package/dist/search/QueryCostEstimator.d.ts +0 -244
- package/dist/search/QueryCostEstimator.d.ts.map +0 -1
- package/dist/search/QueryCostEstimator.js +0 -652
- package/dist/search/QueryPlanCache.d.ts +0 -220
- package/dist/search/QueryPlanCache.d.ts.map +0 -1
- package/dist/search/QueryPlanCache.js +0 -379
- package/dist/search/QueryPlanner.d.ts +0 -58
- package/dist/search/QueryPlanner.d.ts.map +0 -1
- package/dist/search/QueryPlanner.js +0 -137
- package/dist/search/ReflectionManager.d.ts +0 -120
- package/dist/search/ReflectionManager.d.ts.map +0 -1
- package/dist/search/ReflectionManager.js +0 -231
- package/dist/search/SymbolicSearch.d.ts +0 -61
- package/dist/search/SymbolicSearch.d.ts.map +0 -1
- package/dist/search/SymbolicSearch.js +0 -163
- package/dist/search/TFIDFEventSync.d.ts +0 -85
- package/dist/search/TFIDFEventSync.d.ts.map +0 -1
- package/dist/search/TFIDFEventSync.js +0 -133
- package/dist/utils/BatchProcessor.d.ts +0 -271
- package/dist/utils/BatchProcessor.d.ts.map +0 -1
- package/dist/utils/BatchProcessor.js +0 -376
- package/dist/utils/MemoryMonitor.d.ts +0 -176
- package/dist/utils/MemoryMonitor.d.ts.map +0 -1
- package/dist/utils/MemoryMonitor.js +0 -305
- package/dist/utils/WorkerPoolManager.d.ts +0 -233
- package/dist/utils/WorkerPoolManager.d.ts.map +0 -1
- package/dist/utils/WorkerPoolManager.js +0 -420
- package/dist/utils/operationUtils.d.ts +0 -124
- package/dist/utils/operationUtils.d.ts.map +0 -1
- package/dist/utils/operationUtils.js +0 -175
- package/dist/vitest.config.js +0 -13
|
@@ -34,20 +34,6 @@ export interface CompressedCacheOptions {
|
|
|
34
34
|
* @default true
|
|
35
35
|
*/
|
|
36
36
|
autoCompress?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Minimum entry size in bytes before compression is applied.
|
|
39
|
-
* Entries smaller than this are not compressed (overhead exceeds benefit).
|
|
40
|
-
* Phase 12 Sprint 6: Adaptive compression.
|
|
41
|
-
* @default 256
|
|
42
|
-
*/
|
|
43
|
-
minCompressionSize?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Minimum compression ratio to keep entry compressed.
|
|
46
|
-
* If compression achieves less than this ratio, entry stays uncompressed.
|
|
47
|
-
* Phase 12 Sprint 6: Adaptive compression.
|
|
48
|
-
* @default 0.7 (30% reduction minimum)
|
|
49
|
-
*/
|
|
50
|
-
minCompressionRatio?: number;
|
|
51
37
|
}
|
|
52
38
|
/**
|
|
53
39
|
* Statistics about the cache state.
|
|
@@ -63,8 +49,6 @@ export interface CompressedCacheStats {
|
|
|
63
49
|
memorySaved: number;
|
|
64
50
|
/** Total original size of all entries in bytes */
|
|
65
51
|
totalOriginalSize: number;
|
|
66
|
-
/** Total compressed size in bytes */
|
|
67
|
-
totalCompressedSize: number;
|
|
68
52
|
/** Cache hit count since creation */
|
|
69
53
|
hits: number;
|
|
70
54
|
/** Cache miss count since creation */
|
|
@@ -73,14 +57,6 @@ export interface CompressedCacheStats {
|
|
|
73
57
|
compressions: number;
|
|
74
58
|
/** Number of decompressions performed */
|
|
75
59
|
decompressions: number;
|
|
76
|
-
/** Phase 12 Sprint 6: Number of entries skipped due to size */
|
|
77
|
-
skippedSmallEntries: number;
|
|
78
|
-
/** Phase 12 Sprint 6: Number of entries skipped due to poor ratio */
|
|
79
|
-
skippedPoorRatio: number;
|
|
80
|
-
/** Phase 12 Sprint 6: Average compression ratio (0-1) */
|
|
81
|
-
avgCompressionRatio: number;
|
|
82
|
-
/** Phase 12 Sprint 6: Estimated memory usage in bytes */
|
|
83
|
-
estimatedMemoryBytes: number;
|
|
84
60
|
}
|
|
85
61
|
/**
|
|
86
62
|
* LRU cache with automatic compression of old entries.
|
|
@@ -112,15 +88,10 @@ export declare class CompressedCache {
|
|
|
112
88
|
private readonly maxUncompressed;
|
|
113
89
|
private readonly compressionThresholdMs;
|
|
114
90
|
private readonly autoCompress;
|
|
115
|
-
private readonly minCompressionSize;
|
|
116
|
-
private readonly minCompressionRatio;
|
|
117
91
|
private hits;
|
|
118
92
|
private misses;
|
|
119
93
|
private compressions;
|
|
120
94
|
private decompressions;
|
|
121
|
-
private skippedSmallEntries;
|
|
122
|
-
private skippedPoorRatio;
|
|
123
|
-
private compressionRatios;
|
|
124
95
|
constructor(options?: CompressedCacheOptions);
|
|
125
96
|
/**
|
|
126
97
|
* Get an entity from the cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressedCache.d.ts","sourceRoot":"","sources":["../../src/utils/compressedCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAmBhD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,C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AAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IA6BrC;;;;;;;;OAQG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAgBvC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIhC;;;;OAIG;IACH,QAAQ,IAAI,oBAAoB;IA+BhC;;;;;;;OAOG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IA2D/B;;;;;;OAMG;IACH,aAAa,IAAI,MAAM;IAsBvB;;;;OAIG;IACH,cAAc,IAAI,MAAM,EAAE;IAa1B;;;;;;OAMG;IACF,OAAO,IAAI,gBAAgB,CAAC;QAC3B,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,OAAO,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CAUH"}
|
|
@@ -43,25 +43,15 @@ export class CompressedCache {
|
|
|
43
43
|
maxUncompressed;
|
|
44
44
|
compressionThresholdMs;
|
|
45
45
|
autoCompress;
|
|
46
|
-
// Phase 12 Sprint 6: Adaptive compression options
|
|
47
|
-
minCompressionSize;
|
|
48
|
-
minCompressionRatio;
|
|
49
46
|
// Statistics
|
|
50
47
|
hits = 0;
|
|
51
48
|
misses = 0;
|
|
52
49
|
compressions = 0;
|
|
53
50
|
decompressions = 0;
|
|
54
|
-
// Phase 12 Sprint 6: Adaptive compression stats
|
|
55
|
-
skippedSmallEntries = 0;
|
|
56
|
-
skippedPoorRatio = 0;
|
|
57
|
-
compressionRatios = [];
|
|
58
51
|
constructor(options = {}) {
|
|
59
52
|
this.maxUncompressed = options.maxUncompressed ?? 1000;
|
|
60
53
|
this.compressionThresholdMs = options.compressionThresholdMs ?? 5 * 60 * 1000;
|
|
61
54
|
this.autoCompress = options.autoCompress ?? true;
|
|
62
|
-
// Phase 12 Sprint 6: Adaptive compression defaults
|
|
63
|
-
this.minCompressionSize = options.minCompressionSize ?? 256;
|
|
64
|
-
this.minCompressionRatio = options.minCompressionRatio ?? 0.7;
|
|
65
55
|
}
|
|
66
56
|
/**
|
|
67
57
|
* Get an entity from the cache.
|
|
@@ -166,42 +156,27 @@ export class CompressedCache {
|
|
|
166
156
|
let uncompressed = 0;
|
|
167
157
|
let memorySaved = 0;
|
|
168
158
|
let totalOriginalSize = 0;
|
|
169
|
-
let totalCompressedSize = 0;
|
|
170
|
-
let estimatedMemoryBytes = 0;
|
|
171
159
|
for (const entry of this._entryMap.values()) {
|
|
172
160
|
totalOriginalSize += entry.originalSize;
|
|
173
161
|
if (entry.compressed && entry.compressedData) {
|
|
174
162
|
compressed++;
|
|
175
|
-
totalCompressedSize += entry.compressedData.length;
|
|
176
|
-
estimatedMemoryBytes += entry.compressedData.length;
|
|
177
163
|
// Memory saved = original size - compressed size
|
|
178
164
|
memorySaved += entry.originalSize - entry.compressedData.length;
|
|
179
165
|
}
|
|
180
166
|
else {
|
|
181
167
|
uncompressed++;
|
|
182
|
-
estimatedMemoryBytes += entry.originalSize;
|
|
183
168
|
}
|
|
184
169
|
}
|
|
185
|
-
// Calculate average compression ratio
|
|
186
|
-
const avgCompressionRatio = this.compressionRatios.length > 0
|
|
187
|
-
? this.compressionRatios.reduce((a, b) => a + b, 0) / this.compressionRatios.length
|
|
188
|
-
: 0;
|
|
189
170
|
return {
|
|
190
171
|
total: this._entryMap.size,
|
|
191
172
|
compressed,
|
|
192
173
|
uncompressed,
|
|
193
174
|
memorySaved: Math.max(0, memorySaved),
|
|
194
175
|
totalOriginalSize,
|
|
195
|
-
totalCompressedSize,
|
|
196
176
|
hits: this.hits,
|
|
197
177
|
misses: this.misses,
|
|
198
178
|
compressions: this.compressions,
|
|
199
179
|
decompressions: this.decompressions,
|
|
200
|
-
// Phase 12 Sprint 6: Adaptive compression stats
|
|
201
|
-
skippedSmallEntries: this.skippedSmallEntries,
|
|
202
|
-
skippedPoorRatio: this.skippedPoorRatio,
|
|
203
|
-
avgCompressionRatio,
|
|
204
|
-
estimatedMemoryBytes,
|
|
205
180
|
};
|
|
206
181
|
}
|
|
207
182
|
/**
|
|
@@ -251,11 +226,6 @@ export class CompressedCache {
|
|
|
251
226
|
}
|
|
252
227
|
// Compress the entry
|
|
253
228
|
if (entry.entity) {
|
|
254
|
-
// Phase 12 Sprint 6: Skip small entries (adaptive compression)
|
|
255
|
-
if (entry.originalSize < this.minCompressionSize) {
|
|
256
|
-
this.skippedSmallEntries++;
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
229
|
try {
|
|
260
230
|
const jsonStr = JSON.stringify(entry.entity);
|
|
261
231
|
const compressed = brotliCompressSync(Buffer.from(jsonStr, 'utf-8'), {
|
|
@@ -263,15 +233,6 @@ export class CompressedCache {
|
|
|
263
233
|
[constants.BROTLI_PARAM_QUALITY]: COMPRESSION_CONFIG.BROTLI_QUALITY_CACHE,
|
|
264
234
|
},
|
|
265
235
|
});
|
|
266
|
-
// Phase 12 Sprint 6: Check compression ratio
|
|
267
|
-
const ratio = compressed.length / entry.originalSize;
|
|
268
|
-
if (ratio > this.minCompressionRatio) {
|
|
269
|
-
// Compression didn't achieve enough reduction
|
|
270
|
-
this.skippedPoorRatio++;
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
// Track compression ratio
|
|
274
|
-
this.compressionRatios.push(ratio);
|
|
275
236
|
entry.compressedData = compressed;
|
|
276
237
|
entry.compressed = true;
|
|
277
238
|
entry.entity = null; // Free memory
|
|
@@ -11,31 +11,6 @@
|
|
|
11
11
|
* @module utils/entityUtils
|
|
12
12
|
*/
|
|
13
13
|
import type { Entity, KnowledgeGraph } from '../types/index.js';
|
|
14
|
-
/**
|
|
15
|
-
* FNV-1a hash function for fast string hashing.
|
|
16
|
-
*
|
|
17
|
-
* This is a non-cryptographic hash function that provides good distribution
|
|
18
|
-
* for bucketing and deduplication purposes. It's optimized for speed
|
|
19
|
-
* and produces a 32-bit unsigned integer.
|
|
20
|
-
*
|
|
21
|
-
* FNV-1a has the following properties:
|
|
22
|
-
* - Fast computation (single pass through string)
|
|
23
|
-
* - Good distribution for hash table use
|
|
24
|
-
* - Deterministic output for same input
|
|
25
|
-
*
|
|
26
|
-
* @param text - The string to hash
|
|
27
|
-
* @returns A 32-bit unsigned integer hash value
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const hash = fnv1aHash('hello');
|
|
32
|
-
* console.log(hash); // 1335831723
|
|
33
|
-
*
|
|
34
|
-
* // Use for bucketing similar entities
|
|
35
|
-
* const bucket = fnv1aHash(entity.name.toLowerCase()) % numBuckets;
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function fnv1aHash(text: string): number;
|
|
39
14
|
/**
|
|
40
15
|
* Finds an entity by name in the graph.
|
|
41
16
|
* Overloaded to provide type-safe returns based on throwIfNotFound parameter.
|
|
@@ -287,39 +262,6 @@ export interface CommonSearchFilters {
|
|
|
287
262
|
* @returns true if entity passes all filters
|
|
288
263
|
*/
|
|
289
264
|
export declare function entityPassesFilters(entity: Entity, filters: Omit<CommonSearchFilters, 'tags'>): boolean;
|
|
290
|
-
/**
|
|
291
|
-
* Sanitizes an object by removing potentially dangerous keys.
|
|
292
|
-
* This prevents prototype pollution attacks when using Object.assign() or spread operators.
|
|
293
|
-
*
|
|
294
|
-
* @param obj - The object to sanitize
|
|
295
|
-
* @returns A new object with dangerous keys removed
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```typescript
|
|
299
|
-
* // Safe usage with Object.assign
|
|
300
|
-
* const updates = sanitizeObject(userInput);
|
|
301
|
-
* Object.assign(entity, updates);
|
|
302
|
-
*
|
|
303
|
-
* // Protects against prototype pollution
|
|
304
|
-
* const malicious = { __proto__: { admin: true } };
|
|
305
|
-
* const safe = sanitizeObject(malicious); // { }
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
export declare function sanitizeObject<T extends Record<string, unknown>>(obj: T): Partial<T>;
|
|
309
|
-
/**
|
|
310
|
-
* Escapes a CSV field to prevent formula injection attacks.
|
|
311
|
-
* Prepends a single quote to values that start with dangerous characters.
|
|
312
|
-
*
|
|
313
|
-
* @param field - The field value to escape
|
|
314
|
-
* @returns Escaped field value safe for CSV export
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```typescript
|
|
318
|
-
* escapeCsvFormula('=SUM(A1:A10)'); // "'=SUM(A1:A10)"
|
|
319
|
-
* escapeCsvFormula('normal text'); // 'normal text'
|
|
320
|
-
* ```
|
|
321
|
-
*/
|
|
322
|
-
export declare function escapeCsvFormula(field: string | undefined | null): string;
|
|
323
265
|
/**
|
|
324
266
|
* Validate and normalize a file path to prevent path traversal attacks.
|
|
325
267
|
*
|
|
@@ -346,7 +288,7 @@ export declare function escapeCsvFormula(field: string | undefined | null): stri
|
|
|
346
288
|
*/
|
|
347
289
|
export declare function validateFilePath(filePath: string, baseDir?: string): string;
|
|
348
290
|
/**
|
|
349
|
-
* Default memory file path (in
|
|
291
|
+
* Default memory file path (in same directory as compiled code).
|
|
350
292
|
*/
|
|
351
293
|
export declare const defaultMemoryPath: string;
|
|
352
294
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entityUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKhE
|
|
1
|
+
{"version":3,"file":"entityUtils.d.ts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AAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,GACzC,OAAO,CAsBT;AAID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,MAAM,CAuB1F;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAG7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmC5D"}
|
|
@@ -14,39 +14,6 @@ import { promises as fs } from 'fs';
|
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { fileURLToPath } from 'url';
|
|
16
16
|
import { EntityNotFoundError, FileOperationError } from './errors.js';
|
|
17
|
-
// ==================== Hash Functions ====================
|
|
18
|
-
/**
|
|
19
|
-
* FNV-1a hash function for fast string hashing.
|
|
20
|
-
*
|
|
21
|
-
* This is a non-cryptographic hash function that provides good distribution
|
|
22
|
-
* for bucketing and deduplication purposes. It's optimized for speed
|
|
23
|
-
* and produces a 32-bit unsigned integer.
|
|
24
|
-
*
|
|
25
|
-
* FNV-1a has the following properties:
|
|
26
|
-
* - Fast computation (single pass through string)
|
|
27
|
-
* - Good distribution for hash table use
|
|
28
|
-
* - Deterministic output for same input
|
|
29
|
-
*
|
|
30
|
-
* @param text - The string to hash
|
|
31
|
-
* @returns A 32-bit unsigned integer hash value
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const hash = fnv1aHash('hello');
|
|
36
|
-
* console.log(hash); // 1335831723
|
|
37
|
-
*
|
|
38
|
-
* // Use for bucketing similar entities
|
|
39
|
-
* const bucket = fnv1aHash(entity.name.toLowerCase()) % numBuckets;
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export function fnv1aHash(text) {
|
|
43
|
-
let hash = 2166136261; // FNV offset basis
|
|
44
|
-
for (let i = 0; i < text.length; i++) {
|
|
45
|
-
hash ^= text.charCodeAt(i);
|
|
46
|
-
hash = Math.imul(hash, 16777619); // FNV prime
|
|
47
|
-
}
|
|
48
|
-
return hash >>> 0; // Convert to unsigned 32-bit integer
|
|
49
|
-
}
|
|
50
17
|
export function findEntityByName(graph, name, throwIfNotFound = true) {
|
|
51
18
|
const entity = graph.entities.find(e => e.name === name);
|
|
52
19
|
if (!entity && throwIfNotFound) {
|
|
@@ -465,83 +432,6 @@ export function entityPassesFilters(entity, filters) {
|
|
|
465
432
|
}
|
|
466
433
|
return true;
|
|
467
434
|
}
|
|
468
|
-
// ==================== Security Utilities ====================
|
|
469
|
-
/**
|
|
470
|
-
* Dangerous keys that should never be allowed in object assignment.
|
|
471
|
-
* These can be used for prototype pollution attacks.
|
|
472
|
-
*/
|
|
473
|
-
const DANGEROUS_KEYS = new Set([
|
|
474
|
-
'__proto__',
|
|
475
|
-
'constructor',
|
|
476
|
-
'prototype',
|
|
477
|
-
]);
|
|
478
|
-
/**
|
|
479
|
-
* Sanitizes an object by removing potentially dangerous keys.
|
|
480
|
-
* This prevents prototype pollution attacks when using Object.assign() or spread operators.
|
|
481
|
-
*
|
|
482
|
-
* @param obj - The object to sanitize
|
|
483
|
-
* @returns A new object with dangerous keys removed
|
|
484
|
-
*
|
|
485
|
-
* @example
|
|
486
|
-
* ```typescript
|
|
487
|
-
* // Safe usage with Object.assign
|
|
488
|
-
* const updates = sanitizeObject(userInput);
|
|
489
|
-
* Object.assign(entity, updates);
|
|
490
|
-
*
|
|
491
|
-
* // Protects against prototype pollution
|
|
492
|
-
* const malicious = { __proto__: { admin: true } };
|
|
493
|
-
* const safe = sanitizeObject(malicious); // { }
|
|
494
|
-
* ```
|
|
495
|
-
*/
|
|
496
|
-
export function sanitizeObject(obj) {
|
|
497
|
-
if (obj === null || typeof obj !== 'object') {
|
|
498
|
-
return obj;
|
|
499
|
-
}
|
|
500
|
-
const result = {};
|
|
501
|
-
for (const key of Object.keys(obj)) {
|
|
502
|
-
// Skip dangerous keys
|
|
503
|
-
if (DANGEROUS_KEYS.has(key)) {
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
// Recursively sanitize nested objects
|
|
507
|
-
const value = obj[key];
|
|
508
|
-
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
509
|
-
result[key] = sanitizeObject(value);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
result[key] = value;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
return result;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* CSV formula injection dangerous characters.
|
|
519
|
-
* These can cause spreadsheet applications to execute formulas.
|
|
520
|
-
*/
|
|
521
|
-
const CSV_FORMULA_CHARS = new Set(['=', '+', '-', '@', '\t', '\r']);
|
|
522
|
-
/**
|
|
523
|
-
* Escapes a CSV field to prevent formula injection attacks.
|
|
524
|
-
* Prepends a single quote to values that start with dangerous characters.
|
|
525
|
-
*
|
|
526
|
-
* @param field - The field value to escape
|
|
527
|
-
* @returns Escaped field value safe for CSV export
|
|
528
|
-
*
|
|
529
|
-
* @example
|
|
530
|
-
* ```typescript
|
|
531
|
-
* escapeCsvFormula('=SUM(A1:A10)'); // "'=SUM(A1:A10)"
|
|
532
|
-
* escapeCsvFormula('normal text'); // 'normal text'
|
|
533
|
-
* ```
|
|
534
|
-
*/
|
|
535
|
-
export function escapeCsvFormula(field) {
|
|
536
|
-
if (field === undefined || field === null)
|
|
537
|
-
return '';
|
|
538
|
-
const str = String(field);
|
|
539
|
-
// Prefix with single quote if starts with dangerous character
|
|
540
|
-
if (str.length > 0 && CSV_FORMULA_CHARS.has(str[0])) {
|
|
541
|
-
return "'" + str;
|
|
542
|
-
}
|
|
543
|
-
return str;
|
|
544
|
-
}
|
|
545
435
|
// ==================== Path Utilities ====================
|
|
546
436
|
/**
|
|
547
437
|
* Validate and normalize a file path to prevent path traversal attacks.
|
|
@@ -585,9 +475,9 @@ export function validateFilePath(filePath, baseDir = process.cwd()) {
|
|
|
585
475
|
return finalNormalized;
|
|
586
476
|
}
|
|
587
477
|
/**
|
|
588
|
-
* Default memory file path (in
|
|
478
|
+
* Default memory file path (in same directory as compiled code).
|
|
589
479
|
*/
|
|
590
|
-
export const defaultMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '
|
|
480
|
+
export const defaultMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../memory.jsonl');
|
|
591
481
|
/**
|
|
592
482
|
* Ensure memory file path with backward compatibility migration.
|
|
593
483
|
*
|
|
@@ -622,7 +512,7 @@ export async function ensureMemoryFilePath() {
|
|
|
622
512
|
return validatedPath;
|
|
623
513
|
}
|
|
624
514
|
// No custom path set, check for backward compatibility migration
|
|
625
|
-
const oldMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '
|
|
515
|
+
const oldMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../memory.json');
|
|
626
516
|
const newMemoryPath = defaultMemoryPath;
|
|
627
517
|
try {
|
|
628
518
|
// Check if old file exists
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -74,22 +74,4 @@ export declare class ExportError extends KnowledgeGraphError {
|
|
|
74
74
|
export declare class InsufficientEntitiesError extends KnowledgeGraphError {
|
|
75
75
|
constructor(operation: string, required: number, provided: number);
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Phase 9B: Error thrown when an operation is cancelled via AbortSignal.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const controller = new AbortController();
|
|
83
|
-
* try {
|
|
84
|
-
* await manager.createEntities(entities, { signal: controller.signal });
|
|
85
|
-
* } catch (error) {
|
|
86
|
-
* if (error instanceof OperationCancelledError) {
|
|
87
|
-
* console.log('Operation was cancelled');
|
|
88
|
-
* }
|
|
89
|
-
* }
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare class OperationCancelledError extends KnowledgeGraphError {
|
|
93
|
-
constructor(operation?: string);
|
|
94
|
-
}
|
|
95
77
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aACC,IAAI,CAAC,EAAE,MAAM;gBAA9C,OAAO,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAQ3D;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,mBAAmB;gBAC9C,UAAU,EAAE,MAAM;CAI/B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB;gBAChD,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CAO5D;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,UAAU,EAAE,MAAM;CAI/B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,mBAAmB;aAGpC,MAAM,EAAE,MAAM,EAAE;gBADhC,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EAAE;CAKnC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB;gBAC7C,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAOnD;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,mBAAmB;gBACjD,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAAW;CAO7D;AAED;;GAEG;A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AAE,MAAM;CAOnD;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,mBAAmB;gBACjD,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAAW;CAO7D;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB;gBAEvD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,KAAK;CAWhB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,mBAAmB;gBACtC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI5C;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,mBAAmB;gBACtC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI5C;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB;gBACpD,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAOlE"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -119,27 +119,3 @@ export class InsufficientEntitiesError extends KnowledgeGraphError {
|
|
|
119
119
|
this.name = 'InsufficientEntitiesError';
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Phase 9B: Error thrown when an operation is cancelled via AbortSignal.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* const controller = new AbortController();
|
|
128
|
-
* try {
|
|
129
|
-
* await manager.createEntities(entities, { signal: controller.signal });
|
|
130
|
-
* } catch (error) {
|
|
131
|
-
* if (error instanceof OperationCancelledError) {
|
|
132
|
-
* console.log('Operation was cancelled');
|
|
133
|
-
* }
|
|
134
|
-
* }
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
export class OperationCancelledError extends KnowledgeGraphError {
|
|
138
|
-
constructor(operation) {
|
|
139
|
-
const message = operation
|
|
140
|
-
? `Operation '${operation}' was cancelled`
|
|
141
|
-
: 'Operation was cancelled';
|
|
142
|
-
super(message, 'OPERATION_CANCELLED');
|
|
143
|
-
this.name = 'OperationCancelledError';
|
|
144
|
-
}
|
|
145
|
-
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module utils
|
|
8
8
|
*/
|
|
9
|
-
export { KnowledgeGraphError, EntityNotFoundError, RelationNotFoundError, DuplicateEntityError, ValidationError, CycleDetectedError, InvalidImportanceError, FileOperationError, ImportError, ExportError, InsufficientEntitiesError,
|
|
9
|
+
export { KnowledgeGraphError, EntityNotFoundError, RelationNotFoundError, DuplicateEntityError, ValidationError, CycleDetectedError, InvalidImportanceError, FileOperationError, ImportError, ExportError, InsufficientEntitiesError, } from './errors.js';
|
|
10
10
|
export { FILE_EXTENSIONS, FILE_SUFFIXES, DEFAULT_FILE_NAMES, ENV_VARS, DEFAULT_BASE_DIR, LOG_PREFIXES, SIMILARITY_WEIGHTS, DEFAULT_DUPLICATE_THRESHOLD, SEARCH_LIMITS, IMPORTANCE_RANGE, GRAPH_LIMITS, QUERY_LIMITS, COMPRESSION_CONFIG, STREAMING_CONFIG, type CompressionQuality, } from './constants.js';
|
|
11
11
|
export { compress, decompress, compressFile, decompressFile, compressToBase64, decompressFromBase64, hasBrotliExtension, getCompressionRatio, createMetadata, createUncompressedMetadata, type CompressionOptions, type CompressionResult, type CompressionMetadata, } from './compressionUtil.js';
|
|
12
12
|
export { CompressedCache, type CompressedCacheOptions, type CompressedCacheStats, } from './compressedCache.js';
|
|
@@ -16,11 +16,7 @@ export { NameIndex, TypeIndex, LowercaseCache, RelationIndex, } from './indexes.
|
|
|
16
16
|
export { SearchCache, searchCaches, clearAllSearchCaches, getAllCacheStats, cleanupAllCaches, type CacheStats, } from './searchCache.js';
|
|
17
17
|
export { EntitySchema, CreateEntitySchema, UpdateEntitySchema, RelationSchema, CreateRelationSchema, SearchQuerySchema, DateRangeSchema, TagAliasSchema, ExportFormatSchema, BatchCreateEntitiesSchema, BatchCreateRelationsSchema, EntityNamesSchema, DeleteRelationsSchema, AddObservationInputSchema, AddObservationsInputSchema, DeleteObservationInputSchema, DeleteObservationsInputSchema, ArchiveCriteriaSchema, SavedSearchInputSchema, SavedSearchUpdateSchema, ImportFormatSchema, ExtendedExportFormatSchema, MergeStrategySchema, ExportFilterSchema, OptionalTagsSchema, OptionalEntityNamesSchema, type EntityInput, type CreateEntityInput, type UpdateEntityInput, type RelationInput, type CreateRelationInput, type SearchQuery, type DateRange, type TagAlias, type ExportFormat, type AddObservationInput, type DeleteObservationInput, type ArchiveCriteriaInput, type SavedSearchInput, type SavedSearchUpdateInput, type ImportFormat, type ExtendedExportFormat, type MergeStrategy, type ExportFilterInput, type ValidationResult, formatZodErrors, validateWithSchema, validateSafe, validateArrayWithSchema, validateEntity, validateRelation, validateImportance, validateTags, } from './schemas.js';
|
|
18
18
|
export { formatToolResponse, formatTextResponse, formatRawResponse, formatErrorResponse, type ToolResponse, validatePagination, applyPagination, paginateArray, getPaginationMeta, type ValidatedPagination, } from './formatters.js';
|
|
19
|
-
export {
|
|
19
|
+
export { findEntityByName, findEntitiesByNames, entityExists, getEntityIndex, removeEntityByName, getEntityNameSet, groupEntitiesByType, touchEntity, normalizeTag, normalizeTags, hasMatchingTag, hasAllTags, filterByTags, addUniqueTags, removeTags, isWithinDateRange, parseDateRange, isValidISODate, getCurrentTimestamp, isWithinImportanceRange, filterByImportance, filterByCreatedDate, filterByModifiedDate, filterByEntityType, entityPassesFilters, type CommonSearchFilters, validateFilePath, defaultMemoryPath, ensureMemoryFilePath, } from './entityUtils.js';
|
|
20
20
|
export { parallelMap, parallelFilter, getPoolStats, shutdownParallelUtils, } from './parallelUtils.js';
|
|
21
21
|
export { TaskPriority, TaskStatus, type Task, type TaskResult, type ProgressCallback, type BatchOptions, type QueueStats, TaskQueue, batchProcess, rateLimitedProcess, withRetry, debounce, throttle, } from './taskScheduler.js';
|
|
22
|
-
export { checkCancellation, createProgressReporter, createProgress, executeWithPhases, processBatchesWithProgress, type PhaseDefinition, } from './operationUtils.js';
|
|
23
|
-
export { WorkerPoolManager, getWorkerPoolManager, type WorkerPoolConfig, type ExtendedPoolStats, type PoolEventCallback, } from './WorkerPoolManager.js';
|
|
24
|
-
export { BatchProcessor, processBatch, processWithRetry, chunkArray, parallelLimit, mapParallel, filterParallel, type BatchProgress, type BatchProgressCallback, type BatchItemResult, type BatchProcessResult, type BatchProcessorOptions, } from './BatchProcessor.js';
|
|
25
|
-
export { MemoryMonitor, globalMemoryMonitor, type ComponentMemoryUsage, type MemoryUsageStats, type MemoryThresholds, type MemoryAlert, type MemoryChangeCallback, } from './MemoryMonitor.js';
|
|
26
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,E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Y,EACZ,kBAAkB,EAClB,SAAS,EAET,QAAQ,EACR,QAAQ,GACT,MAAM,oBAAoB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module utils
|
|
8
8
|
*/
|
|
9
9
|
// ==================== Error Types ====================
|
|
10
|
-
export { KnowledgeGraphError, EntityNotFoundError, RelationNotFoundError, DuplicateEntityError, ValidationError, CycleDetectedError, InvalidImportanceError, FileOperationError, ImportError, ExportError, InsufficientEntitiesError,
|
|
10
|
+
export { KnowledgeGraphError, EntityNotFoundError, RelationNotFoundError, DuplicateEntityError, ValidationError, CycleDetectedError, InvalidImportanceError, FileOperationError, ImportError, ExportError, InsufficientEntitiesError, } from './errors.js';
|
|
11
11
|
// ==================== Constants ====================
|
|
12
12
|
export { FILE_EXTENSIONS, FILE_SUFFIXES, DEFAULT_FILE_NAMES, ENV_VARS, DEFAULT_BASE_DIR, LOG_PREFIXES, SIMILARITY_WEIGHTS, DEFAULT_DUPLICATE_THRESHOLD, SEARCH_LIMITS, IMPORTANCE_RANGE, GRAPH_LIMITS, QUERY_LIMITS, COMPRESSION_CONFIG, STREAMING_CONFIG, } from './constants.js';
|
|
13
13
|
// ==================== Compression Utilities ====================
|
|
@@ -51,8 +51,6 @@ validatePagination, applyPagination, paginateArray, getPaginationMeta, } from '.
|
|
|
51
51
|
// ==================== Entity Utilities ====================
|
|
52
52
|
// Consolidated from: entityUtils.ts, tagUtils.ts, dateUtils.ts, filterUtils.ts, pathUtils.ts
|
|
53
53
|
export {
|
|
54
|
-
// Hash functions (Phase 12 Sprint 1)
|
|
55
|
-
fnv1aHash,
|
|
56
54
|
// Entity lookup
|
|
57
55
|
findEntityByName, findEntitiesByNames, entityExists, getEntityIndex, removeEntityByName, getEntityNameSet, groupEntitiesByType, touchEntity,
|
|
58
56
|
// Tag utilities
|
|
@@ -62,9 +60,7 @@ isWithinDateRange, parseDateRange, isValidISODate, getCurrentTimestamp,
|
|
|
62
60
|
// Filter utilities
|
|
63
61
|
isWithinImportanceRange, filterByImportance, filterByCreatedDate, filterByModifiedDate, filterByEntityType, entityPassesFilters,
|
|
64
62
|
// Path utilities
|
|
65
|
-
validateFilePath, defaultMemoryPath, ensureMemoryFilePath,
|
|
66
|
-
// Security utilities
|
|
67
|
-
sanitizeObject, escapeCsvFormula, } from './entityUtils.js';
|
|
63
|
+
validateFilePath, defaultMemoryPath, ensureMemoryFilePath, } from './entityUtils.js';
|
|
68
64
|
// ==================== Parallel Utilities ====================
|
|
69
65
|
export { parallelMap, parallelFilter, getPoolStats, shutdownParallelUtils, } from './parallelUtils.js';
|
|
70
66
|
// ==================== Task Scheduler ====================
|
|
@@ -77,11 +73,3 @@ TaskQueue,
|
|
|
77
73
|
batchProcess, rateLimitedProcess, withRetry,
|
|
78
74
|
// Rate Limiting
|
|
79
75
|
debounce, throttle, } from './taskScheduler.js';
|
|
80
|
-
// ==================== Operation Utilities (Phase 9B) ====================
|
|
81
|
-
export { checkCancellation, createProgressReporter, createProgress, executeWithPhases, processBatchesWithProgress, } from './operationUtils.js';
|
|
82
|
-
// ==================== Worker Pool Manager (Phase 12 Sprint 2) ====================
|
|
83
|
-
export { WorkerPoolManager, getWorkerPoolManager, } from './WorkerPoolManager.js';
|
|
84
|
-
// ==================== Batch Processor (Phase 12 Sprint 2) ====================
|
|
85
|
-
export { BatchProcessor, processBatch, processWithRetry, chunkArray, parallelLimit, mapParallel, filterParallel, } from './BatchProcessor.js';
|
|
86
|
-
// ==================== Memory Monitor (Phase 12 Sprint 6) ====================
|
|
87
|
-
export { MemoryMonitor, globalMemoryMonitor, } from './MemoryMonitor.js';
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -2,29 +2,22 @@
|
|
|
2
2
|
* Simple logging utility for the Memory MCP Server
|
|
3
3
|
*
|
|
4
4
|
* Provides consistent log formatting with levels: debug, info, warn, error
|
|
5
|
-
*
|
|
6
|
-
* IMPORTANT: All log output goes to stderr to avoid interfering with
|
|
7
|
-
* JSON-RPC communication on stdout when running as an MCP server.
|
|
8
5
|
*/
|
|
9
6
|
export declare const logger: {
|
|
10
7
|
/**
|
|
11
8
|
* Debug level logging (verbose, for development)
|
|
12
|
-
* Output: stderr (to avoid interfering with JSON-RPC)
|
|
13
9
|
*/
|
|
14
10
|
debug: (msg: string, ...args: unknown[]) => void;
|
|
15
11
|
/**
|
|
16
12
|
* Info level logging (general informational messages)
|
|
17
|
-
* Output: stderr (to avoid interfering with JSON-RPC)
|
|
18
13
|
*/
|
|
19
14
|
info: (msg: string, ...args: unknown[]) => void;
|
|
20
15
|
/**
|
|
21
16
|
* Warning level logging (warnings that don't prevent operation)
|
|
22
|
-
* Output: stderr (native console.warn behavior)
|
|
23
17
|
*/
|
|
24
18
|
warn: (msg: string, ...args: unknown[]) => void;
|
|
25
19
|
/**
|
|
26
20
|
* Error level logging (errors that affect functionality)
|
|
27
|
-
* Output: stderr (native console.error behavior)
|
|
28
21
|
*/
|
|
29
22
|
error: (msg: string, ...args: unknown[]) => void;
|
|
30
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,MAAM;IACjB;;OAEG;iBACU,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAM9C;;OAEG;gBACS,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAI7C;;OAEG;gBACS,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAI7C;;OAEG;iBACU,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;CAG/C,CAAC"}
|
package/dist/utils/logger.js
CHANGED
|
@@ -2,37 +2,30 @@
|
|
|
2
2
|
* Simple logging utility for the Memory MCP Server
|
|
3
3
|
*
|
|
4
4
|
* Provides consistent log formatting with levels: debug, info, warn, error
|
|
5
|
-
*
|
|
6
|
-
* IMPORTANT: All log output goes to stderr to avoid interfering with
|
|
7
|
-
* JSON-RPC communication on stdout when running as an MCP server.
|
|
8
5
|
*/
|
|
9
6
|
export const logger = {
|
|
10
7
|
/**
|
|
11
8
|
* Debug level logging (verbose, for development)
|
|
12
|
-
* Output: stderr (to avoid interfering with JSON-RPC)
|
|
13
9
|
*/
|
|
14
10
|
debug: (msg, ...args) => {
|
|
15
11
|
if (process.env.LOG_LEVEL === 'debug') {
|
|
16
|
-
console.
|
|
12
|
+
console.debug(`[DEBUG] ${msg}`, ...args);
|
|
17
13
|
}
|
|
18
14
|
},
|
|
19
15
|
/**
|
|
20
16
|
* Info level logging (general informational messages)
|
|
21
|
-
* Output: stderr (to avoid interfering with JSON-RPC)
|
|
22
17
|
*/
|
|
23
18
|
info: (msg, ...args) => {
|
|
24
|
-
console.
|
|
19
|
+
console.log(`[INFO] ${msg}`, ...args);
|
|
25
20
|
},
|
|
26
21
|
/**
|
|
27
22
|
* Warning level logging (warnings that don't prevent operation)
|
|
28
|
-
* Output: stderr (native console.warn behavior)
|
|
29
23
|
*/
|
|
30
24
|
warn: (msg, ...args) => {
|
|
31
25
|
console.warn(`[WARN] ${msg}`, ...args);
|
|
32
26
|
},
|
|
33
27
|
/**
|
|
34
28
|
* Error level logging (errors that affect functionality)
|
|
35
|
-
* Output: stderr (native console.error behavior)
|
|
36
29
|
*/
|
|
37
30
|
error: (msg, ...args) => {
|
|
38
31
|
console.error(`[ERROR] ${msg}`, ...args);
|
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* Utilities for parallel array operations using workerpool.
|
|
5
5
|
* Phase 8 Sprint 3: Parallel array operations for improved performance.
|
|
6
6
|
*
|
|
7
|
-
* **SECURITY WARNING:** These functions use `new Function()` internally for worker serialization.
|
|
8
|
-
* The `fn` parameter MUST be a real function object, never a user-provided string.
|
|
9
|
-
* Runtime validation ensures only function objects are accepted.
|
|
10
|
-
*
|
|
11
7
|
* @module utils/parallelUtils
|
|
12
8
|
*/
|
|
13
|
-
import workerpool from '@danielsimonjr/workerpool';
|
|
9
|
+
import workerpool from '@danielsimonjr/workerpool/modern';
|
|
14
10
|
/**
|
|
15
11
|
* Shutdown the shared worker pool and clean up resources.
|
|
16
12
|
* Should be called when parallel utilities are no longer needed.
|