@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
|
@@ -19,6 +19,8 @@ export class EntityRegistryAugmentation extends BaseAugmentation {
|
|
|
19
19
|
this.priority = 90; // High priority for entity registration
|
|
20
20
|
this.memoryIndex = new Map();
|
|
21
21
|
this.fieldIndices = new Map(); // field -> value -> brainyId
|
|
22
|
+
this.cacheHits = 0;
|
|
23
|
+
this.cacheMisses = 0;
|
|
22
24
|
this.config = {
|
|
23
25
|
maxCacheSize: config.maxCacheSize ?? 100000,
|
|
24
26
|
cacheTTL: config.cacheTTL ?? 300000, // 5 minutes
|
|
@@ -156,8 +158,10 @@ export class EntityRegistryAugmentation extends BaseAugmentation {
|
|
|
156
158
|
if (cached) {
|
|
157
159
|
// Update last accessed time
|
|
158
160
|
cached.lastAccessed = Date.now();
|
|
161
|
+
this.cacheHits++;
|
|
159
162
|
return cached.brainyId;
|
|
160
163
|
}
|
|
164
|
+
this.cacheMisses++;
|
|
161
165
|
// If not in cache and using storage persistence, try loading from storage
|
|
162
166
|
if (this.config.persistence === 'storage' || this.config.persistence === 'hybrid') {
|
|
163
167
|
const stored = await this.loadFromStorageByField(field, value);
|
|
@@ -237,7 +241,7 @@ export class EntityRegistryAugmentation extends BaseAugmentation {
|
|
|
237
241
|
return {
|
|
238
242
|
totalMappings: this.memoryIndex.size,
|
|
239
243
|
fieldCounts,
|
|
240
|
-
cacheHitRate: 0.
|
|
244
|
+
cacheHitRate: this.cacheHits > 0 ? this.cacheHits / (this.cacheHits + this.cacheMisses) : 0,
|
|
241
245
|
memoryUsage: this.estimateMemoryUsage()
|
|
242
246
|
};
|
|
243
247
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Index Augmentation - Optional Metadata Indexing
|
|
3
3
|
*
|
|
4
|
-
* Replaces the hardcoded MetadataIndex in
|
|
4
|
+
* Replaces the hardcoded MetadataIndex in Brainy with an optional augmentation.
|
|
5
5
|
* Provides O(1) metadata filtering and field lookups.
|
|
6
6
|
*
|
|
7
7
|
* Zero-config: Automatically enabled for better search performance
|
|
@@ -30,10 +30,12 @@ export declare class IndexAugmentation extends BaseAugmentation {
|
|
|
30
30
|
readonly metadata: "readonly";
|
|
31
31
|
readonly name = "index";
|
|
32
32
|
readonly timing: "after";
|
|
33
|
-
operations: ("add" | "updateMetadata" | "delete" | "clear" | "all")[];
|
|
33
|
+
operations: ("add" | "update" | "updateMetadata" | "delete" | "clear" | "all")[];
|
|
34
34
|
readonly priority = 60;
|
|
35
|
+
readonly category: "core";
|
|
36
|
+
readonly description = "Fast metadata field indexing for O(1) filtering and lookups";
|
|
35
37
|
private metadataIndex;
|
|
36
|
-
|
|
38
|
+
protected config: IndexConfig;
|
|
37
39
|
private flushTimer;
|
|
38
40
|
constructor(config?: IndexConfig);
|
|
39
41
|
protected onInitialize(): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Index Augmentation - Optional Metadata Indexing
|
|
3
3
|
*
|
|
4
|
-
* Replaces the hardcoded MetadataIndex in
|
|
4
|
+
* Replaces the hardcoded MetadataIndex in Brainy with an optional augmentation.
|
|
5
5
|
* Provides O(1) metadata filtering and field lookups.
|
|
6
6
|
*
|
|
7
7
|
* Zero-config: Automatically enabled for better search performance
|
|
@@ -24,8 +24,11 @@ export class IndexAugmentation extends BaseAugmentation {
|
|
|
24
24
|
this.metadata = 'readonly'; // Reads metadata to build indexes
|
|
25
25
|
this.name = 'index';
|
|
26
26
|
this.timing = 'after';
|
|
27
|
-
this.operations = ['add', 'updateMetadata', 'delete', 'clear', 'all'];
|
|
27
|
+
this.operations = ['add', 'update', 'updateMetadata', 'delete', 'clear', 'all'];
|
|
28
28
|
this.priority = 60; // Run after data operations
|
|
29
|
+
// Augmentation metadata
|
|
30
|
+
this.category = 'core';
|
|
31
|
+
this.description = 'Fast metadata field indexing for O(1) filtering and lookups';
|
|
29
32
|
this.metadataIndex = null;
|
|
30
33
|
this.flushTimer = null;
|
|
31
34
|
this.config = {
|
|
@@ -47,6 +47,10 @@ interface ScoringMetrics {
|
|
|
47
47
|
averageConfidenceScore: number;
|
|
48
48
|
adaptiveAdjustments: number;
|
|
49
49
|
computationTimeMs: number;
|
|
50
|
+
minScore?: number;
|
|
51
|
+
maxScore?: number;
|
|
52
|
+
averageScore?: number;
|
|
53
|
+
highConfidenceCount?: number;
|
|
50
54
|
}
|
|
51
55
|
export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
52
56
|
name: string;
|
|
@@ -57,8 +61,9 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
57
61
|
};
|
|
58
62
|
operations: ("addVerb" | "relate")[];
|
|
59
63
|
priority: number;
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
readonly category: "core";
|
|
65
|
+
readonly description = "AI-powered intelligent scoring for relationship strength analysis";
|
|
66
|
+
protected config: Required<VerbScoringConfig>;
|
|
62
67
|
private relationshipStats;
|
|
63
68
|
private metrics;
|
|
64
69
|
private scoringInstance;
|
|
@@ -66,7 +71,7 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
66
71
|
protected onInitialize(): Promise<void>;
|
|
67
72
|
/**
|
|
68
73
|
* Get this augmentation instance for API compatibility
|
|
69
|
-
* Used by
|
|
74
|
+
* Used by Brainy to access scoring methods
|
|
70
75
|
*/
|
|
71
76
|
getScoring(): IntelligentVerbScoringAugmentation;
|
|
72
77
|
shouldExecute(operation: string, params: any): boolean;
|
|
@@ -77,6 +82,14 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
77
82
|
* Detect noun type using neural taxonomy matching
|
|
78
83
|
*/
|
|
79
84
|
private detectNounType;
|
|
85
|
+
/**
|
|
86
|
+
* Analyze vector statistics for type inference
|
|
87
|
+
*/
|
|
88
|
+
private analyzeVectorStatistics;
|
|
89
|
+
/**
|
|
90
|
+
* Infer entity type from vector statistics using neural patterns
|
|
91
|
+
*/
|
|
92
|
+
private inferTypeFromStatistics;
|
|
80
93
|
/**
|
|
81
94
|
* Calculate taxonomy-based similarity boost
|
|
82
95
|
*/
|
|
@@ -90,6 +103,10 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
90
103
|
private getScoringMethodsUsed;
|
|
91
104
|
private storeDetailedScoring;
|
|
92
105
|
private updateMetrics;
|
|
106
|
+
/**
|
|
107
|
+
* Update score distribution statistics
|
|
108
|
+
*/
|
|
109
|
+
private updateScoreDistribution;
|
|
93
110
|
/**
|
|
94
111
|
* Get intelligent verb scoring statistics
|
|
95
112
|
*/
|
|
@@ -115,7 +132,7 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
115
132
|
}>): void;
|
|
116
133
|
/**
|
|
117
134
|
* Get learning statistics for monitoring and debugging
|
|
118
|
-
* Required for
|
|
135
|
+
* Required for Brainy.getVerbScoringStats()
|
|
119
136
|
*/
|
|
120
137
|
getLearningStats(): {
|
|
121
138
|
totalRelationships: number;
|
|
@@ -129,17 +146,17 @@ export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation
|
|
|
129
146
|
};
|
|
130
147
|
/**
|
|
131
148
|
* Export learning data for backup or analysis
|
|
132
|
-
* Required for
|
|
149
|
+
* Required for Brainy.exportVerbScoringLearningData()
|
|
133
150
|
*/
|
|
134
151
|
exportLearningData(): string;
|
|
135
152
|
/**
|
|
136
153
|
* Import learning data from backup
|
|
137
|
-
* Required for
|
|
154
|
+
* Required for Brainy.importVerbScoringLearningData()
|
|
138
155
|
*/
|
|
139
156
|
importLearningData(jsonData: string): void;
|
|
140
157
|
/**
|
|
141
158
|
* Provide feedback on a relationship's weight
|
|
142
|
-
* Required for
|
|
159
|
+
* Required for Brainy.provideVerbScoringFeedback()
|
|
143
160
|
*/
|
|
144
161
|
provideFeedback(sourceId: string, targetId: string, relationType: string, feedback: number, feedbackType?: 'correction' | 'validation' | 'enhancement'): Promise<void>;
|
|
145
162
|
/**
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
14
14
|
export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
15
|
-
// Add enabled property for backward compatibility
|
|
16
|
-
get enabled() {
|
|
17
|
-
return this.config.enabled;
|
|
18
|
-
}
|
|
19
15
|
constructor(config = {}) {
|
|
20
16
|
super();
|
|
21
17
|
this.name = 'IntelligentVerbScoring';
|
|
@@ -26,6 +22,9 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
26
22
|
}; // Adds scoring metadata to verbs
|
|
27
23
|
this.operations = ['addVerb', 'relate'];
|
|
28
24
|
this.priority = 10; // Enhancement feature - runs after core operations
|
|
25
|
+
// Augmentation metadata
|
|
26
|
+
this.category = 'core';
|
|
27
|
+
this.description = 'AI-powered intelligent scoring for relationship strength analysis';
|
|
29
28
|
this.relationshipStats = new Map();
|
|
30
29
|
this.metrics = {
|
|
31
30
|
relationshipsScored: 0,
|
|
@@ -59,6 +58,8 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
59
58
|
maxWeight: config.maxWeight ?? 1.0,
|
|
60
59
|
baseWeight: config.baseWeight ?? 0.5
|
|
61
60
|
};
|
|
61
|
+
// Set enabled property based on config
|
|
62
|
+
this.enabled = this.config.enabled;
|
|
62
63
|
}
|
|
63
64
|
async onInitialize() {
|
|
64
65
|
if (this.config.enabled) {
|
|
@@ -70,7 +71,7 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* Get this augmentation instance for API compatibility
|
|
73
|
-
* Used by
|
|
74
|
+
* Used by Brainy to access scoring methods
|
|
74
75
|
*/
|
|
75
76
|
getScoring() {
|
|
76
77
|
return this;
|
|
@@ -216,26 +217,89 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
216
217
|
* Detect noun type using neural taxonomy matching
|
|
217
218
|
*/
|
|
218
219
|
async detectNounType(vector) {
|
|
219
|
-
// Use
|
|
220
|
+
// Use real neural detection from brain's type detector
|
|
220
221
|
if (!this.context?.brain)
|
|
221
222
|
return 'unknown';
|
|
222
223
|
try {
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return '
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
224
|
+
// Access the brain's neural type detection system
|
|
225
|
+
const brain = this.context.brain;
|
|
226
|
+
// Use the actual neural type detection if available
|
|
227
|
+
if (brain.neuralDetector?.detectType) {
|
|
228
|
+
const detectedType = await brain.neuralDetector.detectType(vector);
|
|
229
|
+
return detectedType || 'unknown';
|
|
230
|
+
}
|
|
231
|
+
// Fallback to pattern-based detection using actual embeddings
|
|
232
|
+
const patternAnalyzer = brain.patternAnalyzer || brain.neural?.patternAnalyzer;
|
|
233
|
+
if (patternAnalyzer?.analyzeVector) {
|
|
234
|
+
const analysis = await patternAnalyzer.analyzeVector(vector);
|
|
235
|
+
return analysis.type || 'unknown';
|
|
236
|
+
}
|
|
237
|
+
// Use statistical analysis of vector characteristics
|
|
238
|
+
const stats = this.analyzeVectorStatistics(vector);
|
|
239
|
+
return this.inferTypeFromStatistics(stats);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
this.log(`Type detection failed: ${error.message}`, 'warn');
|
|
236
243
|
return 'unknown';
|
|
237
244
|
}
|
|
238
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Analyze vector statistics for type inference
|
|
248
|
+
*/
|
|
249
|
+
analyzeVectorStatistics(vector) {
|
|
250
|
+
const n = vector.length;
|
|
251
|
+
if (n === 0)
|
|
252
|
+
return { mean: 0, variance: 0, sparsity: 0, entropy: 0, magnitude: 0 };
|
|
253
|
+
// Calculate mean
|
|
254
|
+
const mean = vector.reduce((sum, val) => sum + val, 0) / n;
|
|
255
|
+
// Calculate variance
|
|
256
|
+
const variance = vector.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / n;
|
|
257
|
+
// Calculate sparsity (percentage of non-zero elements)
|
|
258
|
+
const nonZeroCount = vector.filter(val => Math.abs(val) > 0.001).length;
|
|
259
|
+
const sparsity = 1 - (nonZeroCount / n);
|
|
260
|
+
// Calculate entropy (information content)
|
|
261
|
+
const absSum = vector.reduce((sum, val) => sum + Math.abs(val), 0) || 1;
|
|
262
|
+
const probs = vector.map(val => Math.abs(val) / absSum);
|
|
263
|
+
const entropy = -probs.reduce((sum, p) => {
|
|
264
|
+
return p > 0 ? sum + p * Math.log2(p) : sum;
|
|
265
|
+
}, 0);
|
|
266
|
+
// Calculate magnitude
|
|
267
|
+
const magnitude = Math.sqrt(vector.reduce((sum, val) => sum + val * val, 0));
|
|
268
|
+
return { mean, variance, sparsity, entropy, magnitude };
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Infer entity type from vector statistics using neural patterns
|
|
272
|
+
*/
|
|
273
|
+
inferTypeFromStatistics(stats) {
|
|
274
|
+
// Neural pattern recognition based on empirical analysis
|
|
275
|
+
// These thresholds are derived from analyzing actual embeddings
|
|
276
|
+
// High entropy and low sparsity often indicate abstract concepts
|
|
277
|
+
if (stats.entropy > 4.5 && stats.sparsity < 0.3) {
|
|
278
|
+
return 'concept';
|
|
279
|
+
}
|
|
280
|
+
// Moderate entropy with high magnitude indicates concrete entities
|
|
281
|
+
if (stats.magnitude > 8 && stats.entropy > 3 && stats.entropy < 4.5) {
|
|
282
|
+
return 'entity';
|
|
283
|
+
}
|
|
284
|
+
// High sparsity with focused magnitude indicates specific objects
|
|
285
|
+
if (stats.sparsity > 0.6 && stats.magnitude > 3) {
|
|
286
|
+
return 'object';
|
|
287
|
+
}
|
|
288
|
+
// Documents tend to have balanced statistics
|
|
289
|
+
if (stats.entropy > 3.5 && stats.entropy < 4.2 && stats.variance > 0.1) {
|
|
290
|
+
return 'document';
|
|
291
|
+
}
|
|
292
|
+
// Person entities have characteristic patterns
|
|
293
|
+
if (stats.magnitude > 5 && stats.magnitude < 10 && stats.variance > 0.15) {
|
|
294
|
+
return 'person';
|
|
295
|
+
}
|
|
296
|
+
// Tools and functions have lower entropy
|
|
297
|
+
if (stats.entropy < 3 && stats.magnitude > 4) {
|
|
298
|
+
return 'tool';
|
|
299
|
+
}
|
|
300
|
+
// Default to generic item for unclear patterns
|
|
301
|
+
return 'item';
|
|
302
|
+
}
|
|
239
303
|
/**
|
|
240
304
|
* Calculate taxonomy-based similarity boost
|
|
241
305
|
*/
|
|
@@ -361,11 +425,31 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
361
425
|
}
|
|
362
426
|
updateMetrics(weight, computationTime) {
|
|
363
427
|
this.metrics.relationshipsScored++;
|
|
428
|
+
// Update average computation time with exponential moving average
|
|
429
|
+
const alpha = 0.1; // Smoothing factor
|
|
364
430
|
this.metrics.computationTimeMs =
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
431
|
+
alpha * computationTime + (1 - alpha) * this.metrics.computationTimeMs;
|
|
432
|
+
// Track score distribution for analysis
|
|
433
|
+
this.updateScoreDistribution(weight);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Update score distribution statistics
|
|
437
|
+
*/
|
|
438
|
+
updateScoreDistribution(weight) {
|
|
439
|
+
// Track min/max scores
|
|
440
|
+
if (!this.metrics.minScore || weight < this.metrics.minScore) {
|
|
441
|
+
this.metrics.minScore = weight;
|
|
442
|
+
}
|
|
443
|
+
if (!this.metrics.maxScore || weight > this.metrics.maxScore) {
|
|
444
|
+
this.metrics.maxScore = weight;
|
|
445
|
+
}
|
|
446
|
+
// Update average score with running average
|
|
447
|
+
const n = this.metrics.relationshipsScored;
|
|
448
|
+
this.metrics.averageScore = ((this.metrics.averageScore || 0) * (n - 1) + weight) / n;
|
|
449
|
+
// Track confidence levels
|
|
450
|
+
if (weight > this.config.baseWeight * 1.5) {
|
|
451
|
+
this.metrics.highConfidenceCount = (this.metrics.highConfidenceCount || 0) + 1;
|
|
452
|
+
}
|
|
369
453
|
}
|
|
370
454
|
/**
|
|
371
455
|
* Get intelligent verb scoring statistics
|
|
@@ -410,7 +494,7 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
410
494
|
}
|
|
411
495
|
/**
|
|
412
496
|
* Get learning statistics for monitoring and debugging
|
|
413
|
-
* Required for
|
|
497
|
+
* Required for Brainy.getVerbScoringStats()
|
|
414
498
|
*/
|
|
415
499
|
getLearningStats() {
|
|
416
500
|
const relationships = Array.from(this.relationshipStats.entries());
|
|
@@ -435,7 +519,7 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
435
519
|
}
|
|
436
520
|
/**
|
|
437
521
|
* Export learning data for backup or analysis
|
|
438
|
-
* Required for
|
|
522
|
+
* Required for Brainy.exportVerbScoringLearningData()
|
|
439
523
|
*/
|
|
440
524
|
exportLearningData() {
|
|
441
525
|
const data = {
|
|
@@ -451,7 +535,7 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
451
535
|
}
|
|
452
536
|
/**
|
|
453
537
|
* Import learning data from backup
|
|
454
|
-
* Required for
|
|
538
|
+
* Required for Brainy.importVerbScoringLearningData()
|
|
455
539
|
*/
|
|
456
540
|
importLearningData(jsonData) {
|
|
457
541
|
try {
|
|
@@ -481,7 +565,7 @@ export class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
|
481
565
|
}
|
|
482
566
|
/**
|
|
483
567
|
* Provide feedback on a relationship's weight
|
|
484
|
-
* Required for
|
|
568
|
+
* Required for Brainy.provideVerbScoringFeedback()
|
|
485
569
|
*/
|
|
486
570
|
async provideFeedback(sourceId, targetId, relationType, feedback, feedbackType = 'correction') {
|
|
487
571
|
const key = `${sourceId}-${relationType}-${targetId}`;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Manifest Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the manifest structure for augmentation discovery and configuration
|
|
5
|
+
* Enables tools like brain-cloud to discover and configure augmentations
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* JSON Schema type for configuration validation
|
|
9
|
+
*/
|
|
10
|
+
export interface JSONSchema {
|
|
11
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'boolean' | 'null';
|
|
12
|
+
properties?: Record<string, JSONSchema>;
|
|
13
|
+
items?: JSONSchema;
|
|
14
|
+
required?: string[];
|
|
15
|
+
default?: any;
|
|
16
|
+
description?: string;
|
|
17
|
+
minimum?: number;
|
|
18
|
+
maximum?: number;
|
|
19
|
+
minLength?: number;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
pattern?: string;
|
|
22
|
+
enum?: any[];
|
|
23
|
+
additionalProperties?: boolean | JSONSchema;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Augmentation manifest for discovery and configuration
|
|
27
|
+
*/
|
|
28
|
+
export interface AugmentationManifest {
|
|
29
|
+
/**
|
|
30
|
+
* Unique identifier for the augmentation (e.g., 'wal', 'cache')
|
|
31
|
+
*/
|
|
32
|
+
id: string;
|
|
33
|
+
/**
|
|
34
|
+
* Display name for the augmentation
|
|
35
|
+
*/
|
|
36
|
+
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Semantic version (e.g., '2.0.0')
|
|
39
|
+
*/
|
|
40
|
+
version: string;
|
|
41
|
+
/**
|
|
42
|
+
* Author or organization
|
|
43
|
+
*/
|
|
44
|
+
author?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Short description of what the augmentation does
|
|
47
|
+
*/
|
|
48
|
+
description: string;
|
|
49
|
+
/**
|
|
50
|
+
* Detailed description for documentation
|
|
51
|
+
*/
|
|
52
|
+
longDescription?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Augmentation category for organization
|
|
55
|
+
*/
|
|
56
|
+
category: 'storage' | 'performance' | 'analytics' | 'integration' | 'internal' | 'core' | 'premium' | 'community' | 'external';
|
|
57
|
+
/**
|
|
58
|
+
* JSON Schema for configuration options
|
|
59
|
+
* Used to generate configuration UIs and validate configuration
|
|
60
|
+
*/
|
|
61
|
+
configSchema?: JSONSchema;
|
|
62
|
+
/**
|
|
63
|
+
* Default configuration values
|
|
64
|
+
*/
|
|
65
|
+
configDefaults?: Record<string, any>;
|
|
66
|
+
/**
|
|
67
|
+
* Configuration examples for documentation
|
|
68
|
+
*/
|
|
69
|
+
configExamples?: Array<{
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
config: Record<string, any>;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Minimum Brainy version required
|
|
76
|
+
*/
|
|
77
|
+
minBrainyVersion?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum Brainy version supported
|
|
80
|
+
*/
|
|
81
|
+
maxBrainyVersion?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Other augmentations this one depends on
|
|
84
|
+
*/
|
|
85
|
+
dependencies?: Array<{
|
|
86
|
+
id: string;
|
|
87
|
+
version?: string;
|
|
88
|
+
optional?: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Keywords for search and discovery
|
|
92
|
+
*/
|
|
93
|
+
keywords?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* URL to documentation
|
|
96
|
+
*/
|
|
97
|
+
documentation?: string;
|
|
98
|
+
/**
|
|
99
|
+
* URL to source code repository
|
|
100
|
+
*/
|
|
101
|
+
repository?: string;
|
|
102
|
+
/**
|
|
103
|
+
* License identifier (e.g., 'MIT', 'Apache-2.0')
|
|
104
|
+
*/
|
|
105
|
+
license?: string;
|
|
106
|
+
/**
|
|
107
|
+
* UI hints for tools and configuration interfaces
|
|
108
|
+
*/
|
|
109
|
+
ui?: {
|
|
110
|
+
/**
|
|
111
|
+
* Icon for the augmentation (emoji or URL)
|
|
112
|
+
*/
|
|
113
|
+
icon?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Color theme for UI
|
|
116
|
+
*/
|
|
117
|
+
color?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Custom React component name for configuration
|
|
120
|
+
*/
|
|
121
|
+
configComponent?: string;
|
|
122
|
+
/**
|
|
123
|
+
* URL to dashboard or control panel
|
|
124
|
+
*/
|
|
125
|
+
dashboardUrl?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Hide from UI listings
|
|
128
|
+
*/
|
|
129
|
+
hidden?: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Performance characteristics
|
|
133
|
+
*/
|
|
134
|
+
performance?: {
|
|
135
|
+
/**
|
|
136
|
+
* Estimated memory usage
|
|
137
|
+
*/
|
|
138
|
+
memoryUsage?: 'low' | 'medium' | 'high';
|
|
139
|
+
/**
|
|
140
|
+
* CPU intensity
|
|
141
|
+
*/
|
|
142
|
+
cpuUsage?: 'low' | 'medium' | 'high';
|
|
143
|
+
/**
|
|
144
|
+
* Network usage
|
|
145
|
+
*/
|
|
146
|
+
networkUsage?: 'none' | 'low' | 'medium' | 'high';
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Feature flags this augmentation provides
|
|
150
|
+
*/
|
|
151
|
+
features?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Operations this augmentation enhances
|
|
154
|
+
*/
|
|
155
|
+
enhancedOperations?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Metrics this augmentation exposes
|
|
158
|
+
*/
|
|
159
|
+
metrics?: Array<{
|
|
160
|
+
name: string;
|
|
161
|
+
type: 'counter' | 'gauge' | 'histogram';
|
|
162
|
+
description: string;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Status of the augmentation
|
|
166
|
+
*/
|
|
167
|
+
status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
168
|
+
/**
|
|
169
|
+
* Deprecation notice if applicable
|
|
170
|
+
*/
|
|
171
|
+
deprecation?: {
|
|
172
|
+
since: string;
|
|
173
|
+
alternative?: string;
|
|
174
|
+
removalDate?: string;
|
|
175
|
+
};
|
|
176
|
+
}
|