@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,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Marketplace
|
|
3
|
+
*
|
|
4
|
+
* A VS Code/WebStorm-style plugin marketplace for Brainy augmentations
|
|
5
|
+
* Integrates with Soulcraft Brain-Cloud API for premium augmentations
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Browse and search augmentations
|
|
9
|
+
* - Install from cloud registry
|
|
10
|
+
* - Manage local augmentations
|
|
11
|
+
* - Auto-updates and licensing
|
|
12
|
+
*/
|
|
13
|
+
import { AugmentationManifest } from '../manifest.js';
|
|
14
|
+
/**
|
|
15
|
+
* Cloud augmentation metadata from Brain-Cloud API
|
|
16
|
+
*/
|
|
17
|
+
export interface CloudAugmentation {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
author: string;
|
|
22
|
+
authorUrl?: string;
|
|
23
|
+
version: string;
|
|
24
|
+
description: string;
|
|
25
|
+
longDescription?: string;
|
|
26
|
+
category: 'premium' | 'community' | 'official' | 'enterprise';
|
|
27
|
+
tags: string[];
|
|
28
|
+
price?: number;
|
|
29
|
+
currency?: string;
|
|
30
|
+
rating: number;
|
|
31
|
+
reviews: number;
|
|
32
|
+
downloads: number;
|
|
33
|
+
lastUpdated: string;
|
|
34
|
+
minBrainyVersion: string;
|
|
35
|
+
maxBrainyVersion?: string;
|
|
36
|
+
requirements: string[];
|
|
37
|
+
permissions: string[];
|
|
38
|
+
screenshots?: string[];
|
|
39
|
+
repositoryUrl?: string;
|
|
40
|
+
documentationUrl?: string;
|
|
41
|
+
supportUrl?: string;
|
|
42
|
+
license: string;
|
|
43
|
+
size: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Local augmentation installation info
|
|
47
|
+
*/
|
|
48
|
+
export interface InstalledAugmentation {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
version: string;
|
|
52
|
+
installedAt: string;
|
|
53
|
+
installedFrom: 'local' | 'cloud' | 'file';
|
|
54
|
+
cloudId?: string;
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
autoUpdate: boolean;
|
|
57
|
+
config?: Record<string, any>;
|
|
58
|
+
path: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Installation options
|
|
62
|
+
*/
|
|
63
|
+
export interface InstallOptions {
|
|
64
|
+
version?: string;
|
|
65
|
+
autoUpdate?: boolean;
|
|
66
|
+
enable?: boolean;
|
|
67
|
+
config?: Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Search filters
|
|
71
|
+
*/
|
|
72
|
+
export interface SearchFilters {
|
|
73
|
+
category?: CloudAugmentation['category'];
|
|
74
|
+
tags?: string[];
|
|
75
|
+
minRating?: number;
|
|
76
|
+
free?: boolean;
|
|
77
|
+
verified?: boolean;
|
|
78
|
+
compatible?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Marketplace configuration
|
|
82
|
+
*/
|
|
83
|
+
export interface MarketplaceConfig {
|
|
84
|
+
apiUrl?: string;
|
|
85
|
+
apiKey?: string;
|
|
86
|
+
cacheDir?: string;
|
|
87
|
+
augmentationsDir?: string;
|
|
88
|
+
autoUpdate?: boolean;
|
|
89
|
+
checkInterval?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Augmentation Marketplace - Main class
|
|
93
|
+
*/
|
|
94
|
+
export declare class AugmentationMarketplace {
|
|
95
|
+
private config;
|
|
96
|
+
private installedCache;
|
|
97
|
+
private cloudCache;
|
|
98
|
+
private updateCheckTimer?;
|
|
99
|
+
constructor(config?: MarketplaceConfig);
|
|
100
|
+
/**
|
|
101
|
+
* Get all installed augmentations
|
|
102
|
+
*/
|
|
103
|
+
getInstalled(): InstalledAugmentation[];
|
|
104
|
+
/**
|
|
105
|
+
* Get available local augmentations (built-in)
|
|
106
|
+
*/
|
|
107
|
+
getAvailableLocal(): Promise<AugmentationManifest[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Search cloud registry
|
|
110
|
+
*/
|
|
111
|
+
searchCloud(query?: string, filters?: SearchFilters, page?: number, limit?: number): Promise<{
|
|
112
|
+
results: CloudAugmentation[];
|
|
113
|
+
total: number;
|
|
114
|
+
page: number;
|
|
115
|
+
pages: number;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Get detailed information about a cloud augmentation
|
|
119
|
+
*/
|
|
120
|
+
getCloudDetails(id: string): Promise<CloudAugmentation>;
|
|
121
|
+
/**
|
|
122
|
+
* Install augmentation from cloud
|
|
123
|
+
*/
|
|
124
|
+
installFromCloud(id: string, options?: InstallOptions): Promise<InstalledAugmentation>;
|
|
125
|
+
/**
|
|
126
|
+
* Install from local file
|
|
127
|
+
*/
|
|
128
|
+
installFromFile(filePath: string, options?: InstallOptions): Promise<InstalledAugmentation>;
|
|
129
|
+
/**
|
|
130
|
+
* Enable an installed augmentation
|
|
131
|
+
*/
|
|
132
|
+
enable(name: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Disable an installed augmentation
|
|
135
|
+
*/
|
|
136
|
+
disable(name: string): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Uninstall an augmentation
|
|
139
|
+
*/
|
|
140
|
+
uninstall(name: string): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Update an augmentation
|
|
143
|
+
*/
|
|
144
|
+
update(name: string): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Check for updates for all installed augmentations
|
|
147
|
+
*/
|
|
148
|
+
checkForUpdates(): Promise<Array<{
|
|
149
|
+
augmentation: InstalledAugmentation;
|
|
150
|
+
newVersion: string;
|
|
151
|
+
}>>;
|
|
152
|
+
private getBrainyVersion;
|
|
153
|
+
private isCompatible;
|
|
154
|
+
private getInstalledByName;
|
|
155
|
+
private getInstalledByCloudId;
|
|
156
|
+
private downloadPackage;
|
|
157
|
+
private extractPackage;
|
|
158
|
+
private loadAugmentation;
|
|
159
|
+
private unloadAugmentation;
|
|
160
|
+
private removeAugmentationFiles;
|
|
161
|
+
private loadInstalledAugmentations;
|
|
162
|
+
private saveInstalledAugmentations;
|
|
163
|
+
private startUpdateChecker;
|
|
164
|
+
/**
|
|
165
|
+
* Cleanup resources
|
|
166
|
+
*/
|
|
167
|
+
destroy(): void;
|
|
168
|
+
}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Marketplace
|
|
3
|
+
*
|
|
4
|
+
* A VS Code/WebStorm-style plugin marketplace for Brainy augmentations
|
|
5
|
+
* Integrates with Soulcraft Brain-Cloud API for premium augmentations
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Browse and search augmentations
|
|
9
|
+
* - Install from cloud registry
|
|
10
|
+
* - Manage local augmentations
|
|
11
|
+
* - Auto-updates and licensing
|
|
12
|
+
*/
|
|
13
|
+
import { v4 as uuidv4 } from '../../universal/uuid.js';
|
|
14
|
+
/**
|
|
15
|
+
* Augmentation Marketplace - Main class
|
|
16
|
+
*/
|
|
17
|
+
export class AugmentationMarketplace {
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
this.installedCache = new Map();
|
|
20
|
+
this.cloudCache = new Map();
|
|
21
|
+
this.config = {
|
|
22
|
+
apiUrl: config.apiUrl || 'https://api.brain-cloud.soulcraft.com/v1',
|
|
23
|
+
apiKey: config.apiKey || process.env.BRAIN_CLOUD_API_KEY || '',
|
|
24
|
+
cacheDir: config.cacheDir || '.brainy/cache',
|
|
25
|
+
augmentationsDir: config.augmentationsDir || '.brainy/augmentations',
|
|
26
|
+
autoUpdate: config.autoUpdate ?? true,
|
|
27
|
+
checkInterval: config.checkInterval || 24 * 60 * 60 * 1000 // 24 hours
|
|
28
|
+
};
|
|
29
|
+
this.loadInstalledAugmentations();
|
|
30
|
+
if (this.config.autoUpdate) {
|
|
31
|
+
this.startUpdateChecker();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get all installed augmentations
|
|
36
|
+
*/
|
|
37
|
+
getInstalled() {
|
|
38
|
+
return Array.from(this.installedCache.values());
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get available local augmentations (built-in)
|
|
42
|
+
*/
|
|
43
|
+
async getAvailableLocal() {
|
|
44
|
+
// Import and return built-in augmentations
|
|
45
|
+
const { createDefaultAugmentations } = await import('../defaultAugmentations.js');
|
|
46
|
+
const augmentations = createDefaultAugmentations();
|
|
47
|
+
return augmentations.map(aug => aug.getManifest());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Search cloud registry
|
|
51
|
+
*/
|
|
52
|
+
async searchCloud(query = '', filters = {}, page = 1, limit = 20) {
|
|
53
|
+
const params = new URLSearchParams({
|
|
54
|
+
q: query,
|
|
55
|
+
page: page.toString(),
|
|
56
|
+
limit: limit.toString()
|
|
57
|
+
});
|
|
58
|
+
// Add filters
|
|
59
|
+
if (filters.category)
|
|
60
|
+
params.append('category', filters.category);
|
|
61
|
+
if (filters.tags)
|
|
62
|
+
filters.tags.forEach(tag => params.append('tag', tag));
|
|
63
|
+
if (filters.minRating)
|
|
64
|
+
params.append('minRating', filters.minRating.toString());
|
|
65
|
+
if (filters.free !== undefined)
|
|
66
|
+
params.append('free', filters.free.toString());
|
|
67
|
+
if (filters.verified !== undefined)
|
|
68
|
+
params.append('verified', filters.verified.toString());
|
|
69
|
+
if (filters.compatible !== undefined)
|
|
70
|
+
params.append('compatible', filters.compatible.toString());
|
|
71
|
+
const response = await fetch(`${this.config.apiUrl}/augmentations?${params}`, {
|
|
72
|
+
headers: {
|
|
73
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
74
|
+
'Content-Type': 'application/json'
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error(`Failed to search augmentations: ${response.statusText}`);
|
|
79
|
+
}
|
|
80
|
+
const data = await response.json();
|
|
81
|
+
// Cache results
|
|
82
|
+
data.results.forEach((aug) => {
|
|
83
|
+
this.cloudCache.set(aug.id, aug);
|
|
84
|
+
});
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get detailed information about a cloud augmentation
|
|
89
|
+
*/
|
|
90
|
+
async getCloudDetails(id) {
|
|
91
|
+
// Check cache first
|
|
92
|
+
if (this.cloudCache.has(id)) {
|
|
93
|
+
return this.cloudCache.get(id);
|
|
94
|
+
}
|
|
95
|
+
const response = await fetch(`${this.config.apiUrl}/augmentations/${id}`, {
|
|
96
|
+
headers: {
|
|
97
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
98
|
+
'Content-Type': 'application/json'
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new Error(`Failed to get augmentation details: ${response.statusText}`);
|
|
103
|
+
}
|
|
104
|
+
const augmentation = await response.json();
|
|
105
|
+
this.cloudCache.set(id, augmentation);
|
|
106
|
+
return augmentation;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Install augmentation from cloud
|
|
110
|
+
*/
|
|
111
|
+
async installFromCloud(id, options = {}) {
|
|
112
|
+
// Get augmentation details
|
|
113
|
+
const cloudAug = await this.getCloudDetails(id);
|
|
114
|
+
// Check compatibility
|
|
115
|
+
const brainyVersion = await this.getBrainyVersion();
|
|
116
|
+
if (!this.isCompatible(cloudAug, brainyVersion)) {
|
|
117
|
+
throw new Error(`Augmentation ${cloudAug.name} is not compatible with Brainy ${brainyVersion}`);
|
|
118
|
+
}
|
|
119
|
+
// Check if already installed
|
|
120
|
+
const existing = this.getInstalledByCloudId(id);
|
|
121
|
+
if (existing) {
|
|
122
|
+
throw new Error(`Augmentation ${cloudAug.name} is already installed`);
|
|
123
|
+
}
|
|
124
|
+
// Download augmentation package
|
|
125
|
+
const packageData = await this.downloadPackage(id);
|
|
126
|
+
// Extract and install
|
|
127
|
+
const installPath = await this.extractPackage(packageData, cloudAug);
|
|
128
|
+
// Create installation record
|
|
129
|
+
const installed = {
|
|
130
|
+
id: uuidv4(),
|
|
131
|
+
name: cloudAug.name,
|
|
132
|
+
version: options.version || cloudAug.version,
|
|
133
|
+
installedAt: new Date().toISOString(),
|
|
134
|
+
installedFrom: 'cloud',
|
|
135
|
+
cloudId: id,
|
|
136
|
+
enabled: options.enable ?? true,
|
|
137
|
+
autoUpdate: options.autoUpdate ?? this.config.autoUpdate,
|
|
138
|
+
config: options.config,
|
|
139
|
+
path: installPath
|
|
140
|
+
};
|
|
141
|
+
// Save installation info
|
|
142
|
+
this.installedCache.set(installed.id, installed);
|
|
143
|
+
await this.saveInstalledAugmentations();
|
|
144
|
+
// Load and initialize if enabled
|
|
145
|
+
if (installed.enabled) {
|
|
146
|
+
await this.loadAugmentation(installed);
|
|
147
|
+
}
|
|
148
|
+
return installed;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Install from local file
|
|
152
|
+
*/
|
|
153
|
+
async installFromFile(filePath, options = {}) {
|
|
154
|
+
// Implementation for installing from local .brainy-aug file
|
|
155
|
+
throw new Error('Not implemented yet');
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Enable an installed augmentation
|
|
159
|
+
*/
|
|
160
|
+
async enable(name) {
|
|
161
|
+
const augmentation = this.getInstalledByName(name);
|
|
162
|
+
if (!augmentation) {
|
|
163
|
+
throw new Error(`Augmentation ${name} not found`);
|
|
164
|
+
}
|
|
165
|
+
augmentation.enabled = true;
|
|
166
|
+
await this.saveInstalledAugmentations();
|
|
167
|
+
await this.loadAugmentation(augmentation);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Disable an installed augmentation
|
|
171
|
+
*/
|
|
172
|
+
async disable(name) {
|
|
173
|
+
const augmentation = this.getInstalledByName(name);
|
|
174
|
+
if (!augmentation) {
|
|
175
|
+
throw new Error(`Augmentation ${name} not found`);
|
|
176
|
+
}
|
|
177
|
+
augmentation.enabled = false;
|
|
178
|
+
await this.saveInstalledAugmentations();
|
|
179
|
+
await this.unloadAugmentation(augmentation);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Uninstall an augmentation
|
|
183
|
+
*/
|
|
184
|
+
async uninstall(name) {
|
|
185
|
+
const augmentation = this.getInstalledByName(name);
|
|
186
|
+
if (!augmentation) {
|
|
187
|
+
throw new Error(`Augmentation ${name} not found`);
|
|
188
|
+
}
|
|
189
|
+
// Unload if loaded
|
|
190
|
+
if (augmentation.enabled) {
|
|
191
|
+
await this.unloadAugmentation(augmentation);
|
|
192
|
+
}
|
|
193
|
+
// Remove files
|
|
194
|
+
await this.removeAugmentationFiles(augmentation);
|
|
195
|
+
// Remove from cache
|
|
196
|
+
this.installedCache.delete(augmentation.id);
|
|
197
|
+
await this.saveInstalledAugmentations();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Update an augmentation
|
|
201
|
+
*/
|
|
202
|
+
async update(name) {
|
|
203
|
+
const augmentation = this.getInstalledByName(name);
|
|
204
|
+
if (!augmentation) {
|
|
205
|
+
throw new Error(`Augmentation ${name} not found`);
|
|
206
|
+
}
|
|
207
|
+
if (!augmentation.cloudId) {
|
|
208
|
+
throw new Error(`Augmentation ${name} was not installed from cloud`);
|
|
209
|
+
}
|
|
210
|
+
// Check for updates
|
|
211
|
+
const cloudAug = await this.getCloudDetails(augmentation.cloudId);
|
|
212
|
+
if (cloudAug.version === augmentation.version) {
|
|
213
|
+
throw new Error(`Augmentation ${name} is already up to date`);
|
|
214
|
+
}
|
|
215
|
+
// Uninstall old version
|
|
216
|
+
await this.uninstall(name);
|
|
217
|
+
// Install new version
|
|
218
|
+
await this.installFromCloud(augmentation.cloudId, {
|
|
219
|
+
enable: augmentation.enabled,
|
|
220
|
+
autoUpdate: augmentation.autoUpdate,
|
|
221
|
+
config: augmentation.config
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Check for updates for all installed augmentations
|
|
226
|
+
*/
|
|
227
|
+
async checkForUpdates() {
|
|
228
|
+
const updates = [];
|
|
229
|
+
for (const augmentation of this.installedCache.values()) {
|
|
230
|
+
if (!augmentation.cloudId)
|
|
231
|
+
continue;
|
|
232
|
+
try {
|
|
233
|
+
const cloudAug = await this.getCloudDetails(augmentation.cloudId);
|
|
234
|
+
if (cloudAug.version !== augmentation.version) {
|
|
235
|
+
updates.push({
|
|
236
|
+
augmentation,
|
|
237
|
+
newVersion: cloudAug.version
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
console.warn(`Failed to check updates for ${augmentation.name}:`, error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return updates;
|
|
246
|
+
}
|
|
247
|
+
// Private helper methods
|
|
248
|
+
async getBrainyVersion() {
|
|
249
|
+
// Get Brainy version from package.json
|
|
250
|
+
try {
|
|
251
|
+
const packageJson = await import('../../../package.json');
|
|
252
|
+
return packageJson.version;
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
return '0.0.0';
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
isCompatible(augmentation, brainyVersion) {
|
|
259
|
+
// Simple version comparison - can be enhanced
|
|
260
|
+
return true; // TODO: Implement proper semver comparison
|
|
261
|
+
}
|
|
262
|
+
getInstalledByName(name) {
|
|
263
|
+
return Array.from(this.installedCache.values()).find(a => a.name === name);
|
|
264
|
+
}
|
|
265
|
+
getInstalledByCloudId(cloudId) {
|
|
266
|
+
return Array.from(this.installedCache.values()).find(a => a.cloudId === cloudId);
|
|
267
|
+
}
|
|
268
|
+
async downloadPackage(id) {
|
|
269
|
+
const response = await fetch(`${this.config.apiUrl}/augmentations/${id}/download`, {
|
|
270
|
+
headers: {
|
|
271
|
+
'Authorization': `Bearer ${this.config.apiKey}`
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
if (!response.ok) {
|
|
275
|
+
throw new Error(`Failed to download augmentation: ${response.statusText}`);
|
|
276
|
+
}
|
|
277
|
+
return response.arrayBuffer();
|
|
278
|
+
}
|
|
279
|
+
async extractPackage(packageData, cloudAug) {
|
|
280
|
+
// Extract package to augmentations directory
|
|
281
|
+
// This would use tar/zip extraction in real implementation
|
|
282
|
+
const installPath = `${this.config.augmentationsDir}/${cloudAug.name}-${cloudAug.version}`;
|
|
283
|
+
// TODO: Implement actual extraction
|
|
284
|
+
return installPath;
|
|
285
|
+
}
|
|
286
|
+
async loadAugmentation(augmentation) {
|
|
287
|
+
// Dynamically import and register the augmentation
|
|
288
|
+
// TODO: Implement dynamic loading
|
|
289
|
+
}
|
|
290
|
+
async unloadAugmentation(augmentation) {
|
|
291
|
+
// Unregister the augmentation from the system
|
|
292
|
+
// TODO: Implement unloading
|
|
293
|
+
}
|
|
294
|
+
async removeAugmentationFiles(augmentation) {
|
|
295
|
+
// Remove augmentation files from disk
|
|
296
|
+
// TODO: Implement file removal
|
|
297
|
+
}
|
|
298
|
+
async loadInstalledAugmentations() {
|
|
299
|
+
// Load installed augmentations from disk
|
|
300
|
+
// TODO: Implement loading from disk
|
|
301
|
+
}
|
|
302
|
+
async saveInstalledAugmentations() {
|
|
303
|
+
// Save installed augmentations to disk
|
|
304
|
+
// TODO: Implement saving to disk
|
|
305
|
+
}
|
|
306
|
+
startUpdateChecker() {
|
|
307
|
+
this.updateCheckTimer = setInterval(async () => {
|
|
308
|
+
try {
|
|
309
|
+
const updates = await this.checkForUpdates();
|
|
310
|
+
if (updates.length > 0) {
|
|
311
|
+
console.log(`Found ${updates.length} augmentation updates available`);
|
|
312
|
+
// Could emit an event or callback here
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
console.warn('Failed to check for augmentation updates:', error);
|
|
317
|
+
}
|
|
318
|
+
}, this.config.checkInterval);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Cleanup resources
|
|
322
|
+
*/
|
|
323
|
+
destroy() {
|
|
324
|
+
if (this.updateCheckTimer) {
|
|
325
|
+
clearInterval(this.updateCheckTimer);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=AugmentationMarketplace.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Marketplace CLI Commands
|
|
3
|
+
*
|
|
4
|
+
* Provides command-line interface for managing augmentations
|
|
5
|
+
* Similar to npm/yarn but for Brainy augmentations
|
|
6
|
+
*/
|
|
7
|
+
import { AugmentationMarketplace } from './AugmentationMarketplace.js';
|
|
8
|
+
/**
|
|
9
|
+
* List installed augmentations
|
|
10
|
+
*/
|
|
11
|
+
export declare function listCommand(marketplace: AugmentationMarketplace): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Search cloud registry
|
|
14
|
+
*/
|
|
15
|
+
export declare function searchCommand(marketplace: AugmentationMarketplace, query: string, options?: {
|
|
16
|
+
category?: string;
|
|
17
|
+
free?: boolean;
|
|
18
|
+
limit?: number;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Show augmentation details
|
|
22
|
+
*/
|
|
23
|
+
export declare function infoCommand(marketplace: AugmentationMarketplace, nameOrId: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Install augmentation
|
|
26
|
+
*/
|
|
27
|
+
export declare function installCommand(marketplace: AugmentationMarketplace, nameOrId: string, options?: {
|
|
28
|
+
version?: string;
|
|
29
|
+
noEnable?: boolean;
|
|
30
|
+
noAutoUpdate?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Uninstall augmentation
|
|
34
|
+
*/
|
|
35
|
+
export declare function uninstallCommand(marketplace: AugmentationMarketplace, name: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Enable augmentation
|
|
38
|
+
*/
|
|
39
|
+
export declare function enableCommand(marketplace: AugmentationMarketplace, name: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Disable augmentation
|
|
42
|
+
*/
|
|
43
|
+
export declare function disableCommand(marketplace: AugmentationMarketplace, name: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Update augmentation
|
|
46
|
+
*/
|
|
47
|
+
export declare function updateCommand(marketplace: AugmentationMarketplace, name?: string): Promise<void>;
|