@soulcraft/brainy 2.15.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 +18 -0
- package/README.md +249 -152
- 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 +288 -7
- 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 +87 -8
- package/dist/augmentations/brainyAugmentation.js +159 -2
- package/dist/augmentations/cacheAugmentation.d.ts +6 -5
- package/dist/augmentations/cacheAugmentation.js +113 -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 +9 -11
- package/dist/augmentations/defaultAugmentations.js +4 -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/intelligentComputation.d.ts +1 -1
- package/dist/augmentations/display/intelligentComputation.js +4 -4
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +3 -3
- package/dist/augmentations/indexAugmentation.js +2 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +22 -6
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +106 -23
- 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/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/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +2 -2
- package/dist/augmentations/universalDisplayAugmentation.js +2 -2
- 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 +29 -72
- package/dist/brainyData.js +350 -304
- 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/index.d.ts +2 -2
- package/dist/config/index.js +3 -3
- package/dist/config/modelAutoConfig.d.ts +6 -7
- package/dist/config/modelAutoConfig.js +17 -76
- 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/EmbeddingManager.d.ts +0 -4
- package/dist/embeddings/EmbeddingManager.js +21 -26
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +3 -3
- 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 +6 -3
- package/dist/index.d.ts +12 -21
- package/dist/index.js +14 -22
- 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.js +90 -79
- 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/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/fileSystemStorage.d.ts +4 -0
- package/dist/storage/adapters/fileSystemStorage.js +54 -1
- package/dist/storage/adapters/memoryStorage.js +13 -8
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +6 -0
- package/dist/storage/baseStorage.js +17 -0
- 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 +3 -3
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.js +8 -14
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- 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/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 +34 -0
- package/dist/utils/typeValidation.js +247 -0
- package/package.json +14 -6
- package/scripts/download-models.cjs +6 -15
- package/dist/augmentations/walAugmentation.d.ts +0 -111
- package/dist/augmentations/walAugmentation.js +0 -519
- 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
|
@@ -12,9 +12,65 @@ import { S3CompatibleStorage, R2Storage } from '../storage/adapters/s3Compatible
|
|
|
12
12
|
* Memory Storage Augmentation - Fast in-memory storage
|
|
13
13
|
*/
|
|
14
14
|
export class MemoryStorageAugmentation extends StorageAugmentation {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config);
|
|
17
17
|
this.name = 'memory-storage';
|
|
18
|
+
this.category = 'core';
|
|
19
|
+
this.description = 'High-performance in-memory storage for development and testing';
|
|
20
|
+
}
|
|
21
|
+
getManifest() {
|
|
22
|
+
return {
|
|
23
|
+
id: 'memory-storage',
|
|
24
|
+
name: 'Memory Storage',
|
|
25
|
+
version: '2.0.0',
|
|
26
|
+
description: 'Fast in-memory storage with no persistence',
|
|
27
|
+
longDescription: 'Perfect for development, testing, and temporary data. All data is lost when the process ends. Provides the fastest possible performance with zero I/O overhead.',
|
|
28
|
+
category: 'storage',
|
|
29
|
+
configSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
maxSize: {
|
|
33
|
+
type: 'number',
|
|
34
|
+
default: 104857600, // 100MB
|
|
35
|
+
minimum: 1048576, // 1MB
|
|
36
|
+
maximum: 1073741824, // 1GB
|
|
37
|
+
description: 'Maximum memory usage in bytes'
|
|
38
|
+
},
|
|
39
|
+
gcInterval: {
|
|
40
|
+
type: 'number',
|
|
41
|
+
default: 60000, // 1 minute
|
|
42
|
+
minimum: 1000, // 1 second
|
|
43
|
+
maximum: 3600000, // 1 hour
|
|
44
|
+
description: 'Garbage collection interval in milliseconds'
|
|
45
|
+
},
|
|
46
|
+
enableStats: {
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
default: false,
|
|
49
|
+
description: 'Enable memory usage statistics'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false
|
|
53
|
+
},
|
|
54
|
+
configDefaults: {
|
|
55
|
+
maxSize: 104857600,
|
|
56
|
+
gcInterval: 60000,
|
|
57
|
+
enableStats: false
|
|
58
|
+
},
|
|
59
|
+
minBrainyVersion: '2.0.0',
|
|
60
|
+
keywords: ['storage', 'memory', 'ram', 'volatile', 'fast'],
|
|
61
|
+
documentation: 'https://docs.brainy.dev/augmentations/memory-storage',
|
|
62
|
+
status: 'stable',
|
|
63
|
+
performance: {
|
|
64
|
+
memoryUsage: 'high',
|
|
65
|
+
cpuUsage: 'low',
|
|
66
|
+
networkUsage: 'none'
|
|
67
|
+
},
|
|
68
|
+
features: ['fast-access', 'zero-latency', 'no-persistence'],
|
|
69
|
+
ui: {
|
|
70
|
+
icon: '💾',
|
|
71
|
+
color: '#4CAF50'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
18
74
|
}
|
|
19
75
|
async provideStorage() {
|
|
20
76
|
const storage = new MemoryStorage();
|
|
@@ -23,23 +79,90 @@ export class MemoryStorageAugmentation extends StorageAugmentation {
|
|
|
23
79
|
}
|
|
24
80
|
async onInitialize() {
|
|
25
81
|
await this.storageAdapter.init();
|
|
26
|
-
this.log(
|
|
82
|
+
this.log(`Memory storage initialized (max size: ${this.config.maxSize} bytes)`);
|
|
27
83
|
}
|
|
28
84
|
}
|
|
29
85
|
/**
|
|
30
86
|
* FileSystem Storage Augmentation - Node.js persistent storage
|
|
31
87
|
*/
|
|
32
88
|
export class FileSystemStorageAugmentation extends StorageAugmentation {
|
|
33
|
-
constructor(
|
|
34
|
-
super();
|
|
89
|
+
constructor(config) {
|
|
90
|
+
super(config);
|
|
35
91
|
this.name = 'filesystem-storage';
|
|
36
|
-
this.
|
|
92
|
+
this.category = 'core';
|
|
93
|
+
this.description = 'Persistent file-based storage for Node.js environments';
|
|
94
|
+
}
|
|
95
|
+
getManifest() {
|
|
96
|
+
return {
|
|
97
|
+
id: 'filesystem-storage',
|
|
98
|
+
name: 'FileSystem Storage',
|
|
99
|
+
version: '2.0.0',
|
|
100
|
+
description: 'Persistent storage using the local filesystem',
|
|
101
|
+
longDescription: 'Stores data as files on the local filesystem. Perfect for Node.js applications, desktop apps, and servers. Provides persistent storage with good performance and unlimited capacity.',
|
|
102
|
+
category: 'storage',
|
|
103
|
+
configSchema: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: {
|
|
106
|
+
rootDirectory: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
default: './brainy-data',
|
|
109
|
+
description: 'Root directory for storing data files'
|
|
110
|
+
},
|
|
111
|
+
compression: {
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
default: false,
|
|
114
|
+
description: 'Enable gzip compression for stored files'
|
|
115
|
+
},
|
|
116
|
+
maxFileSize: {
|
|
117
|
+
type: 'number',
|
|
118
|
+
default: 10485760, // 10MB
|
|
119
|
+
minimum: 1048576, // 1MB
|
|
120
|
+
maximum: 104857600, // 100MB
|
|
121
|
+
description: 'Maximum size per file in bytes'
|
|
122
|
+
},
|
|
123
|
+
autoBackup: {
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
default: false,
|
|
126
|
+
description: 'Enable automatic backups'
|
|
127
|
+
},
|
|
128
|
+
backupInterval: {
|
|
129
|
+
type: 'number',
|
|
130
|
+
default: 3600000, // 1 hour
|
|
131
|
+
minimum: 60000, // 1 minute
|
|
132
|
+
maximum: 86400000, // 24 hours
|
|
133
|
+
description: 'Backup interval in milliseconds'
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
additionalProperties: false
|
|
137
|
+
},
|
|
138
|
+
configDefaults: {
|
|
139
|
+
rootDirectory: './brainy-data',
|
|
140
|
+
compression: false,
|
|
141
|
+
maxFileSize: 10485760,
|
|
142
|
+
autoBackup: false,
|
|
143
|
+
backupInterval: 3600000
|
|
144
|
+
},
|
|
145
|
+
minBrainyVersion: '2.0.0',
|
|
146
|
+
keywords: ['storage', 'filesystem', 'persistent', 'node', 'disk'],
|
|
147
|
+
documentation: 'https://docs.brainy.dev/augmentations/filesystem-storage',
|
|
148
|
+
status: 'stable',
|
|
149
|
+
performance: {
|
|
150
|
+
memoryUsage: 'low',
|
|
151
|
+
cpuUsage: 'low',
|
|
152
|
+
networkUsage: 'none'
|
|
153
|
+
},
|
|
154
|
+
features: ['persistence', 'unlimited-capacity', 'file-based', 'compression-support'],
|
|
155
|
+
ui: {
|
|
156
|
+
icon: '📁',
|
|
157
|
+
color: '#FF9800'
|
|
158
|
+
}
|
|
159
|
+
};
|
|
37
160
|
}
|
|
38
161
|
async provideStorage() {
|
|
39
162
|
try {
|
|
40
163
|
// Dynamically import for Node.js environments
|
|
41
164
|
const { FileSystemStorage } = await import('../storage/adapters/fileSystemStorage.js');
|
|
42
|
-
const storage = new FileSystemStorage(this.rootDirectory);
|
|
165
|
+
const storage = new FileSystemStorage(this.config.rootDirectory);
|
|
43
166
|
this.storageAdapter = storage;
|
|
44
167
|
return storage;
|
|
45
168
|
}
|
|
@@ -53,17 +176,79 @@ export class FileSystemStorageAugmentation extends StorageAugmentation {
|
|
|
53
176
|
}
|
|
54
177
|
async onInitialize() {
|
|
55
178
|
await this.storageAdapter.init();
|
|
56
|
-
this.log(`FileSystem storage initialized at ${this.rootDirectory}`);
|
|
179
|
+
this.log(`FileSystem storage initialized at ${this.config.rootDirectory}`);
|
|
180
|
+
if (this.config.compression) {
|
|
181
|
+
this.log('Compression enabled for stored files');
|
|
182
|
+
}
|
|
57
183
|
}
|
|
58
184
|
}
|
|
59
185
|
/**
|
|
60
186
|
* OPFS Storage Augmentation - Browser persistent storage
|
|
61
187
|
*/
|
|
62
188
|
export class OPFSStorageAugmentation extends StorageAugmentation {
|
|
63
|
-
constructor(
|
|
64
|
-
super();
|
|
189
|
+
constructor(config) {
|
|
190
|
+
super(config);
|
|
65
191
|
this.name = 'opfs-storage';
|
|
66
|
-
this.
|
|
192
|
+
this.category = 'core';
|
|
193
|
+
this.description = 'Persistent browser storage using Origin Private File System';
|
|
194
|
+
}
|
|
195
|
+
getManifest() {
|
|
196
|
+
return {
|
|
197
|
+
id: 'opfs-storage',
|
|
198
|
+
name: 'OPFS Storage',
|
|
199
|
+
version: '2.0.0',
|
|
200
|
+
description: 'Modern browser storage with file system capabilities',
|
|
201
|
+
longDescription: 'Uses the Origin Private File System API for persistent browser storage. Provides file-like storage in modern browsers with better performance than IndexedDB and unlimited storage quota.',
|
|
202
|
+
category: 'storage',
|
|
203
|
+
configSchema: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
requestPersistent: {
|
|
207
|
+
type: 'boolean',
|
|
208
|
+
default: false,
|
|
209
|
+
description: 'Request persistent storage permission from browser'
|
|
210
|
+
},
|
|
211
|
+
directoryName: {
|
|
212
|
+
type: 'string',
|
|
213
|
+
default: 'brainy-data',
|
|
214
|
+
description: 'Directory name within OPFS'
|
|
215
|
+
},
|
|
216
|
+
chunkSize: {
|
|
217
|
+
type: 'number',
|
|
218
|
+
default: 1048576, // 1MB
|
|
219
|
+
minimum: 65536, // 64KB
|
|
220
|
+
maximum: 10485760, // 10MB
|
|
221
|
+
description: 'Chunk size for file operations in bytes'
|
|
222
|
+
},
|
|
223
|
+
enableCache: {
|
|
224
|
+
type: 'boolean',
|
|
225
|
+
default: true,
|
|
226
|
+
description: 'Enable in-memory caching for frequently accessed data'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
additionalProperties: false
|
|
230
|
+
},
|
|
231
|
+
configDefaults: {
|
|
232
|
+
requestPersistent: false,
|
|
233
|
+
directoryName: 'brainy-data',
|
|
234
|
+
chunkSize: 1048576,
|
|
235
|
+
enableCache: true
|
|
236
|
+
},
|
|
237
|
+
minBrainyVersion: '2.0.0',
|
|
238
|
+
keywords: ['storage', 'browser', 'opfs', 'persistent', 'web'],
|
|
239
|
+
documentation: 'https://docs.brainy.dev/augmentations/opfs-storage',
|
|
240
|
+
status: 'stable',
|
|
241
|
+
performance: {
|
|
242
|
+
memoryUsage: 'medium',
|
|
243
|
+
cpuUsage: 'low',
|
|
244
|
+
networkUsage: 'none'
|
|
245
|
+
},
|
|
246
|
+
features: ['browser-persistent', 'file-system-api', 'unlimited-quota', 'async-operations'],
|
|
247
|
+
ui: {
|
|
248
|
+
icon: '🌐',
|
|
249
|
+
color: '#2196F3'
|
|
250
|
+
}
|
|
251
|
+
};
|
|
67
252
|
}
|
|
68
253
|
async provideStorage() {
|
|
69
254
|
const storage = new OPFSStorage();
|
|
@@ -78,11 +263,11 @@ export class OPFSStorageAugmentation extends StorageAugmentation {
|
|
|
78
263
|
}
|
|
79
264
|
async onInitialize() {
|
|
80
265
|
await this.storageAdapter.init();
|
|
81
|
-
if (this.requestPersistent && this.storageAdapter instanceof OPFSStorage) {
|
|
266
|
+
if (this.config.requestPersistent && this.storageAdapter instanceof OPFSStorage) {
|
|
82
267
|
const granted = await this.storageAdapter.requestPersistentStorage();
|
|
83
268
|
this.log(`Persistent storage ${granted ? 'granted' : 'denied'}`);
|
|
84
269
|
}
|
|
85
|
-
this.log(
|
|
270
|
+
this.log(`OPFS storage initialized in directory: ${this.config.directoryName}`);
|
|
86
271
|
}
|
|
87
272
|
}
|
|
88
273
|
/**
|
|
@@ -163,11 +348,15 @@ export async function createAutoStorageAugmentation(options = {}) {
|
|
|
163
348
|
process.versions.node != null);
|
|
164
349
|
if (isNodeEnv) {
|
|
165
350
|
// Node.js environment - use FileSystem
|
|
166
|
-
return new FileSystemStorageAugmentation(
|
|
351
|
+
return new FileSystemStorageAugmentation({
|
|
352
|
+
rootDirectory: options.rootDirectory || './brainy-data'
|
|
353
|
+
});
|
|
167
354
|
}
|
|
168
355
|
else {
|
|
169
356
|
// Browser environment - try OPFS, fall back to memory
|
|
170
|
-
const opfsAug = new OPFSStorageAugmentation(
|
|
357
|
+
const opfsAug = new OPFSStorageAugmentation({
|
|
358
|
+
requestPersistent: options.requestPersistentStorage || false
|
|
359
|
+
});
|
|
171
360
|
// Test if OPFS is available
|
|
172
361
|
const testStorage = new OPFSStorage();
|
|
173
362
|
if (testStorage.isOPFSAvailable()) {
|
|
@@ -114,7 +114,7 @@ export declare abstract class SynapseAugmentation extends BaseAugmentation {
|
|
|
114
114
|
/**
|
|
115
115
|
* Helper method to query existing synced data
|
|
116
116
|
*/
|
|
117
|
-
protected
|
|
117
|
+
protected queryBrainy(filter: {
|
|
118
118
|
connector?: string;
|
|
119
119
|
[key: string]: any;
|
|
120
120
|
}): Promise<any[]>;
|
|
@@ -54,7 +54,7 @@ export class SynapseAugmentation extends BaseAugmentation {
|
|
|
54
54
|
else {
|
|
55
55
|
// Create a new instance for this synapse
|
|
56
56
|
this.neuralImport = new NeuralImportAugmentation();
|
|
57
|
-
// NeuralImport will be initialized when the synapse is added to
|
|
57
|
+
// NeuralImport will be initialized when the synapse is added to Brainy
|
|
58
58
|
// await this.neuralImport.initialize()
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -133,7 +133,7 @@ export class SynapseAugmentation extends BaseAugmentation {
|
|
|
133
133
|
*/
|
|
134
134
|
async storeInBrainy(content, metadata, options = {}) {
|
|
135
135
|
if (!this.context?.brain) {
|
|
136
|
-
throw new Error('
|
|
136
|
+
throw new Error('Brainy context not initialized');
|
|
137
137
|
}
|
|
138
138
|
// Add synapse source metadata
|
|
139
139
|
const enrichedMetadata = {
|
|
@@ -154,10 +154,13 @@ export class SynapseAugmentation extends BaseAugmentation {
|
|
|
154
154
|
if (neuralResult.success && neuralResult.data) {
|
|
155
155
|
// Store detected nouns (entities)
|
|
156
156
|
for (const noun of neuralResult.data.nouns) {
|
|
157
|
-
await this.context.brain.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
await this.context.brain.add({
|
|
158
|
+
text: noun,
|
|
159
|
+
metadata: {
|
|
160
|
+
...enrichedMetadata,
|
|
161
|
+
_neuralConfidence: neuralResult.data.confidence,
|
|
162
|
+
_neuralInsights: neuralResult.data.insights
|
|
163
|
+
}
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
// Store detected verbs (relationships)
|
|
@@ -173,12 +176,16 @@ export class SynapseAugmentation extends BaseAugmentation {
|
|
|
173
176
|
}
|
|
174
177
|
// Store original content with neural metadata
|
|
175
178
|
if (typeof content === 'string') {
|
|
176
|
-
await this.context.brain.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
await this.context.brain.add({
|
|
180
|
+
text: content,
|
|
181
|
+
metadata: {
|
|
182
|
+
...enrichedMetadata,
|
|
183
|
+
category: 'Content',
|
|
184
|
+
_neuralProcessed: true,
|
|
185
|
+
_neuralConfidence: neuralResult.data.confidence,
|
|
186
|
+
_detectedEntities: neuralResult.data.nouns.length,
|
|
187
|
+
_detectedRelationships: neuralResult.data.verbs.length
|
|
188
|
+
}
|
|
182
189
|
});
|
|
183
190
|
}
|
|
184
191
|
return; // Successfully processed with Neural Import
|
|
@@ -190,19 +197,31 @@ export class SynapseAugmentation extends BaseAugmentation {
|
|
|
190
197
|
}
|
|
191
198
|
// Fallback to basic storage
|
|
192
199
|
if (typeof content === 'string') {
|
|
193
|
-
await this.context.brain.
|
|
200
|
+
await this.context.brain.add({
|
|
201
|
+
text: content,
|
|
202
|
+
metadata: {
|
|
203
|
+
...enrichedMetadata,
|
|
204
|
+
category: 'Content'
|
|
205
|
+
}
|
|
206
|
+
});
|
|
194
207
|
}
|
|
195
208
|
else {
|
|
196
209
|
// For structured data, store as JSON
|
|
197
|
-
await this.context.brain.
|
|
210
|
+
await this.context.brain.add({
|
|
211
|
+
text: JSON.stringify(content),
|
|
212
|
+
metadata: {
|
|
213
|
+
...enrichedMetadata,
|
|
214
|
+
category: 'Content'
|
|
215
|
+
}
|
|
216
|
+
});
|
|
198
217
|
}
|
|
199
218
|
}
|
|
200
219
|
/**
|
|
201
220
|
* Helper method to query existing synced data
|
|
202
221
|
*/
|
|
203
|
-
async
|
|
222
|
+
async queryBrainy(filter) {
|
|
204
223
|
if (!this.context?.brain) {
|
|
205
|
-
throw new Error('
|
|
224
|
+
throw new Error('Brainy context not initialized');
|
|
206
225
|
}
|
|
207
226
|
const searchFilter = {
|
|
208
227
|
...filter,
|
|
@@ -1,83 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* IntelligentTypeMatcher - Wrapper around BrainyTypes for testing
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Semantic similarity matching using embeddings
|
|
9
|
-
* - Context-aware type detection
|
|
10
|
-
* - Confidence scoring
|
|
11
|
-
* - Caching for performance
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Result of type matching with confidence scores
|
|
4
|
+
* Provides intelligent type detection using semantic embeddings
|
|
5
|
+
* for matching data to our 31 noun types and 40 verb types.
|
|
15
6
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type: string;
|
|
22
|
-
confidence: number;
|
|
23
|
-
}>;
|
|
7
|
+
import { NounType, VerbType } from '../../types/graphTypes.js';
|
|
8
|
+
export interface TypeMatchOptions {
|
|
9
|
+
threshold?: number;
|
|
10
|
+
topK?: number;
|
|
11
|
+
useCache?: boolean;
|
|
24
12
|
}
|
|
25
13
|
/**
|
|
26
|
-
* Intelligent
|
|
14
|
+
* Intelligent type matcher using semantic embeddings
|
|
27
15
|
*/
|
|
28
16
|
export declare class IntelligentTypeMatcher {
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private verbEmbeddings;
|
|
32
|
-
private initialized;
|
|
17
|
+
private options;
|
|
18
|
+
private brainyTypes;
|
|
33
19
|
private cache;
|
|
34
|
-
constructor();
|
|
20
|
+
constructor(options?: TypeMatchOptions);
|
|
35
21
|
/**
|
|
36
|
-
* Initialize the type matcher
|
|
22
|
+
* Initialize the type matcher
|
|
37
23
|
*/
|
|
38
24
|
init(): Promise<void>;
|
|
39
25
|
/**
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
matchNounType(obj: any): Promise<TypeMatchResult>;
|
|
43
|
-
/**
|
|
44
|
-
* Match a relationship to the most appropriate verb type
|
|
45
|
-
*/
|
|
46
|
-
matchVerbType(sourceObj: any, targetObj: any, relationshipHint?: string): Promise<TypeMatchResult>;
|
|
47
|
-
/**
|
|
48
|
-
* Create text representation of an object for embedding
|
|
49
|
-
*/
|
|
50
|
-
private createTextRepresentation;
|
|
51
|
-
/**
|
|
52
|
-
* Create text representation of a relationship
|
|
53
|
-
*/
|
|
54
|
-
private createRelationshipText;
|
|
55
|
-
/**
|
|
56
|
-
* Get a brief summary of an object
|
|
57
|
-
*/
|
|
58
|
-
private getObjectSummary;
|
|
59
|
-
/**
|
|
60
|
-
* Apply heuristic rules for noun type detection
|
|
26
|
+
* Dispose of resources
|
|
61
27
|
*/
|
|
62
|
-
|
|
28
|
+
dispose(): Promise<void>;
|
|
63
29
|
/**
|
|
64
|
-
*
|
|
30
|
+
* Match data to a noun type
|
|
65
31
|
*/
|
|
66
|
-
|
|
32
|
+
matchNounType(data: any): Promise<{
|
|
33
|
+
type: NounType;
|
|
34
|
+
confidence: number;
|
|
35
|
+
alternatives: Array<{
|
|
36
|
+
type: NounType;
|
|
37
|
+
confidence: number;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
67
40
|
/**
|
|
68
|
-
*
|
|
41
|
+
* Match a relationship to a verb type
|
|
69
42
|
*/
|
|
70
|
-
|
|
43
|
+
matchVerbType(source: any, target: any, relationship?: string): Promise<{
|
|
44
|
+
type: VerbType;
|
|
45
|
+
confidence: number;
|
|
46
|
+
alternatives: Array<{
|
|
47
|
+
type: VerbType;
|
|
48
|
+
confidence: number;
|
|
49
|
+
}>;
|
|
50
|
+
}>;
|
|
71
51
|
/**
|
|
72
52
|
* Clear the cache
|
|
73
53
|
*/
|
|
74
54
|
clearCache(): void;
|
|
75
55
|
/**
|
|
76
|
-
*
|
|
56
|
+
* Get cache statistics
|
|
77
57
|
*/
|
|
78
|
-
|
|
58
|
+
getCacheStats(): {
|
|
59
|
+
size: number;
|
|
60
|
+
maxSize: number;
|
|
61
|
+
};
|
|
79
62
|
}
|
|
80
|
-
|
|
81
|
-
* Get or create the global type matcher instance
|
|
82
|
-
*/
|
|
83
|
-
export declare function getTypeMatcher(): Promise<IntelligentTypeMatcher>;
|
|
63
|
+
export default IntelligentTypeMatcher;
|