@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.
Files changed (260) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/README.md +353 -110
  3. package/bin/brainy.js +340 -62
  4. package/dist/api/ConfigAPI.d.ts +67 -0
  5. package/dist/api/ConfigAPI.js +166 -0
  6. package/dist/api/DataAPI.d.ts +123 -0
  7. package/dist/api/DataAPI.js +391 -0
  8. package/dist/api/SecurityAPI.d.ts +50 -0
  9. package/dist/api/SecurityAPI.js +139 -0
  10. package/dist/api/UniversalImportAPI.d.ts +134 -0
  11. package/dist/api/UniversalImportAPI.js +615 -0
  12. package/dist/augmentationManager.js +12 -7
  13. package/dist/augmentationPipeline.d.ts +0 -61
  14. package/dist/augmentationPipeline.js +0 -87
  15. package/dist/augmentationRegistry.d.ts +1 -1
  16. package/dist/augmentationRegistry.js +1 -1
  17. package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
  18. package/dist/augmentations/apiServerAugmentation.js +290 -9
  19. package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
  20. package/dist/augmentations/auditLogAugmentation.js +358 -0
  21. package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
  22. package/dist/augmentations/batchProcessingAugmentation.js +123 -22
  23. package/dist/augmentations/brainyAugmentation.d.ts +142 -8
  24. package/dist/augmentations/brainyAugmentation.js +179 -2
  25. package/dist/augmentations/cacheAugmentation.d.ts +8 -5
  26. package/dist/augmentations/cacheAugmentation.js +116 -17
  27. package/dist/augmentations/conduitAugmentations.d.ts +2 -2
  28. package/dist/augmentations/conduitAugmentations.js +2 -2
  29. package/dist/augmentations/configResolver.d.ts +122 -0
  30. package/dist/augmentations/configResolver.js +440 -0
  31. package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
  32. package/dist/augmentations/connectionPoolAugmentation.js +37 -12
  33. package/dist/augmentations/defaultAugmentations.d.ts +14 -10
  34. package/dist/augmentations/defaultAugmentations.js +16 -11
  35. package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
  36. package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
  37. package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
  38. package/dist/augmentations/discovery/localDiscovery.js +246 -0
  39. package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
  40. package/dist/augmentations/discovery/runtimeLoader.js +337 -0
  41. package/dist/augmentations/discovery.d.ts +152 -0
  42. package/dist/augmentations/discovery.js +441 -0
  43. package/dist/augmentations/display/cache.d.ts +130 -0
  44. package/dist/augmentations/display/cache.js +319 -0
  45. package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
  46. package/dist/augmentations/display/fieldPatterns.js +393 -0
  47. package/dist/augmentations/display/iconMappings.d.ts +57 -0
  48. package/dist/augmentations/display/iconMappings.js +68 -0
  49. package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
  50. package/dist/augmentations/display/intelligentComputation.js +462 -0
  51. package/dist/augmentations/display/types.d.ts +203 -0
  52. package/dist/augmentations/display/types.js +7 -0
  53. package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
  54. package/dist/augmentations/entityRegistryAugmentation.js +5 -1
  55. package/dist/augmentations/indexAugmentation.d.ts +5 -3
  56. package/dist/augmentations/indexAugmentation.js +5 -2
  57. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +24 -7
  58. package/dist/augmentations/intelligentVerbScoringAugmentation.js +111 -27
  59. package/dist/augmentations/manifest.d.ts +176 -0
  60. package/dist/augmentations/manifest.js +8 -0
  61. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
  62. package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
  63. package/dist/augmentations/marketplace/cli.d.ts +47 -0
  64. package/dist/augmentations/marketplace/cli.js +265 -0
  65. package/dist/augmentations/metricsAugmentation.d.ts +3 -3
  66. package/dist/augmentations/metricsAugmentation.js +2 -2
  67. package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
  68. package/dist/augmentations/monitoringAugmentation.js +2 -2
  69. package/dist/augmentations/neuralImport.d.ts +1 -1
  70. package/dist/augmentations/neuralImport.js +4 -4
  71. package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
  72. package/dist/augmentations/rateLimitAugmentation.js +321 -0
  73. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
  74. package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
  75. package/dist/augmentations/storageAugmentation.d.ts +1 -1
  76. package/dist/augmentations/storageAugmentation.js +2 -2
  77. package/dist/augmentations/storageAugmentations.d.ts +37 -8
  78. package/dist/augmentations/storageAugmentations.js +204 -15
  79. package/dist/augmentations/synapseAugmentation.d.ts +1 -1
  80. package/dist/augmentations/synapseAugmentation.js +35 -16
  81. package/dist/augmentations/typeMatching/brainyTypes.d.ts +83 -0
  82. package/dist/augmentations/typeMatching/brainyTypes.js +425 -0
  83. package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
  84. package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
  85. package/dist/augmentations/universalDisplayAugmentation.d.ts +191 -0
  86. package/dist/augmentations/universalDisplayAugmentation.js +371 -0
  87. package/dist/brainy-unified.d.ts +106 -0
  88. package/dist/brainy-unified.js +327 -0
  89. package/dist/brainy.d.ts +273 -0
  90. package/dist/brainy.js +1181 -0
  91. package/dist/brainyData.d.ts +56 -111
  92. package/dist/brainyData.js +912 -756
  93. package/dist/brainyDataV3.d.ts +186 -0
  94. package/dist/brainyDataV3.js +337 -0
  95. package/dist/browserFramework.d.ts +6 -6
  96. package/dist/browserFramework.js +11 -8
  97. package/dist/browserFramework.minimal.d.ts +5 -5
  98. package/dist/browserFramework.minimal.js +11 -8
  99. package/dist/config/distributedPresets-new.d.ts +118 -0
  100. package/dist/config/distributedPresets-new.js +318 -0
  101. package/dist/config/distributedPresets.d.ts +118 -0
  102. package/dist/config/distributedPresets.js +318 -0
  103. package/dist/config/extensibleConfig.d.ts +99 -0
  104. package/dist/config/extensibleConfig.js +268 -0
  105. package/dist/config/index.d.ts +17 -0
  106. package/dist/config/index.js +35 -0
  107. package/dist/config/modelAutoConfig.d.ts +32 -0
  108. package/dist/config/modelAutoConfig.js +139 -0
  109. package/dist/config/modelPrecisionManager.d.ts +42 -0
  110. package/dist/config/modelPrecisionManager.js +98 -0
  111. package/dist/config/sharedConfigManager.d.ts +67 -0
  112. package/dist/config/sharedConfigManager.js +215 -0
  113. package/dist/config/storageAutoConfig.d.ts +41 -0
  114. package/dist/config/storageAutoConfig.js +328 -0
  115. package/dist/config/zeroConfig.d.ts +68 -0
  116. package/dist/config/zeroConfig.js +301 -0
  117. package/dist/cortex/backupRestore.d.ts +2 -2
  118. package/dist/cortex/backupRestore.js +85 -27
  119. package/dist/cortex/healthCheck.d.ts +2 -2
  120. package/dist/cortex/neuralImport.d.ts +2 -2
  121. package/dist/cortex/neuralImport.js +18 -13
  122. package/dist/cortex/performanceMonitor.d.ts +2 -2
  123. package/dist/critical/model-guardian.d.ts +4 -0
  124. package/dist/critical/model-guardian.js +31 -11
  125. package/dist/demo.d.ts +4 -4
  126. package/dist/demo.js +7 -7
  127. package/dist/distributed/cacheSync.d.ts +112 -0
  128. package/dist/distributed/cacheSync.js +265 -0
  129. package/dist/distributed/coordinator.d.ts +193 -0
  130. package/dist/distributed/coordinator.js +548 -0
  131. package/dist/distributed/httpTransport.d.ts +120 -0
  132. package/dist/distributed/httpTransport.js +446 -0
  133. package/dist/distributed/index.d.ts +8 -0
  134. package/dist/distributed/index.js +5 -0
  135. package/dist/distributed/networkTransport.d.ts +132 -0
  136. package/dist/distributed/networkTransport.js +633 -0
  137. package/dist/distributed/queryPlanner.d.ts +104 -0
  138. package/dist/distributed/queryPlanner.js +327 -0
  139. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  140. package/dist/distributed/readWriteSeparation.js +350 -0
  141. package/dist/distributed/shardManager.d.ts +114 -0
  142. package/dist/distributed/shardManager.js +357 -0
  143. package/dist/distributed/shardMigration.d.ts +110 -0
  144. package/dist/distributed/shardMigration.js +289 -0
  145. package/dist/distributed/storageDiscovery.d.ts +160 -0
  146. package/dist/distributed/storageDiscovery.js +551 -0
  147. package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
  148. package/dist/embeddings/CachedEmbeddings.js +146 -0
  149. package/dist/embeddings/EmbeddingManager.d.ts +102 -0
  150. package/dist/embeddings/EmbeddingManager.js +291 -0
  151. package/dist/embeddings/SingletonModelManager.d.ts +95 -0
  152. package/dist/embeddings/SingletonModelManager.js +220 -0
  153. package/dist/embeddings/index.d.ts +12 -0
  154. package/dist/embeddings/index.js +16 -0
  155. package/dist/embeddings/lightweight-embedder.d.ts +0 -1
  156. package/dist/embeddings/lightweight-embedder.js +4 -12
  157. package/dist/embeddings/model-manager.d.ts +11 -0
  158. package/dist/embeddings/model-manager.js +43 -7
  159. package/dist/embeddings/universal-memory-manager.d.ts +1 -1
  160. package/dist/embeddings/universal-memory-manager.js +27 -67
  161. package/dist/embeddings/worker-embedding.js +4 -8
  162. package/dist/errors/brainyError.d.ts +5 -1
  163. package/dist/errors/brainyError.js +12 -0
  164. package/dist/examples/basicUsage.js +7 -4
  165. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  166. package/dist/graph/graphAdjacencyIndex.js +288 -0
  167. package/dist/graph/pathfinding.js +4 -2
  168. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  169. package/dist/importManager.js +8 -5
  170. package/dist/index.d.ts +17 -22
  171. package/dist/index.js +37 -23
  172. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  173. package/dist/mcp/brainyMCPAdapter.js +5 -5
  174. package/dist/mcp/brainyMCPService.d.ts +3 -3
  175. package/dist/mcp/brainyMCPService.js +3 -11
  176. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  177. package/dist/neural/embeddedPatterns.d.ts +1 -1
  178. package/dist/neural/embeddedPatterns.js +2 -2
  179. package/dist/neural/entityExtractor.d.ts +65 -0
  180. package/dist/neural/entityExtractor.js +316 -0
  181. package/dist/neural/improvedNeuralAPI.d.ts +357 -0
  182. package/dist/neural/improvedNeuralAPI.js +2628 -0
  183. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  184. package/dist/neural/naturalLanguageProcessor.js +941 -66
  185. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  186. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  187. package/dist/neural/neuralAPI.js +8 -2
  188. package/dist/neural/patternLibrary.d.ts +57 -3
  189. package/dist/neural/patternLibrary.js +348 -13
  190. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  191. package/dist/neural/staticPatternMatcher.js +2 -2
  192. package/dist/neural/types.d.ts +287 -0
  193. package/dist/neural/types.js +24 -0
  194. package/dist/shared/default-augmentations.d.ts +3 -3
  195. package/dist/shared/default-augmentations.js +5 -5
  196. package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
  197. package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
  198. package/dist/storage/adapters/fileSystemStorage.js +218 -15
  199. package/dist/storage/adapters/memoryStorage.d.ts +4 -4
  200. package/dist/storage/adapters/memoryStorage.js +17 -12
  201. package/dist/storage/adapters/opfsStorage.d.ts +2 -2
  202. package/dist/storage/adapters/opfsStorage.js +2 -2
  203. package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
  204. package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
  205. package/dist/storage/backwardCompatibility.d.ts +10 -78
  206. package/dist/storage/backwardCompatibility.js +17 -132
  207. package/dist/storage/baseStorage.d.ts +18 -2
  208. package/dist/storage/baseStorage.js +74 -3
  209. package/dist/storage/cacheManager.js +2 -2
  210. package/dist/storage/readOnlyOptimizations.js +8 -3
  211. package/dist/streaming/pipeline.d.ts +154 -0
  212. package/dist/streaming/pipeline.js +551 -0
  213. package/dist/triple/TripleIntelligence.d.ts +25 -110
  214. package/dist/triple/TripleIntelligence.js +4 -574
  215. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  216. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  217. package/dist/types/apiTypes.d.ts +278 -0
  218. package/dist/types/apiTypes.js +33 -0
  219. package/dist/types/brainy.types.d.ts +308 -0
  220. package/dist/types/brainy.types.js +8 -0
  221. package/dist/types/brainyDataInterface.d.ts +5 -8
  222. package/dist/types/brainyDataInterface.js +2 -2
  223. package/dist/types/graphTypes.js +2 -2
  224. package/dist/utils/brainyTypes.d.ts +217 -0
  225. package/dist/utils/brainyTypes.js +261 -0
  226. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  227. package/dist/utils/embedding.d.ts +9 -4
  228. package/dist/utils/embedding.js +89 -26
  229. package/dist/utils/enhancedLogger.d.ts +104 -0
  230. package/dist/utils/enhancedLogger.js +232 -0
  231. package/dist/utils/hybridModelManager.d.ts +19 -28
  232. package/dist/utils/hybridModelManager.js +36 -200
  233. package/dist/utils/index.d.ts +1 -1
  234. package/dist/utils/index.js +1 -1
  235. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  236. package/dist/utils/intelligentTypeMapper.js +349 -0
  237. package/dist/utils/metadataIndex.d.ts +118 -1
  238. package/dist/utils/metadataIndex.js +539 -16
  239. package/dist/utils/nodeVersionCheck.d.ts +24 -0
  240. package/dist/utils/nodeVersionCheck.js +65 -0
  241. package/dist/utils/paramValidation.d.ts +39 -0
  242. package/dist/utils/paramValidation.js +192 -0
  243. package/dist/utils/rateLimiter.d.ts +160 -0
  244. package/dist/utils/rateLimiter.js +271 -0
  245. package/dist/utils/statistics.d.ts +4 -4
  246. package/dist/utils/statistics.js +3 -3
  247. package/dist/utils/structuredLogger.d.ts +146 -0
  248. package/dist/utils/structuredLogger.js +394 -0
  249. package/dist/utils/textEncoding.js +2 -1
  250. package/dist/utils/typeValidation.d.ts +59 -0
  251. package/dist/utils/typeValidation.js +374 -0
  252. package/dist/utils/version.js +19 -3
  253. package/package.json +15 -4
  254. package/scripts/download-models.cjs +94 -20
  255. package/dist/augmentations/walAugmentation.d.ts +0 -109
  256. package/dist/augmentations/walAugmentation.js +0 -516
  257. package/dist/chat/BrainyChat.d.ts +0 -121
  258. package/dist/chat/BrainyChat.js +0 -396
  259. package/dist/chat/ChatCLI.d.ts +0 -61
  260. 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('Memory storage initialized');
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(rootDirectory = './brainy-data') {
34
- super();
89
+ constructor(config) {
90
+ super(config);
35
91
  this.name = 'filesystem-storage';
36
- this.rootDirectory = rootDirectory;
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(requestPersistent = false) {
64
- super();
189
+ constructor(config) {
190
+ super(config);
65
191
  this.name = 'opfs-storage';
66
- this.requestPersistent = requestPersistent;
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('OPFS storage initialized');
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(options.rootDirectory || './brainy-data');
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(options.requestPersistentStorage || false);
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 queryBrainyData(filter: {
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 BrainyData
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('BrainyData context not initialized');
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.addNoun(noun, {
158
- ...enrichedMetadata,
159
- _neuralConfidence: neuralResult.data.confidence,
160
- _neuralInsights: neuralResult.data.insights
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.add(content, {
177
- ...enrichedMetadata,
178
- _neuralProcessed: true,
179
- _neuralConfidence: neuralResult.data.confidence,
180
- _detectedEntities: neuralResult.data.nouns.length,
181
- _detectedRelationships: neuralResult.data.verbs.length
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.add(content, enrichedMetadata);
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.add(JSON.stringify(content), enrichedMetadata);
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 queryBrainyData(filter) {
222
+ async queryBrainy(filter) {
204
223
  if (!this.context?.brain) {
205
- throw new Error('BrainyData context not initialized');
224
+ throw new Error('Brainy context not initialized');
206
225
  }
207
226
  const searchFilter = {
208
227
  ...filter,
@@ -0,0 +1,83 @@
1
+ /**
2
+ * BrainyTypes - Intelligent type detection using semantic embeddings
3
+ *
4
+ * This module uses our existing TransformerEmbedding and similarity functions
5
+ * to intelligently match data to our 31 noun types and 40 verb types.
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
15
+ */
16
+ export interface TypeMatchResult {
17
+ type: string;
18
+ confidence: number;
19
+ reasoning: string;
20
+ alternatives: Array<{
21
+ type: string;
22
+ confidence: number;
23
+ }>;
24
+ }
25
+ /**
26
+ * BrainyTypes - Intelligent type detection for nouns and verbs
27
+ */
28
+ export declare class BrainyTypes {
29
+ private embedder;
30
+ private nounEmbeddings;
31
+ private verbEmbeddings;
32
+ private initialized;
33
+ private cache;
34
+ constructor();
35
+ /**
36
+ * Initialize the type matcher by generating embeddings for all types
37
+ */
38
+ init(): Promise<void>;
39
+ /**
40
+ * Match an object to the most appropriate noun type
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
61
+ */
62
+ private applyNounHeuristics;
63
+ /**
64
+ * Apply heuristic rules for verb type detection
65
+ */
66
+ private applyVerbHeuristics;
67
+ /**
68
+ * Generate human-readable reasoning for the type selection
69
+ */
70
+ private generateReasoning;
71
+ /**
72
+ * Clear the cache
73
+ */
74
+ clearCache(): void;
75
+ /**
76
+ * Dispose of resources
77
+ */
78
+ dispose(): Promise<void>;
79
+ }
80
+ /**
81
+ * Get or create the global BrainyTypes instance
82
+ */
83
+ export declare function getBrainyTypes(): Promise<BrainyTypes>;