@soulcraft/brainy 3.0.0 → 3.0.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/CHANGELOG.md +53 -3
- package/README.md +353 -110
- package/bin/brainy.js +340 -62
- package/dist/api/ConfigAPI.d.ts +67 -0
- package/dist/api/ConfigAPI.js +166 -0
- package/dist/api/DataAPI.d.ts +123 -0
- package/dist/api/DataAPI.js +391 -0
- package/dist/api/SecurityAPI.d.ts +50 -0
- package/dist/api/SecurityAPI.js +139 -0
- package/dist/api/UniversalImportAPI.d.ts +134 -0
- package/dist/api/UniversalImportAPI.js +615 -0
- package/dist/augmentationManager.js +12 -7
- package/dist/augmentationPipeline.d.ts +0 -61
- package/dist/augmentationPipeline.js +0 -87
- package/dist/augmentationRegistry.d.ts +1 -1
- package/dist/augmentationRegistry.js +1 -1
- package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
- package/dist/augmentations/apiServerAugmentation.js +290 -9
- package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
- package/dist/augmentations/auditLogAugmentation.js +358 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
- package/dist/augmentations/batchProcessingAugmentation.js +123 -22
- package/dist/augmentations/brainyAugmentation.d.ts +142 -8
- package/dist/augmentations/brainyAugmentation.js +179 -2
- package/dist/augmentations/cacheAugmentation.d.ts +8 -5
- package/dist/augmentations/cacheAugmentation.js +116 -17
- package/dist/augmentations/conduitAugmentations.d.ts +2 -2
- package/dist/augmentations/conduitAugmentations.js +2 -2
- package/dist/augmentations/configResolver.d.ts +122 -0
- package/dist/augmentations/configResolver.js +440 -0
- package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
- package/dist/augmentations/connectionPoolAugmentation.js +37 -12
- package/dist/augmentations/defaultAugmentations.d.ts +14 -10
- package/dist/augmentations/defaultAugmentations.js +16 -11
- package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
- package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
- package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
- package/dist/augmentations/discovery/localDiscovery.js +246 -0
- package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
- package/dist/augmentations/discovery/runtimeLoader.js +337 -0
- package/dist/augmentations/discovery.d.ts +152 -0
- package/dist/augmentations/discovery.js +441 -0
- package/dist/augmentations/display/cache.d.ts +130 -0
- package/dist/augmentations/display/cache.js +319 -0
- package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
- package/dist/augmentations/display/fieldPatterns.js +393 -0
- package/dist/augmentations/display/iconMappings.d.ts +57 -0
- package/dist/augmentations/display/iconMappings.js +68 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
- package/dist/augmentations/display/intelligentComputation.js +462 -0
- package/dist/augmentations/display/types.d.ts +203 -0
- package/dist/augmentations/display/types.js +7 -0
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +5 -3
- package/dist/augmentations/indexAugmentation.js +5 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +24 -7
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +111 -27
- package/dist/augmentations/manifest.d.ts +176 -0
- package/dist/augmentations/manifest.js +8 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
- package/dist/augmentations/marketplace/cli.d.ts +47 -0
- package/dist/augmentations/marketplace/cli.js +265 -0
- package/dist/augmentations/metricsAugmentation.d.ts +3 -3
- package/dist/augmentations/metricsAugmentation.js +2 -2
- package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
- package/dist/augmentations/monitoringAugmentation.js +2 -2
- package/dist/augmentations/neuralImport.d.ts +1 -1
- package/dist/augmentations/neuralImport.js +4 -4
- package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
- package/dist/augmentations/rateLimitAugmentation.js +321 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
- package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
- package/dist/augmentations/storageAugmentation.d.ts +1 -1
- package/dist/augmentations/storageAugmentation.js +2 -2
- package/dist/augmentations/storageAugmentations.d.ts +37 -8
- package/dist/augmentations/storageAugmentations.js +204 -15
- package/dist/augmentations/synapseAugmentation.d.ts +1 -1
- package/dist/augmentations/synapseAugmentation.js +35 -16
- package/dist/augmentations/typeMatching/brainyTypes.d.ts +83 -0
- package/dist/augmentations/typeMatching/brainyTypes.js +425 -0
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +191 -0
- package/dist/augmentations/universalDisplayAugmentation.js +371 -0
- package/dist/brainy-unified.d.ts +106 -0
- package/dist/brainy-unified.js +327 -0
- package/dist/brainy.d.ts +273 -0
- package/dist/brainy.js +1181 -0
- package/dist/brainyData.d.ts +56 -111
- package/dist/brainyData.js +912 -756
- package/dist/brainyDataV3.d.ts +186 -0
- package/dist/brainyDataV3.js +337 -0
- package/dist/browserFramework.d.ts +6 -6
- package/dist/browserFramework.js +11 -8
- package/dist/browserFramework.minimal.d.ts +5 -5
- package/dist/browserFramework.minimal.js +11 -8
- package/dist/config/distributedPresets-new.d.ts +118 -0
- package/dist/config/distributedPresets-new.js +318 -0
- package/dist/config/distributedPresets.d.ts +118 -0
- package/dist/config/distributedPresets.js +318 -0
- package/dist/config/extensibleConfig.d.ts +99 -0
- package/dist/config/extensibleConfig.js +268 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +35 -0
- package/dist/config/modelAutoConfig.d.ts +32 -0
- package/dist/config/modelAutoConfig.js +139 -0
- package/dist/config/modelPrecisionManager.d.ts +42 -0
- package/dist/config/modelPrecisionManager.js +98 -0
- package/dist/config/sharedConfigManager.d.ts +67 -0
- package/dist/config/sharedConfigManager.js +215 -0
- package/dist/config/storageAutoConfig.d.ts +41 -0
- package/dist/config/storageAutoConfig.js +328 -0
- package/dist/config/zeroConfig.d.ts +68 -0
- package/dist/config/zeroConfig.js +301 -0
- package/dist/cortex/backupRestore.d.ts +2 -2
- package/dist/cortex/backupRestore.js +85 -27
- package/dist/cortex/healthCheck.d.ts +2 -2
- package/dist/cortex/neuralImport.d.ts +2 -2
- package/dist/cortex/neuralImport.js +18 -13
- package/dist/cortex/performanceMonitor.d.ts +2 -2
- package/dist/critical/model-guardian.d.ts +4 -0
- package/dist/critical/model-guardian.js +31 -11
- package/dist/demo.d.ts +4 -4
- package/dist/demo.js +7 -7
- package/dist/distributed/cacheSync.d.ts +112 -0
- package/dist/distributed/cacheSync.js +265 -0
- package/dist/distributed/coordinator.d.ts +193 -0
- package/dist/distributed/coordinator.js +548 -0
- package/dist/distributed/httpTransport.d.ts +120 -0
- package/dist/distributed/httpTransport.js +446 -0
- package/dist/distributed/index.d.ts +8 -0
- package/dist/distributed/index.js +5 -0
- package/dist/distributed/networkTransport.d.ts +132 -0
- package/dist/distributed/networkTransport.js +633 -0
- package/dist/distributed/queryPlanner.d.ts +104 -0
- package/dist/distributed/queryPlanner.js +327 -0
- package/dist/distributed/readWriteSeparation.d.ts +134 -0
- package/dist/distributed/readWriteSeparation.js +350 -0
- package/dist/distributed/shardManager.d.ts +114 -0
- package/dist/distributed/shardManager.js +357 -0
- package/dist/distributed/shardMigration.d.ts +110 -0
- package/dist/distributed/shardMigration.js +289 -0
- package/dist/distributed/storageDiscovery.d.ts +160 -0
- package/dist/distributed/storageDiscovery.js +551 -0
- package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
- package/dist/embeddings/CachedEmbeddings.js +146 -0
- package/dist/embeddings/EmbeddingManager.d.ts +102 -0
- package/dist/embeddings/EmbeddingManager.js +291 -0
- package/dist/embeddings/SingletonModelManager.d.ts +95 -0
- package/dist/embeddings/SingletonModelManager.js +220 -0
- package/dist/embeddings/index.d.ts +12 -0
- package/dist/embeddings/index.js +16 -0
- package/dist/embeddings/lightweight-embedder.d.ts +0 -1
- package/dist/embeddings/lightweight-embedder.js +4 -12
- package/dist/embeddings/model-manager.d.ts +11 -0
- package/dist/embeddings/model-manager.js +43 -7
- package/dist/embeddings/universal-memory-manager.d.ts +1 -1
- package/dist/embeddings/universal-memory-manager.js +27 -67
- package/dist/embeddings/worker-embedding.js +4 -8
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +7 -4
- package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
- package/dist/graph/graphAdjacencyIndex.js +288 -0
- package/dist/graph/pathfinding.js +4 -2
- package/dist/hnsw/scaledHNSWSystem.js +11 -2
- package/dist/importManager.js +8 -5
- package/dist/index.d.ts +17 -22
- package/dist/index.js +37 -23
- package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
- package/dist/mcp/brainyMCPAdapter.js +5 -5
- package/dist/mcp/brainyMCPService.d.ts +3 -3
- package/dist/mcp/brainyMCPService.js +3 -11
- package/dist/mcp/mcpAugmentationToolset.js +20 -30
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +2 -2
- package/dist/neural/entityExtractor.d.ts +65 -0
- package/dist/neural/entityExtractor.js +316 -0
- package/dist/neural/improvedNeuralAPI.d.ts +357 -0
- package/dist/neural/improvedNeuralAPI.js +2628 -0
- package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
- package/dist/neural/naturalLanguageProcessor.js +941 -66
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
- package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
- package/dist/neural/neuralAPI.js +8 -2
- package/dist/neural/patternLibrary.d.ts +57 -3
- package/dist/neural/patternLibrary.js +348 -13
- package/dist/neural/staticPatternMatcher.d.ts +2 -2
- package/dist/neural/staticPatternMatcher.js +2 -2
- package/dist/neural/types.d.ts +287 -0
- package/dist/neural/types.js +24 -0
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
- package/dist/storage/adapters/fileSystemStorage.js +218 -15
- package/dist/storage/adapters/memoryStorage.d.ts +4 -4
- package/dist/storage/adapters/memoryStorage.js +17 -12
- package/dist/storage/adapters/opfsStorage.d.ts +2 -2
- package/dist/storage/adapters/opfsStorage.js +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +18 -2
- package/dist/storage/baseStorage.js +74 -3
- package/dist/storage/cacheManager.js +2 -2
- package/dist/storage/readOnlyOptimizations.js +8 -3
- package/dist/streaming/pipeline.d.ts +154 -0
- package/dist/streaming/pipeline.js +551 -0
- package/dist/triple/TripleIntelligence.d.ts +25 -110
- package/dist/triple/TripleIntelligence.js +4 -574
- package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
- package/dist/triple/TripleIntelligenceSystem.js +519 -0
- package/dist/types/apiTypes.d.ts +278 -0
- package/dist/types/apiTypes.js +33 -0
- package/dist/types/brainy.types.d.ts +308 -0
- package/dist/types/brainy.types.js +8 -0
- package/dist/types/brainyDataInterface.d.ts +5 -8
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/brainyTypes.d.ts +217 -0
- package/dist/utils/brainyTypes.js +261 -0
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.d.ts +9 -4
- package/dist/utils/embedding.js +89 -26
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- package/dist/utils/hybridModelManager.d.ts +19 -28
- package/dist/utils/hybridModelManager.js +36 -200
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/intelligentTypeMapper.d.ts +60 -0
- package/dist/utils/intelligentTypeMapper.js +349 -0
- package/dist/utils/metadataIndex.d.ts +118 -1
- package/dist/utils/metadataIndex.js +539 -16
- package/dist/utils/nodeVersionCheck.d.ts +24 -0
- package/dist/utils/nodeVersionCheck.js +65 -0
- package/dist/utils/paramValidation.d.ts +39 -0
- package/dist/utils/paramValidation.js +192 -0
- package/dist/utils/rateLimiter.d.ts +160 -0
- package/dist/utils/rateLimiter.js +271 -0
- package/dist/utils/statistics.d.ts +4 -4
- package/dist/utils/statistics.js +3 -3
- package/dist/utils/structuredLogger.d.ts +146 -0
- package/dist/utils/structuredLogger.js +394 -0
- package/dist/utils/textEncoding.js +2 -1
- package/dist/utils/typeValidation.d.ts +59 -0
- package/dist/utils/typeValidation.js +374 -0
- package/dist/utils/version.js +19 -3
- package/package.json +15 -4
- package/scripts/download-models.cjs +94 -20
- package/dist/augmentations/walAugmentation.d.ts +0 -109
- package/dist/augmentations/walAugmentation.js +0 -516
- package/dist/chat/BrainyChat.d.ts +0 -121
- package/dist/chat/BrainyChat.js +0 -396
- package/dist/chat/ChatCLI.d.ts +0 -61
- package/dist/chat/ChatCLI.js +0 -351
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* Each augmentation knows its place and when to execute automatically.
|
|
6
6
|
*
|
|
7
7
|
* The Vision: Components that enhance Brainy's capabilities seamlessly
|
|
8
|
-
* - WAL: Adds durability to storage operations
|
|
9
8
|
* - RequestDeduplicator: Prevents duplicate concurrent requests
|
|
10
9
|
* - ConnectionPool: Optimizes cloud storage throughput
|
|
11
10
|
* - IntelligentVerbScoring: Enhances relationship analysis
|
|
12
11
|
* - StreamingPipeline: Enables unlimited data processing
|
|
13
12
|
*/
|
|
13
|
+
import { AugmentationManifest } from './manifest.js';
|
|
14
14
|
/**
|
|
15
15
|
* Metadata access declaration for augmentations
|
|
16
16
|
*/
|
|
@@ -43,10 +43,10 @@ export interface BrainyAugmentation {
|
|
|
43
43
|
* Which operations this augmentation applies to
|
|
44
44
|
* Granular operation matching for precise augmentation targeting
|
|
45
45
|
*/
|
|
46
|
-
operations: ('add' | 'addNoun' | 'addVerb' | 'saveNoun' | 'saveVerb' | 'updateMetadata' | 'delete' | 'deleteVerb' | 'clear' | 'get' | 'search' | 'searchText' | 'searchByNounTypes' | 'findSimilar' | 'searchWithCursor' | 'relate' | 'getConnections' | 'storage' | 'backup' | 'restore' | 'all')[];
|
|
46
|
+
operations: ('add' | 'addNoun' | 'addVerb' | 'saveNoun' | 'saveVerb' | 'updateMetadata' | 'update' | 'delete' | 'deleteVerb' | 'clear' | 'get' | 'search' | 'searchText' | 'searchByNounTypes' | 'find' | 'findSimilar' | 'searchWithCursor' | 'similar' | 'relate' | 'unrelate' | 'getConnections' | 'getRelations' | 'storage' | 'backup' | 'restore' | 'all')[];
|
|
47
47
|
/**
|
|
48
48
|
* Priority for execution order (higher numbers execute first)
|
|
49
|
-
* - 100: Critical system operations (
|
|
49
|
+
* - 100: Critical system operations (ConnectionPool)
|
|
50
50
|
* - 50: Performance optimizations (RequestDeduplicator, Caching)
|
|
51
51
|
* - 10: Enhancement features (IntelligentVerbScoring)
|
|
52
52
|
* - 1: Optional features (Logging, Analytics)
|
|
@@ -54,9 +54,9 @@ export interface BrainyAugmentation {
|
|
|
54
54
|
priority: number;
|
|
55
55
|
/**
|
|
56
56
|
* Initialize the augmentation
|
|
57
|
-
* Called once during
|
|
57
|
+
* Called once during Brainy initialization
|
|
58
58
|
*
|
|
59
|
-
* @param context - The
|
|
59
|
+
* @param context - The Brainy instance and storage
|
|
60
60
|
*/
|
|
61
61
|
initialize(context: AugmentationContext): Promise<void>;
|
|
62
62
|
/**
|
|
@@ -74,16 +74,38 @@ export interface BrainyAugmentation {
|
|
|
74
74
|
*/
|
|
75
75
|
shouldExecute?(operation: string, params: any): boolean;
|
|
76
76
|
/**
|
|
77
|
-
* Optional: Cleanup when
|
|
77
|
+
* Optional: Cleanup when Brainy is destroyed
|
|
78
78
|
*/
|
|
79
79
|
shutdown?(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Optional: Computed fields this augmentation provides
|
|
82
|
+
* Used for discovery, TypeScript support, and API documentation
|
|
83
|
+
*/
|
|
84
|
+
computedFields?: {
|
|
85
|
+
[namespace: string]: {
|
|
86
|
+
[field: string]: {
|
|
87
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
88
|
+
description: string;
|
|
89
|
+
confidence?: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Optional: Compute fields for a result entity
|
|
95
|
+
* Called when user accesses getDisplay(), getSchema(), etc.
|
|
96
|
+
*
|
|
97
|
+
* @param result - The result entity (VectorDocument, GraphVerb, etc.)
|
|
98
|
+
* @param namespace - The namespace being requested ('display', 'schema', etc.)
|
|
99
|
+
* @returns Computed fields for the namespace
|
|
100
|
+
*/
|
|
101
|
+
computeFields?(result: any, namespace: string): Promise<Record<string, any>> | Record<string, any>;
|
|
80
102
|
}
|
|
81
103
|
/**
|
|
82
104
|
* Context provided to augmentations
|
|
83
105
|
*/
|
|
84
106
|
export interface AugmentationContext {
|
|
85
107
|
/**
|
|
86
|
-
* The
|
|
108
|
+
* The Brainy instance (for accessing methods and config)
|
|
87
109
|
*/
|
|
88
110
|
brain: any;
|
|
89
111
|
/**
|
|
@@ -101,15 +123,69 @@ export interface AugmentationContext {
|
|
|
101
123
|
}
|
|
102
124
|
/**
|
|
103
125
|
* Base class for augmentations with common functionality
|
|
126
|
+
*
|
|
127
|
+
* This is the unified base class that combines the features of both
|
|
128
|
+
* BaseAugmentation and ConfigurableAugmentation. All augmentations
|
|
129
|
+
* should extend this class for consistent configuration support.
|
|
104
130
|
*/
|
|
105
131
|
export declare abstract class BaseAugmentation implements BrainyAugmentation {
|
|
106
132
|
abstract name: string;
|
|
107
133
|
abstract timing: 'before' | 'after' | 'around' | 'replace';
|
|
108
134
|
abstract metadata: 'none' | 'readonly' | MetadataAccess;
|
|
109
|
-
abstract operations: ('add' | 'addNoun' | 'addVerb' | 'saveNoun' | 'saveVerb' | 'updateMetadata' | 'delete' | 'deleteVerb' | 'clear' | 'get' | 'search' | 'searchText' | 'searchByNounTypes' | 'findSimilar' | 'searchWithCursor' | 'relate' | 'getConnections' | 'storage' | 'backup' | 'restore' | 'all')[];
|
|
135
|
+
abstract operations: ('add' | 'addNoun' | 'addVerb' | 'saveNoun' | 'saveVerb' | 'updateMetadata' | 'update' | 'delete' | 'deleteVerb' | 'clear' | 'get' | 'search' | 'searchText' | 'searchByNounTypes' | 'find' | 'findSimilar' | 'searchWithCursor' | 'similar' | 'relate' | 'unrelate' | 'getConnections' | 'getRelations' | 'storage' | 'backup' | 'restore' | 'all')[];
|
|
110
136
|
abstract priority: number;
|
|
137
|
+
category: 'internal' | 'core' | 'premium' | 'community' | 'external';
|
|
138
|
+
description: string;
|
|
139
|
+
enabled: boolean;
|
|
111
140
|
protected context?: AugmentationContext;
|
|
112
141
|
protected isInitialized: boolean;
|
|
142
|
+
protected config: any;
|
|
143
|
+
private configResolver?;
|
|
144
|
+
/**
|
|
145
|
+
* Constructor with optional configuration
|
|
146
|
+
* @param config Optional configuration to override defaults
|
|
147
|
+
*/
|
|
148
|
+
constructor(config?: any);
|
|
149
|
+
/**
|
|
150
|
+
* Get the augmentation manifest for discovery
|
|
151
|
+
* Override this to enable configuration support
|
|
152
|
+
* CRITICAL: This enables tools to discover parameters and configuration
|
|
153
|
+
*/
|
|
154
|
+
getManifest?(): AugmentationManifest;
|
|
155
|
+
/**
|
|
156
|
+
* Get parameter schema for operations
|
|
157
|
+
* Enables tools to know what parameters each operation needs
|
|
158
|
+
*/
|
|
159
|
+
getParameterSchema?(operation: string): any;
|
|
160
|
+
/**
|
|
161
|
+
* Get operation descriptions
|
|
162
|
+
* Enables tools to show what each operation does
|
|
163
|
+
*/
|
|
164
|
+
getOperationInfo?(): Record<string, {
|
|
165
|
+
description: string;
|
|
166
|
+
parameters?: any;
|
|
167
|
+
returns?: any;
|
|
168
|
+
examples?: any[];
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* Get current configuration
|
|
172
|
+
*/
|
|
173
|
+
getConfig(): any;
|
|
174
|
+
/**
|
|
175
|
+
* Update configuration at runtime
|
|
176
|
+
* @param partial Partial configuration to merge
|
|
177
|
+
*/
|
|
178
|
+
updateConfig(partial: any): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Optional: Handle configuration changes
|
|
181
|
+
* Override this to react to runtime configuration updates
|
|
182
|
+
*/
|
|
183
|
+
protected onConfigChange?(newConfig: any, oldConfig: any): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Resolve configuration from all sources
|
|
186
|
+
* Priority: constructor > env > files > defaults
|
|
187
|
+
*/
|
|
188
|
+
private resolveConfiguration;
|
|
113
189
|
initialize(context: AugmentationContext): Promise<void>;
|
|
114
190
|
/**
|
|
115
191
|
* Override this in subclasses for initialization logic
|
|
@@ -122,11 +198,36 @@ export declare abstract class BaseAugmentation implements BrainyAugmentation {
|
|
|
122
198
|
* Override this in subclasses for cleanup logic
|
|
123
199
|
*/
|
|
124
200
|
protected onShutdown(): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Optional computed fields declaration (override in subclasses)
|
|
203
|
+
*/
|
|
204
|
+
computedFields?: {
|
|
205
|
+
[namespace: string]: {
|
|
206
|
+
[field: string]: {
|
|
207
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
208
|
+
description: string;
|
|
209
|
+
confidence?: number;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Optional computed fields implementation (override in subclasses)
|
|
215
|
+
* @param result The result entity
|
|
216
|
+
* @param namespace The requested namespace
|
|
217
|
+
* @returns Computed fields for the namespace
|
|
218
|
+
*/
|
|
219
|
+
computeFields?(result: any, namespace: string): Promise<Record<string, any>> | Record<string, any>;
|
|
125
220
|
/**
|
|
126
221
|
* Log a message with the augmentation name
|
|
127
222
|
*/
|
|
128
223
|
protected log(message: string, level?: 'info' | 'warn' | 'error'): void;
|
|
129
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Alias for backward compatibility
|
|
227
|
+
* ConfigurableAugmentation is now merged into BaseAugmentation
|
|
228
|
+
* @deprecated Use BaseAugmentation instead
|
|
229
|
+
*/
|
|
230
|
+
export declare const ConfigurableAugmentation: typeof BaseAugmentation;
|
|
130
231
|
/**
|
|
131
232
|
* Registry for managing augmentations
|
|
132
233
|
*/
|
|
@@ -158,10 +259,43 @@ export declare class AugmentationRegistry {
|
|
|
158
259
|
* Get all registered augmentations
|
|
159
260
|
*/
|
|
160
261
|
getAll(): BrainyAugmentation[];
|
|
262
|
+
/**
|
|
263
|
+
* Get augmentation info for listing
|
|
264
|
+
*/
|
|
265
|
+
getInfo(): Array<{
|
|
266
|
+
name: string;
|
|
267
|
+
type: string;
|
|
268
|
+
enabled: boolean;
|
|
269
|
+
description: string;
|
|
270
|
+
category: string;
|
|
271
|
+
priority: number;
|
|
272
|
+
}>;
|
|
161
273
|
/**
|
|
162
274
|
* Get augmentations by name
|
|
163
275
|
*/
|
|
164
276
|
get(name: string): BrainyAugmentation | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Discover augmentation parameters and schemas
|
|
279
|
+
* Critical for tools like brain-cloud to generate UIs
|
|
280
|
+
*/
|
|
281
|
+
discover(name?: string): any;
|
|
282
|
+
/**
|
|
283
|
+
* Get configuration schema for an augmentation
|
|
284
|
+
* Enables UI generation for configuration
|
|
285
|
+
*/
|
|
286
|
+
getConfigSchema(name: string): any;
|
|
287
|
+
/**
|
|
288
|
+
* Configure an augmentation at runtime
|
|
289
|
+
*/
|
|
290
|
+
configure(name: string, config: any): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Get metrics for an augmentation
|
|
293
|
+
*/
|
|
294
|
+
metrics(name?: string): any;
|
|
295
|
+
/**
|
|
296
|
+
* Get health status
|
|
297
|
+
*/
|
|
298
|
+
health(): any;
|
|
165
299
|
/**
|
|
166
300
|
* Shutdown all augmentations
|
|
167
301
|
*/
|
|
@@ -5,18 +5,89 @@
|
|
|
5
5
|
* Each augmentation knows its place and when to execute automatically.
|
|
6
6
|
*
|
|
7
7
|
* The Vision: Components that enhance Brainy's capabilities seamlessly
|
|
8
|
-
* - WAL: Adds durability to storage operations
|
|
9
8
|
* - RequestDeduplicator: Prevents duplicate concurrent requests
|
|
10
9
|
* - ConnectionPool: Optimizes cloud storage throughput
|
|
11
10
|
* - IntelligentVerbScoring: Enhances relationship analysis
|
|
12
11
|
* - StreamingPipeline: Enables unlimited data processing
|
|
13
12
|
*/
|
|
13
|
+
import { AugmentationConfigResolver } from './configResolver.js';
|
|
14
14
|
/**
|
|
15
15
|
* Base class for augmentations with common functionality
|
|
16
|
+
*
|
|
17
|
+
* This is the unified base class that combines the features of both
|
|
18
|
+
* BaseAugmentation and ConfigurableAugmentation. All augmentations
|
|
19
|
+
* should extend this class for consistent configuration support.
|
|
16
20
|
*/
|
|
17
21
|
export class BaseAugmentation {
|
|
18
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Constructor with optional configuration
|
|
24
|
+
* @param config Optional configuration to override defaults
|
|
25
|
+
*/
|
|
26
|
+
constructor(config) {
|
|
27
|
+
// Metadata for augmentation listing and management
|
|
28
|
+
this.category = 'core';
|
|
29
|
+
this.description = '';
|
|
30
|
+
this.enabled = true;
|
|
19
31
|
this.isInitialized = false;
|
|
32
|
+
this.config = {};
|
|
33
|
+
// Only resolve configuration if getManifest is implemented
|
|
34
|
+
if (this.getManifest) {
|
|
35
|
+
this.config = this.resolveConfiguration(config);
|
|
36
|
+
}
|
|
37
|
+
else if (config) {
|
|
38
|
+
// Legacy support: direct config assignment for augmentations without manifests
|
|
39
|
+
this.config = config;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get current configuration
|
|
44
|
+
*/
|
|
45
|
+
getConfig() {
|
|
46
|
+
return { ...this.config };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update configuration at runtime
|
|
50
|
+
* @param partial Partial configuration to merge
|
|
51
|
+
*/
|
|
52
|
+
async updateConfig(partial) {
|
|
53
|
+
if (!this.configResolver) {
|
|
54
|
+
// For legacy augmentations without manifest, just merge config
|
|
55
|
+
const oldConfig = this.config;
|
|
56
|
+
this.config = { ...this.config, ...partial };
|
|
57
|
+
if (this.onConfigChange) {
|
|
58
|
+
await this.onConfigChange(this.config, oldConfig);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const oldConfig = this.config;
|
|
63
|
+
try {
|
|
64
|
+
// Use resolver to update and validate
|
|
65
|
+
this.config = this.configResolver.updateRuntime(partial);
|
|
66
|
+
// Call config change handler if implemented
|
|
67
|
+
if (this.onConfigChange) {
|
|
68
|
+
await this.onConfigChange(this.config, oldConfig);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// Revert on error
|
|
73
|
+
this.config = oldConfig;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Resolve configuration from all sources
|
|
79
|
+
* Priority: constructor > env > files > defaults
|
|
80
|
+
*/
|
|
81
|
+
resolveConfiguration(constructorConfig) {
|
|
82
|
+
const manifest = this.getManifest();
|
|
83
|
+
// Create config resolver
|
|
84
|
+
this.configResolver = new AugmentationConfigResolver({
|
|
85
|
+
augmentationId: manifest.id,
|
|
86
|
+
schema: manifest.configSchema,
|
|
87
|
+
defaults: manifest.configDefaults
|
|
88
|
+
});
|
|
89
|
+
// Resolve configuration from all sources
|
|
90
|
+
return this.configResolver.resolve(constructorConfig);
|
|
20
91
|
}
|
|
21
92
|
async initialize(context) {
|
|
22
93
|
this.context = context;
|
|
@@ -54,6 +125,12 @@ export class BaseAugmentation {
|
|
|
54
125
|
}
|
|
55
126
|
}
|
|
56
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Alias for backward compatibility
|
|
130
|
+
* ConfigurableAugmentation is now merged into BaseAugmentation
|
|
131
|
+
* @deprecated Use BaseAugmentation instead
|
|
132
|
+
*/
|
|
133
|
+
export const ConfigurableAugmentation = BaseAugmentation;
|
|
57
134
|
/**
|
|
58
135
|
* Registry for managing augmentations
|
|
59
136
|
*/
|
|
@@ -124,12 +201,112 @@ export class AugmentationRegistry {
|
|
|
124
201
|
getAll() {
|
|
125
202
|
return [...this.augmentations];
|
|
126
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Get augmentation info for listing
|
|
206
|
+
*/
|
|
207
|
+
getInfo() {
|
|
208
|
+
return this.augmentations.map(aug => {
|
|
209
|
+
const baseAug = aug;
|
|
210
|
+
return {
|
|
211
|
+
name: aug.name,
|
|
212
|
+
type: baseAug.category || 'core',
|
|
213
|
+
enabled: baseAug.enabled !== false,
|
|
214
|
+
description: baseAug.description || `${aug.name} augmentation`,
|
|
215
|
+
category: baseAug.category || 'core',
|
|
216
|
+
priority: aug.priority
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
127
220
|
/**
|
|
128
221
|
* Get augmentations by name
|
|
129
222
|
*/
|
|
130
223
|
get(name) {
|
|
131
224
|
return this.augmentations.find(aug => aug.name === name);
|
|
132
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Discover augmentation parameters and schemas
|
|
228
|
+
* Critical for tools like brain-cloud to generate UIs
|
|
229
|
+
*/
|
|
230
|
+
discover(name) {
|
|
231
|
+
if (name) {
|
|
232
|
+
const aug = this.get(name);
|
|
233
|
+
if (!aug)
|
|
234
|
+
return null;
|
|
235
|
+
const baseAug = aug;
|
|
236
|
+
return {
|
|
237
|
+
name: aug.name,
|
|
238
|
+
operations: aug.operations,
|
|
239
|
+
priority: aug.priority,
|
|
240
|
+
timing: aug.timing,
|
|
241
|
+
metadata: aug.metadata,
|
|
242
|
+
manifest: baseAug.getManifest ? baseAug.getManifest() : undefined,
|
|
243
|
+
parameters: baseAug.getParameterSchema ?
|
|
244
|
+
aug.operations.reduce((acc, op) => {
|
|
245
|
+
acc[op] = baseAug.getParameterSchema(op);
|
|
246
|
+
return acc;
|
|
247
|
+
}, {}) : undefined,
|
|
248
|
+
operationInfo: baseAug.getOperationInfo ? baseAug.getOperationInfo() : undefined,
|
|
249
|
+
config: baseAug.getConfig ? baseAug.getConfig() : undefined
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// Return all augmentations discovery info
|
|
253
|
+
return this.augmentations.map(aug => this.discover(aug.name));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get configuration schema for an augmentation
|
|
257
|
+
* Enables UI generation for configuration
|
|
258
|
+
*/
|
|
259
|
+
getConfigSchema(name) {
|
|
260
|
+
const aug = this.get(name);
|
|
261
|
+
if (!aug || !aug.getManifest)
|
|
262
|
+
return null;
|
|
263
|
+
const manifest = aug.getManifest();
|
|
264
|
+
return manifest?.configSchema;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Configure an augmentation at runtime
|
|
268
|
+
*/
|
|
269
|
+
async configure(name, config) {
|
|
270
|
+
const aug = this.get(name);
|
|
271
|
+
if (!aug || !aug.updateConfig) {
|
|
272
|
+
throw new Error(`Augmentation ${name} does not support configuration`);
|
|
273
|
+
}
|
|
274
|
+
await aug.updateConfig(config);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get metrics for an augmentation
|
|
278
|
+
*/
|
|
279
|
+
metrics(name) {
|
|
280
|
+
if (name) {
|
|
281
|
+
const aug = this.get(name);
|
|
282
|
+
if (!aug || !aug.metrics)
|
|
283
|
+
return null;
|
|
284
|
+
return aug.metrics();
|
|
285
|
+
}
|
|
286
|
+
// Return all metrics
|
|
287
|
+
const allMetrics = {};
|
|
288
|
+
for (const aug of this.augmentations) {
|
|
289
|
+
const a = aug;
|
|
290
|
+
if (a.metrics) {
|
|
291
|
+
allMetrics[aug.name] = a.metrics();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return allMetrics;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Get health status
|
|
298
|
+
*/
|
|
299
|
+
health() {
|
|
300
|
+
const health = {
|
|
301
|
+
overall: 'healthy',
|
|
302
|
+
augmentations: {}
|
|
303
|
+
};
|
|
304
|
+
for (const aug of this.augmentations) {
|
|
305
|
+
const a = aug;
|
|
306
|
+
health.augmentations[aug.name] = a.health ? a.health() : 'unknown';
|
|
307
|
+
}
|
|
308
|
+
return health;
|
|
309
|
+
}
|
|
133
310
|
/**
|
|
134
311
|
* Shutdown all augmentations
|
|
135
312
|
*/
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cache Augmentation - Optional Search Result Caching
|
|
3
3
|
*
|
|
4
|
-
* Replaces the hardcoded SearchCache in
|
|
4
|
+
* Replaces the hardcoded SearchCache in Brainy with an optional augmentation.
|
|
5
5
|
* This reduces core size and allows custom cache implementations.
|
|
6
6
|
*
|
|
7
7
|
* Zero-config: Automatically enabled with sensible defaults
|
|
8
8
|
* Can be disabled or customized via augmentation registry
|
|
9
9
|
*/
|
|
10
10
|
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
11
|
+
import { AugmentationManifest } from './manifest.js';
|
|
11
12
|
import { SearchCache } from '../utils/searchCache.js';
|
|
12
13
|
import type { GraphNoun } from '../types/graphTypes.js';
|
|
13
14
|
export interface CacheConfig {
|
|
@@ -29,11 +30,13 @@ export declare class CacheAugmentation extends BaseAugmentation {
|
|
|
29
30
|
readonly name = "cache";
|
|
30
31
|
readonly timing: "around";
|
|
31
32
|
readonly metadata: "none";
|
|
32
|
-
operations: ("search" | "add" | "delete" | "clear" | "all")[];
|
|
33
|
+
operations: ("search" | "find" | "similar" | "add" | "update" | "delete" | "clear" | "all")[];
|
|
33
34
|
readonly priority = 50;
|
|
35
|
+
readonly category: "core";
|
|
36
|
+
readonly description = "Transparent search result caching with automatic invalidation";
|
|
34
37
|
private searchCache;
|
|
35
|
-
private config;
|
|
36
38
|
constructor(config?: CacheConfig);
|
|
39
|
+
getManifest(): AugmentationManifest;
|
|
37
40
|
protected onInitialize(): Promise<void>;
|
|
38
41
|
protected onShutdown(): Promise<void>;
|
|
39
42
|
/**
|
|
@@ -68,9 +71,9 @@ export declare class CacheAugmentation extends BaseAugmentation {
|
|
|
68
71
|
*/
|
|
69
72
|
clear(): void;
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* Handle runtime configuration changes
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
protected onConfigChange(newConfig: CacheConfig, oldConfig: CacheConfig): Promise<void>;
|
|
74
77
|
/**
|
|
75
78
|
* Clean up expired entries
|
|
76
79
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cache Augmentation - Optional Search Result Caching
|
|
3
3
|
*
|
|
4
|
-
* Replaces the hardcoded SearchCache in
|
|
4
|
+
* Replaces the hardcoded SearchCache in Brainy with an optional augmentation.
|
|
5
5
|
* This reduces core size and allows custom cache implementations.
|
|
6
6
|
*
|
|
7
7
|
* Zero-config: Automatically enabled with sensible defaults
|
|
@@ -19,20 +19,116 @@ import { SearchCache } from '../utils/searchCache.js';
|
|
|
19
19
|
* - Zero-config with smart defaults
|
|
20
20
|
*/
|
|
21
21
|
export class CacheAugmentation extends BaseAugmentation {
|
|
22
|
-
constructor(config
|
|
23
|
-
super();
|
|
22
|
+
constructor(config) {
|
|
23
|
+
super(config);
|
|
24
24
|
this.name = 'cache';
|
|
25
25
|
this.timing = 'around';
|
|
26
26
|
this.metadata = 'none'; // Cache doesn't access metadata
|
|
27
|
-
this.operations = ['search', 'add', 'delete', 'clear', 'all'];
|
|
27
|
+
this.operations = ['search', 'find', 'similar', 'add', 'update', 'delete', 'clear', 'all'];
|
|
28
28
|
this.priority = 50; // Mid-priority, runs after data operations
|
|
29
|
+
// Augmentation metadata
|
|
30
|
+
this.category = 'core';
|
|
31
|
+
this.description = 'Transparent search result caching with automatic invalidation';
|
|
29
32
|
this.searchCache = null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
getManifest() {
|
|
35
|
+
return {
|
|
36
|
+
id: 'cache',
|
|
37
|
+
name: 'Cache',
|
|
38
|
+
version: '2.0.0',
|
|
39
|
+
description: 'Intelligent caching for search and query operations',
|
|
40
|
+
longDescription: 'Provides transparent caching for search results with automatic invalidation on data changes. Significantly improves performance for repeated queries while maintaining data consistency.',
|
|
41
|
+
category: 'performance',
|
|
42
|
+
configSchema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
enabled: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: true,
|
|
48
|
+
description: 'Enable or disable caching'
|
|
49
|
+
},
|
|
50
|
+
maxSize: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
default: 1000,
|
|
53
|
+
minimum: 10,
|
|
54
|
+
maximum: 100000,
|
|
55
|
+
description: 'Maximum number of cached entries'
|
|
56
|
+
},
|
|
57
|
+
ttl: {
|
|
58
|
+
type: 'number',
|
|
59
|
+
default: 300000, // 5 minutes
|
|
60
|
+
minimum: 1000, // 1 second
|
|
61
|
+
maximum: 3600000, // 1 hour
|
|
62
|
+
description: 'Time to live for cache entries in milliseconds'
|
|
63
|
+
},
|
|
64
|
+
invalidateOnWrite: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
default: true,
|
|
67
|
+
description: 'Automatically invalidate cache on data modifications'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
additionalProperties: false
|
|
71
|
+
},
|
|
72
|
+
configDefaults: {
|
|
73
|
+
enabled: true,
|
|
74
|
+
maxSize: 1000,
|
|
75
|
+
ttl: 300000,
|
|
76
|
+
invalidateOnWrite: true
|
|
77
|
+
},
|
|
78
|
+
configExamples: [
|
|
79
|
+
{
|
|
80
|
+
name: 'High Performance',
|
|
81
|
+
description: 'Large cache with longer TTL for read-heavy workloads',
|
|
82
|
+
config: {
|
|
83
|
+
enabled: true,
|
|
84
|
+
maxSize: 10000,
|
|
85
|
+
ttl: 1800000, // 30 minutes
|
|
86
|
+
invalidateOnWrite: true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'Conservative',
|
|
91
|
+
description: 'Small cache with short TTL for frequently changing data',
|
|
92
|
+
config: {
|
|
93
|
+
enabled: true,
|
|
94
|
+
maxSize: 100,
|
|
95
|
+
ttl: 60000, // 1 minute
|
|
96
|
+
invalidateOnWrite: true
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
minBrainyVersion: '2.0.0',
|
|
101
|
+
keywords: ['cache', 'performance', 'search', 'optimization'],
|
|
102
|
+
documentation: 'https://docs.brainy.dev/augmentations/cache',
|
|
103
|
+
status: 'stable',
|
|
104
|
+
performance: {
|
|
105
|
+
memoryUsage: 'medium',
|
|
106
|
+
cpuUsage: 'low',
|
|
107
|
+
networkUsage: 'none'
|
|
108
|
+
},
|
|
109
|
+
features: ['search-caching', 'auto-invalidation', 'ttl-support', 'memory-management'],
|
|
110
|
+
enhancedOperations: ['search', 'searchText', 'findSimilar'],
|
|
111
|
+
metrics: [
|
|
112
|
+
{
|
|
113
|
+
name: 'cache_hits',
|
|
114
|
+
type: 'counter',
|
|
115
|
+
description: 'Number of cache hits'
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'cache_misses',
|
|
119
|
+
type: 'counter',
|
|
120
|
+
description: 'Number of cache misses'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'cache_size',
|
|
124
|
+
type: 'gauge',
|
|
125
|
+
description: 'Current cache size'
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
ui: {
|
|
129
|
+
icon: '⚡',
|
|
130
|
+
color: '#FFC107'
|
|
131
|
+
}
|
|
36
132
|
};
|
|
37
133
|
}
|
|
38
134
|
async onInitialize() {
|
|
@@ -157,18 +253,21 @@ export class CacheAugmentation extends BaseAugmentation {
|
|
|
157
253
|
}
|
|
158
254
|
}
|
|
159
255
|
/**
|
|
160
|
-
*
|
|
256
|
+
* Handle runtime configuration changes
|
|
161
257
|
*/
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
if (this.searchCache && this.config.enabled) {
|
|
258
|
+
async onConfigChange(newConfig, oldConfig) {
|
|
259
|
+
if (this.searchCache && newConfig.enabled) {
|
|
165
260
|
this.searchCache.updateConfig({
|
|
166
|
-
maxSize:
|
|
167
|
-
maxAge:
|
|
168
|
-
enabled:
|
|
261
|
+
maxSize: newConfig.maxSize,
|
|
262
|
+
maxAge: newConfig.ttl, // SearchCache uses maxAge
|
|
263
|
+
enabled: newConfig.enabled
|
|
169
264
|
});
|
|
170
265
|
this.log('Cache configuration updated');
|
|
171
266
|
}
|
|
267
|
+
else if (!newConfig.enabled && this.searchCache) {
|
|
268
|
+
this.searchCache.clear();
|
|
269
|
+
this.log('Cache disabled and cleared');
|
|
270
|
+
}
|
|
172
271
|
}
|
|
173
272
|
/**
|
|
174
273
|
* Clean up expired entries
|
|
@@ -52,12 +52,12 @@ export {};
|
|
|
52
52
|
* Example usage:
|
|
53
53
|
*
|
|
54
54
|
* // Server instance
|
|
55
|
-
* const serverBrain = new
|
|
55
|
+
* const serverBrain = new Brainy()
|
|
56
56
|
* serverBrain.augmentations.register(new APIServerAugmentation())
|
|
57
57
|
* await serverBrain.init()
|
|
58
58
|
*
|
|
59
59
|
* // Client instance
|
|
60
|
-
* const clientBrain = new
|
|
60
|
+
* const clientBrain = new Brainy()
|
|
61
61
|
* const conduit = new WebSocketConduitAugmentation()
|
|
62
62
|
* clientBrain.augmentations.register(conduit)
|
|
63
63
|
* await clientBrain.init()
|
|
@@ -213,12 +213,12 @@ export class WebSocketConduitAugmentation extends BaseConduitAugmentation {
|
|
|
213
213
|
* Example usage:
|
|
214
214
|
*
|
|
215
215
|
* // Server instance
|
|
216
|
-
* const serverBrain = new
|
|
216
|
+
* const serverBrain = new Brainy()
|
|
217
217
|
* serverBrain.augmentations.register(new APIServerAugmentation())
|
|
218
218
|
* await serverBrain.init()
|
|
219
219
|
*
|
|
220
220
|
* // Client instance
|
|
221
|
-
* const clientBrain = new
|
|
221
|
+
* const clientBrain = new Brainy()
|
|
222
222
|
* const conduit = new WebSocketConduitAugmentation()
|
|
223
223
|
* clientBrain.augmentations.register(conduit)
|
|
224
224
|
* await clientBrain.init()
|