@soulcraft/brainy 3.0.0 → 3.1.0

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 (270) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/README.md +427 -111
  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 +277 -0
  90. package/dist/brainy.js +1241 -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/config/distributedPresets-new.d.ts +118 -0
  96. package/dist/config/distributedPresets-new.js +318 -0
  97. package/dist/config/distributedPresets.d.ts +118 -0
  98. package/dist/config/distributedPresets.js +318 -0
  99. package/dist/config/extensibleConfig.d.ts +99 -0
  100. package/dist/config/extensibleConfig.js +268 -0
  101. package/dist/config/index.d.ts +17 -0
  102. package/dist/config/index.js +35 -0
  103. package/dist/config/modelAutoConfig.d.ts +32 -0
  104. package/dist/config/modelAutoConfig.js +139 -0
  105. package/dist/config/modelPrecisionManager.d.ts +42 -0
  106. package/dist/config/modelPrecisionManager.js +98 -0
  107. package/dist/config/sharedConfigManager.d.ts +67 -0
  108. package/dist/config/sharedConfigManager.js +215 -0
  109. package/dist/config/storageAutoConfig.d.ts +41 -0
  110. package/dist/config/storageAutoConfig.js +328 -0
  111. package/dist/config/zeroConfig.d.ts +68 -0
  112. package/dist/config/zeroConfig.js +301 -0
  113. package/dist/cortex/backupRestore.d.ts +2 -2
  114. package/dist/cortex/backupRestore.js +85 -27
  115. package/dist/cortex/healthCheck.d.ts +2 -2
  116. package/dist/cortex/neuralImport.d.ts +2 -2
  117. package/dist/cortex/neuralImport.js +18 -13
  118. package/dist/cortex/performanceMonitor.d.ts +2 -2
  119. package/dist/critical/model-guardian.d.ts +4 -0
  120. package/dist/critical/model-guardian.js +31 -11
  121. package/dist/demo.d.ts +4 -4
  122. package/dist/demo.js +7 -7
  123. package/dist/distributed/cacheSync.d.ts +112 -0
  124. package/dist/distributed/cacheSync.js +265 -0
  125. package/dist/distributed/coordinator.d.ts +193 -0
  126. package/dist/distributed/coordinator.js +548 -0
  127. package/dist/distributed/httpTransport.d.ts +120 -0
  128. package/dist/distributed/httpTransport.js +446 -0
  129. package/dist/distributed/index.d.ts +8 -0
  130. package/dist/distributed/index.js +5 -0
  131. package/dist/distributed/networkTransport.d.ts +132 -0
  132. package/dist/distributed/networkTransport.js +633 -0
  133. package/dist/distributed/queryPlanner.d.ts +104 -0
  134. package/dist/distributed/queryPlanner.js +327 -0
  135. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  136. package/dist/distributed/readWriteSeparation.js +350 -0
  137. package/dist/distributed/shardManager.d.ts +114 -0
  138. package/dist/distributed/shardManager.js +357 -0
  139. package/dist/distributed/shardMigration.d.ts +110 -0
  140. package/dist/distributed/shardMigration.js +289 -0
  141. package/dist/distributed/storageDiscovery.d.ts +160 -0
  142. package/dist/distributed/storageDiscovery.js +551 -0
  143. package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
  144. package/dist/embeddings/CachedEmbeddings.js +146 -0
  145. package/dist/embeddings/EmbeddingManager.d.ts +102 -0
  146. package/dist/embeddings/EmbeddingManager.js +291 -0
  147. package/dist/embeddings/SingletonModelManager.d.ts +95 -0
  148. package/dist/embeddings/SingletonModelManager.js +220 -0
  149. package/dist/embeddings/index.d.ts +12 -0
  150. package/dist/embeddings/index.js +16 -0
  151. package/dist/embeddings/lightweight-embedder.d.ts +0 -1
  152. package/dist/embeddings/lightweight-embedder.js +4 -12
  153. package/dist/embeddings/model-manager.d.ts +11 -0
  154. package/dist/embeddings/model-manager.js +43 -7
  155. package/dist/embeddings/universal-memory-manager.d.ts +1 -1
  156. package/dist/embeddings/universal-memory-manager.js +27 -67
  157. package/dist/embeddings/worker-embedding.js +4 -8
  158. package/dist/errors/brainyError.d.ts +5 -1
  159. package/dist/errors/brainyError.js +12 -0
  160. package/dist/examples/basicUsage.js +7 -4
  161. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  162. package/dist/graph/graphAdjacencyIndex.js +288 -0
  163. package/dist/graph/pathfinding.js +4 -2
  164. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  165. package/dist/importManager.js +8 -5
  166. package/dist/index.d.ts +17 -22
  167. package/dist/index.js +37 -23
  168. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  169. package/dist/mcp/brainyMCPAdapter.js +5 -5
  170. package/dist/mcp/brainyMCPService.d.ts +3 -3
  171. package/dist/mcp/brainyMCPService.js +3 -11
  172. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  173. package/dist/neural/embeddedPatterns.d.ts +1 -1
  174. package/dist/neural/embeddedPatterns.js +2 -2
  175. package/dist/neural/entityExtractor.d.ts +65 -0
  176. package/dist/neural/entityExtractor.js +316 -0
  177. package/dist/neural/improvedNeuralAPI.d.ts +357 -0
  178. package/dist/neural/improvedNeuralAPI.js +2628 -0
  179. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  180. package/dist/neural/naturalLanguageProcessor.js +941 -66
  181. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  182. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  183. package/dist/neural/neuralAPI.js +8 -2
  184. package/dist/neural/patternLibrary.d.ts +57 -3
  185. package/dist/neural/patternLibrary.js +348 -13
  186. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  187. package/dist/neural/staticPatternMatcher.js +2 -2
  188. package/dist/neural/types.d.ts +287 -0
  189. package/dist/neural/types.js +24 -0
  190. package/dist/shared/default-augmentations.d.ts +3 -3
  191. package/dist/shared/default-augmentations.js +5 -5
  192. package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
  193. package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
  194. package/dist/storage/adapters/fileSystemStorage.js +218 -15
  195. package/dist/storage/adapters/memoryStorage.d.ts +4 -4
  196. package/dist/storage/adapters/memoryStorage.js +17 -12
  197. package/dist/storage/adapters/opfsStorage.d.ts +2 -2
  198. package/dist/storage/adapters/opfsStorage.js +2 -2
  199. package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
  200. package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
  201. package/dist/storage/backwardCompatibility.d.ts +10 -78
  202. package/dist/storage/backwardCompatibility.js +17 -132
  203. package/dist/storage/baseStorage.d.ts +18 -2
  204. package/dist/storage/baseStorage.js +74 -3
  205. package/dist/storage/cacheManager.js +2 -2
  206. package/dist/storage/readOnlyOptimizations.js +8 -3
  207. package/dist/streaming/pipeline.d.ts +154 -0
  208. package/dist/streaming/pipeline.js +551 -0
  209. package/dist/triple/TripleIntelligence.d.ts +25 -110
  210. package/dist/triple/TripleIntelligence.js +4 -574
  211. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  212. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  213. package/dist/types/apiTypes.d.ts +278 -0
  214. package/dist/types/apiTypes.js +33 -0
  215. package/dist/types/brainy.types.d.ts +308 -0
  216. package/dist/types/brainy.types.js +8 -0
  217. package/dist/types/brainyDataInterface.d.ts +5 -8
  218. package/dist/types/brainyDataInterface.js +2 -2
  219. package/dist/types/graphTypes.js +2 -2
  220. package/dist/universal/crypto.d.ts +11 -1
  221. package/dist/universal/crypto.js +24 -93
  222. package/dist/universal/events.d.ts +3 -2
  223. package/dist/universal/events.js +6 -75
  224. package/dist/universal/fs.d.ts +2 -3
  225. package/dist/universal/fs.js +5 -211
  226. package/dist/universal/path.d.ts +3 -2
  227. package/dist/universal/path.js +22 -78
  228. package/dist/universal/uuid.d.ts +1 -1
  229. package/dist/universal/uuid.js +1 -1
  230. package/dist/utils/brainyTypes.d.ts +217 -0
  231. package/dist/utils/brainyTypes.js +261 -0
  232. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  233. package/dist/utils/embedding.d.ts +9 -4
  234. package/dist/utils/embedding.js +89 -26
  235. package/dist/utils/enhancedLogger.d.ts +104 -0
  236. package/dist/utils/enhancedLogger.js +232 -0
  237. package/dist/utils/hybridModelManager.d.ts +19 -28
  238. package/dist/utils/hybridModelManager.js +36 -200
  239. package/dist/utils/index.d.ts +1 -1
  240. package/dist/utils/index.js +1 -1
  241. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  242. package/dist/utils/intelligentTypeMapper.js +349 -0
  243. package/dist/utils/metadataIndex.d.ts +118 -1
  244. package/dist/utils/metadataIndex.js +539 -16
  245. package/dist/utils/nodeVersionCheck.d.ts +24 -0
  246. package/dist/utils/nodeVersionCheck.js +65 -0
  247. package/dist/utils/paramValidation.d.ts +39 -0
  248. package/dist/utils/paramValidation.js +192 -0
  249. package/dist/utils/rateLimiter.d.ts +160 -0
  250. package/dist/utils/rateLimiter.js +271 -0
  251. package/dist/utils/statistics.d.ts +4 -4
  252. package/dist/utils/statistics.js +3 -3
  253. package/dist/utils/structuredLogger.d.ts +146 -0
  254. package/dist/utils/structuredLogger.js +394 -0
  255. package/dist/utils/textEncoding.js +2 -1
  256. package/dist/utils/typeValidation.d.ts +59 -0
  257. package/dist/utils/typeValidation.js +374 -0
  258. package/dist/utils/version.js +19 -3
  259. package/package.json +15 -17
  260. package/scripts/download-models.cjs +94 -20
  261. package/dist/augmentations/walAugmentation.d.ts +0 -109
  262. package/dist/augmentations/walAugmentation.js +0 -516
  263. package/dist/browserFramework.d.ts +0 -15
  264. package/dist/browserFramework.js +0 -31
  265. package/dist/browserFramework.minimal.d.ts +0 -14
  266. package/dist/browserFramework.minimal.js +0 -31
  267. package/dist/chat/BrainyChat.d.ts +0 -121
  268. package/dist/chat/BrainyChat.js +0 -396
  269. package/dist/chat/ChatCLI.d.ts +0 -61
  270. package/dist/chat/ChatCLI.js +0 -351
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Consistent API Types for Brainy
3
+ *
4
+ * These types provide a uniform interface for all public methods,
5
+ * using object parameters for consistency and extensibility.
6
+ */
7
+ import type { Vector } from '../coreTypes.js';
8
+ import type { NounType, VerbType } from './graphTypes.js';
9
+ /**
10
+ * Parameters for adding a noun
11
+ */
12
+ export interface AddNounParams {
13
+ data: any | Vector;
14
+ type: NounType | string;
15
+ metadata?: any;
16
+ id?: string;
17
+ service?: string;
18
+ }
19
+ /**
20
+ * Parameters for updating a noun
21
+ */
22
+ export interface UpdateNounParams {
23
+ id: string;
24
+ data?: any;
25
+ metadata?: any;
26
+ type?: NounType | string;
27
+ }
28
+ /**
29
+ * Parameters for getting nouns
30
+ */
31
+ export interface GetNounsParams {
32
+ ids?: string[];
33
+ type?: NounType | string | string[];
34
+ limit?: number;
35
+ offset?: number;
36
+ cursor?: string;
37
+ filter?: Record<string, any>;
38
+ service?: string;
39
+ }
40
+ /**
41
+ * Parameters for adding a verb (relationship)
42
+ */
43
+ export interface AddVerbParams {
44
+ source: string;
45
+ target: string;
46
+ type: VerbType | string;
47
+ weight?: number;
48
+ metadata?: any;
49
+ service?: string;
50
+ }
51
+ /**
52
+ * Parameters for getting verbs
53
+ */
54
+ export interface GetVerbsParams {
55
+ source?: string;
56
+ target?: string;
57
+ type?: VerbType | string | string[];
58
+ limit?: number;
59
+ offset?: number;
60
+ cursor?: string;
61
+ filter?: Record<string, any>;
62
+ service?: string;
63
+ }
64
+ /**
65
+ * Unified search parameters
66
+ */
67
+ export interface SearchParams {
68
+ query: string | Vector;
69
+ limit?: number;
70
+ threshold?: number;
71
+ filter?: {
72
+ type?: NounType | string | string[];
73
+ metadata?: Record<string, any>;
74
+ service?: string;
75
+ };
76
+ includeMetadata?: boolean;
77
+ includeVectors?: boolean;
78
+ }
79
+ /**
80
+ * Parameters for similarity search
81
+ */
82
+ export interface SimilarityParams {
83
+ id?: string;
84
+ data?: any | Vector;
85
+ limit?: number;
86
+ threshold?: number;
87
+ filter?: {
88
+ type?: NounType | string | string[];
89
+ metadata?: Record<string, any>;
90
+ service?: string;
91
+ };
92
+ }
93
+ /**
94
+ * Parameters for related items search
95
+ */
96
+ export interface RelatedParams {
97
+ id: string;
98
+ depth?: number;
99
+ limit?: number;
100
+ types?: VerbType[] | string[];
101
+ direction?: 'outgoing' | 'incoming' | 'both';
102
+ }
103
+ /**
104
+ * Parameters for batch noun operations
105
+ */
106
+ export interface BatchNounsParams {
107
+ items: AddNounParams[];
108
+ parallel?: boolean;
109
+ chunkSize?: number;
110
+ onProgress?: (completed: number, total: number) => void;
111
+ }
112
+ /**
113
+ * Parameters for batch verb operations
114
+ */
115
+ export interface BatchVerbsParams {
116
+ items: AddVerbParams[];
117
+ parallel?: boolean;
118
+ chunkSize?: number;
119
+ onProgress?: (completed: number, total: number) => void;
120
+ }
121
+ /**
122
+ * Parameters for statistics queries
123
+ */
124
+ export interface StatisticsParams {
125
+ detailed?: boolean;
126
+ includeAugmentations?: boolean;
127
+ includeMemory?: boolean;
128
+ service?: string;
129
+ }
130
+ /**
131
+ * Parameters for metadata operations
132
+ */
133
+ export interface MetadataParams {
134
+ id: string;
135
+ metadata: any;
136
+ merge?: boolean;
137
+ }
138
+ /**
139
+ * Dynamic configuration update parameters
140
+ */
141
+ export interface ConfigUpdateParams {
142
+ embeddings?: {
143
+ model?: string;
144
+ precision?: 'q8';
145
+ cache?: boolean;
146
+ };
147
+ augmentations?: {
148
+ [name: string]: boolean | Record<string, any>;
149
+ };
150
+ storage?: {
151
+ type?: string;
152
+ config?: any;
153
+ };
154
+ performance?: {
155
+ batchSize?: number;
156
+ maxConcurrency?: number;
157
+ cacheSize?: number;
158
+ };
159
+ }
160
+ /**
161
+ * API for Triple Intelligence Engine to access Brainy internals
162
+ * This provides type-safe access without 'as any' casts
163
+ */
164
+ export interface TripleIntelligenceAPI {
165
+ vectorSearch(vector: Vector | string, limit: number): Promise<Array<{
166
+ id: string;
167
+ score: number;
168
+ entity?: any;
169
+ }>>;
170
+ graphTraversal(options: {
171
+ start: string | string[];
172
+ type?: string | string[];
173
+ direction?: 'in' | 'out' | 'both';
174
+ maxDepth?: number;
175
+ }): Promise<Array<{
176
+ id: string;
177
+ score: number;
178
+ depth: number;
179
+ }>>;
180
+ metadataQuery(where: Record<string, any>): Promise<Set<string>>;
181
+ getEntity(id: string): Promise<any>;
182
+ getVerbsBySource(sourceId: string): Promise<any[]>;
183
+ getVerbsByTarget(targetId: string): Promise<any[]>;
184
+ getStatistics(): Promise<{
185
+ totalCount: number;
186
+ fieldStats: Record<string, {
187
+ min: number;
188
+ max: number;
189
+ cardinality: number;
190
+ type: string;
191
+ }>;
192
+ }>;
193
+ getAllNouns(): Map<string, any>;
194
+ hasMetadataIndex(): boolean;
195
+ }
196
+ /**
197
+ * Unified search result
198
+ */
199
+ export interface SearchResult<T = any> {
200
+ id: string;
201
+ score: number;
202
+ data?: T;
203
+ metadata?: any;
204
+ vector?: Vector;
205
+ type?: string;
206
+ distance?: number;
207
+ }
208
+ /**
209
+ * Paginated result wrapper
210
+ */
211
+ export interface PaginatedResult<T> {
212
+ items: T[];
213
+ total?: number;
214
+ hasMore: boolean;
215
+ nextCursor?: string;
216
+ previousCursor?: string;
217
+ }
218
+ /**
219
+ * Batch operation result
220
+ */
221
+ export interface BatchResult {
222
+ successful: string[];
223
+ failed: Array<{
224
+ index: number;
225
+ error: string;
226
+ item?: any;
227
+ }>;
228
+ total: number;
229
+ duration: number;
230
+ }
231
+ /**
232
+ * Statistics result
233
+ */
234
+ export interface StatisticsResult {
235
+ nouns: {
236
+ total: number;
237
+ byType: Record<string, number>;
238
+ };
239
+ verbs: {
240
+ total: number;
241
+ byType: Record<string, number>;
242
+ };
243
+ storage: {
244
+ used: number;
245
+ type: string;
246
+ };
247
+ performance?: {
248
+ avgLatency: number;
249
+ throughput: number;
250
+ cacheHitRate?: number;
251
+ };
252
+ augmentations?: Record<string, any>;
253
+ memory?: {
254
+ used: number;
255
+ limit: number;
256
+ };
257
+ }
258
+ /**
259
+ * Structured error for API operations
260
+ */
261
+ export declare class BrainyAPIError extends Error {
262
+ code: string;
263
+ statusCode: number;
264
+ details?: any | undefined;
265
+ constructor(message: string, code: string, statusCode?: number, details?: any | undefined);
266
+ }
267
+ export declare const ErrorCodes: {
268
+ readonly INVALID_TYPE: "INVALID_TYPE";
269
+ readonly NOT_FOUND: "NOT_FOUND";
270
+ readonly DUPLICATE_ID: "DUPLICATE_ID";
271
+ readonly INVALID_VECTOR: "INVALID_VECTOR";
272
+ readonly STORAGE_ERROR: "STORAGE_ERROR";
273
+ readonly EMBEDDING_ERROR: "EMBEDDING_ERROR";
274
+ readonly AUGMENTATION_ERROR: "AUGMENTATION_ERROR";
275
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
276
+ readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
277
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
278
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Consistent API Types for Brainy
3
+ *
4
+ * These types provide a uniform interface for all public methods,
5
+ * using object parameters for consistency and extensibility.
6
+ */
7
+ // ============= ERRORS =============
8
+ /**
9
+ * Structured error for API operations
10
+ */
11
+ export class BrainyAPIError extends Error {
12
+ constructor(message, code, statusCode = 400, details) {
13
+ super(message);
14
+ this.code = code;
15
+ this.statusCode = statusCode;
16
+ this.details = details;
17
+ this.name = 'BrainyAPIError';
18
+ }
19
+ }
20
+ // Error codes
21
+ export const ErrorCodes = {
22
+ INVALID_TYPE: 'INVALID_TYPE',
23
+ NOT_FOUND: 'NOT_FOUND',
24
+ DUPLICATE_ID: 'DUPLICATE_ID',
25
+ INVALID_VECTOR: 'INVALID_VECTOR',
26
+ STORAGE_ERROR: 'STORAGE_ERROR',
27
+ EMBEDDING_ERROR: 'EMBEDDING_ERROR',
28
+ AUGMENTATION_ERROR: 'AUGMENTATION_ERROR',
29
+ VALIDATION_ERROR: 'VALIDATION_ERROR',
30
+ QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
31
+ UNAUTHORIZED: 'UNAUTHORIZED'
32
+ };
33
+ //# sourceMappingURL=apiTypes.js.map
@@ -0,0 +1,308 @@
1
+ /**
2
+ * 🧠 Brainy 3.0 Type Definitions
3
+ *
4
+ * Beautiful, consistent, type-safe interfaces for the future of neural databases
5
+ */
6
+ import { Vector } from '../coreTypes.js';
7
+ import { NounType, VerbType } from './graphTypes.js';
8
+ /**
9
+ * Entity representation (replaces GraphNoun)
10
+ */
11
+ export interface Entity<T = any> {
12
+ id: string;
13
+ vector: Vector;
14
+ type: NounType;
15
+ data?: any;
16
+ metadata?: T;
17
+ service?: string;
18
+ createdAt: number;
19
+ updatedAt?: number;
20
+ createdBy?: string;
21
+ }
22
+ /**
23
+ * Relation representation (replaces GraphVerb)
24
+ */
25
+ export interface Relation<T = any> {
26
+ id: string;
27
+ from: string;
28
+ to: string;
29
+ type: VerbType;
30
+ weight?: number;
31
+ metadata?: T;
32
+ service?: string;
33
+ createdAt: number;
34
+ updatedAt?: number;
35
+ }
36
+ /**
37
+ * Search result with similarity score
38
+ */
39
+ export interface Result<T = any> {
40
+ id: string;
41
+ score: number;
42
+ entity: Entity<T>;
43
+ explanation?: ScoreExplanation;
44
+ }
45
+ /**
46
+ * Score explanation for transparency
47
+ */
48
+ export interface ScoreExplanation {
49
+ vectorScore?: number;
50
+ metadataScore?: number;
51
+ graphScore?: number;
52
+ boosts?: Record<string, number>;
53
+ penalties?: Record<string, number>;
54
+ }
55
+ /**
56
+ * Parameters for adding entities
57
+ */
58
+ export interface AddParams<T = any> {
59
+ data: any | Vector;
60
+ type: NounType;
61
+ metadata?: T;
62
+ id?: string;
63
+ vector?: Vector;
64
+ service?: string;
65
+ }
66
+ /**
67
+ * Parameters for updating entities
68
+ */
69
+ export interface UpdateParams<T = any> {
70
+ id: string;
71
+ data?: any;
72
+ type?: NounType;
73
+ metadata?: Partial<T>;
74
+ merge?: boolean;
75
+ vector?: Vector;
76
+ }
77
+ /**
78
+ * Parameters for creating relationships
79
+ */
80
+ export interface RelateParams<T = any> {
81
+ from: string;
82
+ to: string;
83
+ type: VerbType;
84
+ weight?: number;
85
+ metadata?: T;
86
+ bidirectional?: boolean;
87
+ service?: string;
88
+ }
89
+ /**
90
+ * Parameters for updating relationships
91
+ */
92
+ export interface UpdateRelationParams<T = any> {
93
+ id: string;
94
+ weight?: number;
95
+ metadata?: Partial<T>;
96
+ merge?: boolean;
97
+ }
98
+ /**
99
+ * Unified find parameters - Triple Intelligence
100
+ */
101
+ export interface FindParams<T = any> {
102
+ query?: string;
103
+ vector?: Vector;
104
+ type?: NounType | NounType[];
105
+ where?: Partial<T>;
106
+ connected?: GraphConstraints;
107
+ near?: {
108
+ id: string;
109
+ threshold?: number;
110
+ };
111
+ limit?: number;
112
+ offset?: number;
113
+ cursor?: string;
114
+ mode?: SearchMode;
115
+ explain?: boolean;
116
+ includeRelations?: boolean;
117
+ service?: string;
118
+ fusion?: {
119
+ strategy?: 'adaptive' | 'weighted' | 'progressive';
120
+ weights?: {
121
+ vector?: number;
122
+ graph?: number;
123
+ field?: number;
124
+ };
125
+ };
126
+ writeOnly?: boolean;
127
+ }
128
+ /**
129
+ * Graph constraints for search
130
+ */
131
+ export interface GraphConstraints {
132
+ to?: string;
133
+ from?: string;
134
+ via?: VerbType | VerbType[];
135
+ type?: VerbType | VerbType[];
136
+ depth?: number;
137
+ direction?: 'in' | 'out' | 'both';
138
+ bidirectional?: boolean;
139
+ }
140
+ /**
141
+ * Search modes
142
+ */
143
+ export type SearchMode = 'auto' | 'vector' | 'metadata' | 'graph' | 'hybrid';
144
+ /**
145
+ * Parameters for similarity search
146
+ */
147
+ export interface SimilarParams<T = any> {
148
+ to: string | Entity<T> | Vector;
149
+ limit?: number;
150
+ threshold?: number;
151
+ type?: NounType | NounType[];
152
+ where?: Partial<T>;
153
+ service?: string;
154
+ }
155
+ /**
156
+ * Parameters for getting relationships
157
+ */
158
+ export interface GetRelationsParams {
159
+ from?: string;
160
+ to?: string;
161
+ type?: VerbType | VerbType[];
162
+ limit?: number;
163
+ offset?: number;
164
+ cursor?: string;
165
+ service?: string;
166
+ }
167
+ /**
168
+ * Batch add parameters
169
+ */
170
+ export interface AddManyParams<T = any> {
171
+ items: AddParams<T>[];
172
+ parallel?: boolean;
173
+ chunkSize?: number;
174
+ onProgress?: (done: number, total: number) => void;
175
+ continueOnError?: boolean;
176
+ }
177
+ /**
178
+ * Batch update parameters
179
+ */
180
+ export interface UpdateManyParams<T = any> {
181
+ items: UpdateParams<T>[];
182
+ parallel?: boolean;
183
+ chunkSize?: number;
184
+ onProgress?: (done: number, total: number) => void;
185
+ continueOnError?: boolean;
186
+ }
187
+ /**
188
+ * Batch delete parameters
189
+ */
190
+ export interface DeleteManyParams {
191
+ ids?: string[];
192
+ type?: NounType;
193
+ where?: any;
194
+ limit?: number;
195
+ onProgress?: (done: number, total: number) => void;
196
+ }
197
+ /**
198
+ * Batch relate parameters
199
+ */
200
+ export interface RelateManyParams<T = any> {
201
+ items: RelateParams<T>[];
202
+ parallel?: boolean;
203
+ chunkSize?: number;
204
+ onProgress?: (done: number, total: number) => void;
205
+ continueOnError?: boolean;
206
+ }
207
+ /**
208
+ * Batch result
209
+ */
210
+ export interface BatchResult<T = any> {
211
+ successful: T[];
212
+ failed: Array<{
213
+ item: any;
214
+ error: string;
215
+ }>;
216
+ total: number;
217
+ duration: number;
218
+ }
219
+ /**
220
+ * Graph traversal parameters
221
+ */
222
+ export interface TraverseParams {
223
+ from: string | string[];
224
+ direction?: 'out' | 'in' | 'both';
225
+ types?: VerbType[];
226
+ depth?: number;
227
+ strategy?: 'bfs' | 'dfs';
228
+ filter?: (entity: Entity, depth: number, path: string[]) => boolean;
229
+ limit?: number;
230
+ }
231
+ /**
232
+ * Aggregation parameters
233
+ */
234
+ export interface AggregateParams<T = any> {
235
+ query?: FindParams<T>;
236
+ groupBy: string | string[];
237
+ metrics: AggregateMetric[];
238
+ having?: any;
239
+ orderBy?: string;
240
+ limit?: number;
241
+ }
242
+ /**
243
+ * Aggregate metrics
244
+ */
245
+ export type AggregateMetric = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'stddev' | {
246
+ custom: string;
247
+ field: string;
248
+ };
249
+ /**
250
+ * Brainy configuration
251
+ */
252
+ export interface BrainyConfig {
253
+ storage?: {
254
+ type: 'memory' | 'filesystem' | 's3' | 'r2' | 'opfs';
255
+ options?: any;
256
+ };
257
+ model?: {
258
+ type: 'fast' | 'accurate' | 'balanced' | 'custom';
259
+ name?: string;
260
+ precision?: 'q8';
261
+ };
262
+ index?: {
263
+ m?: number;
264
+ efConstruction?: number;
265
+ efSearch?: number;
266
+ };
267
+ cache?: boolean | {
268
+ maxSize?: number;
269
+ ttl?: number;
270
+ };
271
+ augmentations?: Record<string, any>;
272
+ warmup?: boolean;
273
+ realtime?: boolean;
274
+ multiTenancy?: boolean;
275
+ telemetry?: boolean;
276
+ }
277
+ /**
278
+ * Neural similarity parameters
279
+ */
280
+ export interface NeuralSimilarityParams {
281
+ between?: [any, any];
282
+ items?: any[];
283
+ explain?: boolean;
284
+ }
285
+ /**
286
+ * Neural clustering parameters
287
+ */
288
+ export interface NeuralClusterParams {
289
+ items?: string[] | Entity[];
290
+ algorithm?: 'hierarchical' | 'kmeans' | 'dbscan' | 'spectral';
291
+ params?: {
292
+ k?: number;
293
+ threshold?: number;
294
+ epsilon?: number;
295
+ minPoints?: number;
296
+ };
297
+ visualize?: boolean;
298
+ }
299
+ /**
300
+ * Neural anomaly detection parameters
301
+ */
302
+ export interface NeuralAnomalyParams {
303
+ threshold?: number;
304
+ type?: NounType;
305
+ method?: 'isolation' | 'lof' | 'statistical' | 'autoencoder';
306
+ returnScores?: boolean;
307
+ }
308
+ export * from './graphTypes.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 🧠 Brainy 3.0 Type Definitions
3
+ *
4
+ * Beautiful, consistent, type-safe interfaces for the future of neural databases
5
+ */
6
+ // ============= Export all types =============
7
+ export * from './graphTypes.js'; // Re-export NounType, VerbType, etc.
8
+ //# sourceMappingURL=brainy.types.js.map
@@ -1,11 +1,11 @@
1
1
  /**
2
- * BrainyDataInterface
2
+ * BrainyInterface
3
3
  *
4
- * This interface defines the methods from BrainyData that are used by serverSearchAugmentations.ts.
4
+ * This interface defines the methods from Brainy that are used by serverSearchAugmentations.ts.
5
5
  * It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
6
6
  */
7
7
  import { Vector } from '../coreTypes.js';
8
- export interface BrainyDataInterface<T = unknown> {
8
+ export interface BrainyInterface<T = unknown> {
9
9
  /**
10
10
  * Initialize the database
11
11
  */
@@ -18,14 +18,11 @@ export interface BrainyDataInterface<T = unknown> {
18
18
  /**
19
19
  * Add a noun (entity with vector and metadata) to the database
20
20
  * @param data Text string or vector representation (will auto-embed strings)
21
+ * @param nounType Required noun type (one of 31 types)
21
22
  * @param metadata Optional metadata to associate with the noun
22
- * @param options Optional configuration including custom ID
23
23
  * @returns The ID of the added noun
24
24
  */
25
- addNoun(data: string | Vector, metadata?: T, options?: {
26
- id?: string;
27
- [key: string]: any;
28
- }): Promise<string>;
25
+ addNoun(data: string | Vector, nounType: string, metadata?: T): Promise<string>;
29
26
  /**
30
27
  * Search for text in the database
31
28
  * @param text The text to search for
@@ -1,7 +1,7 @@
1
1
  /**
2
- * BrainyDataInterface
2
+ * BrainyInterface
3
3
  *
4
- * This interface defines the methods from BrainyData that are used by serverSearchAugmentations.ts.
4
+ * This interface defines the methods from Brainy that are used by serverSearchAugmentations.ts.
5
5
  * It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
6
6
  */
7
7
  export {};
@@ -169,7 +169,7 @@ export const NounType = {
169
169
  Person: 'person', // Human entities
170
170
  Organization: 'organization', // Formal organizations (companies, institutions, etc.)
171
171
  Location: 'location', // Geographic locations (merges previous Place and Location)
172
- Thing: 'thing', // Physical objects
172
+ Thing: 'thing', // Physical objects (generic items/entities should use this)
173
173
  Concept: 'concept', // Abstract ideas, concepts, and intangible entities
174
174
  Event: 'event', // Occurrences with time and place
175
175
  // Digital/Content Types
@@ -181,7 +181,7 @@ export const NounType = {
181
181
  // Collection Types
182
182
  Collection: 'collection', // Generic grouping of items (merges Group, List, and Category)
183
183
  Dataset: 'dataset', // Structured collections of data
184
- // Business/Application Types
184
+ // Business/Application Types
185
185
  Product: 'product', // Commercial products and offerings
186
186
  Service: 'service', // Services and offerings
187
187
  User: 'user', // User accounts and profiles