@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.
Files changed (204) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +249 -152
  3. package/dist/api/ConfigAPI.d.ts +67 -0
  4. package/dist/api/ConfigAPI.js +166 -0
  5. package/dist/api/DataAPI.d.ts +123 -0
  6. package/dist/api/DataAPI.js +391 -0
  7. package/dist/api/SecurityAPI.d.ts +50 -0
  8. package/dist/api/SecurityAPI.js +139 -0
  9. package/dist/api/UniversalImportAPI.d.ts +134 -0
  10. package/dist/api/UniversalImportAPI.js +615 -0
  11. package/dist/augmentationManager.js +12 -7
  12. package/dist/augmentationPipeline.d.ts +0 -61
  13. package/dist/augmentationPipeline.js +0 -87
  14. package/dist/augmentationRegistry.d.ts +1 -1
  15. package/dist/augmentationRegistry.js +1 -1
  16. package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
  17. package/dist/augmentations/apiServerAugmentation.js +288 -7
  18. package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
  19. package/dist/augmentations/auditLogAugmentation.js +358 -0
  20. package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
  21. package/dist/augmentations/batchProcessingAugmentation.js +123 -22
  22. package/dist/augmentations/brainyAugmentation.d.ts +87 -8
  23. package/dist/augmentations/brainyAugmentation.js +159 -2
  24. package/dist/augmentations/cacheAugmentation.d.ts +6 -5
  25. package/dist/augmentations/cacheAugmentation.js +113 -17
  26. package/dist/augmentations/conduitAugmentations.d.ts +2 -2
  27. package/dist/augmentations/conduitAugmentations.js +2 -2
  28. package/dist/augmentations/configResolver.d.ts +122 -0
  29. package/dist/augmentations/configResolver.js +440 -0
  30. package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
  31. package/dist/augmentations/connectionPoolAugmentation.js +37 -12
  32. package/dist/augmentations/defaultAugmentations.d.ts +9 -11
  33. package/dist/augmentations/defaultAugmentations.js +4 -11
  34. package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
  35. package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
  36. package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
  37. package/dist/augmentations/discovery/localDiscovery.js +246 -0
  38. package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
  39. package/dist/augmentations/discovery/runtimeLoader.js +337 -0
  40. package/dist/augmentations/discovery.d.ts +152 -0
  41. package/dist/augmentations/discovery.js +441 -0
  42. package/dist/augmentations/display/intelligentComputation.d.ts +1 -1
  43. package/dist/augmentations/display/intelligentComputation.js +4 -4
  44. package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
  45. package/dist/augmentations/entityRegistryAugmentation.js +5 -1
  46. package/dist/augmentations/indexAugmentation.d.ts +3 -3
  47. package/dist/augmentations/indexAugmentation.js +2 -2
  48. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +22 -6
  49. package/dist/augmentations/intelligentVerbScoringAugmentation.js +106 -23
  50. package/dist/augmentations/manifest.d.ts +176 -0
  51. package/dist/augmentations/manifest.js +8 -0
  52. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
  53. package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
  54. package/dist/augmentations/marketplace/cli.d.ts +47 -0
  55. package/dist/augmentations/marketplace/cli.js +265 -0
  56. package/dist/augmentations/metricsAugmentation.d.ts +3 -3
  57. package/dist/augmentations/metricsAugmentation.js +2 -2
  58. package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
  59. package/dist/augmentations/monitoringAugmentation.js +2 -2
  60. package/dist/augmentations/neuralImport.d.ts +1 -1
  61. package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
  62. package/dist/augmentations/rateLimitAugmentation.js +321 -0
  63. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
  64. package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
  65. package/dist/augmentations/storageAugmentation.d.ts +1 -1
  66. package/dist/augmentations/storageAugmentation.js +2 -2
  67. package/dist/augmentations/storageAugmentations.d.ts +37 -8
  68. package/dist/augmentations/storageAugmentations.js +204 -15
  69. package/dist/augmentations/synapseAugmentation.d.ts +1 -1
  70. package/dist/augmentations/synapseAugmentation.js +35 -16
  71. package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
  72. package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
  73. package/dist/augmentations/universalDisplayAugmentation.d.ts +2 -2
  74. package/dist/augmentations/universalDisplayAugmentation.js +2 -2
  75. package/dist/brainy-unified.d.ts +106 -0
  76. package/dist/brainy-unified.js +327 -0
  77. package/dist/brainy.d.ts +273 -0
  78. package/dist/brainy.js +1181 -0
  79. package/dist/brainyData.d.ts +29 -72
  80. package/dist/brainyData.js +350 -304
  81. package/dist/brainyDataV3.d.ts +186 -0
  82. package/dist/brainyDataV3.js +337 -0
  83. package/dist/browserFramework.d.ts +6 -6
  84. package/dist/browserFramework.js +11 -8
  85. package/dist/browserFramework.minimal.d.ts +5 -5
  86. package/dist/browserFramework.minimal.js +11 -8
  87. package/dist/config/index.d.ts +2 -2
  88. package/dist/config/index.js +3 -3
  89. package/dist/config/modelAutoConfig.d.ts +6 -7
  90. package/dist/config/modelAutoConfig.js +17 -76
  91. package/dist/cortex/backupRestore.d.ts +2 -2
  92. package/dist/cortex/backupRestore.js +85 -27
  93. package/dist/cortex/healthCheck.d.ts +2 -2
  94. package/dist/cortex/neuralImport.d.ts +2 -2
  95. package/dist/cortex/neuralImport.js +18 -13
  96. package/dist/cortex/performanceMonitor.d.ts +2 -2
  97. package/dist/critical/model-guardian.d.ts +4 -0
  98. package/dist/critical/model-guardian.js +31 -11
  99. package/dist/demo.d.ts +4 -4
  100. package/dist/demo.js +7 -7
  101. package/dist/distributed/cacheSync.d.ts +112 -0
  102. package/dist/distributed/cacheSync.js +265 -0
  103. package/dist/distributed/coordinator.d.ts +193 -0
  104. package/dist/distributed/coordinator.js +548 -0
  105. package/dist/distributed/httpTransport.d.ts +120 -0
  106. package/dist/distributed/httpTransport.js +446 -0
  107. package/dist/distributed/index.d.ts +8 -0
  108. package/dist/distributed/index.js +5 -0
  109. package/dist/distributed/networkTransport.d.ts +132 -0
  110. package/dist/distributed/networkTransport.js +633 -0
  111. package/dist/distributed/queryPlanner.d.ts +104 -0
  112. package/dist/distributed/queryPlanner.js +327 -0
  113. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  114. package/dist/distributed/readWriteSeparation.js +350 -0
  115. package/dist/distributed/shardManager.d.ts +114 -0
  116. package/dist/distributed/shardManager.js +357 -0
  117. package/dist/distributed/shardMigration.d.ts +110 -0
  118. package/dist/distributed/shardMigration.js +289 -0
  119. package/dist/distributed/storageDiscovery.d.ts +160 -0
  120. package/dist/distributed/storageDiscovery.js +551 -0
  121. package/dist/embeddings/EmbeddingManager.d.ts +0 -4
  122. package/dist/embeddings/EmbeddingManager.js +21 -26
  123. package/dist/errors/brainyError.d.ts +5 -1
  124. package/dist/errors/brainyError.js +12 -0
  125. package/dist/examples/basicUsage.js +3 -3
  126. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  127. package/dist/graph/graphAdjacencyIndex.js +288 -0
  128. package/dist/graph/pathfinding.js +4 -2
  129. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  130. package/dist/importManager.js +6 -3
  131. package/dist/index.d.ts +12 -21
  132. package/dist/index.js +14 -22
  133. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  134. package/dist/mcp/brainyMCPAdapter.js +5 -5
  135. package/dist/mcp/brainyMCPService.d.ts +3 -3
  136. package/dist/mcp/brainyMCPService.js +3 -11
  137. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  138. package/dist/neural/embeddedPatterns.d.ts +1 -1
  139. package/dist/neural/embeddedPatterns.js +2 -2
  140. package/dist/neural/entityExtractor.d.ts +65 -0
  141. package/dist/neural/entityExtractor.js +316 -0
  142. package/dist/neural/improvedNeuralAPI.js +90 -79
  143. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  144. package/dist/neural/naturalLanguageProcessor.js +941 -66
  145. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  146. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  147. package/dist/neural/neuralAPI.js +8 -2
  148. package/dist/neural/patternLibrary.d.ts +57 -3
  149. package/dist/neural/patternLibrary.js +348 -13
  150. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  151. package/dist/neural/staticPatternMatcher.js +2 -2
  152. package/dist/shared/default-augmentations.d.ts +3 -3
  153. package/dist/shared/default-augmentations.js +5 -5
  154. package/dist/storage/adapters/fileSystemStorage.d.ts +4 -0
  155. package/dist/storage/adapters/fileSystemStorage.js +54 -1
  156. package/dist/storage/adapters/memoryStorage.js +13 -8
  157. package/dist/storage/backwardCompatibility.d.ts +10 -78
  158. package/dist/storage/backwardCompatibility.js +17 -132
  159. package/dist/storage/baseStorage.d.ts +6 -0
  160. package/dist/storage/baseStorage.js +17 -0
  161. package/dist/storage/cacheManager.js +2 -2
  162. package/dist/storage/readOnlyOptimizations.js +8 -3
  163. package/dist/streaming/pipeline.d.ts +154 -0
  164. package/dist/streaming/pipeline.js +551 -0
  165. package/dist/triple/TripleIntelligence.d.ts +25 -110
  166. package/dist/triple/TripleIntelligence.js +4 -574
  167. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  168. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  169. package/dist/types/apiTypes.d.ts +278 -0
  170. package/dist/types/apiTypes.js +33 -0
  171. package/dist/types/brainy.types.d.ts +308 -0
  172. package/dist/types/brainy.types.js +8 -0
  173. package/dist/types/brainyDataInterface.d.ts +3 -3
  174. package/dist/types/brainyDataInterface.js +2 -2
  175. package/dist/types/graphTypes.js +2 -2
  176. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  177. package/dist/utils/embedding.js +8 -14
  178. package/dist/utils/enhancedLogger.d.ts +104 -0
  179. package/dist/utils/enhancedLogger.js +232 -0
  180. package/dist/utils/index.d.ts +1 -1
  181. package/dist/utils/index.js +1 -1
  182. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  183. package/dist/utils/intelligentTypeMapper.js +349 -0
  184. package/dist/utils/metadataIndex.d.ts +118 -1
  185. package/dist/utils/metadataIndex.js +539 -16
  186. package/dist/utils/paramValidation.d.ts +39 -0
  187. package/dist/utils/paramValidation.js +192 -0
  188. package/dist/utils/rateLimiter.d.ts +160 -0
  189. package/dist/utils/rateLimiter.js +271 -0
  190. package/dist/utils/statistics.d.ts +4 -4
  191. package/dist/utils/statistics.js +3 -3
  192. package/dist/utils/structuredLogger.d.ts +146 -0
  193. package/dist/utils/structuredLogger.js +394 -0
  194. package/dist/utils/textEncoding.js +2 -1
  195. package/dist/utils/typeValidation.d.ts +34 -0
  196. package/dist/utils/typeValidation.js +247 -0
  197. package/package.json +14 -6
  198. package/scripts/download-models.cjs +6 -15
  199. package/dist/augmentations/walAugmentation.d.ts +0 -111
  200. package/dist/augmentations/walAugmentation.js +0 -519
  201. package/dist/chat/BrainyChat.d.ts +0 -121
  202. package/dist/chat/BrainyChat.js +0 -396
  203. package/dist/chat/ChatCLI.d.ts +0 -61
  204. 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.addNoun(content, '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.addNoun(content, '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.addNoun(JSON.stringify(content), '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,
@@ -1,83 +1,63 @@
1
1
  /**
2
- * Intelligent Type Matcher - Uses embeddings for semantic type detection
2
+ * IntelligentTypeMatcher - Wrapper around BrainyTypes for testing
3
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
4
+ * Provides intelligent type detection using semantic embeddings
5
+ * for matching data to our 31 noun types and 40 verb types.
15
6
  */
16
- export interface TypeMatchResult {
17
- type: string;
18
- confidence: number;
19
- reasoning: string;
20
- alternatives: Array<{
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 Type Matcher using semantic embeddings
14
+ * Intelligent type matcher using semantic embeddings
27
15
  */
28
16
  export declare class IntelligentTypeMatcher {
29
- private embedder;
30
- private nounEmbeddings;
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 by generating embeddings for all types
22
+ * Initialize the type matcher
37
23
  */
38
24
  init(): Promise<void>;
39
25
  /**
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
26
+ * Dispose of resources
61
27
  */
62
- private applyNounHeuristics;
28
+ dispose(): Promise<void>;
63
29
  /**
64
- * Apply heuristic rules for verb type detection
30
+ * Match data to a noun type
65
31
  */
66
- private applyVerbHeuristics;
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
- * Generate human-readable reasoning for the type selection
41
+ * Match a relationship to a verb type
69
42
  */
70
- private generateReasoning;
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
- * Dispose of resources
56
+ * Get cache statistics
77
57
  */
78
- dispose(): Promise<void>;
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;