@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
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Display Augmentation - Intelligent Computation Engine
|
|
3
|
+
*
|
|
4
|
+
* Leverages existing Brainy AI infrastructure for intelligent field computation:
|
|
5
|
+
* - BrainyTypes for semantic type detection
|
|
6
|
+
* - Neural Import patterns for field analysis
|
|
7
|
+
* - JSON processing utilities for field extraction
|
|
8
|
+
* - Existing NounType/VerbType taxonomy (31+40 types)
|
|
9
|
+
*/
|
|
10
|
+
import { getBrainyTypes } from '../typeMatching/brainyTypes.js';
|
|
11
|
+
import { getFieldPatterns, getPriorityFields } from './fieldPatterns.js';
|
|
12
|
+
import { prepareJsonForVectorization } from '../../utils/jsonProcessing.js';
|
|
13
|
+
import { NounType, VerbType } from '../../types/graphTypes.js';
|
|
14
|
+
/**
|
|
15
|
+
* Intelligent field computation engine
|
|
16
|
+
* Coordinates AI-powered analysis with fallback heuristics
|
|
17
|
+
*/
|
|
18
|
+
export class IntelligentComputationEngine {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.typeMatcher = null;
|
|
21
|
+
this.initialized = false;
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the computation engine with AI components
|
|
26
|
+
*/
|
|
27
|
+
async initialize() {
|
|
28
|
+
if (this.initialized)
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
// 🧠 LEVERAGE YOUR EXISTING AI INFRASTRUCTURE
|
|
32
|
+
this.typeMatcher = await getBrainyTypes();
|
|
33
|
+
if (this.typeMatcher) {
|
|
34
|
+
console.log('🎨 Display computation engine initialized with AI intelligence');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.warn('🎨 Display computation engine running in basic mode (AI unavailable)');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.warn('🎨 AI initialization failed, using heuristic fallback:', error);
|
|
42
|
+
}
|
|
43
|
+
this.initialized = true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compute display fields for a noun using AI-first approach
|
|
47
|
+
* @param data The noun data/metadata
|
|
48
|
+
* @param id Optional noun ID
|
|
49
|
+
* @returns Computed display fields
|
|
50
|
+
*/
|
|
51
|
+
async computeNounDisplay(data, id) {
|
|
52
|
+
const startTime = Date.now();
|
|
53
|
+
try {
|
|
54
|
+
// 🟢 PRIMARY PATH: Use your existing AI intelligence
|
|
55
|
+
if (this.typeMatcher) {
|
|
56
|
+
return await this.computeWithAI(data, 'noun', { id });
|
|
57
|
+
}
|
|
58
|
+
// 🟡 FALLBACK PATH: Use heuristic patterns
|
|
59
|
+
return await this.computeWithHeuristics(data, 'noun', { id });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.warn('Display computation failed, using minimal fallback:', error);
|
|
63
|
+
return this.createMinimalDisplay(data, 'noun');
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
const computationTime = Date.now() - startTime;
|
|
67
|
+
if (this.config.debugMode) {
|
|
68
|
+
console.log(`Display computation took ${computationTime}ms`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compute display fields for a verb using AI-first approach
|
|
74
|
+
* @param verb The verb/relationship data
|
|
75
|
+
* @returns Computed display fields
|
|
76
|
+
*/
|
|
77
|
+
async computeVerbDisplay(verb) {
|
|
78
|
+
const startTime = Date.now();
|
|
79
|
+
try {
|
|
80
|
+
// 🟢 PRIMARY PATH: Use your existing AI for verb analysis
|
|
81
|
+
if (this.typeMatcher) {
|
|
82
|
+
return await this.computeVerbWithAI(verb);
|
|
83
|
+
}
|
|
84
|
+
// 🟡 FALLBACK PATH: Use heuristic patterns for verbs
|
|
85
|
+
return await this.computeWithHeuristics(verb, 'verb');
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.warn('Verb display computation failed, using minimal fallback:', error);
|
|
89
|
+
return this.createMinimalDisplay(verb, 'verb');
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
const computationTime = Date.now() - startTime;
|
|
93
|
+
if (this.config.debugMode) {
|
|
94
|
+
console.log(`Verb display computation took ${computationTime}ms`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* AI-powered computation using your existing BrainyTypes
|
|
100
|
+
* @param data Entity data/metadata
|
|
101
|
+
* @param entityType Type of entity (noun/verb)
|
|
102
|
+
* @param options Additional options
|
|
103
|
+
* @returns AI-computed display fields
|
|
104
|
+
*/
|
|
105
|
+
async computeWithAI(data, entityType, options = {}) {
|
|
106
|
+
// 🧠 USE YOUR EXISTING TYPE DETECTION AI
|
|
107
|
+
const typeResult = await this.typeMatcher.matchNounType(data);
|
|
108
|
+
// Create computation context
|
|
109
|
+
const context = {
|
|
110
|
+
data,
|
|
111
|
+
metadata: data,
|
|
112
|
+
typeResult,
|
|
113
|
+
config: this.config,
|
|
114
|
+
entityType
|
|
115
|
+
};
|
|
116
|
+
// 🟢 INTELLIGENT FIELD EXTRACTION using your patterns + AI insights
|
|
117
|
+
const displayFields = {
|
|
118
|
+
title: await this.computeIntelligentTitle(context),
|
|
119
|
+
description: await this.computeIntelligentDescription(context),
|
|
120
|
+
type: typeResult.type,
|
|
121
|
+
tags: await this.computeIntelligentTags(context),
|
|
122
|
+
confidence: typeResult.confidence,
|
|
123
|
+
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
|
124
|
+
alternatives: this.config.debugMode ? typeResult.alternatives : undefined,
|
|
125
|
+
computedAt: Date.now(),
|
|
126
|
+
version: '1.0.0'
|
|
127
|
+
};
|
|
128
|
+
return displayFields;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* AI-powered verb computation using relationship analysis
|
|
132
|
+
* @param verb The verb/relationship
|
|
133
|
+
* @returns AI-computed display fields
|
|
134
|
+
*/
|
|
135
|
+
async computeVerbWithAI(verb) {
|
|
136
|
+
// 🧠 USE YOUR EXISTING VERB TYPE DETECTION
|
|
137
|
+
const typeResult = await this.typeMatcher.matchVerbType(verb, 0.7);
|
|
138
|
+
// Create verb computation context
|
|
139
|
+
const context = {
|
|
140
|
+
data: verb,
|
|
141
|
+
metadata: verb.metadata || {},
|
|
142
|
+
typeResult,
|
|
143
|
+
config: this.config,
|
|
144
|
+
entityType: 'verb',
|
|
145
|
+
verbContext: {
|
|
146
|
+
sourceId: verb.sourceId,
|
|
147
|
+
targetId: verb.targetId,
|
|
148
|
+
verbType: verb.type
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
// 🟢 INTELLIGENT VERB DISPLAY COMPUTATION
|
|
152
|
+
const displayFields = {
|
|
153
|
+
title: await this.computeVerbTitle(context),
|
|
154
|
+
description: await this.computeVerbDescription(context),
|
|
155
|
+
type: typeResult.type,
|
|
156
|
+
tags: await this.computeVerbTags(context),
|
|
157
|
+
relationship: await this.computeHumanReadableRelationship(context),
|
|
158
|
+
confidence: typeResult.confidence,
|
|
159
|
+
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
|
160
|
+
alternatives: this.config.debugMode ? typeResult.alternatives : undefined,
|
|
161
|
+
computedAt: Date.now(),
|
|
162
|
+
version: '1.0.0'
|
|
163
|
+
};
|
|
164
|
+
return displayFields;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Heuristic computation when AI is unavailable
|
|
168
|
+
* @param data Entity data
|
|
169
|
+
* @param entityType Type of entity
|
|
170
|
+
* @param options Additional options
|
|
171
|
+
* @returns Heuristically computed display fields
|
|
172
|
+
*/
|
|
173
|
+
async computeWithHeuristics(data, entityType, options = {}) {
|
|
174
|
+
// Use basic type detection
|
|
175
|
+
const detectedType = this.detectTypeHeuristically(data, entityType);
|
|
176
|
+
const typeResult = {
|
|
177
|
+
type: detectedType,
|
|
178
|
+
confidence: 0.6, // Lower confidence for heuristics
|
|
179
|
+
reasoning: 'Heuristic detection (AI unavailable)',
|
|
180
|
+
alternatives: []
|
|
181
|
+
};
|
|
182
|
+
const context = {
|
|
183
|
+
data,
|
|
184
|
+
metadata: data,
|
|
185
|
+
typeResult: typeResult,
|
|
186
|
+
config: this.config,
|
|
187
|
+
entityType
|
|
188
|
+
};
|
|
189
|
+
// Use pattern-based field extraction
|
|
190
|
+
const patterns = getFieldPatterns(entityType, detectedType);
|
|
191
|
+
return {
|
|
192
|
+
title: this.extractFieldWithPatterns(data, patterns, 'title') || 'Untitled',
|
|
193
|
+
description: this.extractFieldWithPatterns(data, patterns, 'description') || 'No description',
|
|
194
|
+
type: detectedType,
|
|
195
|
+
tags: this.extractFieldWithPatterns(data, patterns, 'tags') || [],
|
|
196
|
+
confidence: typeResult.confidence,
|
|
197
|
+
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
|
198
|
+
computedAt: Date.now(),
|
|
199
|
+
version: '1.0.0'
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Compute intelligent title using AI insights and your field extraction
|
|
204
|
+
* @param context Computation context with AI results
|
|
205
|
+
* @returns Computed title
|
|
206
|
+
*/
|
|
207
|
+
async computeIntelligentTitle(context) {
|
|
208
|
+
const { data, typeResult } = context;
|
|
209
|
+
// 🟢 USE TYPE-SPECIFIC LOGIC based on your NounType taxonomy
|
|
210
|
+
switch (typeResult?.type) {
|
|
211
|
+
case NounType.Person:
|
|
212
|
+
return this.computePersonTitle(data);
|
|
213
|
+
case NounType.Organization:
|
|
214
|
+
return this.computeOrganizationTitle(data);
|
|
215
|
+
case NounType.Project:
|
|
216
|
+
return this.computeProjectTitle(data);
|
|
217
|
+
case NounType.Document:
|
|
218
|
+
return this.computeDocumentTitle(data);
|
|
219
|
+
default:
|
|
220
|
+
// 🟢 LEVERAGE YOUR JSON PROCESSING for unknown types
|
|
221
|
+
return this.extractBestTitle(data, typeResult?.type);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Compute intelligent description using AI insights and context
|
|
226
|
+
* @param context Computation context
|
|
227
|
+
* @returns Enhanced description
|
|
228
|
+
*/
|
|
229
|
+
async computeIntelligentDescription(context) {
|
|
230
|
+
const { data, typeResult } = context;
|
|
231
|
+
// 🟢 USE YOUR EXISTING JSON PROCESSING for vectorization-quality text
|
|
232
|
+
const priorityFields = getPriorityFields('noun', typeResult?.type);
|
|
233
|
+
const enhancedText = prepareJsonForVectorization(data, {
|
|
234
|
+
priorityFields,
|
|
235
|
+
includeFieldNames: false,
|
|
236
|
+
maxDepth: 2
|
|
237
|
+
});
|
|
238
|
+
// Create context-aware description based on type
|
|
239
|
+
return this.createContextAwareDescription(data, typeResult, enhancedText);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Compute intelligent tags using type analysis
|
|
243
|
+
* @param context Computation context
|
|
244
|
+
* @returns Generated tags array
|
|
245
|
+
*/
|
|
246
|
+
async computeIntelligentTags(context) {
|
|
247
|
+
const { data, typeResult } = context;
|
|
248
|
+
const tags = [];
|
|
249
|
+
// Add type-based tag
|
|
250
|
+
if (typeResult?.type) {
|
|
251
|
+
tags.push(typeResult.type.toLowerCase());
|
|
252
|
+
}
|
|
253
|
+
// Extract explicit tags from data
|
|
254
|
+
const explicitTags = this.extractExplicitTags(data);
|
|
255
|
+
tags.push(...explicitTags);
|
|
256
|
+
// Add semantic tags based on AI analysis
|
|
257
|
+
if (typeResult && this.typeMatcher) {
|
|
258
|
+
const semanticTags = this.generateSemanticTags(data, typeResult);
|
|
259
|
+
tags.push(...semanticTags);
|
|
260
|
+
}
|
|
261
|
+
// Remove duplicates and return
|
|
262
|
+
return [...new Set(tags.filter(Boolean))];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Compute verb title (relationship summary)
|
|
266
|
+
* @param context Verb computation context
|
|
267
|
+
* @returns Verb title
|
|
268
|
+
*/
|
|
269
|
+
async computeVerbTitle(context) {
|
|
270
|
+
const { verbContext, typeResult } = context;
|
|
271
|
+
if (!verbContext)
|
|
272
|
+
return 'Relationship';
|
|
273
|
+
const { sourceId, targetId } = verbContext;
|
|
274
|
+
const relationshipType = typeResult?.type || 'RelatedTo';
|
|
275
|
+
// Try to get readable names for source and target
|
|
276
|
+
// This could be enhanced to actually resolve the entities
|
|
277
|
+
return `${sourceId} ${this.getReadableVerbPhrase(relationshipType)} ${targetId}`;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Create minimal display for error cases
|
|
281
|
+
* @param data Entity data
|
|
282
|
+
* @param entityType Entity type
|
|
283
|
+
* @returns Minimal display fields
|
|
284
|
+
*/
|
|
285
|
+
createMinimalDisplay(data, entityType) {
|
|
286
|
+
return {
|
|
287
|
+
title: data.name || data.title || data.id || 'Untitled',
|
|
288
|
+
description: data.description || data.summary || 'No description available',
|
|
289
|
+
type: entityType === 'noun' ? 'Item' : 'RelatedTo',
|
|
290
|
+
tags: [],
|
|
291
|
+
confidence: 0.1, // Very low confidence for fallback
|
|
292
|
+
computedAt: Date.now(),
|
|
293
|
+
version: '1.0.0'
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
// Helper methods for specific noun types
|
|
297
|
+
computePersonTitle(data) {
|
|
298
|
+
if (data.firstName && data.lastName) {
|
|
299
|
+
return `${data.firstName} ${data.lastName}`.trim();
|
|
300
|
+
}
|
|
301
|
+
return data.name || data.fullName || data.displayName || data.firstName || data.lastName || 'Person';
|
|
302
|
+
}
|
|
303
|
+
computeOrganizationTitle(data) {
|
|
304
|
+
return data.name || data.companyName || data.organizationName || data.title || 'Organization';
|
|
305
|
+
}
|
|
306
|
+
computeProjectTitle(data) {
|
|
307
|
+
return data.name || data.projectName || data.title || data.projectTitle || 'Project';
|
|
308
|
+
}
|
|
309
|
+
computeDocumentTitle(data) {
|
|
310
|
+
return data.title || data.filename || data.name || data.subject || 'Document';
|
|
311
|
+
}
|
|
312
|
+
extractBestTitle(data, type) {
|
|
313
|
+
const titleFields = ['name', 'title', 'displayName', 'label', 'subject', 'heading'];
|
|
314
|
+
for (const field of titleFields) {
|
|
315
|
+
if (data[field])
|
|
316
|
+
return String(data[field]);
|
|
317
|
+
}
|
|
318
|
+
return data.id || Object.keys(data)[0] || 'Untitled';
|
|
319
|
+
}
|
|
320
|
+
createContextAwareDescription(data, typeResult, enhancedText) {
|
|
321
|
+
// Start with basic description fields
|
|
322
|
+
const basicDesc = data.description || data.summary || data.about || data.details;
|
|
323
|
+
if (basicDesc)
|
|
324
|
+
return String(basicDesc);
|
|
325
|
+
// Use enhanced text from JSON processing
|
|
326
|
+
if (enhancedText && enhancedText.length > 10) {
|
|
327
|
+
return enhancedText.substring(0, 200) + (enhancedText.length > 200 ? '...' : '');
|
|
328
|
+
}
|
|
329
|
+
// Generate from available fields
|
|
330
|
+
const parts = [];
|
|
331
|
+
if (data.role)
|
|
332
|
+
parts.push(data.role);
|
|
333
|
+
if (data.company)
|
|
334
|
+
parts.push(`at ${data.company}`);
|
|
335
|
+
if (data.location)
|
|
336
|
+
parts.push(`in ${data.location}`);
|
|
337
|
+
return parts.length > 0 ? parts.join(' ') : 'No description available';
|
|
338
|
+
}
|
|
339
|
+
extractExplicitTags(data) {
|
|
340
|
+
const tagFields = ['tags', 'keywords', 'labels', 'categories', 'topics'];
|
|
341
|
+
for (const field of tagFields) {
|
|
342
|
+
if (data[field]) {
|
|
343
|
+
if (Array.isArray(data[field])) {
|
|
344
|
+
return data[field].map(String).filter(Boolean);
|
|
345
|
+
}
|
|
346
|
+
if (typeof data[field] === 'string') {
|
|
347
|
+
return data[field].split(/[,;]\s*|\s+/).filter(Boolean);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return [];
|
|
352
|
+
}
|
|
353
|
+
generateSemanticTags(data, typeResult) {
|
|
354
|
+
const tags = [];
|
|
355
|
+
// Add confidence-based tags
|
|
356
|
+
if (typeResult.confidence > 0.9)
|
|
357
|
+
tags.push('verified');
|
|
358
|
+
else if (typeResult.confidence < 0.7)
|
|
359
|
+
tags.push('uncertain');
|
|
360
|
+
// Add type-specific semantic tags
|
|
361
|
+
if (data.status)
|
|
362
|
+
tags.push(String(data.status).toLowerCase());
|
|
363
|
+
if (data.priority)
|
|
364
|
+
tags.push(String(data.priority).toLowerCase());
|
|
365
|
+
if (data.category)
|
|
366
|
+
tags.push(String(data.category).toLowerCase());
|
|
367
|
+
return tags;
|
|
368
|
+
}
|
|
369
|
+
getReadableVerbPhrase(verbType) {
|
|
370
|
+
const verbPhrases = {
|
|
371
|
+
[VerbType.WorksWith]: 'works with',
|
|
372
|
+
[VerbType.MemberOf]: 'is member of',
|
|
373
|
+
[VerbType.ReportsTo]: 'reports to',
|
|
374
|
+
[VerbType.CreatedBy]: 'created by',
|
|
375
|
+
[VerbType.Owns]: 'owns',
|
|
376
|
+
[VerbType.LocatedAt]: 'located at',
|
|
377
|
+
[VerbType.Likes]: 'likes',
|
|
378
|
+
[VerbType.Follows]: 'follows',
|
|
379
|
+
[VerbType.Supervises]: 'supervises'
|
|
380
|
+
};
|
|
381
|
+
return verbPhrases[verbType] || 'related to';
|
|
382
|
+
}
|
|
383
|
+
async computeVerbDescription(context) {
|
|
384
|
+
const { data, verbContext, typeResult } = context;
|
|
385
|
+
if (data.description)
|
|
386
|
+
return String(data.description);
|
|
387
|
+
// Generate contextual description for relationship
|
|
388
|
+
if (verbContext && typeResult) {
|
|
389
|
+
const parts = [];
|
|
390
|
+
const relationshipPhrase = this.getReadableVerbPhrase(typeResult.type);
|
|
391
|
+
if (data.role)
|
|
392
|
+
parts.push(`Role: ${data.role}`);
|
|
393
|
+
if (data.startDate)
|
|
394
|
+
parts.push(`Since: ${new Date(data.startDate).toLocaleDateString()}`);
|
|
395
|
+
if (data.department)
|
|
396
|
+
parts.push(`Department: ${data.department}`);
|
|
397
|
+
return parts.length > 0
|
|
398
|
+
? `${relationshipPhrase} - ${parts.join(', ')}`
|
|
399
|
+
: `${relationshipPhrase} relationship`;
|
|
400
|
+
}
|
|
401
|
+
return 'Relationship';
|
|
402
|
+
}
|
|
403
|
+
async computeVerbTags(context) {
|
|
404
|
+
const { data, typeResult } = context;
|
|
405
|
+
const tags = ['relationship'];
|
|
406
|
+
if (typeResult?.type) {
|
|
407
|
+
tags.push(typeResult.type.toLowerCase());
|
|
408
|
+
}
|
|
409
|
+
// Add relationship-specific tags
|
|
410
|
+
if (data.status)
|
|
411
|
+
tags.push(String(data.status).toLowerCase());
|
|
412
|
+
if (data.type)
|
|
413
|
+
tags.push(String(data.type).toLowerCase());
|
|
414
|
+
return [...new Set(tags)];
|
|
415
|
+
}
|
|
416
|
+
async computeHumanReadableRelationship(context) {
|
|
417
|
+
const { verbContext, typeResult } = context;
|
|
418
|
+
if (!verbContext || !typeResult)
|
|
419
|
+
return 'Related';
|
|
420
|
+
const { sourceId, targetId } = verbContext;
|
|
421
|
+
const phrase = this.getReadableVerbPhrase(typeResult.type);
|
|
422
|
+
return `${sourceId} ${phrase} ${targetId}`;
|
|
423
|
+
}
|
|
424
|
+
detectTypeHeuristically(data, entityType) {
|
|
425
|
+
if (entityType === 'verb')
|
|
426
|
+
return VerbType.RelatedTo;
|
|
427
|
+
// Basic heuristics for noun types
|
|
428
|
+
if (data.firstName || data.lastName || data.email)
|
|
429
|
+
return NounType.Person;
|
|
430
|
+
if (data.companyName || data.organization)
|
|
431
|
+
return NounType.Organization;
|
|
432
|
+
if (data.filename || data.fileType)
|
|
433
|
+
return NounType.Document;
|
|
434
|
+
if (data.projectName || data.initiative)
|
|
435
|
+
return NounType.Project;
|
|
436
|
+
if (data.taskName || data.todo)
|
|
437
|
+
return NounType.Task;
|
|
438
|
+
if (data.startDate || data.endDate)
|
|
439
|
+
return NounType.Event;
|
|
440
|
+
return 'Item'; // Generic fallback
|
|
441
|
+
}
|
|
442
|
+
extractFieldWithPatterns(data, patterns, fieldType) {
|
|
443
|
+
const relevantPatterns = patterns.filter(p => p.displayField === fieldType);
|
|
444
|
+
for (const pattern of relevantPatterns) {
|
|
445
|
+
for (const field of pattern.fields) {
|
|
446
|
+
if (data[field]) {
|
|
447
|
+
return pattern.transform ? pattern.transform(data[field], { data, config: this.config }) : data[field];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Shutdown the computation engine
|
|
455
|
+
*/
|
|
456
|
+
async shutdown() {
|
|
457
|
+
// Cleanup if needed
|
|
458
|
+
this.typeMatcher = null;
|
|
459
|
+
this.initialized = false;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=intelligentComputation.js.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Display Augmentation - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Clean TypeScript interfaces for the display augmentation system
|
|
5
|
+
*/
|
|
6
|
+
import type { VectorDocument, GraphVerb } from '../../coreTypes.js';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration interface for the Universal Display Augmentation
|
|
9
|
+
*/
|
|
10
|
+
export interface DisplayConfig {
|
|
11
|
+
/** Enable/disable the augmentation */
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/** LRU cache size for computed display fields */
|
|
14
|
+
cacheSize: number;
|
|
15
|
+
/** Use lazy computation (recommended for performance) */
|
|
16
|
+
lazyComputation: boolean;
|
|
17
|
+
/** Batch processing size for multiple requests */
|
|
18
|
+
batchSize: number;
|
|
19
|
+
/** Minimum confidence threshold for AI type detection */
|
|
20
|
+
confidenceThreshold: number;
|
|
21
|
+
/** Custom field mappings (userField -> displayField) */
|
|
22
|
+
customFieldMappings: Record<string, string>;
|
|
23
|
+
/** Type-specific priority fields for intelligent detection */
|
|
24
|
+
priorityFields: Record<string, string[]>;
|
|
25
|
+
/** Enable debug mode with reasoning output */
|
|
26
|
+
debugMode: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Computed display fields for any noun or verb
|
|
30
|
+
*/
|
|
31
|
+
export interface ComputedDisplayFields {
|
|
32
|
+
/** Primary display name (AI-detected best field combination) */
|
|
33
|
+
title: string;
|
|
34
|
+
/** Enhanced description with context awareness */
|
|
35
|
+
description: string;
|
|
36
|
+
/** Human-readable type name */
|
|
37
|
+
type: string;
|
|
38
|
+
/** Generated display tags for categorization */
|
|
39
|
+
tags: string[];
|
|
40
|
+
/** For verbs: human-readable relationship description */
|
|
41
|
+
relationship?: string;
|
|
42
|
+
/** AI confidence score (0-1) */
|
|
43
|
+
confidence: number;
|
|
44
|
+
/** Explanation of type detection reasoning (debug mode) */
|
|
45
|
+
reasoning?: string;
|
|
46
|
+
/** Alternative type suggestions with confidence scores */
|
|
47
|
+
alternatives?: Array<{
|
|
48
|
+
type: string;
|
|
49
|
+
confidence: number;
|
|
50
|
+
}>;
|
|
51
|
+
/** Timestamp when fields were computed */
|
|
52
|
+
computedAt: number;
|
|
53
|
+
/** Version of augmentation that computed these fields */
|
|
54
|
+
version: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Cache entry for computed display fields
|
|
58
|
+
*/
|
|
59
|
+
export interface DisplayCacheEntry {
|
|
60
|
+
fields: ComputedDisplayFields;
|
|
61
|
+
lastAccessed: number;
|
|
62
|
+
accessCount: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Field computation context passed to computation functions
|
|
66
|
+
*/
|
|
67
|
+
export interface FieldComputationContext {
|
|
68
|
+
/** The original data object */
|
|
69
|
+
data: any;
|
|
70
|
+
/** Metadata associated with the object */
|
|
71
|
+
metadata: any;
|
|
72
|
+
/** Type detection result from AI */
|
|
73
|
+
typeResult?: TypeMatchResult;
|
|
74
|
+
/** Display configuration */
|
|
75
|
+
config: DisplayConfig;
|
|
76
|
+
/** Whether this is a noun or verb */
|
|
77
|
+
entityType: 'noun' | 'verb';
|
|
78
|
+
/** For verbs: source and target information */
|
|
79
|
+
verbContext?: {
|
|
80
|
+
sourceId: string;
|
|
81
|
+
targetId: string;
|
|
82
|
+
verbType?: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Type matching result from BrainyTypes
|
|
87
|
+
*/
|
|
88
|
+
export interface TypeMatchResult {
|
|
89
|
+
type: string;
|
|
90
|
+
confidence: number;
|
|
91
|
+
reasoning: string;
|
|
92
|
+
alternatives: Array<{
|
|
93
|
+
type: string;
|
|
94
|
+
confidence: number;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Enhanced VectorDocument with display capabilities
|
|
99
|
+
*/
|
|
100
|
+
export interface EnhancedVectorDocument<T = any> extends VectorDocument<T> {
|
|
101
|
+
/**
|
|
102
|
+
* Get computed display field(s)
|
|
103
|
+
* @param field Optional specific field name
|
|
104
|
+
* @returns Single field value or all display fields
|
|
105
|
+
*/
|
|
106
|
+
getDisplay(): Promise<ComputedDisplayFields>;
|
|
107
|
+
getDisplay(field: keyof ComputedDisplayFields): Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* Get available fields for a specific augmentation namespace
|
|
110
|
+
* @param namespace The augmentation namespace (e.g., 'display')
|
|
111
|
+
* @returns Array of available field names
|
|
112
|
+
*/
|
|
113
|
+
getAvailableFields(namespace: string): string[];
|
|
114
|
+
/**
|
|
115
|
+
* Get available augmentation namespaces
|
|
116
|
+
* @returns Array of available augmentation names
|
|
117
|
+
*/
|
|
118
|
+
getAvailableAugmentations(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Debug exploration of all computed fields
|
|
121
|
+
*/
|
|
122
|
+
explore(): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Enhanced GraphVerb with display capabilities
|
|
126
|
+
*/
|
|
127
|
+
export interface EnhancedGraphVerb extends GraphVerb {
|
|
128
|
+
/**
|
|
129
|
+
* Get computed display field(s) for relationships
|
|
130
|
+
* @param field Optional specific field name
|
|
131
|
+
* @returns Single field value or all display fields
|
|
132
|
+
*/
|
|
133
|
+
getDisplay(): Promise<ComputedDisplayFields>;
|
|
134
|
+
getDisplay(field: keyof ComputedDisplayFields): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
* Get available fields for a specific augmentation namespace
|
|
137
|
+
* @param namespace The augmentation namespace (e.g., 'display')
|
|
138
|
+
* @returns Array of available field names
|
|
139
|
+
*/
|
|
140
|
+
getAvailableFields(namespace: string): string[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Batch computation request for performance optimization
|
|
144
|
+
*/
|
|
145
|
+
export interface BatchComputationRequest {
|
|
146
|
+
id: string;
|
|
147
|
+
data: any;
|
|
148
|
+
metadata: any;
|
|
149
|
+
entityType: 'noun' | 'verb';
|
|
150
|
+
verbContext?: {
|
|
151
|
+
sourceId: string;
|
|
152
|
+
targetId: string;
|
|
153
|
+
verbType?: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Batch computation result
|
|
158
|
+
*/
|
|
159
|
+
export interface BatchComputationResult {
|
|
160
|
+
id: string;
|
|
161
|
+
fields: ComputedDisplayFields;
|
|
162
|
+
error?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Field pattern for intelligent field detection
|
|
166
|
+
*/
|
|
167
|
+
export interface FieldPattern {
|
|
168
|
+
/** Field names that match this pattern */
|
|
169
|
+
fields: string[];
|
|
170
|
+
/** Target display field name */
|
|
171
|
+
displayField: keyof ComputedDisplayFields;
|
|
172
|
+
/** Confidence score for this pattern match */
|
|
173
|
+
confidence: number;
|
|
174
|
+
/** Optional: specific noun/verb types this applies to */
|
|
175
|
+
applicableTypes?: string[];
|
|
176
|
+
/** Optional: transformation function for the field value */
|
|
177
|
+
transform?: (value: any, context: FieldComputationContext) => string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Statistics for the display augmentation
|
|
181
|
+
*/
|
|
182
|
+
export interface DisplayAugmentationStats {
|
|
183
|
+
/** Total number of computations performed */
|
|
184
|
+
totalComputations: number;
|
|
185
|
+
/** Cache hit ratio */
|
|
186
|
+
cacheHitRatio: number;
|
|
187
|
+
/** Average computation time in milliseconds */
|
|
188
|
+
averageComputationTime: number;
|
|
189
|
+
/** Type detection accuracy (when ground truth available) */
|
|
190
|
+
typeDetectionAccuracy?: number;
|
|
191
|
+
/** Most commonly detected types */
|
|
192
|
+
commonTypes: Array<{
|
|
193
|
+
type: string;
|
|
194
|
+
count: number;
|
|
195
|
+
percentage: number;
|
|
196
|
+
}>;
|
|
197
|
+
/** Performance metrics */
|
|
198
|
+
performance: {
|
|
199
|
+
fastestComputation: number;
|
|
200
|
+
slowestComputation: number;
|
|
201
|
+
totalComputationTime: number;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -52,12 +52,14 @@ export declare class EntityRegistryAugmentation extends BaseAugmentation {
|
|
|
52
52
|
readonly timing: 'before' | 'after' | 'around' | 'replace';
|
|
53
53
|
readonly operations: ("add" | "addNoun" | "addVerb")[];
|
|
54
54
|
readonly priority = 90;
|
|
55
|
-
|
|
55
|
+
protected config: Required<EntityRegistryConfig>;
|
|
56
56
|
private memoryIndex;
|
|
57
57
|
private fieldIndices;
|
|
58
58
|
private syncTimer?;
|
|
59
59
|
private brain?;
|
|
60
60
|
private storage?;
|
|
61
|
+
private cacheHits;
|
|
62
|
+
private cacheMisses;
|
|
61
63
|
constructor(config?: EntityRegistryConfig);
|
|
62
64
|
initialize(context: AugmentationContext): Promise<void>;
|
|
63
65
|
shutdown(): Promise<void>;
|