@soulcraft/brainy 0.40.0 → 0.43.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/README.md +605 -194
- package/dist/augmentations/conduitAugmentations.js +1158 -0
- package/dist/augmentations/conduitAugmentations.js.map +1 -0
- package/dist/augmentations/memoryAugmentations.d.ts +2 -0
- package/dist/augmentations/memoryAugmentations.d.ts.map +1 -1
- package/dist/augmentations/memoryAugmentations.js +270 -0
- package/dist/augmentations/memoryAugmentations.js.map +1 -0
- package/dist/augmentations/serverSearchAugmentations.js +531 -0
- package/dist/augmentations/serverSearchAugmentations.js.map +1 -0
- package/dist/browserFramework.d.ts +15 -0
- package/dist/demo.d.ts +106 -0
- package/dist/examples/basicUsage.js +118 -0
- package/dist/examples/basicUsage.js.map +1 -0
- package/dist/hnsw/distributedSearch.js +452 -0
- package/dist/hnsw/distributedSearch.js.map +1 -0
- package/dist/hnsw/hnswIndex.js +602 -0
- package/dist/hnsw/hnswIndex.js.map +1 -0
- package/dist/hnsw/hnswIndexOptimized.js +471 -0
- package/dist/hnsw/hnswIndexOptimized.js.map +1 -0
- package/dist/hnsw/optimizedHNSWIndex.js +313 -0
- package/dist/hnsw/optimizedHNSWIndex.js.map +1 -0
- package/dist/hnsw/partitionedHNSWIndex.js +304 -0
- package/dist/hnsw/partitionedHNSWIndex.js.map +1 -0
- package/dist/hnsw/scaledHNSWSystem.js +559 -0
- package/dist/hnsw/scaledHNSWSystem.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +81 -0
- package/dist/mcp/brainyMCPAdapter.js +142 -0
- package/dist/mcp/brainyMCPAdapter.js.map +1 -0
- package/dist/mcp/brainyMCPService.js +248 -0
- package/dist/mcp/brainyMCPService.js.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcpAugmentationToolset.js +180 -0
- package/dist/mcp/mcpAugmentationToolset.js.map +1 -0
- package/dist/storage/adapters/baseStorageAdapter.js +349 -0
- package/dist/storage/adapters/baseStorageAdapter.js.map +1 -0
- package/dist/storage/adapters/batchS3Operations.js +287 -0
- package/dist/storage/adapters/batchS3Operations.js.map +1 -0
- package/dist/storage/adapters/fileSystemStorage.js +846 -0
- package/dist/storage/adapters/fileSystemStorage.js.map +1 -0
- package/dist/storage/adapters/memoryStorage.js +532 -0
- package/dist/storage/adapters/memoryStorage.js.map +1 -0
- package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
- package/dist/storage/adapters/opfsStorage.js +1118 -0
- package/dist/storage/adapters/opfsStorage.js.map +1 -0
- package/dist/storage/adapters/optimizedS3Search.d.ts +79 -0
- package/dist/storage/adapters/optimizedS3Search.d.ts.map +1 -0
- package/dist/storage/adapters/optimizedS3Search.js +248 -0
- package/dist/storage/adapters/optimizedS3Search.js.map +1 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +21 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.js +2026 -0
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -0
- package/dist/storage/baseStorage.d.ts +1 -0
- package/dist/storage/baseStorage.d.ts.map +1 -1
- package/dist/storage/baseStorage.js +603 -0
- package/dist/storage/baseStorage.js.map +1 -0
- package/dist/storage/cacheManager.js +1306 -0
- package/dist/storage/cacheManager.js.map +1 -0
- package/dist/storage/enhancedCacheManager.js +520 -0
- package/dist/storage/enhancedCacheManager.js.map +1 -0
- package/dist/storage/readOnlyOptimizations.js +425 -0
- package/dist/storage/readOnlyOptimizations.js.map +1 -0
- package/dist/storage/storageFactory.d.ts +0 -1
- package/dist/storage/storageFactory.d.ts.map +1 -1
- package/dist/storage/storageFactory.js +227 -0
- package/dist/storage/storageFactory.js.map +1 -0
- package/dist/types/augmentations.js +16 -0
- package/dist/types/augmentations.js.map +1 -0
- package/dist/types/brainyDataInterface.js +8 -0
- package/dist/types/brainyDataInterface.js.map +1 -0
- package/dist/types/distributedTypes.js +6 -0
- package/dist/types/distributedTypes.js.map +1 -0
- package/dist/types/fileSystemTypes.js +8 -0
- package/dist/types/fileSystemTypes.js.map +1 -0
- package/dist/types/graphTypes.js +247 -0
- package/dist/types/graphTypes.js.map +1 -0
- package/dist/types/mcpTypes.js +22 -0
- package/dist/types/mcpTypes.js.map +1 -0
- package/dist/types/paginationTypes.js +5 -0
- package/dist/types/paginationTypes.js.map +1 -0
- package/dist/types/pipelineTypes.js +7 -0
- package/dist/types/pipelineTypes.js.map +1 -0
- package/dist/types/tensorflowTypes.js +6 -0
- package/dist/types/tensorflowTypes.js.map +1 -0
- package/dist/unified.js +52 -128048
- package/dist/utils/autoConfiguration.js +341 -0
- package/dist/utils/autoConfiguration.js.map +1 -0
- package/dist/utils/cacheAutoConfig.js +261 -0
- package/dist/utils/cacheAutoConfig.js.map +1 -0
- package/dist/utils/crypto.js +45 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/distance.js +239 -0
- package/dist/utils/distance.js.map +1 -0
- package/dist/utils/embedding.d.ts.map +1 -1
- package/dist/utils/embedding.js +702 -0
- package/dist/utils/embedding.js.map +1 -0
- package/dist/utils/environment.js +75 -0
- package/dist/utils/environment.js.map +1 -0
- package/dist/utils/fieldNameTracking.js +90 -0
- package/dist/utils/fieldNameTracking.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/jsonProcessing.js +179 -0
- package/dist/utils/jsonProcessing.js.map +1 -0
- package/dist/utils/logger.d.ts +45 -92
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +129 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/operationUtils.js +126 -0
- package/dist/utils/operationUtils.js.map +1 -0
- package/dist/utils/robustModelLoader.d.ts +14 -0
- package/dist/utils/robustModelLoader.d.ts.map +1 -1
- package/dist/utils/robustModelLoader.js +537 -0
- package/dist/utils/robustModelLoader.js.map +1 -0
- package/dist/utils/searchCache.js +248 -0
- package/dist/utils/searchCache.js.map +1 -0
- package/dist/utils/statistics.js +25 -0
- package/dist/utils/statistics.js.map +1 -0
- package/dist/utils/statisticsCollector.js +224 -0
- package/dist/utils/statisticsCollector.js.map +1 -0
- package/dist/utils/textEncoding.js +309 -0
- package/dist/utils/textEncoding.js.map +1 -0
- package/dist/utils/typeUtils.js +40 -0
- package/dist/utils/typeUtils.js.map +1 -0
- package/dist/utils/version.d.ts +15 -3
- package/dist/utils/version.d.ts.map +1 -1
- package/dist/utils/version.js +24 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/utils/workerUtils.js +458 -0
- package/dist/utils/workerUtils.js.map +1 -0
- package/package.json +23 -15
- package/dist/brainy.js +0 -90220
- package/dist/brainy.min.js +0 -12511
- package/dist/patched-platform-node.d.ts +0 -17
- package/dist/statistics/statisticsManager.d.ts +0 -121
- package/dist/storage/fileSystemStorage.d.ts +0 -73
- package/dist/storage/fileSystemStorage.d.ts.map +0 -1
- package/dist/storage/opfsStorage.d.ts +0 -236
- package/dist/storage/opfsStorage.d.ts.map +0 -1
- package/dist/storage/s3CompatibleStorage.d.ts +0 -157
- package/dist/storage/s3CompatibleStorage.d.ts.map +0 -1
- package/dist/testing/prettyReporter.d.ts +0 -23
- package/dist/testing/prettySummaryReporter.d.ts +0 -22
- package/dist/unified.min.js +0 -16153
- package/dist/utils/environmentDetection.d.ts +0 -47
- package/dist/utils/environmentDetection.d.ts.map +0 -1
- package/dist/utils/tensorflowUtils.d.ts +0 -17
- package/dist/utils/tensorflowUtils.d.ts.map +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCPAugmentationToolset
|
|
3
|
+
*
|
|
4
|
+
* This class exposes the Brainy augmentation pipeline as tools through the Model Control Protocol (MCP).
|
|
5
|
+
* It provides methods for getting available tools and executing tools.
|
|
6
|
+
*/
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { MCP_VERSION } from '../types/mcpTypes.js';
|
|
9
|
+
import { AugmentationType } from '../types/augmentations.js';
|
|
10
|
+
// Import the augmentation pipeline
|
|
11
|
+
import { augmentationPipeline } from '../augmentationPipeline.js';
|
|
12
|
+
export class MCPAugmentationToolset {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new MCPAugmentationToolset
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
// No initialization needed
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Handles an MCP tool execution request
|
|
21
|
+
* @param request The MCP request
|
|
22
|
+
* @returns An MCP response
|
|
23
|
+
*/
|
|
24
|
+
async handleRequest(request) {
|
|
25
|
+
try {
|
|
26
|
+
const { toolName, parameters } = request;
|
|
27
|
+
// Extract the augmentation type and method from the tool name
|
|
28
|
+
// Tool names are in the format: brainy_{augmentationType}_{method}
|
|
29
|
+
const parts = toolName.split('_');
|
|
30
|
+
if (parts.length < 3 || parts[0] !== 'brainy') {
|
|
31
|
+
return this.createErrorResponse(request.requestId, 'INVALID_TOOL', `Invalid tool name: ${toolName}. Tool names should be in the format: brainy_{augmentationType}_{method}`);
|
|
32
|
+
}
|
|
33
|
+
const augmentationType = parts[1];
|
|
34
|
+
const method = parts.slice(2).join('_');
|
|
35
|
+
// Validate the augmentation type
|
|
36
|
+
if (!this.isValidAugmentationType(augmentationType)) {
|
|
37
|
+
return this.createErrorResponse(request.requestId, 'INVALID_AUGMENTATION_TYPE', `Invalid augmentation type: ${augmentationType}`);
|
|
38
|
+
}
|
|
39
|
+
// Execute the appropriate pipeline based on the augmentation type
|
|
40
|
+
const result = await this.executePipeline(augmentationType, method, parameters);
|
|
41
|
+
return this.createSuccessResponse(request.requestId, result);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return this.createErrorResponse(request.requestId, 'INTERNAL_ERROR', error instanceof Error ? error.message : String(error));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets all available tools
|
|
49
|
+
* @returns An array of MCP tools
|
|
50
|
+
*/
|
|
51
|
+
async getAvailableTools() {
|
|
52
|
+
const tools = [];
|
|
53
|
+
// Get all available augmentation types
|
|
54
|
+
const augmentationTypes = augmentationPipeline.getAvailableAugmentationTypes();
|
|
55
|
+
for (const type of augmentationTypes) {
|
|
56
|
+
// Get all augmentations of this type
|
|
57
|
+
const augmentations = augmentationPipeline.getAugmentationsByType(type);
|
|
58
|
+
for (const augmentation of augmentations) {
|
|
59
|
+
// Get all methods of this augmentation (excluding private methods and base methods)
|
|
60
|
+
const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(augmentation))
|
|
61
|
+
.filter(method => !method.startsWith('_') &&
|
|
62
|
+
method !== 'constructor' &&
|
|
63
|
+
method !== 'initialize' &&
|
|
64
|
+
method !== 'shutDown' &&
|
|
65
|
+
method !== 'getStatus' &&
|
|
66
|
+
typeof augmentation[method] === 'function');
|
|
67
|
+
// Create a tool for each method
|
|
68
|
+
for (const method of methods) {
|
|
69
|
+
tools.push(this.createToolDefinition(type, augmentation.name, method));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return tools;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a tool definition
|
|
77
|
+
* @param type The augmentation type
|
|
78
|
+
* @param augmentationName The augmentation name
|
|
79
|
+
* @param method The method name
|
|
80
|
+
* @returns An MCP tool definition
|
|
81
|
+
*/
|
|
82
|
+
createToolDefinition(type, augmentationName, method) {
|
|
83
|
+
return {
|
|
84
|
+
name: `brainy_${type}_${method}`,
|
|
85
|
+
description: `Access to Brainy's ${type} augmentation '${augmentationName}' method '${method}'`,
|
|
86
|
+
parameters: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
args: {
|
|
90
|
+
type: 'array',
|
|
91
|
+
description: `Arguments for the ${method} method`
|
|
92
|
+
},
|
|
93
|
+
options: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
description: 'Optional execution options'
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
required: ['args']
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Executes the appropriate pipeline based on the augmentation type
|
|
104
|
+
* @param type The augmentation type
|
|
105
|
+
* @param method The method to execute
|
|
106
|
+
* @param parameters The parameters for the method
|
|
107
|
+
* @returns The result of the pipeline execution
|
|
108
|
+
*/
|
|
109
|
+
async executePipeline(type, method, parameters) {
|
|
110
|
+
const { args = [], options = {} } = parameters;
|
|
111
|
+
switch (type) {
|
|
112
|
+
case AugmentationType.SENSE:
|
|
113
|
+
return await augmentationPipeline.executeSensePipeline(method, args, options);
|
|
114
|
+
case AugmentationType.CONDUIT:
|
|
115
|
+
return await augmentationPipeline.executeConduitPipeline(method, args, options);
|
|
116
|
+
case AugmentationType.COGNITION:
|
|
117
|
+
return await augmentationPipeline.executeCognitionPipeline(method, args, options);
|
|
118
|
+
case AugmentationType.MEMORY:
|
|
119
|
+
return await augmentationPipeline.executeMemoryPipeline(method, args, options);
|
|
120
|
+
case AugmentationType.PERCEPTION:
|
|
121
|
+
return await augmentationPipeline.executePerceptionPipeline(method, args, options);
|
|
122
|
+
case AugmentationType.DIALOG:
|
|
123
|
+
return await augmentationPipeline.executeDialogPipeline(method, args, options);
|
|
124
|
+
case AugmentationType.ACTIVATION:
|
|
125
|
+
return await augmentationPipeline.executeActivationPipeline(method, args, options);
|
|
126
|
+
default:
|
|
127
|
+
throw new Error(`Unsupported augmentation type: ${type}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Checks if an augmentation type is valid
|
|
132
|
+
* @param type The augmentation type to check
|
|
133
|
+
* @returns Whether the augmentation type is valid
|
|
134
|
+
*/
|
|
135
|
+
isValidAugmentationType(type) {
|
|
136
|
+
return Object.values(AugmentationType).includes(type);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a success response
|
|
140
|
+
* @param requestId The request ID
|
|
141
|
+
* @param data The response data
|
|
142
|
+
* @returns An MCP response
|
|
143
|
+
*/
|
|
144
|
+
createSuccessResponse(requestId, data) {
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
requestId,
|
|
148
|
+
version: MCP_VERSION,
|
|
149
|
+
data
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates an error response
|
|
154
|
+
* @param requestId The request ID
|
|
155
|
+
* @param code The error code
|
|
156
|
+
* @param message The error message
|
|
157
|
+
* @param details Optional error details
|
|
158
|
+
* @returns An MCP response
|
|
159
|
+
*/
|
|
160
|
+
createErrorResponse(requestId, code, message, details) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
requestId,
|
|
164
|
+
version: MCP_VERSION,
|
|
165
|
+
error: {
|
|
166
|
+
code,
|
|
167
|
+
message,
|
|
168
|
+
details
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Creates a new request ID
|
|
174
|
+
* @returns A new UUID
|
|
175
|
+
*/
|
|
176
|
+
generateRequestId() {
|
|
177
|
+
return uuidv4();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=mcpAugmentationToolset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpAugmentationToolset.js","sourceRoot":"","sources":["../../src/mcp/mcpAugmentationToolset.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAIL,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,mCAAmC;AACnC,OAAO,EAAE,oBAAoB,EAAE,M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E,IAAI,EAAE,OAAO,CAAC,CAAA;YAChF,KAAK,gBAAgB,CAAC,UAAU;gBAC9B,OAAO,MAAM,oBAAoB,CAAC,yBAAyB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;YACpF;gBACE,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,uBAAuB,CAAC,IAAY;QAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,IAAwB,CAAC,CAAA;IAC3E,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,SAAiB,EAAE,IAAS;QACxD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS;YACT,OAAO,EAAE,WAAW;YACpB,IAAI;SACL,CAAA;IACH,CAAC;IAED;;;;;;;OAOG;IACK,mBAAmB,CACzB,SAAiB,EACjB,IAAY,EACZ,OAAe,EACf,OAAa;QAEb,OAAO;YACL,OAAO,EAAE,KAAK;YACd,SAAS;YACT,OAAO,EAAE,WAAW;YACpB,KAAK,EAAE;gBACL,IAAI;gBACJ,OAAO;gBACP,OAAO;aACR;SACF,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,iBAAiB;QACf,OAAO,MAAM,EAAE,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Storage Adapter
|
|
3
|
+
* Provides common functionality for all storage adapters, including statistics tracking
|
|
4
|
+
*/
|
|
5
|
+
import { extractFieldNamesFromJson, mapToStandardField } from '../../utils/fieldNameTracking.js';
|
|
6
|
+
/**
|
|
7
|
+
* Base class for storage adapters that implements statistics tracking
|
|
8
|
+
*/
|
|
9
|
+
export class BaseStorageAdapter {
|
|
10
|
+
constructor() {
|
|
11
|
+
// Statistics cache
|
|
12
|
+
this.statisticsCache = null;
|
|
13
|
+
// Batch update timer ID
|
|
14
|
+
this.statisticsBatchUpdateTimerId = null;
|
|
15
|
+
// Flag to indicate if statistics have been modified since last save
|
|
16
|
+
this.statisticsModified = false;
|
|
17
|
+
// Time of last statistics flush to storage
|
|
18
|
+
this.lastStatisticsFlushTime = 0;
|
|
19
|
+
// Minimum time between statistics flushes (5 seconds)
|
|
20
|
+
this.MIN_FLUSH_INTERVAL_MS = 5000;
|
|
21
|
+
// Maximum time to wait before flushing statistics (30 seconds)
|
|
22
|
+
this.MAX_FLUSH_DELAY_MS = 30000;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Save statistics data
|
|
26
|
+
* @param statistics The statistics data to save
|
|
27
|
+
*/
|
|
28
|
+
async saveStatistics(statistics) {
|
|
29
|
+
// Update the cache with a deep copy to avoid reference issues
|
|
30
|
+
this.statisticsCache = {
|
|
31
|
+
nounCount: { ...statistics.nounCount },
|
|
32
|
+
verbCount: { ...statistics.verbCount },
|
|
33
|
+
metadataCount: { ...statistics.metadataCount },
|
|
34
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
35
|
+
lastUpdated: statistics.lastUpdated
|
|
36
|
+
};
|
|
37
|
+
// Schedule a batch update instead of saving immediately
|
|
38
|
+
this.scheduleBatchUpdate();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get statistics data
|
|
42
|
+
* @returns Promise that resolves to the statistics data
|
|
43
|
+
*/
|
|
44
|
+
async getStatistics() {
|
|
45
|
+
// If we have cached statistics, return a deep copy
|
|
46
|
+
if (this.statisticsCache) {
|
|
47
|
+
return {
|
|
48
|
+
nounCount: { ...this.statisticsCache.nounCount },
|
|
49
|
+
verbCount: { ...this.statisticsCache.verbCount },
|
|
50
|
+
metadataCount: { ...this.statisticsCache.metadataCount },
|
|
51
|
+
hnswIndexSize: this.statisticsCache.hnswIndexSize,
|
|
52
|
+
lastUpdated: this.statisticsCache.lastUpdated
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Otherwise, get from storage
|
|
56
|
+
const statistics = await this.getStatisticsData();
|
|
57
|
+
// If we found statistics, update the cache
|
|
58
|
+
if (statistics) {
|
|
59
|
+
// Update the cache with a deep copy
|
|
60
|
+
this.statisticsCache = {
|
|
61
|
+
nounCount: { ...statistics.nounCount },
|
|
62
|
+
verbCount: { ...statistics.verbCount },
|
|
63
|
+
metadataCount: { ...statistics.metadataCount },
|
|
64
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
65
|
+
lastUpdated: statistics.lastUpdated
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return statistics;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Schedule a batch update of statistics
|
|
72
|
+
*/
|
|
73
|
+
scheduleBatchUpdate() {
|
|
74
|
+
// Mark statistics as modified
|
|
75
|
+
this.statisticsModified = true;
|
|
76
|
+
// If a timer is already set, don't set another one
|
|
77
|
+
if (this.statisticsBatchUpdateTimerId !== null) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Calculate time since last flush
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
const timeSinceLastFlush = now - this.lastStatisticsFlushTime;
|
|
83
|
+
// If we've recently flushed, wait longer before the next flush
|
|
84
|
+
const delayMs = timeSinceLastFlush < this.MIN_FLUSH_INTERVAL_MS
|
|
85
|
+
? this.MAX_FLUSH_DELAY_MS
|
|
86
|
+
: this.MIN_FLUSH_INTERVAL_MS;
|
|
87
|
+
// Schedule the batch update
|
|
88
|
+
this.statisticsBatchUpdateTimerId = setTimeout(() => {
|
|
89
|
+
this.flushStatistics();
|
|
90
|
+
}, delayMs);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Flush statistics to storage
|
|
94
|
+
*/
|
|
95
|
+
async flushStatistics() {
|
|
96
|
+
// Clear the timer
|
|
97
|
+
if (this.statisticsBatchUpdateTimerId !== null) {
|
|
98
|
+
clearTimeout(this.statisticsBatchUpdateTimerId);
|
|
99
|
+
this.statisticsBatchUpdateTimerId = null;
|
|
100
|
+
}
|
|
101
|
+
// If statistics haven't been modified, no need to flush
|
|
102
|
+
if (!this.statisticsModified || !this.statisticsCache) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
// Save the statistics to storage
|
|
107
|
+
await this.saveStatisticsData(this.statisticsCache);
|
|
108
|
+
// Update the last flush time
|
|
109
|
+
this.lastStatisticsFlushTime = Date.now();
|
|
110
|
+
// Reset the modified flag
|
|
111
|
+
this.statisticsModified = false;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.error('Failed to flush statistics data:', error);
|
|
115
|
+
// Mark as still modified so we'll try again later
|
|
116
|
+
this.statisticsModified = true;
|
|
117
|
+
// Don't throw the error to avoid disrupting the application
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Increment a statistic counter
|
|
122
|
+
* @param type The type of statistic to increment ('noun', 'verb', 'metadata')
|
|
123
|
+
* @param service The service that inserted the data
|
|
124
|
+
* @param amount The amount to increment by (default: 1)
|
|
125
|
+
*/
|
|
126
|
+
async incrementStatistic(type, service, amount = 1) {
|
|
127
|
+
// Get current statistics from cache or storage
|
|
128
|
+
let statistics = this.statisticsCache;
|
|
129
|
+
if (!statistics) {
|
|
130
|
+
statistics = await this.getStatisticsData();
|
|
131
|
+
if (!statistics) {
|
|
132
|
+
statistics = this.createDefaultStatistics();
|
|
133
|
+
}
|
|
134
|
+
// Update the cache
|
|
135
|
+
this.statisticsCache = {
|
|
136
|
+
nounCount: { ...statistics.nounCount },
|
|
137
|
+
verbCount: { ...statistics.verbCount },
|
|
138
|
+
metadataCount: { ...statistics.metadataCount },
|
|
139
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
140
|
+
lastUpdated: statistics.lastUpdated
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Increment the appropriate counter
|
|
144
|
+
const counterMap = {
|
|
145
|
+
noun: this.statisticsCache.nounCount,
|
|
146
|
+
verb: this.statisticsCache.verbCount,
|
|
147
|
+
metadata: this.statisticsCache.metadataCount
|
|
148
|
+
};
|
|
149
|
+
const counter = counterMap[type];
|
|
150
|
+
counter[service] = (counter[service] || 0) + amount;
|
|
151
|
+
// Update timestamp
|
|
152
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
153
|
+
// Schedule a batch update instead of saving immediately
|
|
154
|
+
this.scheduleBatchUpdate();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Decrement a statistic counter
|
|
158
|
+
* @param type The type of statistic to decrement ('noun', 'verb', 'metadata')
|
|
159
|
+
* @param service The service that inserted the data
|
|
160
|
+
* @param amount The amount to decrement by (default: 1)
|
|
161
|
+
*/
|
|
162
|
+
async decrementStatistic(type, service, amount = 1) {
|
|
163
|
+
// Get current statistics from cache or storage
|
|
164
|
+
let statistics = this.statisticsCache;
|
|
165
|
+
if (!statistics) {
|
|
166
|
+
statistics = await this.getStatisticsData();
|
|
167
|
+
if (!statistics) {
|
|
168
|
+
statistics = this.createDefaultStatistics();
|
|
169
|
+
}
|
|
170
|
+
// Update the cache
|
|
171
|
+
this.statisticsCache = {
|
|
172
|
+
nounCount: { ...statistics.nounCount },
|
|
173
|
+
verbCount: { ...statistics.verbCount },
|
|
174
|
+
metadataCount: { ...statistics.metadataCount },
|
|
175
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
176
|
+
lastUpdated: statistics.lastUpdated
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// Decrement the appropriate counter
|
|
180
|
+
const counterMap = {
|
|
181
|
+
noun: this.statisticsCache.nounCount,
|
|
182
|
+
verb: this.statisticsCache.verbCount,
|
|
183
|
+
metadata: this.statisticsCache.metadataCount
|
|
184
|
+
};
|
|
185
|
+
const counter = counterMap[type];
|
|
186
|
+
counter[service] = Math.max(0, (counter[service] || 0) - amount);
|
|
187
|
+
// Update timestamp
|
|
188
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
189
|
+
// Schedule a batch update instead of saving immediately
|
|
190
|
+
this.scheduleBatchUpdate();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Update the HNSW index size statistic
|
|
194
|
+
* @param size The new size of the HNSW index
|
|
195
|
+
*/
|
|
196
|
+
async updateHnswIndexSize(size) {
|
|
197
|
+
// Get current statistics from cache or storage
|
|
198
|
+
let statistics = this.statisticsCache;
|
|
199
|
+
if (!statistics) {
|
|
200
|
+
statistics = await this.getStatisticsData();
|
|
201
|
+
if (!statistics) {
|
|
202
|
+
statistics = this.createDefaultStatistics();
|
|
203
|
+
}
|
|
204
|
+
// Update the cache
|
|
205
|
+
this.statisticsCache = {
|
|
206
|
+
nounCount: { ...statistics.nounCount },
|
|
207
|
+
verbCount: { ...statistics.verbCount },
|
|
208
|
+
metadataCount: { ...statistics.metadataCount },
|
|
209
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
210
|
+
lastUpdated: statistics.lastUpdated
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
// Update HNSW index size
|
|
214
|
+
this.statisticsCache.hnswIndexSize = size;
|
|
215
|
+
// Update timestamp
|
|
216
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
217
|
+
// Schedule a batch update instead of saving immediately
|
|
218
|
+
this.scheduleBatchUpdate();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Force an immediate flush of statistics to storage
|
|
222
|
+
* This ensures that any pending statistics updates are written to persistent storage
|
|
223
|
+
*/
|
|
224
|
+
async flushStatisticsToStorage() {
|
|
225
|
+
// If there are no statistics in cache or they haven't been modified, nothing to flush
|
|
226
|
+
if (!this.statisticsCache || !this.statisticsModified) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// Call the protected flushStatistics method to immediately write to storage
|
|
230
|
+
await this.flushStatistics();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Track field names from a JSON document
|
|
234
|
+
* @param jsonDocument The JSON document to extract field names from
|
|
235
|
+
* @param service The service that inserted the data
|
|
236
|
+
*/
|
|
237
|
+
async trackFieldNames(jsonDocument, service) {
|
|
238
|
+
// Skip if not a JSON object
|
|
239
|
+
if (typeof jsonDocument !== 'object' || jsonDocument === null || Array.isArray(jsonDocument)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// Get current statistics from cache or storage
|
|
243
|
+
let statistics = this.statisticsCache;
|
|
244
|
+
if (!statistics) {
|
|
245
|
+
statistics = await this.getStatisticsData();
|
|
246
|
+
if (!statistics) {
|
|
247
|
+
statistics = this.createDefaultStatistics();
|
|
248
|
+
}
|
|
249
|
+
// Update the cache
|
|
250
|
+
this.statisticsCache = {
|
|
251
|
+
...statistics,
|
|
252
|
+
nounCount: { ...statistics.nounCount },
|
|
253
|
+
verbCount: { ...statistics.verbCount },
|
|
254
|
+
metadataCount: { ...statistics.metadataCount },
|
|
255
|
+
fieldNames: { ...statistics.fieldNames },
|
|
256
|
+
standardFieldMappings: { ...statistics.standardFieldMappings }
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
// Ensure fieldNames exists
|
|
260
|
+
if (!this.statisticsCache.fieldNames) {
|
|
261
|
+
this.statisticsCache.fieldNames = {};
|
|
262
|
+
}
|
|
263
|
+
// Ensure standardFieldMappings exists
|
|
264
|
+
if (!this.statisticsCache.standardFieldMappings) {
|
|
265
|
+
this.statisticsCache.standardFieldMappings = {};
|
|
266
|
+
}
|
|
267
|
+
// Extract field names from the JSON document
|
|
268
|
+
const fieldNames = extractFieldNamesFromJson(jsonDocument);
|
|
269
|
+
// Initialize service entry if it doesn't exist
|
|
270
|
+
if (!this.statisticsCache.fieldNames[service]) {
|
|
271
|
+
this.statisticsCache.fieldNames[service] = [];
|
|
272
|
+
}
|
|
273
|
+
// Add new field names to the service's list
|
|
274
|
+
for (const fieldName of fieldNames) {
|
|
275
|
+
if (!this.statisticsCache.fieldNames[service].includes(fieldName)) {
|
|
276
|
+
this.statisticsCache.fieldNames[service].push(fieldName);
|
|
277
|
+
}
|
|
278
|
+
// Map to standard field if possible
|
|
279
|
+
const standardField = mapToStandardField(fieldName);
|
|
280
|
+
if (standardField) {
|
|
281
|
+
// Initialize standard field entry if it doesn't exist
|
|
282
|
+
if (!this.statisticsCache.standardFieldMappings[standardField]) {
|
|
283
|
+
this.statisticsCache.standardFieldMappings[standardField] = {};
|
|
284
|
+
}
|
|
285
|
+
// Initialize service entry if it doesn't exist
|
|
286
|
+
if (!this.statisticsCache.standardFieldMappings[standardField][service]) {
|
|
287
|
+
this.statisticsCache.standardFieldMappings[standardField][service] = [];
|
|
288
|
+
}
|
|
289
|
+
// Add field name to standard field mapping if not already there
|
|
290
|
+
if (!this.statisticsCache.standardFieldMappings[standardField][service].includes(fieldName)) {
|
|
291
|
+
this.statisticsCache.standardFieldMappings[standardField][service].push(fieldName);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Update timestamp
|
|
296
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
297
|
+
// Schedule a batch update
|
|
298
|
+
this.statisticsModified = true;
|
|
299
|
+
this.scheduleBatchUpdate();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get available field names by service
|
|
303
|
+
* @returns Record of field names by service
|
|
304
|
+
*/
|
|
305
|
+
async getAvailableFieldNames() {
|
|
306
|
+
// Get current statistics from cache or storage
|
|
307
|
+
let statistics = this.statisticsCache;
|
|
308
|
+
if (!statistics) {
|
|
309
|
+
statistics = await this.getStatisticsData();
|
|
310
|
+
if (!statistics) {
|
|
311
|
+
return {};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Return field names by service
|
|
315
|
+
return statistics.fieldNames || {};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get standard field mappings
|
|
319
|
+
* @returns Record of standard field mappings
|
|
320
|
+
*/
|
|
321
|
+
async getStandardFieldMappings() {
|
|
322
|
+
// Get current statistics from cache or storage
|
|
323
|
+
let statistics = this.statisticsCache;
|
|
324
|
+
if (!statistics) {
|
|
325
|
+
statistics = await this.getStatisticsData();
|
|
326
|
+
if (!statistics) {
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Return standard field mappings
|
|
331
|
+
return statistics.standardFieldMappings || {};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Create default statistics data
|
|
335
|
+
* @returns Default statistics data
|
|
336
|
+
*/
|
|
337
|
+
createDefaultStatistics() {
|
|
338
|
+
return {
|
|
339
|
+
nounCount: {},
|
|
340
|
+
verbCount: {},
|
|
341
|
+
metadataCount: {},
|
|
342
|
+
hnswIndexSize: 0,
|
|
343
|
+
fieldNames: {},
|
|
344
|
+
standardFieldMappings: {},
|
|
345
|
+
lastUpdated: new Date().toISOString()
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=baseStorageAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseStorageAdapter.js","sourceRoot":"","sources":["../../../src/storage/adapters/baseStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAEhG;;GAEG;AACH,MAAM,OAAgB,kBAAkB;IAAxC;QA6FE,mBAAmB;QACT,oBAAe,GAA0B,IAAI,CAAA;QAEvD,wBAAwB;QACd,iCAA4B,GAA0B,IAAI,CAAA;QAEpE,oEAAoE;QAC1D,uBAAkB,GAAG,KAAK,CAAA;QAEpC,2CAA2C;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAErC,sDAAsD;QACnC,0BAAqB,GAAG,IAAI,CAAA;QAE/C,+DAA+D;QAC5C,uBAAkB,GAAG,KAAK,CAAA;IAwY/C,CAAC;IA/XC;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,UAA0B;QAC7C,8DA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