@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
package/bin/brainy.js
CHANGED
|
@@ -61,6 +61,200 @@ const initBrainy = async () => {
|
|
|
61
61
|
return new BrainyData()
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Enhanced result formatting using display augmentation
|
|
66
|
+
* @param {any} result - The result object from search/get/find
|
|
67
|
+
* @param {number} index - Result index for numbering
|
|
68
|
+
* @returns {Promise<string>} Formatted result string
|
|
69
|
+
*/
|
|
70
|
+
const formatResultWithDisplay = async (result, index) => {
|
|
71
|
+
try {
|
|
72
|
+
// Check if result has display capabilities (enhanced by display augmentation)
|
|
73
|
+
if (result.getDisplay && typeof result.getDisplay === 'function') {
|
|
74
|
+
const displayFields = await result.getDisplay()
|
|
75
|
+
|
|
76
|
+
// Format with enhanced display fields (clean, no icons)
|
|
77
|
+
let output = colors.primary(`\n${index + 1}. ${displayFields.title}`)
|
|
78
|
+
|
|
79
|
+
if (displayFields.type) {
|
|
80
|
+
output += colors.dim(` (${displayFields.type})`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (result.score) {
|
|
84
|
+
output += colors.info(`\n 🎯 Relevance: ${(result.score * 100).toFixed(1)}%`)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (result.fusionScore) {
|
|
88
|
+
output += colors.info(`\n 🧠 AI Score: ${(result.fusionScore * 100).toFixed(1)}%`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (displayFields.description && displayFields.description !== displayFields.title) {
|
|
92
|
+
output += colors.info(`\n 📄 ${displayFields.description}`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
96
|
+
output += colors.cyan(`\n 🏷️ ${displayFields.tags.join(', ')}`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Show relationship info for verbs
|
|
100
|
+
if (displayFields.relationship) {
|
|
101
|
+
output += colors.yellow(`\n 🔗 ${displayFields.relationship}`)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Show metadata only if there's additional useful info
|
|
105
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
106
|
+
const filteredMetadata = Object.fromEntries(
|
|
107
|
+
Object.entries(result.metadata).filter(([key]) =>
|
|
108
|
+
!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
if (Object.keys(filteredMetadata).length > 0) {
|
|
112
|
+
output += colors.dim(`\n 📝 ${JSON.stringify(filteredMetadata)}`)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return output
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
// Fallback silently to basic formatting if display augmentation fails
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Fallback: Basic formatting without display augmentation
|
|
123
|
+
let output = colors.primary(`\n${index + 1}. ${result.content || result.id}`)
|
|
124
|
+
|
|
125
|
+
if (result.score) {
|
|
126
|
+
output += colors.info(`\n Relevance: ${(result.score * 100).toFixed(1)}%`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (result.fusionScore) {
|
|
130
|
+
output += colors.info(`\n AI Score: ${(result.fusionScore * 100).toFixed(1)}%`)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (result.type) {
|
|
134
|
+
output += colors.info(`\n Type: ${result.type}`)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
138
|
+
output += colors.dim(`\n Metadata: ${JSON.stringify(result.metadata)}`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return output
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Enhanced single item formatting for get command
|
|
146
|
+
* @param {any} item - The item object
|
|
147
|
+
* @param {string} format - Output format (json, table, plain)
|
|
148
|
+
* @returns {Promise<string>} Formatted item string
|
|
149
|
+
*/
|
|
150
|
+
const formatItemWithDisplay = async (item, format = 'plain') => {
|
|
151
|
+
if (format === 'json') {
|
|
152
|
+
return JSON.stringify(item, null, 2)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
// Check if item has display capabilities
|
|
157
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
158
|
+
const displayFields = await item.getDisplay()
|
|
159
|
+
|
|
160
|
+
if (format === 'table') {
|
|
161
|
+
const table = new Table({
|
|
162
|
+
head: [colors.brain('Property'), colors.brain('Value')],
|
|
163
|
+
style: { head: [], border: [] }
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
table.push(['ID', colors.primary(item.id)])
|
|
167
|
+
table.push(['Title', colors.primary(displayFields.title)])
|
|
168
|
+
table.push(['Type', colors.info(displayFields.type)])
|
|
169
|
+
table.push(['Description', colors.info(displayFields.description)])
|
|
170
|
+
|
|
171
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
172
|
+
table.push(['Tags', colors.cyan(displayFields.tags.join(', '))])
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (displayFields.relationship) {
|
|
176
|
+
table.push(['Relationship', colors.yellow(displayFields.relationship)])
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (item.content && item.content !== displayFields.title) {
|
|
180
|
+
table.push(['Content', colors.dim(item.content)])
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Add non-internal metadata
|
|
184
|
+
if (item.metadata) {
|
|
185
|
+
Object.entries(item.metadata).forEach(([key, value]) => {
|
|
186
|
+
if (!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)) {
|
|
187
|
+
table.push([key, colors.dim(JSON.stringify(value))])
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return table.toString()
|
|
193
|
+
} else {
|
|
194
|
+
// Plain format with display enhancement
|
|
195
|
+
let output = colors.primary(`ID: ${item.id}`)
|
|
196
|
+
output += colors.primary(`\nTitle: ${displayFields.title}`)
|
|
197
|
+
output += colors.info(`\nType: ${displayFields.type}`)
|
|
198
|
+
output += colors.info(`\nDescription: ${displayFields.description}`)
|
|
199
|
+
|
|
200
|
+
if (displayFields.tags && displayFields.tags.length > 0) {
|
|
201
|
+
output += colors.cyan(`\nTags: ${displayFields.tags.join(', ')}`)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (displayFields.relationship) {
|
|
205
|
+
output += colors.yellow(`\nRelationship: ${displayFields.relationship}`)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (item.content && item.content !== displayFields.title) {
|
|
209
|
+
output += colors.dim(`\nOriginal Content: ${item.content}`)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Show additional metadata
|
|
213
|
+
if (item.metadata) {
|
|
214
|
+
const additionalMetadata = Object.fromEntries(
|
|
215
|
+
Object.entries(item.metadata).filter(([key]) =>
|
|
216
|
+
!key.startsWith('_') && !['type', 'title', 'description', 'icon'].includes(key)
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
if (Object.keys(additionalMetadata).length > 0) {
|
|
220
|
+
output += colors.dim(`\nAdditional Metadata: ${JSON.stringify(additionalMetadata, null, 2)}`)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return output
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
// Fallback silently to basic formatting
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Fallback: Basic formatting
|
|
232
|
+
if (format === 'table') {
|
|
233
|
+
const table = new Table({
|
|
234
|
+
head: [colors.brain('Property'), colors.brain('Value')],
|
|
235
|
+
style: { head: [], border: [] }
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
table.push(['ID', colors.primary(item.id)])
|
|
239
|
+
table.push(['Content', colors.info(item.content || 'N/A')])
|
|
240
|
+
if (item.metadata) {
|
|
241
|
+
Object.entries(item.metadata).forEach(([key, value]) => {
|
|
242
|
+
table.push([key, colors.dim(JSON.stringify(value))])
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
return table.toString()
|
|
246
|
+
} else {
|
|
247
|
+
let output = colors.primary(`ID: ${item.id}`)
|
|
248
|
+
if (item.content) {
|
|
249
|
+
output += colors.info(`\nContent: ${item.content}`)
|
|
250
|
+
}
|
|
251
|
+
if (item.metadata && Object.keys(item.metadata).length > 0) {
|
|
252
|
+
output += colors.info(`\nMetadata: ${JSON.stringify(item.metadata, null, 2)}`)
|
|
253
|
+
}
|
|
254
|
+
return output
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
64
258
|
const wrapAction = (fn) => {
|
|
65
259
|
return async (...args) => {
|
|
66
260
|
try {
|
|
@@ -675,18 +869,12 @@ program
|
|
|
675
869
|
}
|
|
676
870
|
|
|
677
871
|
console.log(colors.success(`✅ Found ${results.length} intelligent results:`))
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
console.log(colors.info(` AI Score: ${(result.fusionScore * 100).toFixed(1)}%`))
|
|
685
|
-
}
|
|
686
|
-
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
687
|
-
console.log(colors.dim(` Metadata: ${JSON.stringify(result.metadata)}`))
|
|
688
|
-
}
|
|
689
|
-
})
|
|
872
|
+
|
|
873
|
+
// Use enhanced formatting with display augmentation
|
|
874
|
+
for (let i = 0; i < results.length; i++) {
|
|
875
|
+
const formattedResult = await formatResultWithDisplay(results[i], i)
|
|
876
|
+
console.log(formattedResult)
|
|
877
|
+
}
|
|
690
878
|
}))
|
|
691
879
|
|
|
692
880
|
// Command 4: SEARCH - Triple-power search
|
|
@@ -777,15 +965,12 @@ program
|
|
|
777
965
|
}
|
|
778
966
|
|
|
779
967
|
console.log(colors.success(`✅ Found ${results.length} results:`))
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
console.log(colors.info(` Type: ${result.type}`))
|
|
787
|
-
}
|
|
788
|
-
})
|
|
968
|
+
|
|
969
|
+
// Use enhanced formatting with display augmentation
|
|
970
|
+
for (let i = 0; i < results.length; i++) {
|
|
971
|
+
const formattedResult = await formatResultWithDisplay(results[i], i)
|
|
972
|
+
console.log(formattedResult)
|
|
973
|
+
}
|
|
789
974
|
}))
|
|
790
975
|
|
|
791
976
|
// Command 4: GET - Retrieve specific data by ID
|
|
@@ -793,6 +978,7 @@ program
|
|
|
793
978
|
.command('get [id]')
|
|
794
979
|
.description('Get a specific item by ID')
|
|
795
980
|
.option('-f, --format <format>', 'Output format (json, table, plain)', 'plain')
|
|
981
|
+
.option('--display-debug', 'Show debug information about display augmentation')
|
|
796
982
|
.action(wrapAction(async (id, options) => {
|
|
797
983
|
if (!id) {
|
|
798
984
|
console.log(colors.primary('🔍 Interactive Get Mode'))
|
|
@@ -826,31 +1012,52 @@ program
|
|
|
826
1012
|
return
|
|
827
1013
|
}
|
|
828
1014
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
head: [colors.brain('Property'), colors.brain('Value')],
|
|
834
|
-
style: { head: [], border: [] }
|
|
835
|
-
})
|
|
1015
|
+
// Show display debug information if requested
|
|
1016
|
+
if (options.displayDebug) {
|
|
1017
|
+
console.log(colors.primary('🔍 Display Augmentation Debug Information'))
|
|
1018
|
+
console.log('=' .repeat(50))
|
|
836
1019
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1020
|
+
try {
|
|
1021
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1022
|
+
console.log(colors.success('✅ Display augmentation active'))
|
|
1023
|
+
|
|
1024
|
+
const displayFields = await item.getDisplay()
|
|
1025
|
+
console.log(colors.info('\n🎨 Computed Display Fields:'))
|
|
1026
|
+
Object.entries(displayFields).forEach(([key, value]) => {
|
|
1027
|
+
console.log(colors.cyan(` ${key}: ${JSON.stringify(value)}`))
|
|
1028
|
+
})
|
|
1029
|
+
|
|
1030
|
+
// Show available fields
|
|
1031
|
+
if (item.getAvailableFields && typeof item.getAvailableFields === 'function') {
|
|
1032
|
+
const availableFields = item.getAvailableFields('display')
|
|
1033
|
+
console.log(colors.info('\n📋 Available Display Fields:'))
|
|
1034
|
+
availableFields.forEach(field => {
|
|
1035
|
+
console.log(colors.dim(` - ${field}`))
|
|
1036
|
+
})
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Show augmentation info
|
|
1040
|
+
if (item.getAvailableAugmentations && typeof item.getAvailableAugmentations === 'function') {
|
|
1041
|
+
const augs = item.getAvailableAugmentations()
|
|
1042
|
+
console.log(colors.info('\n🔌 Available Augmentations:'))
|
|
1043
|
+
augs.forEach(aug => {
|
|
1044
|
+
console.log(colors.dim(` - ${aug}`))
|
|
1045
|
+
})
|
|
1046
|
+
}
|
|
1047
|
+
} else {
|
|
1048
|
+
console.log(colors.warning('⚠️ Display augmentation not active or not enhanced'))
|
|
1049
|
+
console.log(colors.dim(' Item does not have getDisplay() method'))
|
|
1050
|
+
}
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
console.log(colors.error(`❌ Display debug error: ${error.message}`))
|
|
852
1053
|
}
|
|
1054
|
+
|
|
1055
|
+
console.log('\n' + '=' .repeat(50))
|
|
853
1056
|
}
|
|
1057
|
+
|
|
1058
|
+
// Use enhanced formatting with display augmentation
|
|
1059
|
+
const formattedItem = await formatItemWithDisplay(item, options.format)
|
|
1060
|
+
console.log(formattedItem)
|
|
854
1061
|
}))
|
|
855
1062
|
|
|
856
1063
|
// Command 5: UPDATE - Update existing data
|
|
@@ -875,9 +1082,21 @@ program
|
|
|
875
1082
|
|
|
876
1083
|
if (recent.length > 0) {
|
|
877
1084
|
console.log(colors.cyan('Recent items:'))
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1085
|
+
|
|
1086
|
+
// Enhanced display for recent items
|
|
1087
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1088
|
+
const item = recent[i]
|
|
1089
|
+
try {
|
|
1090
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1091
|
+
const displayFields = await item.getDisplay()
|
|
1092
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${displayFields.title}`))
|
|
1093
|
+
} else {
|
|
1094
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1095
|
+
}
|
|
1096
|
+
} catch {
|
|
1097
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
881
1100
|
console.log()
|
|
882
1101
|
}
|
|
883
1102
|
|
|
@@ -953,9 +1172,21 @@ program
|
|
|
953
1172
|
|
|
954
1173
|
if (recent.length > 0) {
|
|
955
1174
|
console.log(colors.cyan('Recent items:'))
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1175
|
+
|
|
1176
|
+
// Enhanced display for recent items
|
|
1177
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1178
|
+
const item = recent[i]
|
|
1179
|
+
try {
|
|
1180
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1181
|
+
const displayFields = await item.getDisplay()
|
|
1182
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${displayFields.title}`))
|
|
1183
|
+
} else {
|
|
1184
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1185
|
+
}
|
|
1186
|
+
} catch {
|
|
1187
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 50)}...`))
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
959
1190
|
console.log()
|
|
960
1191
|
}
|
|
961
1192
|
|
|
@@ -1150,9 +1381,21 @@ program
|
|
|
1150
1381
|
const recent = await brainyInstance.search('*', { limit: 10, sortBy: 'timestamp' })
|
|
1151
1382
|
if (recent.length > 0) {
|
|
1152
1383
|
console.log(colors.cyan('Recent items (source):'))
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1384
|
+
|
|
1385
|
+
// Enhanced display for recent items
|
|
1386
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1387
|
+
const item = recent[i]
|
|
1388
|
+
try {
|
|
1389
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1390
|
+
const displayFields = await item.getDisplay()
|
|
1391
|
+
console.log(colors.info(` ${i + 1}. ${displayFields.icon} ${item.id} - ${displayFields.title}`))
|
|
1392
|
+
} else {
|
|
1393
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1394
|
+
}
|
|
1395
|
+
} catch {
|
|
1396
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1156
1399
|
console.log()
|
|
1157
1400
|
}
|
|
1158
1401
|
|
|
@@ -1202,9 +1445,21 @@ program
|
|
|
1202
1445
|
const recent = await brainyInstance.search('*', { limit: 10, sortBy: 'timestamp' })
|
|
1203
1446
|
if (recent.length > 0) {
|
|
1204
1447
|
console.log(colors.cyan('\nRecent items (target):'))
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1448
|
+
|
|
1449
|
+
// Enhanced display for recent items
|
|
1450
|
+
for (let i = 0; i < Math.min(recent.length, 10); i++) {
|
|
1451
|
+
const item = recent[i]
|
|
1452
|
+
try {
|
|
1453
|
+
if (item.getDisplay && typeof item.getDisplay === 'function') {
|
|
1454
|
+
const displayFields = await item.getDisplay()
|
|
1455
|
+
console.log(colors.info(` ${i + 1}. ${displayFields.icon} ${item.id} - ${displayFields.title}`))
|
|
1456
|
+
} else {
|
|
1457
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1458
|
+
}
|
|
1459
|
+
} catch {
|
|
1460
|
+
console.log(colors.info(` ${i + 1}. ${item.id} - ${item.content?.substring(0, 40)}...`))
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1208
1463
|
console.log()
|
|
1209
1464
|
}
|
|
1210
1465
|
|
|
@@ -1365,16 +1620,39 @@ program
|
|
|
1365
1620
|
|
|
1366
1621
|
// Active Augmentations
|
|
1367
1622
|
console.log(colors.primary('🔌 Active Augmentations'))
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1623
|
+
try {
|
|
1624
|
+
// Check for display augmentation specifically
|
|
1625
|
+
const displayAugmentation = (brainy as any).augmentations?.get('display')
|
|
1626
|
+
if (displayAugmentation) {
|
|
1627
|
+
console.log(colors.success(` ✅ display - Universal Display Augmentation`))
|
|
1628
|
+
console.log(colors.info(` 🎨 AI-powered titles and descriptions`))
|
|
1629
|
+
|
|
1630
|
+
// Get display augmentation stats if available
|
|
1631
|
+
if (displayAugmentation.getStats) {
|
|
1632
|
+
const stats = displayAugmentation.getStats()
|
|
1633
|
+
if (stats.totalComputations > 0) {
|
|
1634
|
+
console.log(colors.dim(` 📊 ${stats.totalComputations} computations, ${(stats.cacheHitRatio * 100).toFixed(1)}% cache hit rate`))
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// Show other augmentations
|
|
1640
|
+
const otherAugs = (brainy as any).augmentations ?
|
|
1641
|
+
Array.from((brainy as any).augmentations.values()).filter((aug: any) => aug.name !== 'display') :
|
|
1642
|
+
[]
|
|
1643
|
+
|
|
1644
|
+
otherAugs.forEach((aug: any) => {
|
|
1373
1645
|
console.log(colors.success(` ✅ ${aug.name}`))
|
|
1374
|
-
if (aug.
|
|
1375
|
-
console.log(colors.info(` ${aug.description}`))
|
|
1646
|
+
if (aug.version) {
|
|
1647
|
+
console.log(colors.info(` v${aug.version} - ${aug.description || 'No description'}`))
|
|
1376
1648
|
}
|
|
1377
1649
|
})
|
|
1650
|
+
|
|
1651
|
+
if (!displayAugmentation && otherAugs.length === 0) {
|
|
1652
|
+
console.log(colors.warning(' No augmentations currently active'))
|
|
1653
|
+
}
|
|
1654
|
+
} catch (error) {
|
|
1655
|
+
console.log(colors.warning(' Augmentation status unavailable'))
|
|
1378
1656
|
}
|
|
1379
1657
|
console.log()
|
|
1380
1658
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration API for Brainy 3.0
|
|
3
|
+
* Provides configuration storage with optional encryption
|
|
4
|
+
*/
|
|
5
|
+
import { StorageAdapter } from '../coreTypes.js';
|
|
6
|
+
export interface ConfigOptions {
|
|
7
|
+
encrypt?: boolean;
|
|
8
|
+
decrypt?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigEntry {
|
|
11
|
+
key: string;
|
|
12
|
+
value: any;
|
|
13
|
+
encrypted: boolean;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class ConfigAPI {
|
|
18
|
+
private storage;
|
|
19
|
+
private security;
|
|
20
|
+
private configCache;
|
|
21
|
+
private CONFIG_NOUN_PREFIX;
|
|
22
|
+
constructor(storage: StorageAdapter);
|
|
23
|
+
/**
|
|
24
|
+
* Set a configuration value with optional encryption
|
|
25
|
+
*/
|
|
26
|
+
set(params: {
|
|
27
|
+
key: string;
|
|
28
|
+
value: any;
|
|
29
|
+
encrypt?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a configuration value with optional decryption
|
|
33
|
+
*/
|
|
34
|
+
get(params: {
|
|
35
|
+
key: string;
|
|
36
|
+
decrypt?: boolean;
|
|
37
|
+
defaultValue?: any;
|
|
38
|
+
}): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a configuration value
|
|
41
|
+
*/
|
|
42
|
+
delete(key: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* List all configuration keys
|
|
45
|
+
*/
|
|
46
|
+
list(): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a configuration key exists
|
|
49
|
+
*/
|
|
50
|
+
has(key: string): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear all configuration
|
|
53
|
+
*/
|
|
54
|
+
clear(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Export all configuration
|
|
57
|
+
*/
|
|
58
|
+
export(): Promise<Record<string, ConfigEntry>>;
|
|
59
|
+
/**
|
|
60
|
+
* Import configuration
|
|
61
|
+
*/
|
|
62
|
+
import(config: Record<string, ConfigEntry>): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get raw config entry (without decryption)
|
|
65
|
+
*/
|
|
66
|
+
private getEntry;
|
|
67
|
+
}
|