@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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Discovery API
|
|
3
|
+
*
|
|
4
|
+
* Provides discovery and configuration capabilities for augmentations
|
|
5
|
+
* Enables tools like brain-cloud to dynamically discover, configure, and manage augmentations
|
|
6
|
+
*/
|
|
7
|
+
import { AugmentationRegistry } from './brainyAugmentation.js';
|
|
8
|
+
import { AugmentationManifest, JSONSchema } from './manifest.js';
|
|
9
|
+
/**
|
|
10
|
+
* Augmentation listing with manifest and status
|
|
11
|
+
*/
|
|
12
|
+
export interface AugmentationListing {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
manifest: AugmentationManifest;
|
|
16
|
+
status: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
initialized: boolean;
|
|
19
|
+
category: string;
|
|
20
|
+
priority: number;
|
|
21
|
+
};
|
|
22
|
+
config?: {
|
|
23
|
+
current: any;
|
|
24
|
+
schema?: JSONSchema;
|
|
25
|
+
sources?: any[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configuration validation result
|
|
30
|
+
*/
|
|
31
|
+
export interface ConfigValidationResult {
|
|
32
|
+
valid: boolean;
|
|
33
|
+
errors?: string[];
|
|
34
|
+
warnings?: string[];
|
|
35
|
+
suggestions?: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Discovery API options
|
|
39
|
+
*/
|
|
40
|
+
export interface DiscoveryOptions {
|
|
41
|
+
includeConfig?: boolean;
|
|
42
|
+
includeSchema?: boolean;
|
|
43
|
+
includeSources?: boolean;
|
|
44
|
+
category?: string;
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Augmentation Discovery API
|
|
49
|
+
*
|
|
50
|
+
* Provides a unified interface for discovering and managing augmentations
|
|
51
|
+
*/
|
|
52
|
+
export declare class AugmentationDiscovery {
|
|
53
|
+
private registry;
|
|
54
|
+
constructor(registry: AugmentationRegistry);
|
|
55
|
+
/**
|
|
56
|
+
* Discover all registered augmentations with manifests
|
|
57
|
+
* @param options Discovery options
|
|
58
|
+
* @returns List of augmentation listings
|
|
59
|
+
*/
|
|
60
|
+
discover(options?: DiscoveryOptions): Promise<AugmentationListing[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a specific augmentation's manifest
|
|
63
|
+
* @param augId Augmentation ID
|
|
64
|
+
* @returns Augmentation manifest or null if not found
|
|
65
|
+
*/
|
|
66
|
+
getManifest(augId: string): Promise<AugmentationManifest | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Get configuration schema for an augmentation
|
|
69
|
+
* @param augId Augmentation ID
|
|
70
|
+
* @returns Configuration schema or null
|
|
71
|
+
*/
|
|
72
|
+
getConfigSchema(augId: string): Promise<JSONSchema | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Get current configuration for an augmentation
|
|
75
|
+
* @param augId Augmentation ID
|
|
76
|
+
* @returns Current configuration or null
|
|
77
|
+
*/
|
|
78
|
+
getConfig(augId: string): Promise<any | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Update configuration for an augmentation
|
|
81
|
+
* @param augId Augmentation ID
|
|
82
|
+
* @param config New configuration
|
|
83
|
+
* @returns Updated configuration or null on failure
|
|
84
|
+
*/
|
|
85
|
+
updateConfig(augId: string, config: any): Promise<any | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Validate configuration against schema
|
|
88
|
+
* @param augId Augmentation ID
|
|
89
|
+
* @param config Configuration to validate
|
|
90
|
+
* @returns Validation result
|
|
91
|
+
*/
|
|
92
|
+
validateConfig(augId: string, config: any): Promise<ConfigValidationResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Validate a property value against its schema
|
|
95
|
+
*/
|
|
96
|
+
private validatePropertyValue;
|
|
97
|
+
/**
|
|
98
|
+
* Get environment variables for an augmentation
|
|
99
|
+
* @param augId Augmentation ID
|
|
100
|
+
* @returns Map of environment variable names to descriptions
|
|
101
|
+
*/
|
|
102
|
+
getEnvironmentVariables(augId: string): Promise<Record<string, any> | null>;
|
|
103
|
+
/**
|
|
104
|
+
* Get configuration examples for an augmentation
|
|
105
|
+
* @param augId Augmentation ID
|
|
106
|
+
* @returns Configuration examples or empty array
|
|
107
|
+
*/
|
|
108
|
+
getConfigExamples(augId: string): Promise<any[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if an augmentation supports configuration
|
|
111
|
+
* @param augId Augmentation ID
|
|
112
|
+
* @returns True if augmentation supports configuration
|
|
113
|
+
*/
|
|
114
|
+
supportsConfiguration(augId: string): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Get augmentations by category
|
|
117
|
+
* @param category Category to filter by
|
|
118
|
+
* @returns List of augmentations in the category
|
|
119
|
+
*/
|
|
120
|
+
getByCategory(category: string): Promise<AugmentationListing[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Get enabled augmentations
|
|
123
|
+
* @returns List of enabled augmentations
|
|
124
|
+
*/
|
|
125
|
+
getEnabled(): Promise<AugmentationListing[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Search augmentations by keyword
|
|
128
|
+
* @param query Search query
|
|
129
|
+
* @returns Matching augmentations
|
|
130
|
+
*/
|
|
131
|
+
search(query: string): Promise<AugmentationListing[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Export configuration for all augmentations
|
|
134
|
+
* @returns Map of augmentation IDs to configurations
|
|
135
|
+
*/
|
|
136
|
+
exportConfigurations(): Promise<Record<string, any>>;
|
|
137
|
+
/**
|
|
138
|
+
* Import configurations for multiple augmentations
|
|
139
|
+
* @param configs Map of augmentation IDs to configurations
|
|
140
|
+
* @returns Results of import operation
|
|
141
|
+
*/
|
|
142
|
+
importConfigurations(configs: Record<string, any>): Promise<Record<string, {
|
|
143
|
+
success: boolean;
|
|
144
|
+
error?: string;
|
|
145
|
+
}>>;
|
|
146
|
+
/**
|
|
147
|
+
* Generate configuration documentation
|
|
148
|
+
* @param augId Augmentation ID
|
|
149
|
+
* @returns Markdown documentation
|
|
150
|
+
*/
|
|
151
|
+
generateConfigDocs(augId: string): Promise<string | null>;
|
|
152
|
+
}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Discovery API
|
|
3
|
+
*
|
|
4
|
+
* Provides discovery and configuration capabilities for augmentations
|
|
5
|
+
* Enables tools like brain-cloud to dynamically discover, configure, and manage augmentations
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Augmentation Discovery API
|
|
9
|
+
*
|
|
10
|
+
* Provides a unified interface for discovering and managing augmentations
|
|
11
|
+
*/
|
|
12
|
+
export class AugmentationDiscovery {
|
|
13
|
+
constructor(registry) {
|
|
14
|
+
this.registry = registry;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Discover all registered augmentations with manifests
|
|
18
|
+
* @param options Discovery options
|
|
19
|
+
* @returns List of augmentation listings
|
|
20
|
+
*/
|
|
21
|
+
async discover(options = {}) {
|
|
22
|
+
const augmentations = this.registry.getAll();
|
|
23
|
+
const listings = [];
|
|
24
|
+
for (const aug of augmentations) {
|
|
25
|
+
// Check if augmentation has manifest support
|
|
26
|
+
const hasManifest = 'getManifest' in aug && typeof aug.getManifest === 'function';
|
|
27
|
+
if (!hasManifest) {
|
|
28
|
+
// Skip augmentations without manifest support (legacy)
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
// Check if augmentation has manifest method
|
|
33
|
+
if (!('getManifest' in aug) || typeof aug.getManifest !== 'function') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const getManifestFn = aug.getManifest;
|
|
37
|
+
const manifest = getManifestFn();
|
|
38
|
+
// Apply filters
|
|
39
|
+
if (options.category && manifest.category !== options.category) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (options.enabled !== undefined) {
|
|
43
|
+
const isEnabled = aug.enabled !== false;
|
|
44
|
+
if (isEnabled !== options.enabled) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Build listing
|
|
49
|
+
const listing = {
|
|
50
|
+
id: manifest.id,
|
|
51
|
+
name: manifest.name,
|
|
52
|
+
manifest,
|
|
53
|
+
status: {
|
|
54
|
+
enabled: aug.enabled !== false,
|
|
55
|
+
initialized: aug.isInitialized || false,
|
|
56
|
+
category: aug.category || manifest.category,
|
|
57
|
+
priority: aug.priority
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Include configuration if requested
|
|
61
|
+
if (options.includeConfig && 'getConfig' in aug) {
|
|
62
|
+
const getConfigFn = aug.getConfig;
|
|
63
|
+
listing.config = {
|
|
64
|
+
current: getConfigFn()
|
|
65
|
+
};
|
|
66
|
+
if (options.includeSchema) {
|
|
67
|
+
listing.config.schema = manifest.configSchema;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
listings.push(listing);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.warn(`Failed to get manifest for augmentation ${aug.name}:`, error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Sort by priority (highest first) then by name
|
|
77
|
+
listings.sort((a, b) => {
|
|
78
|
+
const priorityDiff = b.status.priority - a.status.priority;
|
|
79
|
+
if (priorityDiff !== 0)
|
|
80
|
+
return priorityDiff;
|
|
81
|
+
return a.name.localeCompare(b.name);
|
|
82
|
+
});
|
|
83
|
+
return listings;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get a specific augmentation's manifest
|
|
87
|
+
* @param augId Augmentation ID
|
|
88
|
+
* @returns Augmentation manifest or null if not found
|
|
89
|
+
*/
|
|
90
|
+
async getManifest(augId) {
|
|
91
|
+
const aug = this.registry.get(augId);
|
|
92
|
+
if (!aug || !('getManifest' in aug)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const getManifestFn = aug.getManifest;
|
|
97
|
+
return getManifestFn();
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error(`Failed to get manifest for ${augId}:`, error);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get configuration schema for an augmentation
|
|
106
|
+
* @param augId Augmentation ID
|
|
107
|
+
* @returns Configuration schema or null
|
|
108
|
+
*/
|
|
109
|
+
async getConfigSchema(augId) {
|
|
110
|
+
const manifest = await this.getManifest(augId);
|
|
111
|
+
return manifest?.configSchema || null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get current configuration for an augmentation
|
|
115
|
+
* @param augId Augmentation ID
|
|
116
|
+
* @returns Current configuration or null
|
|
117
|
+
*/
|
|
118
|
+
async getConfig(augId) {
|
|
119
|
+
const aug = this.registry.get(augId);
|
|
120
|
+
if (!aug || !('getConfig' in aug)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const getConfigFn = aug.getConfig;
|
|
125
|
+
return getConfigFn();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error(`Failed to get config for ${augId}:`, error);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Update configuration for an augmentation
|
|
134
|
+
* @param augId Augmentation ID
|
|
135
|
+
* @param config New configuration
|
|
136
|
+
* @returns Updated configuration or null on failure
|
|
137
|
+
*/
|
|
138
|
+
async updateConfig(augId, config) {
|
|
139
|
+
const aug = this.registry.get(augId);
|
|
140
|
+
if (!aug || !('updateConfig' in aug) || !('getConfig' in aug)) {
|
|
141
|
+
throw new Error(`Augmentation ${augId} does not support configuration updates`);
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const updateConfigFn = aug.updateConfig;
|
|
145
|
+
await updateConfigFn(config);
|
|
146
|
+
const getConfigFn = aug.getConfig;
|
|
147
|
+
return getConfigFn();
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw new Error(`Failed to update config for ${augId}: ${error}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Validate configuration against schema
|
|
155
|
+
* @param augId Augmentation ID
|
|
156
|
+
* @param config Configuration to validate
|
|
157
|
+
* @returns Validation result
|
|
158
|
+
*/
|
|
159
|
+
async validateConfig(augId, config) {
|
|
160
|
+
const schema = await this.getConfigSchema(augId);
|
|
161
|
+
if (!schema) {
|
|
162
|
+
return {
|
|
163
|
+
valid: true,
|
|
164
|
+
warnings: ['No schema available for validation']
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const errors = [];
|
|
168
|
+
const warnings = [];
|
|
169
|
+
const suggestions = [];
|
|
170
|
+
// Check required fields
|
|
171
|
+
if (schema.required) {
|
|
172
|
+
for (const field of schema.required) {
|
|
173
|
+
if (config[field] === undefined) {
|
|
174
|
+
errors.push(`Missing required field: ${field}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Validate properties
|
|
179
|
+
if (schema.properties) {
|
|
180
|
+
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
181
|
+
const value = config[key];
|
|
182
|
+
if (value === undefined) {
|
|
183
|
+
// Check if there's a default
|
|
184
|
+
if (propSchema.default !== undefined) {
|
|
185
|
+
suggestions.push(`Field '${key}' not provided, will use default: ${JSON.stringify(propSchema.default)}`);
|
|
186
|
+
}
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
// Type validation
|
|
190
|
+
if (propSchema.type) {
|
|
191
|
+
const actualType = Array.isArray(value) ? 'array' : typeof value;
|
|
192
|
+
if (actualType !== propSchema.type) {
|
|
193
|
+
errors.push(`${key}: expected ${propSchema.type}, got ${actualType}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Additional validations for specific types
|
|
197
|
+
this.validatePropertyValue(key, value, propSchema, errors, warnings);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Check for unknown properties
|
|
201
|
+
if (schema.additionalProperties === false && schema.properties) {
|
|
202
|
+
const allowedKeys = Object.keys(schema.properties);
|
|
203
|
+
for (const key of Object.keys(config)) {
|
|
204
|
+
if (!allowedKeys.includes(key)) {
|
|
205
|
+
warnings.push(`Unknown property: ${key}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
valid: errors.length === 0,
|
|
211
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
212
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
213
|
+
suggestions: suggestions.length > 0 ? suggestions : undefined
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Validate a property value against its schema
|
|
218
|
+
*/
|
|
219
|
+
validatePropertyValue(key, value, schema, errors, warnings) {
|
|
220
|
+
// Number validations
|
|
221
|
+
if (schema.type === 'number') {
|
|
222
|
+
if (schema.minimum !== undefined && value < schema.minimum) {
|
|
223
|
+
errors.push(`${key}: value ${value} is less than minimum ${schema.minimum}`);
|
|
224
|
+
}
|
|
225
|
+
if (schema.maximum !== undefined && value > schema.maximum) {
|
|
226
|
+
errors.push(`${key}: value ${value} is greater than maximum ${schema.maximum}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// String validations
|
|
230
|
+
if (schema.type === 'string') {
|
|
231
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
232
|
+
errors.push(`${key}: length ${value.length} is less than minimum ${schema.minLength}`);
|
|
233
|
+
}
|
|
234
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
235
|
+
errors.push(`${key}: length ${value.length} is greater than maximum ${schema.maxLength}`);
|
|
236
|
+
}
|
|
237
|
+
if (schema.pattern) {
|
|
238
|
+
const regex = new RegExp(schema.pattern);
|
|
239
|
+
if (!regex.test(value)) {
|
|
240
|
+
errors.push(`${key}: value does not match pattern ${schema.pattern}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Enum validation
|
|
245
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
246
|
+
errors.push(`${key}: value '${value}' is not one of allowed values: ${schema.enum.join(', ')}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Get environment variables for an augmentation
|
|
251
|
+
* @param augId Augmentation ID
|
|
252
|
+
* @returns Map of environment variable names to descriptions
|
|
253
|
+
*/
|
|
254
|
+
async getEnvironmentVariables(augId) {
|
|
255
|
+
const manifest = await this.getManifest(augId);
|
|
256
|
+
if (!manifest?.configSchema?.properties) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const prefix = `BRAINY_AUG_${augId.toUpperCase()}_`;
|
|
260
|
+
const vars = {};
|
|
261
|
+
for (const [key, prop] of Object.entries(manifest.configSchema.properties)) {
|
|
262
|
+
const envKey = prefix + key.replace(/([A-Z])/g, '_$1').toUpperCase();
|
|
263
|
+
vars[envKey] = {
|
|
264
|
+
configKey: key,
|
|
265
|
+
description: prop.description,
|
|
266
|
+
type: prop.type,
|
|
267
|
+
default: prop.default,
|
|
268
|
+
required: manifest.configSchema.required?.includes(key),
|
|
269
|
+
currentValue: typeof process !== 'undefined' ? process.env?.[envKey] : undefined
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return vars;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Get configuration examples for an augmentation
|
|
276
|
+
* @param augId Augmentation ID
|
|
277
|
+
* @returns Configuration examples or empty array
|
|
278
|
+
*/
|
|
279
|
+
async getConfigExamples(augId) {
|
|
280
|
+
const manifest = await this.getManifest(augId);
|
|
281
|
+
return manifest?.configExamples || [];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Check if an augmentation supports configuration
|
|
285
|
+
* @param augId Augmentation ID
|
|
286
|
+
* @returns True if augmentation supports configuration
|
|
287
|
+
*/
|
|
288
|
+
async supportsConfiguration(augId) {
|
|
289
|
+
const aug = this.registry.get(augId);
|
|
290
|
+
return !!(aug && 'getConfig' in aug && 'updateConfig' in aug);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get augmentations by category
|
|
294
|
+
* @param category Category to filter by
|
|
295
|
+
* @returns List of augmentations in the category
|
|
296
|
+
*/
|
|
297
|
+
async getByCategory(category) {
|
|
298
|
+
return this.discover({ category });
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get enabled augmentations
|
|
302
|
+
* @returns List of enabled augmentations
|
|
303
|
+
*/
|
|
304
|
+
async getEnabled() {
|
|
305
|
+
return this.discover({ enabled: true });
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Search augmentations by keyword
|
|
309
|
+
* @param query Search query
|
|
310
|
+
* @returns Matching augmentations
|
|
311
|
+
*/
|
|
312
|
+
async search(query) {
|
|
313
|
+
const all = await this.discover();
|
|
314
|
+
const queryLower = query.toLowerCase();
|
|
315
|
+
return all.filter(listing => {
|
|
316
|
+
const manifest = listing.manifest;
|
|
317
|
+
// Search in various fields
|
|
318
|
+
const searchFields = [
|
|
319
|
+
manifest.name,
|
|
320
|
+
manifest.description,
|
|
321
|
+
manifest.longDescription,
|
|
322
|
+
...(manifest.keywords || []),
|
|
323
|
+
manifest.category
|
|
324
|
+
].filter(Boolean).map(s => s.toLowerCase());
|
|
325
|
+
return searchFields.some(field => field.includes(queryLower));
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Export configuration for all augmentations
|
|
330
|
+
* @returns Map of augmentation IDs to configurations
|
|
331
|
+
*/
|
|
332
|
+
async exportConfigurations() {
|
|
333
|
+
const configs = {};
|
|
334
|
+
const listings = await this.discover({ includeConfig: true });
|
|
335
|
+
for (const listing of listings) {
|
|
336
|
+
if (listing.config?.current) {
|
|
337
|
+
configs[listing.id] = listing.config.current;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return configs;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Import configurations for multiple augmentations
|
|
344
|
+
* @param configs Map of augmentation IDs to configurations
|
|
345
|
+
* @returns Results of import operation
|
|
346
|
+
*/
|
|
347
|
+
async importConfigurations(configs) {
|
|
348
|
+
const results = {};
|
|
349
|
+
for (const [augId, config] of Object.entries(configs)) {
|
|
350
|
+
try {
|
|
351
|
+
// Validate before applying
|
|
352
|
+
const validation = await this.validateConfig(augId, config);
|
|
353
|
+
if (!validation.valid) {
|
|
354
|
+
results[augId] = {
|
|
355
|
+
success: false,
|
|
356
|
+
error: `Validation failed: ${validation.errors?.join(', ')}`
|
|
357
|
+
};
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
// Apply configuration
|
|
361
|
+
await this.updateConfig(augId, config);
|
|
362
|
+
results[augId] = { success: true };
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
results[augId] = {
|
|
366
|
+
success: false,
|
|
367
|
+
error: error instanceof Error ? error.message : String(error)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return results;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Generate configuration documentation
|
|
375
|
+
* @param augId Augmentation ID
|
|
376
|
+
* @returns Markdown documentation
|
|
377
|
+
*/
|
|
378
|
+
async generateConfigDocs(augId) {
|
|
379
|
+
const manifest = await this.getManifest(augId);
|
|
380
|
+
if (!manifest)
|
|
381
|
+
return null;
|
|
382
|
+
const schema = manifest.configSchema;
|
|
383
|
+
const examples = manifest.configExamples || [];
|
|
384
|
+
const envVars = await this.getEnvironmentVariables(augId);
|
|
385
|
+
let docs = `# ${manifest.name} Configuration\n\n`;
|
|
386
|
+
docs += `${manifest.description}\n\n`;
|
|
387
|
+
if (manifest.longDescription) {
|
|
388
|
+
docs += `## Overview\n\n${manifest.longDescription}\n\n`;
|
|
389
|
+
}
|
|
390
|
+
// Configuration options
|
|
391
|
+
if (schema?.properties) {
|
|
392
|
+
docs += `## Configuration Options\n\n`;
|
|
393
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
394
|
+
const required = schema.required?.includes(key) ? ' *(required)*' : '';
|
|
395
|
+
docs += `### \`${key}\`${required}\n\n`;
|
|
396
|
+
if (prop.description) {
|
|
397
|
+
docs += `${prop.description}\n\n`;
|
|
398
|
+
}
|
|
399
|
+
docs += `- **Type**: ${prop.type}\n`;
|
|
400
|
+
if (prop.default !== undefined) {
|
|
401
|
+
docs += `- **Default**: \`${JSON.stringify(prop.default)}\`\n`;
|
|
402
|
+
}
|
|
403
|
+
if (prop.minimum !== undefined) {
|
|
404
|
+
docs += `- **Minimum**: ${prop.minimum}\n`;
|
|
405
|
+
}
|
|
406
|
+
if (prop.maximum !== undefined) {
|
|
407
|
+
docs += `- **Maximum**: ${prop.maximum}\n`;
|
|
408
|
+
}
|
|
409
|
+
if (prop.enum) {
|
|
410
|
+
docs += `- **Allowed values**: ${prop.enum.map(v => `\`${v}\``).join(', ')}\n`;
|
|
411
|
+
}
|
|
412
|
+
docs += '\n';
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// Environment variables
|
|
416
|
+
if (envVars && Object.keys(envVars).length > 0) {
|
|
417
|
+
docs += `## Environment Variables\n\n`;
|
|
418
|
+
docs += `| Variable | Config Key | Type | Required | Default |\n`;
|
|
419
|
+
docs += `|----------|------------|------|----------|----------|\n`;
|
|
420
|
+
for (const [envKey, info] of Object.entries(envVars)) {
|
|
421
|
+
docs += `| \`${envKey}\` | ${info.configKey} | ${info.type} | ${info.required ? 'Yes' : 'No'} | ${info.default !== undefined ? `\`${info.default}\`` : '-'} |\n`;
|
|
422
|
+
}
|
|
423
|
+
docs += '\n';
|
|
424
|
+
}
|
|
425
|
+
// Examples
|
|
426
|
+
if (examples.length > 0) {
|
|
427
|
+
docs += `## Examples\n\n`;
|
|
428
|
+
for (const example of examples) {
|
|
429
|
+
docs += `### ${example.name}\n\n`;
|
|
430
|
+
if (example.description) {
|
|
431
|
+
docs += `${example.description}\n\n`;
|
|
432
|
+
}
|
|
433
|
+
docs += '```json\n';
|
|
434
|
+
docs += JSON.stringify(example.config, null, 2);
|
|
435
|
+
docs += '\n```\n\n';
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return docs;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=discovery.js.map
|