@danielsimonjr/memory-mcp 0.47.1 → 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.
- package/LICENSE +22 -0
- package/README.md +2000 -194
- package/dist/__tests__/file-path.test.js +5 -5
- package/dist/__tests__/knowledge-graph.test.js +3 -8
- package/dist/core/EntityManager.d.ts +266 -0
- package/dist/core/EntityManager.d.ts.map +1 -0
- package/dist/core/EntityManager.js +85 -133
- package/dist/core/GraphEventEmitter.d.ts +202 -0
- package/dist/core/GraphEventEmitter.d.ts.map +1 -0
- package/dist/core/GraphEventEmitter.js +346 -0
- package/dist/core/GraphStorage.d.ts +395 -0
- package/dist/core/GraphStorage.d.ts.map +1 -0
- package/dist/core/GraphStorage.js +643 -31
- package/dist/core/GraphTraversal.d.ts +141 -0
- package/dist/core/GraphTraversal.d.ts.map +1 -0
- package/dist/core/GraphTraversal.js +573 -0
- package/dist/core/HierarchyManager.d.ts +111 -0
- package/dist/core/HierarchyManager.d.ts.map +1 -0
- package/dist/{features → core}/HierarchyManager.js +14 -9
- package/dist/core/ManagerContext.d.ts +72 -0
- package/dist/core/ManagerContext.d.ts.map +1 -0
- package/dist/core/ManagerContext.js +118 -0
- package/dist/core/ObservationManager.d.ts +85 -0
- package/dist/core/ObservationManager.d.ts.map +1 -0
- package/dist/core/ObservationManager.js +51 -57
- package/dist/core/RelationManager.d.ts +131 -0
- package/dist/core/RelationManager.d.ts.map +1 -0
- package/dist/core/RelationManager.js +31 -7
- package/dist/core/SQLiteStorage.d.ts +354 -0
- package/dist/core/SQLiteStorage.d.ts.map +1 -0
- package/dist/core/SQLiteStorage.js +917 -0
- package/dist/core/StorageFactory.d.ts +45 -0
- package/dist/core/StorageFactory.d.ts.map +1 -0
- package/dist/core/StorageFactory.js +64 -0
- package/dist/core/TransactionManager.d.ts +464 -0
- package/dist/core/TransactionManager.d.ts.map +1 -0
- package/dist/core/TransactionManager.js +490 -13
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -2
- package/dist/features/AnalyticsManager.d.ts +44 -0
- package/dist/features/AnalyticsManager.d.ts.map +1 -0
- package/dist/features/AnalyticsManager.js +14 -13
- package/dist/features/ArchiveManager.d.ts +133 -0
- package/dist/features/ArchiveManager.d.ts.map +1 -0
- package/dist/features/ArchiveManager.js +221 -14
- package/dist/features/CompressionManager.d.ts +117 -0
- package/dist/features/CompressionManager.d.ts.map +1 -0
- package/dist/features/CompressionManager.js +189 -20
- package/dist/features/IOManager.d.ts +225 -0
- package/dist/features/IOManager.d.ts.map +1 -0
- package/dist/features/IOManager.js +1041 -0
- package/dist/features/StreamingExporter.d.ts +123 -0
- package/dist/features/StreamingExporter.d.ts.map +1 -0
- package/dist/features/StreamingExporter.js +203 -0
- package/dist/features/TagManager.d.ts +147 -0
- package/dist/features/TagManager.d.ts.map +1 -0
- package/dist/features/index.d.ts +12 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +5 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -45
- package/dist/memory.jsonl +1 -18
- package/dist/search/BasicSearch.d.ts +51 -0
- package/dist/search/BasicSearch.d.ts.map +1 -0
- package/dist/search/BasicSearch.js +9 -3
- package/dist/search/BooleanSearch.d.ts +98 -0
- package/dist/search/BooleanSearch.d.ts.map +1 -0
- package/dist/search/BooleanSearch.js +156 -9
- package/dist/search/EmbeddingService.d.ts +178 -0
- package/dist/search/EmbeddingService.d.ts.map +1 -0
- package/dist/search/EmbeddingService.js +358 -0
- package/dist/search/FuzzySearch.d.ts +118 -0
- package/dist/search/FuzzySearch.d.ts.map +1 -0
- package/dist/search/FuzzySearch.js +241 -25
- package/dist/search/QueryCostEstimator.d.ts +111 -0
- package/dist/search/QueryCostEstimator.d.ts.map +1 -0
- package/dist/search/QueryCostEstimator.js +355 -0
- package/dist/search/RankedSearch.d.ts +71 -0
- package/dist/search/RankedSearch.d.ts.map +1 -0
- package/dist/search/RankedSearch.js +54 -6
- package/dist/search/SavedSearchManager.d.ts +79 -0
- package/dist/search/SavedSearchManager.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.d.ts +120 -0
- package/dist/search/SearchFilterChain.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.js +2 -4
- package/dist/search/SearchManager.d.ts +326 -0
- package/dist/search/SearchManager.d.ts.map +1 -0
- package/dist/search/SearchManager.js +148 -0
- package/dist/search/SearchSuggestions.d.ts +27 -0
- package/dist/search/SearchSuggestions.d.ts.map +1 -0
- package/dist/search/SearchSuggestions.js +1 -1
- package/dist/search/SemanticSearch.d.ts +149 -0
- package/dist/search/SemanticSearch.d.ts.map +1 -0
- package/dist/search/SemanticSearch.js +323 -0
- package/dist/search/TFIDFEventSync.d.ts +85 -0
- package/dist/search/TFIDFEventSync.d.ts.map +1 -0
- package/dist/search/TFIDFEventSync.js +133 -0
- package/dist/search/TFIDFIndexManager.d.ts +151 -0
- package/dist/search/TFIDFIndexManager.d.ts.map +1 -0
- package/dist/search/TFIDFIndexManager.js +232 -17
- package/dist/search/VectorStore.d.ts +235 -0
- package/dist/search/VectorStore.d.ts.map +1 -0
- package/dist/search/VectorStore.js +311 -0
- package/dist/search/index.d.ts +21 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +12 -0
- package/dist/server/MCPServer.d.ts +21 -0
- package/dist/server/MCPServer.d.ts.map +1 -0
- package/dist/server/MCPServer.js +4 -4
- package/dist/server/responseCompressor.d.ts +94 -0
- package/dist/server/responseCompressor.d.ts.map +1 -0
- package/dist/server/responseCompressor.js +127 -0
- package/dist/server/toolDefinitions.d.ts +27 -0
- package/dist/server/toolDefinitions.d.ts.map +1 -0
- package/dist/server/toolDefinitions.js +189 -18
- package/dist/server/toolHandlers.d.ts +41 -0
- package/dist/server/toolHandlers.d.ts.map +1 -0
- package/dist/server/toolHandlers.js +467 -75
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/types.d.ts +1654 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +9 -0
- package/dist/utils/compressedCache.d.ts +192 -0
- package/dist/utils/compressedCache.d.ts.map +1 -0
- package/dist/utils/compressedCache.js +309 -0
- package/dist/utils/compressionUtil.d.ts +214 -0
- package/dist/utils/compressionUtil.d.ts.map +1 -0
- package/dist/utils/compressionUtil.js +247 -0
- package/dist/utils/constants.d.ts +245 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +124 -0
- package/dist/utils/entityUtils.d.ts +321 -0
- package/dist/utils/entityUtils.d.ts.map +1 -0
- package/dist/utils/entityUtils.js +434 -4
- package/dist/utils/errors.d.ts +95 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +24 -0
- package/dist/utils/formatters.d.ts +145 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/{paginationUtils.js → formatters.js} +54 -3
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +69 -31
- package/dist/utils/indexes.d.ts +270 -0
- package/dist/utils/indexes.d.ts.map +1 -0
- package/dist/utils/indexes.js +526 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/operationUtils.d.ts +124 -0
- package/dist/utils/operationUtils.d.ts.map +1 -0
- package/dist/utils/operationUtils.js +175 -0
- package/dist/utils/parallelUtils.d.ts +72 -0
- package/dist/utils/parallelUtils.d.ts.map +1 -0
- package/dist/utils/parallelUtils.js +169 -0
- package/dist/utils/schemas.d.ts +374 -0
- package/dist/utils/schemas.d.ts.map +1 -0
- package/dist/utils/schemas.js +302 -2
- package/dist/utils/searchAlgorithms.d.ts +99 -0
- package/dist/utils/searchAlgorithms.d.ts.map +1 -0
- package/dist/utils/searchAlgorithms.js +167 -0
- package/dist/utils/searchCache.d.ts +108 -0
- package/dist/utils/searchCache.d.ts.map +1 -0
- package/dist/utils/taskScheduler.d.ts +290 -0
- package/dist/utils/taskScheduler.d.ts.map +1 -0
- package/dist/utils/taskScheduler.js +466 -0
- package/dist/workers/index.d.ts +12 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +9 -0
- package/dist/workers/levenshteinWorker.d.ts +60 -0
- package/dist/workers/levenshteinWorker.d.ts.map +1 -0
- package/dist/workers/levenshteinWorker.js +98 -0
- package/package.json +17 -4
- package/dist/__tests__/edge-cases/edge-cases.test.js +0 -406
- package/dist/__tests__/integration/workflows.test.js +0 -449
- package/dist/__tests__/performance/benchmarks.test.js +0 -413
- package/dist/__tests__/unit/core/EntityManager.test.js +0 -334
- package/dist/__tests__/unit/core/GraphStorage.test.js +0 -205
- package/dist/__tests__/unit/core/RelationManager.test.js +0 -274
- package/dist/__tests__/unit/features/CompressionManager.test.js +0 -350
- package/dist/__tests__/unit/search/BasicSearch.test.js +0 -311
- package/dist/__tests__/unit/search/BooleanSearch.test.js +0 -432
- package/dist/__tests__/unit/search/FuzzySearch.test.js +0 -448
- package/dist/__tests__/unit/search/RankedSearch.test.js +0 -379
- package/dist/__tests__/unit/utils/levenshtein.test.js +0 -77
- package/dist/core/KnowledgeGraphManager.js +0 -423
- package/dist/features/BackupManager.js +0 -311
- package/dist/features/ExportManager.js +0 -305
- package/dist/features/ImportExportManager.js +0 -50
- package/dist/features/ImportManager.js +0 -328
- package/dist/types/analytics.types.js +0 -6
- package/dist/types/entity.types.js +0 -7
- package/dist/types/import-export.types.js +0 -7
- package/dist/types/search.types.js +0 -7
- package/dist/types/tag.types.js +0 -6
- package/dist/utils/dateUtils.js +0 -89
- package/dist/utils/filterUtils.js +0 -155
- package/dist/utils/levenshtein.js +0 -62
- package/dist/utils/pathUtils.js +0 -115
- package/dist/utils/responseFormatter.js +0 -55
- package/dist/utils/tagUtils.js +0 -107
- package/dist/utils/tfidf.js +0 -90
- package/dist/utils/validationHelper.js +0 -99
- package/dist/utils/validationUtils.js +0 -109
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application Constants
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration constants for file paths, extensions, and default values.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/constants
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* File extensions used by the memory system.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FILE_EXTENSIONS: {
|
|
12
|
+
/** JSONL format for line-delimited JSON storage */
|
|
13
|
+
readonly JSONL: ".jsonl";
|
|
14
|
+
/** Legacy JSON format (backward compatibility) */
|
|
15
|
+
readonly JSON: ".json";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* File name suffixes for auxiliary data files.
|
|
19
|
+
* These suffixes are appended to the base memory file name.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FILE_SUFFIXES: {
|
|
22
|
+
/** Suffix for saved searches file */
|
|
23
|
+
readonly SAVED_SEARCHES: "-saved-searches";
|
|
24
|
+
/** Suffix for tag aliases file */
|
|
25
|
+
readonly TAG_ALIASES: "-tag-aliases";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Default file names used by the memory system.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_FILE_NAMES: {
|
|
31
|
+
/** Default memory file name */
|
|
32
|
+
readonly MEMORY: "memory";
|
|
33
|
+
/** Legacy memory file name (for backward compatibility) */
|
|
34
|
+
readonly MEMORY_LEGACY: "memory";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Environment variable names used for configuration.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ENV_VARS: {
|
|
40
|
+
/** Environment variable for custom memory file path */
|
|
41
|
+
readonly MEMORY_FILE_PATH: "MEMORY_FILE_PATH";
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Default base directory relative to the compiled code.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_BASE_DIR = "../";
|
|
47
|
+
/**
|
|
48
|
+
* Log message prefixes for consistent logging.
|
|
49
|
+
*/
|
|
50
|
+
export declare const LOG_PREFIXES: {
|
|
51
|
+
/** Informational message prefix */
|
|
52
|
+
readonly INFO: "[INFO]";
|
|
53
|
+
/** Error message prefix */
|
|
54
|
+
readonly ERROR: "[ERROR]";
|
|
55
|
+
/** Warning message prefix */
|
|
56
|
+
readonly WARN: "[WARN]";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Similarity scoring weights for duplicate detection.
|
|
60
|
+
* These weights determine the relative importance of each factor
|
|
61
|
+
* when calculating entity similarity for duplicate detection.
|
|
62
|
+
* Total weights must sum to 1.0 (100%).
|
|
63
|
+
*/
|
|
64
|
+
export declare const SIMILARITY_WEIGHTS: {
|
|
65
|
+
/** Name similarity weight (40%) - Uses Levenshtein distance */
|
|
66
|
+
readonly NAME: 0.4;
|
|
67
|
+
/** Entity type match weight (20%) - Exact match required */
|
|
68
|
+
readonly TYPE: 0.2;
|
|
69
|
+
/** Observation overlap weight (30%) - Uses Jaccard similarity */
|
|
70
|
+
readonly OBSERVATIONS: 0.3;
|
|
71
|
+
/** Tag overlap weight (10%) - Uses Jaccard similarity */
|
|
72
|
+
readonly TAGS: 0.1;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Default threshold for duplicate detection (80% similarity required).
|
|
76
|
+
*/
|
|
77
|
+
export declare const DEFAULT_DUPLICATE_THRESHOLD = 0.8;
|
|
78
|
+
/**
|
|
79
|
+
* Search result limits to prevent resource exhaustion.
|
|
80
|
+
*/
|
|
81
|
+
export declare const SEARCH_LIMITS: {
|
|
82
|
+
/** Default number of results to return */
|
|
83
|
+
readonly DEFAULT: 50;
|
|
84
|
+
/** Maximum number of results allowed */
|
|
85
|
+
readonly MAX: 200;
|
|
86
|
+
/** Minimum number of results (must be at least 1) */
|
|
87
|
+
readonly MIN: 1;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Entity importance range validation constants.
|
|
91
|
+
* Importance is used to prioritize entities (0 = lowest, 10 = highest).
|
|
92
|
+
*/
|
|
93
|
+
export declare const IMPORTANCE_RANGE: {
|
|
94
|
+
/** Minimum importance value */
|
|
95
|
+
readonly MIN: 0;
|
|
96
|
+
/** Maximum importance value */
|
|
97
|
+
readonly MAX: 10;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Graph size limits to prevent resource exhaustion and ensure performance.
|
|
101
|
+
* These limits help maintain system stability and responsiveness.
|
|
102
|
+
*/
|
|
103
|
+
export declare const GRAPH_LIMITS: {
|
|
104
|
+
/** Maximum number of entities in the graph */
|
|
105
|
+
readonly MAX_ENTITIES: 100000;
|
|
106
|
+
/** Maximum number of relations in the graph */
|
|
107
|
+
readonly MAX_RELATIONS: 1000000;
|
|
108
|
+
/** Maximum graph file size in megabytes */
|
|
109
|
+
readonly MAX_FILE_SIZE_MB: 500;
|
|
110
|
+
/** Maximum observations per entity */
|
|
111
|
+
readonly MAX_OBSERVATIONS_PER_ENTITY: 1000;
|
|
112
|
+
/** Maximum tags per entity */
|
|
113
|
+
readonly MAX_TAGS_PER_ENTITY: 100;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Query complexity limits to prevent expensive query operations.
|
|
117
|
+
* These limits protect against denial-of-service through complex queries.
|
|
118
|
+
*/
|
|
119
|
+
export declare const QUERY_LIMITS: {
|
|
120
|
+
/** Maximum nesting depth for boolean queries */
|
|
121
|
+
readonly MAX_DEPTH: 10;
|
|
122
|
+
/** Maximum number of terms in a single query */
|
|
123
|
+
readonly MAX_TERMS: 50;
|
|
124
|
+
/** Maximum number of boolean operators (AND/OR/NOT) */
|
|
125
|
+
readonly MAX_OPERATORS: 20;
|
|
126
|
+
/** Maximum query string length */
|
|
127
|
+
readonly MAX_QUERY_LENGTH: 5000;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Brotli compression configuration constants.
|
|
131
|
+
* Brotli is built into Node.js >=11.7.0 via the zlib module.
|
|
132
|
+
* No external dependencies required.
|
|
133
|
+
*
|
|
134
|
+
* Quality levels determine compression ratio vs speed tradeoff:
|
|
135
|
+
* - Lower values (0-4): Faster compression, lower ratio
|
|
136
|
+
* - Higher values (9-11): Slower compression, higher ratio
|
|
137
|
+
*/
|
|
138
|
+
export declare const COMPRESSION_CONFIG: {
|
|
139
|
+
/** Fast compression for real-time entity writes (quality 4) */
|
|
140
|
+
readonly BROTLI_QUALITY_REALTIME: 4;
|
|
141
|
+
/** Balanced compression for exports and imports (quality 6) */
|
|
142
|
+
readonly BROTLI_QUALITY_BATCH: 6;
|
|
143
|
+
/** Maximum compression for backups and archives (quality 11) */
|
|
144
|
+
readonly BROTLI_QUALITY_ARCHIVE: 11;
|
|
145
|
+
/** Fast decompress for cache compression (quality 5) */
|
|
146
|
+
readonly BROTLI_QUALITY_CACHE: 5;
|
|
147
|
+
/** Auto-compress exports larger than 100KB */
|
|
148
|
+
readonly AUTO_COMPRESS_EXPORT_SIZE: number;
|
|
149
|
+
/** Auto-compress MCP responses larger than 256KB */
|
|
150
|
+
readonly AUTO_COMPRESS_RESPONSE_SIZE: number;
|
|
151
|
+
/** Always compress backups by default */
|
|
152
|
+
readonly AUTO_COMPRESS_BACKUP: true;
|
|
153
|
+
/** Brotli compressed file extension */
|
|
154
|
+
readonly BROTLI_EXTENSION: ".br";
|
|
155
|
+
/** Chunk size for streaming compression (64KB) */
|
|
156
|
+
readonly COMPRESSION_CHUNK_SIZE: 65536;
|
|
157
|
+
/** Default window size for brotli (lgwin parameter) */
|
|
158
|
+
readonly COMPRESSION_WINDOW_SIZE: 22;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Type representing valid brotli quality levels used in the application.
|
|
162
|
+
*/
|
|
163
|
+
export type CompressionQuality = typeof COMPRESSION_CONFIG.BROTLI_QUALITY_REALTIME | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_BATCH | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_ARCHIVE | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_CACHE;
|
|
164
|
+
/**
|
|
165
|
+
* Environment variable names for embedding configuration.
|
|
166
|
+
*/
|
|
167
|
+
export declare const EMBEDDING_ENV_VARS: {
|
|
168
|
+
/** Embedding provider: 'openai', 'local', or 'none' (default: 'none') */
|
|
169
|
+
readonly PROVIDER: "MEMORY_EMBEDDING_PROVIDER";
|
|
170
|
+
/** OpenAI API key (required when provider is 'openai') */
|
|
171
|
+
readonly OPENAI_API_KEY: "MEMORY_OPENAI_API_KEY";
|
|
172
|
+
/** Optional model override for the embedding service */
|
|
173
|
+
readonly MODEL: "MEMORY_EMBEDDING_MODEL";
|
|
174
|
+
/** Auto-index entities on creation: 'true' or 'false' (default: 'false') */
|
|
175
|
+
readonly AUTO_INDEX: "MEMORY_AUTO_INDEX_EMBEDDINGS";
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Default embedding configuration values.
|
|
179
|
+
*/
|
|
180
|
+
export declare const EMBEDDING_DEFAULTS: {
|
|
181
|
+
/** Default provider (disabled by default) */
|
|
182
|
+
readonly PROVIDER: "none";
|
|
183
|
+
/** Default OpenAI model for embeddings (1536 dimensions) */
|
|
184
|
+
readonly OPENAI_MODEL: "text-embedding-3-small";
|
|
185
|
+
/** Default local model for embeddings (384 dimensions) */
|
|
186
|
+
readonly LOCAL_MODEL: "Xenova/all-MiniLM-L6-v2";
|
|
187
|
+
/** OpenAI embedding dimensions for text-embedding-3-small */
|
|
188
|
+
readonly OPENAI_DIMENSIONS: 1536;
|
|
189
|
+
/** Local embedding dimensions for all-MiniLM-L6-v2 */
|
|
190
|
+
readonly LOCAL_DIMENSIONS: 384;
|
|
191
|
+
/** Maximum texts per batch for OpenAI */
|
|
192
|
+
readonly OPENAI_MAX_BATCH_SIZE: 2048;
|
|
193
|
+
/** Default batch size for embedding operations */
|
|
194
|
+
readonly DEFAULT_BATCH_SIZE: 100;
|
|
195
|
+
/** Whether to auto-index entities by default */
|
|
196
|
+
readonly AUTO_INDEX: false;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Semantic search configuration limits.
|
|
200
|
+
*/
|
|
201
|
+
export declare const SEMANTIC_SEARCH_LIMITS: {
|
|
202
|
+
/** Default number of results for semantic search */
|
|
203
|
+
readonly DEFAULT_LIMIT: 10;
|
|
204
|
+
/** Maximum number of results for semantic search */
|
|
205
|
+
readonly MAX_LIMIT: 100;
|
|
206
|
+
/** Minimum similarity score for results (0.0-1.0) */
|
|
207
|
+
readonly MIN_SIMILARITY: 0;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* OpenAI API configuration.
|
|
211
|
+
*/
|
|
212
|
+
export declare const OPENAI_API_CONFIG: {
|
|
213
|
+
BASE_URL: string;
|
|
214
|
+
EMBEDDINGS_ENDPOINT: string;
|
|
215
|
+
MAX_RETRIES: number;
|
|
216
|
+
INITIAL_BACKOFF_MS: number;
|
|
217
|
+
MAX_BACKOFF_MS: number;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Get embedding configuration from environment variables.
|
|
221
|
+
*
|
|
222
|
+
* @returns EmbeddingConfig object with values from environment or defaults
|
|
223
|
+
*/
|
|
224
|
+
export declare function getEmbeddingConfig(): {
|
|
225
|
+
provider: 'openai' | 'local' | 'none';
|
|
226
|
+
apiKey?: string;
|
|
227
|
+
model?: string;
|
|
228
|
+
autoIndex: boolean;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Streaming export configuration.
|
|
232
|
+
*
|
|
233
|
+
* Controls when to use streaming mode and buffer sizes for optimal memory usage.
|
|
234
|
+
*/
|
|
235
|
+
export declare const STREAMING_CONFIG: {
|
|
236
|
+
/** Minimum entity count to trigger streaming mode */
|
|
237
|
+
readonly STREAMING_THRESHOLD: 5000;
|
|
238
|
+
/** Chunk size for batched streaming operations */
|
|
239
|
+
readonly CHUNK_SIZE: 500;
|
|
240
|
+
/** High water mark for stream buffers (bytes) */
|
|
241
|
+
readonly HIGH_WATER_MARK: number;
|
|
242
|
+
/** Flush interval for long-running streams (ms) */
|
|
243
|
+
readonly FLUSH_INTERVAL_MS: 100;
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"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"}
|
package/dist/utils/constants.js
CHANGED
|
@@ -126,3 +126,127 @@ export const QUERY_LIMITS = {
|
|
|
126
126
|
/** Maximum query string length */
|
|
127
127
|
MAX_QUERY_LENGTH: 5000,
|
|
128
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Brotli compression configuration constants.
|
|
131
|
+
* Brotli is built into Node.js >=11.7.0 via the zlib module.
|
|
132
|
+
* No external dependencies required.
|
|
133
|
+
*
|
|
134
|
+
* Quality levels determine compression ratio vs speed tradeoff:
|
|
135
|
+
* - Lower values (0-4): Faster compression, lower ratio
|
|
136
|
+
* - Higher values (9-11): Slower compression, higher ratio
|
|
137
|
+
*/
|
|
138
|
+
export const COMPRESSION_CONFIG = {
|
|
139
|
+
// Quality levels (0-11)
|
|
140
|
+
/** Fast compression for real-time entity writes (quality 4) */
|
|
141
|
+
BROTLI_QUALITY_REALTIME: 4,
|
|
142
|
+
/** Balanced compression for exports and imports (quality 6) */
|
|
143
|
+
BROTLI_QUALITY_BATCH: 6,
|
|
144
|
+
/** Maximum compression for backups and archives (quality 11) */
|
|
145
|
+
BROTLI_QUALITY_ARCHIVE: 11,
|
|
146
|
+
/** Fast decompress for cache compression (quality 5) */
|
|
147
|
+
BROTLI_QUALITY_CACHE: 5,
|
|
148
|
+
// Auto-compression thresholds (in bytes)
|
|
149
|
+
/** Auto-compress exports larger than 100KB */
|
|
150
|
+
AUTO_COMPRESS_EXPORT_SIZE: 100 * 1024,
|
|
151
|
+
/** Auto-compress MCP responses larger than 256KB */
|
|
152
|
+
AUTO_COMPRESS_RESPONSE_SIZE: 256 * 1024,
|
|
153
|
+
/** Always compress backups by default */
|
|
154
|
+
AUTO_COMPRESS_BACKUP: true,
|
|
155
|
+
// File extension for compressed files
|
|
156
|
+
/** Brotli compressed file extension */
|
|
157
|
+
BROTLI_EXTENSION: '.br',
|
|
158
|
+
// Performance tuning
|
|
159
|
+
/** Chunk size for streaming compression (64KB) */
|
|
160
|
+
COMPRESSION_CHUNK_SIZE: 65536,
|
|
161
|
+
/** Default window size for brotli (lgwin parameter) */
|
|
162
|
+
COMPRESSION_WINDOW_SIZE: 22,
|
|
163
|
+
};
|
|
164
|
+
// ==================== Semantic Search Configuration (Phase 4 Sprint 10-12) ====================
|
|
165
|
+
/**
|
|
166
|
+
* Environment variable names for embedding configuration.
|
|
167
|
+
*/
|
|
168
|
+
export const EMBEDDING_ENV_VARS = {
|
|
169
|
+
/** Embedding provider: 'openai', 'local', or 'none' (default: 'none') */
|
|
170
|
+
PROVIDER: 'MEMORY_EMBEDDING_PROVIDER',
|
|
171
|
+
/** OpenAI API key (required when provider is 'openai') */
|
|
172
|
+
OPENAI_API_KEY: 'MEMORY_OPENAI_API_KEY',
|
|
173
|
+
/** Optional model override for the embedding service */
|
|
174
|
+
MODEL: 'MEMORY_EMBEDDING_MODEL',
|
|
175
|
+
/** Auto-index entities on creation: 'true' or 'false' (default: 'false') */
|
|
176
|
+
AUTO_INDEX: 'MEMORY_AUTO_INDEX_EMBEDDINGS',
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Default embedding configuration values.
|
|
180
|
+
*/
|
|
181
|
+
export const EMBEDDING_DEFAULTS = {
|
|
182
|
+
/** Default provider (disabled by default) */
|
|
183
|
+
PROVIDER: 'none',
|
|
184
|
+
/** Default OpenAI model for embeddings (1536 dimensions) */
|
|
185
|
+
OPENAI_MODEL: 'text-embedding-3-small',
|
|
186
|
+
/** Default local model for embeddings (384 dimensions) */
|
|
187
|
+
LOCAL_MODEL: 'Xenova/all-MiniLM-L6-v2',
|
|
188
|
+
/** OpenAI embedding dimensions for text-embedding-3-small */
|
|
189
|
+
OPENAI_DIMENSIONS: 1536,
|
|
190
|
+
/** Local embedding dimensions for all-MiniLM-L6-v2 */
|
|
191
|
+
LOCAL_DIMENSIONS: 384,
|
|
192
|
+
/** Maximum texts per batch for OpenAI */
|
|
193
|
+
OPENAI_MAX_BATCH_SIZE: 2048,
|
|
194
|
+
/** Default batch size for embedding operations */
|
|
195
|
+
DEFAULT_BATCH_SIZE: 100,
|
|
196
|
+
/** Whether to auto-index entities by default */
|
|
197
|
+
AUTO_INDEX: false,
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Semantic search configuration limits.
|
|
201
|
+
*/
|
|
202
|
+
export const SEMANTIC_SEARCH_LIMITS = {
|
|
203
|
+
/** Default number of results for semantic search */
|
|
204
|
+
DEFAULT_LIMIT: 10,
|
|
205
|
+
/** Maximum number of results for semantic search */
|
|
206
|
+
MAX_LIMIT: 100,
|
|
207
|
+
/** Minimum similarity score for results (0.0-1.0) */
|
|
208
|
+
MIN_SIMILARITY: 0.0,
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* OpenAI API configuration.
|
|
212
|
+
*/
|
|
213
|
+
export const OPENAI_API_CONFIG = {
|
|
214
|
+
/** Base URL for OpenAI API */
|
|
215
|
+
BASE_URL: 'https://api.openai.com/v1',
|
|
216
|
+
/** Embeddings endpoint */
|
|
217
|
+
EMBEDDINGS_ENDPOINT: '/embeddings',
|
|
218
|
+
/** Maximum retries for rate limiting */
|
|
219
|
+
MAX_RETRIES: 3,
|
|
220
|
+
/** Initial backoff delay in milliseconds */
|
|
221
|
+
INITIAL_BACKOFF_MS: 1000,
|
|
222
|
+
/** Maximum backoff delay in milliseconds */
|
|
223
|
+
MAX_BACKOFF_MS: 10000,
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Get embedding configuration from environment variables.
|
|
227
|
+
*
|
|
228
|
+
* @returns EmbeddingConfig object with values from environment or defaults
|
|
229
|
+
*/
|
|
230
|
+
export function getEmbeddingConfig() {
|
|
231
|
+
const provider = (process.env[EMBEDDING_ENV_VARS.PROVIDER] || EMBEDDING_DEFAULTS.PROVIDER);
|
|
232
|
+
const apiKey = process.env[EMBEDDING_ENV_VARS.OPENAI_API_KEY];
|
|
233
|
+
const model = process.env[EMBEDDING_ENV_VARS.MODEL];
|
|
234
|
+
const autoIndex = process.env[EMBEDDING_ENV_VARS.AUTO_INDEX] === 'true';
|
|
235
|
+
return { provider, apiKey, model, autoIndex };
|
|
236
|
+
}
|
|
237
|
+
// ==================== Streaming Export Configuration (Phase 7 Sprint 1) ====================
|
|
238
|
+
/**
|
|
239
|
+
* Streaming export configuration.
|
|
240
|
+
*
|
|
241
|
+
* Controls when to use streaming mode and buffer sizes for optimal memory usage.
|
|
242
|
+
*/
|
|
243
|
+
export const STREAMING_CONFIG = {
|
|
244
|
+
/** Minimum entity count to trigger streaming mode */
|
|
245
|
+
STREAMING_THRESHOLD: 5000,
|
|
246
|
+
/** Chunk size for batched streaming operations */
|
|
247
|
+
CHUNK_SIZE: 500,
|
|
248
|
+
/** High water mark for stream buffers (bytes) */
|
|
249
|
+
HIGH_WATER_MARK: 64 * 1024,
|
|
250
|
+
/** Flush interval for long-running streams (ms) */
|
|
251
|
+
FLUSH_INTERVAL_MS: 100,
|
|
252
|
+
};
|