@soulcraft/brainy 3.0.0 → 3.1.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/CHANGELOG.md +53 -3
- package/README.md +427 -111
- 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 +277 -0
- package/dist/brainy.js +1241 -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/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/universal/crypto.d.ts +11 -1
- package/dist/universal/crypto.js +24 -93
- package/dist/universal/events.d.ts +3 -2
- package/dist/universal/events.js +6 -75
- package/dist/universal/fs.d.ts +2 -3
- package/dist/universal/fs.js +5 -211
- package/dist/universal/path.d.ts +3 -2
- package/dist/universal/path.js +22 -78
- package/dist/universal/uuid.d.ts +1 -1
- package/dist/universal/uuid.js +1 -1
- 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 -17
- package/scripts/download-models.cjs +94 -20
- package/dist/augmentations/walAugmentation.d.ts +0 -109
- package/dist/augmentations/walAugmentation.js +0 -516
- package/dist/browserFramework.d.ts +0 -15
- package/dist/browserFramework.js +0 -31
- package/dist/browserFramework.minimal.d.ts +0 -14
- package/dist/browserFramework.minimal.js +0 -31
- 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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Improved Neural API - Clean, Consistent, Performant
|
|
3
|
+
*
|
|
4
|
+
* Public API Surface:
|
|
5
|
+
* - brain.neural.similar(a, b, options?) // Similarity calculation
|
|
6
|
+
* - brain.neural.clusters(items?, options?) // Semantic clustering
|
|
7
|
+
* - brain.neural.neighbors(id, options?) // K-nearest neighbors
|
|
8
|
+
* - brain.neural.hierarchy(id, options?) // Semantic hierarchy
|
|
9
|
+
* - brain.neural.outliers(options?) // Anomaly detection
|
|
10
|
+
* - brain.neural.visualize(options?) // Visualization data
|
|
11
|
+
*
|
|
12
|
+
* Advanced Clustering:
|
|
13
|
+
* - brain.neural.clusterByDomain(field, options?) // Domain-aware clustering
|
|
14
|
+
* - brain.neural.clusterByTime(field, windows, options?) // Temporal clustering
|
|
15
|
+
* - brain.neural.clusterStream(options?) // AsyncIterator for streaming
|
|
16
|
+
* - brain.neural.updateClusters(items, options?) // Incremental clustering
|
|
17
|
+
*
|
|
18
|
+
* Private methods are prefixed with _ and not exposed in public API
|
|
19
|
+
*/
|
|
20
|
+
import { Vector } from '../coreTypes.js';
|
|
21
|
+
import { SemanticCluster, DomainCluster, TemporalCluster, EnhancedSemanticCluster, SimilarityOptions, SimilarityResult, NeighborOptions, NeighborsResult, SemanticHierarchy, HierarchyOptions, ClusteringOptions, DomainClusteringOptions, TemporalClusteringOptions, StreamClusteringOptions, VisualizationOptions, VisualizationResult, OutlierOptions, Outlier, StreamingBatch, TimeWindow, PerformanceMetrics, NeuralAPIConfig } from './types.js';
|
|
22
|
+
export declare class ImprovedNeuralAPI {
|
|
23
|
+
private brain;
|
|
24
|
+
private config;
|
|
25
|
+
private similarityCache;
|
|
26
|
+
private clusterCache;
|
|
27
|
+
private hierarchyCache;
|
|
28
|
+
private neighborsCache;
|
|
29
|
+
private performanceMetrics;
|
|
30
|
+
constructor(brain: any, config?: NeuralAPIConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Calculate similarity between any two items (auto-detection)
|
|
33
|
+
* Supports: IDs, text strings, vectors, or mixed types
|
|
34
|
+
*/
|
|
35
|
+
similar(a: string | Vector | any, b: string | Vector | any, options?: SimilarityOptions): Promise<number | SimilarityResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Intelligent semantic clustering with auto-routing
|
|
38
|
+
* - No input: Cluster all data
|
|
39
|
+
* - Array: Cluster specific items
|
|
40
|
+
* - String: Find clusters near this item
|
|
41
|
+
* - Options object: Advanced configuration
|
|
42
|
+
*/
|
|
43
|
+
clusters(input?: string | string[] | ClusteringOptions): Promise<SemanticCluster[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Fast hierarchical clustering using HNSW levels
|
|
46
|
+
*/
|
|
47
|
+
clusterFast(options?: {
|
|
48
|
+
level?: number;
|
|
49
|
+
maxClusters?: number;
|
|
50
|
+
}): Promise<SemanticCluster[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Large-scale clustering with intelligent sampling
|
|
53
|
+
*/
|
|
54
|
+
clusterLarge(options?: {
|
|
55
|
+
sampleSize?: number;
|
|
56
|
+
strategy?: 'random' | 'diverse' | 'recent';
|
|
57
|
+
}): Promise<SemanticCluster[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Domain-aware clustering based on metadata fields
|
|
60
|
+
*/
|
|
61
|
+
clusterByDomain(field: string, options?: DomainClusteringOptions): Promise<DomainCluster[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Temporal clustering based on time windows
|
|
64
|
+
*/
|
|
65
|
+
clusterByTime(timeField: string, windows: TimeWindow[], options?: TemporalClusteringOptions): Promise<TemporalCluster[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Streaming clustering with real-time updates
|
|
68
|
+
*/
|
|
69
|
+
clusterStream(options?: StreamClusteringOptions): AsyncIterableIterator<StreamingBatch>;
|
|
70
|
+
/**
|
|
71
|
+
* Incremental clustering - add new items to existing clusters
|
|
72
|
+
*/
|
|
73
|
+
updateClusters(newItems: string[], options?: ClusteringOptions): Promise<SemanticCluster[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Enhanced clustering with relationship analysis using verbs
|
|
76
|
+
* Returns clusters with intra-cluster and inter-cluster relationship information
|
|
77
|
+
*
|
|
78
|
+
* Scalable for millions of nodes - uses efficient batching and filtering
|
|
79
|
+
*/
|
|
80
|
+
clustersWithRelationships(input?: string | string[] | ClusteringOptions, options?: {
|
|
81
|
+
batchSize?: number;
|
|
82
|
+
maxRelationships?: number;
|
|
83
|
+
}): Promise<EnhancedSemanticCluster[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Find K-nearest semantic neighbors
|
|
86
|
+
*/
|
|
87
|
+
neighbors(id: string, options?: NeighborOptions): Promise<NeighborsResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Build semantic hierarchy around an item
|
|
90
|
+
*/
|
|
91
|
+
hierarchy(id: string, options?: HierarchyOptions): Promise<SemanticHierarchy>;
|
|
92
|
+
/**
|
|
93
|
+
* Detect outliers and anomalous items
|
|
94
|
+
*/
|
|
95
|
+
outliers(options?: OutlierOptions): Promise<Outlier[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Generate visualization data for graph libraries
|
|
98
|
+
*/
|
|
99
|
+
visualize(options?: VisualizationOptions): Promise<VisualizationResult>;
|
|
100
|
+
private _routeClusteringAlgorithm;
|
|
101
|
+
private _performClustering;
|
|
102
|
+
/**
|
|
103
|
+
* SEMANTIC-AWARE CLUSTERING: Uses existing NounType/VerbType taxonomy + HNSW
|
|
104
|
+
*/
|
|
105
|
+
private _performSemanticClustering;
|
|
106
|
+
/**
|
|
107
|
+
* HIERARCHICAL CLUSTERING: Uses existing HNSW levels for O(n) clustering
|
|
108
|
+
*/
|
|
109
|
+
private _performHierarchicalClustering;
|
|
110
|
+
/**
|
|
111
|
+
* K-MEANS CLUSTERING: Real implementation using existing distance functions
|
|
112
|
+
*/
|
|
113
|
+
private _performKMeansClustering;
|
|
114
|
+
/**
|
|
115
|
+
* DBSCAN CLUSTERING: Density-based clustering with adaptive parameters using HNSW
|
|
116
|
+
*/
|
|
117
|
+
private _performDBSCANClustering;
|
|
118
|
+
/**
|
|
119
|
+
* GRAPH COMMUNITY DETECTION: Uses existing verb relationships for clustering
|
|
120
|
+
*/
|
|
121
|
+
private _performGraphClustering;
|
|
122
|
+
/**
|
|
123
|
+
* MULTI-MODAL FUSION: Combines vector + graph + semantic + Triple Intelligence
|
|
124
|
+
*/
|
|
125
|
+
private _performMultiModalClustering;
|
|
126
|
+
/**
|
|
127
|
+
* SAMPLED CLUSTERING: For very large datasets using intelligent sampling
|
|
128
|
+
*/
|
|
129
|
+
private _performSampledClustering;
|
|
130
|
+
private _similarityById;
|
|
131
|
+
private _similarityByVector;
|
|
132
|
+
private _similarityByText;
|
|
133
|
+
private _isId;
|
|
134
|
+
private _isVector;
|
|
135
|
+
private _convertToVector;
|
|
136
|
+
private _createSimilarityKey;
|
|
137
|
+
private _createClusteringKey;
|
|
138
|
+
private _cacheResult;
|
|
139
|
+
private _trackPerformance;
|
|
140
|
+
private _createPerformanceMetrics;
|
|
141
|
+
private _initializeCleanupTimer;
|
|
142
|
+
/**
|
|
143
|
+
* Build graph structure from existing verb relationships
|
|
144
|
+
*/
|
|
145
|
+
private _buildGraphFromVerbs;
|
|
146
|
+
/**
|
|
147
|
+
* Detect communities using Louvain modularity optimization
|
|
148
|
+
*/
|
|
149
|
+
private _detectCommunities;
|
|
150
|
+
/**
|
|
151
|
+
* Refine community boundaries using vector similarity
|
|
152
|
+
*/
|
|
153
|
+
private _refineCommunitiesWithVectors;
|
|
154
|
+
/**
|
|
155
|
+
* Get items with their metadata including noun types
|
|
156
|
+
*/
|
|
157
|
+
private _getItemsWithMetadata;
|
|
158
|
+
/**
|
|
159
|
+
* Group items by their semantic noun types
|
|
160
|
+
*/
|
|
161
|
+
private _groupBySemanticType;
|
|
162
|
+
private _getAllItemIds;
|
|
163
|
+
private _getTotalItemCount;
|
|
164
|
+
private _calculateTotalWeight;
|
|
165
|
+
private _getNeighborCommunities;
|
|
166
|
+
private _calculateModularityGain;
|
|
167
|
+
private _getNodeDegree;
|
|
168
|
+
private _getEdgesToCommunity;
|
|
169
|
+
private _getCommunityWeight;
|
|
170
|
+
private _calculateCommunityModularity;
|
|
171
|
+
private _calculateCommunityDensity;
|
|
172
|
+
private _findStrongestConnections;
|
|
173
|
+
/**
|
|
174
|
+
* Get items with their vector representations
|
|
175
|
+
*/
|
|
176
|
+
private _getItemsWithVectors;
|
|
177
|
+
/**
|
|
178
|
+
* Calculate centroid from items using existing distance functions
|
|
179
|
+
*/
|
|
180
|
+
private _calculateCentroidFromItems;
|
|
181
|
+
/**
|
|
182
|
+
* Initialize centroids using k-means++ algorithm for better convergence
|
|
183
|
+
*/
|
|
184
|
+
private _initializeCentroidsKMeansPlusPlus;
|
|
185
|
+
/**
|
|
186
|
+
* Assign points to nearest centroids using existing distance functions
|
|
187
|
+
*/
|
|
188
|
+
private _assignPointsToCentroids;
|
|
189
|
+
/**
|
|
190
|
+
* Update centroids based on current assignments
|
|
191
|
+
*/
|
|
192
|
+
private _updateCentroids;
|
|
193
|
+
/**
|
|
194
|
+
* Calculate how much assignments have changed between iterations
|
|
195
|
+
*/
|
|
196
|
+
private _calculateAssignmentChangeRate;
|
|
197
|
+
/**
|
|
198
|
+
* Calculate cluster confidence for k-means clusters
|
|
199
|
+
*/
|
|
200
|
+
private _calculateKMeansClusterConfidence;
|
|
201
|
+
/**
|
|
202
|
+
* Estimate optimal eps parameter using k-nearest neighbor distances
|
|
203
|
+
*/
|
|
204
|
+
private _estimateOptimalEps;
|
|
205
|
+
/**
|
|
206
|
+
* Find neighbors within epsilon distance using efficient vector operations
|
|
207
|
+
*/
|
|
208
|
+
private _findNeighborsWithinEps;
|
|
209
|
+
/**
|
|
210
|
+
* Expand DBSCAN cluster by adding density-reachable points
|
|
211
|
+
*/
|
|
212
|
+
private _expandCluster;
|
|
213
|
+
/**
|
|
214
|
+
* Calculate DBSCAN cluster confidence based on density
|
|
215
|
+
*/
|
|
216
|
+
private _calculateDBSCANClusterConfidence;
|
|
217
|
+
/**
|
|
218
|
+
* Calculate squared Euclidean distance (more efficient than sqrt)
|
|
219
|
+
*/
|
|
220
|
+
private _calculateSquaredDistance;
|
|
221
|
+
/**
|
|
222
|
+
* Calculate vector coherence for community refinement
|
|
223
|
+
*/
|
|
224
|
+
private _calculateVectorCoherence;
|
|
225
|
+
private _getItemsByField;
|
|
226
|
+
/**
|
|
227
|
+
* Generate intelligent cluster labels using Triple Intelligence
|
|
228
|
+
*/
|
|
229
|
+
private _generateIntelligentClusterLabel;
|
|
230
|
+
/**
|
|
231
|
+
* Generate simple cluster labels based on semantic analysis
|
|
232
|
+
*/
|
|
233
|
+
private _generateClusterLabel;
|
|
234
|
+
/**
|
|
235
|
+
* Fuse clustering results using Triple Intelligence consensus
|
|
236
|
+
*/
|
|
237
|
+
private _fuseClusteringResultsWithTripleIntelligence;
|
|
238
|
+
/**
|
|
239
|
+
* Get items in a specific cluster from cluster sets
|
|
240
|
+
*/
|
|
241
|
+
private _getItemsInCluster;
|
|
242
|
+
/**
|
|
243
|
+
* Count co-occurrences between two sets of assignments
|
|
244
|
+
*/
|
|
245
|
+
private _countCoOccurrences;
|
|
246
|
+
/**
|
|
247
|
+
* Calculate fusion confidence based on algorithm agreement
|
|
248
|
+
*/
|
|
249
|
+
private _calculateFusionConfidence;
|
|
250
|
+
/**
|
|
251
|
+
* Generate empty clustering result for edge cases
|
|
252
|
+
*/
|
|
253
|
+
private _createEmptyResult;
|
|
254
|
+
/**
|
|
255
|
+
* Get sample using specified strategy for large dataset clustering
|
|
256
|
+
*/
|
|
257
|
+
private _getSampleUsingStrategy;
|
|
258
|
+
/**
|
|
259
|
+
* Random sampling
|
|
260
|
+
*/
|
|
261
|
+
private _getRandomSample;
|
|
262
|
+
/**
|
|
263
|
+
* Diverse sampling using vector space distribution
|
|
264
|
+
*/
|
|
265
|
+
private _getDiverseSample;
|
|
266
|
+
/**
|
|
267
|
+
* Recent sampling based on creation time
|
|
268
|
+
*/
|
|
269
|
+
private _getRecentSample;
|
|
270
|
+
/**
|
|
271
|
+
* Important sampling based on connection count and metadata
|
|
272
|
+
*/
|
|
273
|
+
private _getImportantSample;
|
|
274
|
+
/**
|
|
275
|
+
* Project clusters back to full dataset using HNSW neighbors
|
|
276
|
+
*/
|
|
277
|
+
private _projectClustersToFullDataset;
|
|
278
|
+
private _groupByDomain;
|
|
279
|
+
private _calculateDomainConfidence;
|
|
280
|
+
private _findCrossDomainMembers;
|
|
281
|
+
private _findCrossDomainClusters;
|
|
282
|
+
private _getItemsByTimeWindow;
|
|
283
|
+
private _calculateTemporalMetrics;
|
|
284
|
+
private _mergeOverlappingTemporalClusters;
|
|
285
|
+
private _adjustThresholdAdaptively;
|
|
286
|
+
private _calculateItemToClusterSimilarity;
|
|
287
|
+
private _recalculateClusterCentroid;
|
|
288
|
+
private _calculateSimilarity;
|
|
289
|
+
private _calculateEdgeWeight;
|
|
290
|
+
private _sortNeighbors;
|
|
291
|
+
private _buildSemanticHierarchy;
|
|
292
|
+
private _detectOutliersClusterBased;
|
|
293
|
+
private _detectOutliersIsolation;
|
|
294
|
+
private _detectOutliersStatistical;
|
|
295
|
+
private _generateVisualizationNodes;
|
|
296
|
+
private _generateVisualizationEdges;
|
|
297
|
+
private _generateVisualizationClusters;
|
|
298
|
+
private _applyLayoutAlgorithm;
|
|
299
|
+
private _manhattanDistance;
|
|
300
|
+
private _calculateConfidence;
|
|
301
|
+
private _generateSimilarityExplanation;
|
|
302
|
+
/**
|
|
303
|
+
* Get performance metrics for monitoring
|
|
304
|
+
*/
|
|
305
|
+
getPerformanceMetrics(operation?: string): Map<string, PerformanceMetrics[]> | PerformanceMetrics[];
|
|
306
|
+
/**
|
|
307
|
+
* Clear all caches
|
|
308
|
+
*/
|
|
309
|
+
clearCaches(): void;
|
|
310
|
+
/**
|
|
311
|
+
* Get cache statistics
|
|
312
|
+
*/
|
|
313
|
+
getCacheStats(): Record<string, {
|
|
314
|
+
size: number;
|
|
315
|
+
maxSize: number;
|
|
316
|
+
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Analyze data characteristics for algorithm selection
|
|
319
|
+
*/
|
|
320
|
+
private _analyzeDataCharacteristics;
|
|
321
|
+
/**
|
|
322
|
+
* Calculate centroid for a group of items
|
|
323
|
+
*/
|
|
324
|
+
private _calculateGroupCentroid;
|
|
325
|
+
/**
|
|
326
|
+
* Cluster within semantic type using vector similarity
|
|
327
|
+
*/
|
|
328
|
+
private _clusterWithinSemanticType;
|
|
329
|
+
/**
|
|
330
|
+
* Find cross-type connections via verbs
|
|
331
|
+
*/
|
|
332
|
+
private _findCrossTypeConnections;
|
|
333
|
+
/**
|
|
334
|
+
* Merge semantic clusters based on connections
|
|
335
|
+
*/
|
|
336
|
+
private _mergeSemanticClusters;
|
|
337
|
+
/**
|
|
338
|
+
* Get optimal clustering level for HNSW
|
|
339
|
+
*/
|
|
340
|
+
private _getOptimalClusteringLevel;
|
|
341
|
+
/**
|
|
342
|
+
* Get nodes at HNSW level
|
|
343
|
+
*/
|
|
344
|
+
private _getHNSWLevelNodes;
|
|
345
|
+
/**
|
|
346
|
+
* Find cluster members using HNSW neighbors
|
|
347
|
+
*/
|
|
348
|
+
private _findClusterMembers;
|
|
349
|
+
/**
|
|
350
|
+
* Calculate hierarchical clustering confidence
|
|
351
|
+
*/
|
|
352
|
+
private _calculateHierarchicalConfidence;
|
|
353
|
+
/**
|
|
354
|
+
* Assign unassigned items to nearest clusters
|
|
355
|
+
*/
|
|
356
|
+
private _assignUnassignedItems;
|
|
357
|
+
}
|