@soulcraft/brainy 3.20.2 → 3.20.3

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 (89) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/bin/brainy-interactive.js +2 -2
  3. package/dist/brainy.d.ts +1 -1
  4. package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
  5. package/dist/mcp/brainyMCPService.d.ts +1 -1
  6. package/dist/neural/embeddedPatterns.d.ts +1 -1
  7. package/dist/neural/embeddedPatterns.js +1 -1
  8. package/dist/shared/default-augmentations.d.ts +1 -1
  9. package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
  10. package/package.json +1 -1
  11. package/dist/augmentationFactory.d.ts +0 -86
  12. package/dist/augmentationFactory.js +0 -342
  13. package/dist/augmentationRegistry.d.ts +0 -38
  14. package/dist/augmentationRegistry.js +0 -54
  15. package/dist/augmentationRegistryLoader.d.ts +0 -146
  16. package/dist/augmentationRegistryLoader.js +0 -213
  17. package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
  18. package/dist/augmentations/KnowledgeAugmentation.js +0 -251
  19. package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
  20. package/dist/augmentations/intelligentVerbScoring.js +0 -377
  21. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
  22. package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
  23. package/dist/augmentations/marketplace/cli.d.ts +0 -47
  24. package/dist/augmentations/marketplace/cli.js +0 -265
  25. package/dist/augmentations/memoryAugmentations.d.ts +0 -72
  26. package/dist/augmentations/memoryAugmentations.js +0 -280
  27. package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
  28. package/dist/augmentations/serverSearchAugmentations.js +0 -586
  29. package/dist/brainy-unified.d.ts +0 -106
  30. package/dist/brainy-unified.js +0 -327
  31. package/dist/brainyData.d.ts +0 -1832
  32. package/dist/brainyData.js +0 -6443
  33. package/dist/brainyDataV3.d.ts +0 -186
  34. package/dist/brainyDataV3.js +0 -337
  35. package/dist/config/distributedPresets-new.d.ts +0 -118
  36. package/dist/config/distributedPresets-new.js +0 -318
  37. package/dist/config/modelPrecisionManager.d.ts +0 -42
  38. package/dist/config/modelPrecisionManager.js +0 -98
  39. package/dist/connectors/interfaces/IConnector.d.ts +0 -143
  40. package/dist/connectors/interfaces/IConnector.js +0 -8
  41. package/dist/demo.d.ts +0 -106
  42. package/dist/demo.js +0 -201
  43. package/dist/embeddings/SingletonModelManager.d.ts +0 -95
  44. package/dist/embeddings/SingletonModelManager.js +0 -220
  45. package/dist/embeddings/lightweight-embedder.d.ts +0 -22
  46. package/dist/embeddings/lightweight-embedder.js +0 -128
  47. package/dist/embeddings/model-manager.d.ts +0 -39
  48. package/dist/embeddings/model-manager.js +0 -245
  49. package/dist/embeddings/universal-memory-manager.d.ts +0 -38
  50. package/dist/embeddings/universal-memory-manager.js +0 -166
  51. package/dist/embeddings/worker-embedding.d.ts +0 -7
  52. package/dist/embeddings/worker-embedding.js +0 -73
  53. package/dist/embeddings/worker-manager.d.ts +0 -28
  54. package/dist/embeddings/worker-manager.js +0 -162
  55. package/dist/examples/basicUsage.d.ts +0 -4
  56. package/dist/examples/basicUsage.js +0 -121
  57. package/dist/indices/fieldIndex.d.ts +0 -76
  58. package/dist/indices/fieldIndex.js +0 -357
  59. package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
  60. package/dist/mcp/brainyMCPBroadcast.js +0 -303
  61. package/dist/mcp/brainyMCPClient.d.ts +0 -92
  62. package/dist/mcp/brainyMCPClient.js +0 -258
  63. package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
  64. package/dist/scripts/precomputePatternEmbeddings.js +0 -100
  65. package/dist/utils/cacheAutoConfig.d.ts +0 -63
  66. package/dist/utils/cacheAutoConfig.js +0 -261
  67. package/dist/utils/hybridModelManager.d.ts +0 -64
  68. package/dist/utils/hybridModelManager.js +0 -95
  69. package/dist/utils/statistics.d.ts +0 -28
  70. package/dist/utils/statistics.js +0 -25
  71. package/dist/vfs/ConceptSystem.d.ts +0 -203
  72. package/dist/vfs/ConceptSystem.js +0 -545
  73. package/dist/vfs/EntityManager.d.ts +0 -75
  74. package/dist/vfs/EntityManager.js +0 -216
  75. package/dist/vfs/EventRecorder.d.ts +0 -84
  76. package/dist/vfs/EventRecorder.js +0 -269
  77. package/dist/vfs/GitBridge.d.ts +0 -167
  78. package/dist/vfs/GitBridge.js +0 -537
  79. package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
  80. package/dist/vfs/KnowledgeAugmentation.js +0 -146
  81. package/dist/vfs/KnowledgeLayer.d.ts +0 -35
  82. package/dist/vfs/KnowledgeLayer.js +0 -443
  83. package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
  84. package/dist/vfs/PersistentEntitySystem.js +0 -503
  85. package/dist/vfs/SemanticVersioning.d.ts +0 -105
  86. package/dist/vfs/SemanticVersioning.js +0 -309
  87. package/dist/vfs/VFSHealthCheck.d.ts +0 -78
  88. package/dist/vfs/VFSHealthCheck.js +0 -299
  89. /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
@@ -1,586 +0,0 @@
1
- /**
2
- * Server Search Augmentations
3
- *
4
- * This file implements conduit and activation augmentations for browser-server search functionality.
5
- * It allows Brainy to search a server-hosted instance and store results locally.
6
- */
7
- import { BaseAugmentation } from '../augmentations/brainyAugmentation.js';
8
- /**
9
- * ServerSearchConduitAugmentation
10
- *
11
- * A specialized conduit augmentation that provides functionality for searching
12
- * a server-hosted Brainy instance and storing results locally.
13
- */
14
- export class ServerSearchConduitAugmentation extends BaseAugmentation {
15
- constructor(name) {
16
- super();
17
- this.name = 'server-search-conduit';
18
- this.timing = 'after';
19
- this.metadata = 'readonly'; // Reads metadata to sync with server
20
- this.operations = ['addNoun', 'delete', 'addVerb'];
21
- this.priority = 20;
22
- this.localDb = null;
23
- if (name) {
24
- // Override name if provided (though it's readonly, this won't work)
25
- // Keep constructor parameter for API compatibility but ignore it
26
- }
27
- }
28
- /**
29
- * Initialize the augmentation
30
- */
31
- async onInitialize() {
32
- // Local DB must be set before initialization
33
- if (!this.localDb) {
34
- this.log('Local database not set. Call setLocalDb before using server search.', 'warn');
35
- return;
36
- }
37
- this.log('Server search conduit initialized');
38
- }
39
- /**
40
- * Set the local Brainy instance
41
- * @param db The Brainy instance to use for local storage
42
- */
43
- setLocalDb(db) {
44
- this.localDb = db;
45
- }
46
- /**
47
- * Stub method for performing search operations via WebSocket
48
- * TODO: Implement proper WebSocket communication
49
- */
50
- async performSearch(params) {
51
- this.log('Search operation not yet implemented - returning empty results', 'warn');
52
- return {
53
- success: true,
54
- data: []
55
- };
56
- }
57
- /**
58
- * Stub method for performing write operations via WebSocket
59
- * TODO: Implement proper WebSocket communication
60
- */
61
- async performWrite(params) {
62
- this.log('Write operation not yet implemented', 'warn');
63
- return {
64
- success: false,
65
- data: null,
66
- error: 'Write operation not implemented'
67
- };
68
- }
69
- /**
70
- * Get the local Brainy instance
71
- * @returns The local Brainy instance
72
- */
73
- getLocalDb() {
74
- return this.localDb;
75
- }
76
- /**
77
- * Execute method - required by BaseAugmentation
78
- */
79
- async execute(operation, params, next) {
80
- // Just pass through for now - server search operations are handled by the activation augmentation
81
- return next();
82
- }
83
- /**
84
- * Search the server-hosted Brainy instance and store results locally
85
- * @param connectionId The ID of the established connection
86
- * @param query The search query
87
- * @param limit Maximum number of results to return
88
- * @returns Search results
89
- */
90
- async searchServer(connectionId, query, limit = 10) {
91
- if (!this.isInitialized) {
92
- throw new Error('ServerSearchConduitAugmentation not initialized');
93
- }
94
- try {
95
- // Create a search request (TODO: Implement proper WebSocket communication)
96
- const readResult = await this.performSearch({
97
- connectionId,
98
- query: {
99
- type: 'search',
100
- query,
101
- limit
102
- }
103
- });
104
- if (readResult.success && readResult.data) {
105
- const searchResults = readResult.data;
106
- // Store the results in the local Brainy instance
107
- if (this.localDb) {
108
- for (const result of searchResults) {
109
- // Check if the noun already exists in the local database
110
- const existingNoun = await this.localDb.getNoun(result.id);
111
- if (!existingNoun) {
112
- // Add the noun to the local database
113
- await this.localDb.addNoun(result.vector, result.metadata);
114
- }
115
- }
116
- }
117
- return {
118
- success: true,
119
- data: searchResults
120
- };
121
- }
122
- else {
123
- return {
124
- success: false,
125
- data: null,
126
- error: readResult.error || 'Unknown error searching server'
127
- };
128
- }
129
- }
130
- catch (error) {
131
- console.error('Error searching server:', error);
132
- return {
133
- success: false,
134
- data: null,
135
- error: `Error searching server: ${error}`
136
- };
137
- }
138
- }
139
- /**
140
- * Search the local Brainy instance
141
- * @param query The search query
142
- * @param limit Maximum number of results to return
143
- * @returns Search results
144
- */
145
- async searchLocal(query, limit = 10) {
146
- if (!this.isInitialized) {
147
- throw new Error('ServerSearchConduitAugmentation not initialized');
148
- }
149
- try {
150
- if (!this.localDb) {
151
- return {
152
- success: false,
153
- data: null,
154
- error: 'Local database not initialized'
155
- };
156
- }
157
- const results = await this.localDb.searchText(query, limit);
158
- return {
159
- success: true,
160
- data: results
161
- };
162
- }
163
- catch (error) {
164
- console.error('Error searching local database:', error);
165
- return {
166
- success: false,
167
- data: null,
168
- error: `Error searching local database: ${error}`
169
- };
170
- }
171
- }
172
- /**
173
- * Search both server and local instances, combine results, and store server results locally
174
- * @param connectionId The ID of the established connection
175
- * @param query The search query
176
- * @param limit Maximum number of results to return
177
- * @returns Combined search results
178
- */
179
- async searchCombined(connectionId, query, limit = 10) {
180
- if (!this.isInitialized) {
181
- throw new Error('ServerSearchConduitAugmentation not initialized');
182
- }
183
- try {
184
- // Search local first
185
- const localSearchResult = await this.searchLocal(query, limit);
186
- if (!localSearchResult.success) {
187
- return localSearchResult;
188
- }
189
- const localResults = localSearchResult.data;
190
- // If we have enough local results, return them
191
- if (localResults.length >= limit) {
192
- return localSearchResult;
193
- }
194
- // Otherwise, search server for additional results
195
- const serverSearchResult = await this.searchServer(connectionId, query, limit - localResults.length);
196
- if (!serverSearchResult.success) {
197
- // If server search fails, return local results
198
- return localSearchResult;
199
- }
200
- const serverResults = serverSearchResult.data;
201
- // Combine results, removing duplicates
202
- const combinedResults = [...localResults];
203
- const localIds = new Set(localResults.map((r) => r.id));
204
- for (const result of serverResults) {
205
- if (!localIds.has(result.id)) {
206
- combinedResults.push(result);
207
- }
208
- }
209
- return {
210
- success: true,
211
- data: combinedResults
212
- };
213
- }
214
- catch (error) {
215
- console.error('Error performing combined search:', error);
216
- return {
217
- success: false,
218
- data: null,
219
- error: `Error performing combined search: ${error}`
220
- };
221
- }
222
- }
223
- /**
224
- * Add data to both local and server instances
225
- * @param connectionId The ID of the established connection
226
- * @param data Text or vector to add
227
- * @param metadata Metadata for the data
228
- * @returns ID of the added data
229
- */
230
- async addToBoth(connectionId, data, metadata = {}) {
231
- if (!this.isInitialized) {
232
- throw new Error('ServerSearchConduitAugmentation not initialized');
233
- }
234
- try {
235
- if (!this.localDb) {
236
- return {
237
- success: false,
238
- data: '',
239
- error: 'Local database not initialized'
240
- };
241
- }
242
- // Add to local first - addNoun handles both strings and vectors automatically
243
- const id = await this.localDb.addNoun(data, metadata);
244
- // Get the vector and metadata
245
- const noun = (await this.localDb.getNoun(id));
246
- if (!noun) {
247
- return {
248
- success: false,
249
- data: '',
250
- error: 'Failed to retrieve newly created noun'
251
- };
252
- }
253
- // Add to server (TODO: Implement proper WebSocket communication)
254
- const writeResult = await this.performWrite({
255
- connectionId,
256
- data: {
257
- type: 'addNoun',
258
- vector: noun.vector,
259
- metadata: noun.metadata
260
- }
261
- });
262
- if (!writeResult.success) {
263
- return {
264
- success: true,
265
- data: id,
266
- error: `Added locally but failed to add to server: ${writeResult.error}`
267
- };
268
- }
269
- return {
270
- success: true,
271
- data: id
272
- };
273
- }
274
- catch (error) {
275
- console.error('Error adding data to both:', error);
276
- return {
277
- success: false,
278
- data: '',
279
- error: `Error adding data to both: ${error}`
280
- };
281
- }
282
- }
283
- /**
284
- * Establish connection to remote server
285
- * @param serverUrl Server URL to connect to
286
- * @param options Connection options
287
- * @returns Connection promise
288
- */
289
- establishConnection(serverUrl, options) {
290
- // Stub implementation - remote connection functionality not yet fully implemented in 2.0
291
- console.warn('establishConnection: Remote server connections not yet fully implemented in Brainy 2.0');
292
- return Promise.resolve({ connected: false, reason: 'Not implemented' });
293
- }
294
- /**
295
- * Close WebSocket connection
296
- * @param connectionId Connection ID to close
297
- * @returns Promise that resolves when connection is closed
298
- */
299
- async closeWebSocket(connectionId) {
300
- // Stub implementation - WebSocket functionality not yet fully implemented in 2.0
301
- console.warn(`closeWebSocket: WebSocket functionality not yet fully implemented in Brainy 2.0 (connectionId: ${connectionId})`);
302
- }
303
- }
304
- /**
305
- * ServerSearchActivationAugmentation
306
- *
307
- * An activation augmentation that provides actions for server search functionality.
308
- */
309
- export class ServerSearchActivationAugmentation extends BaseAugmentation {
310
- constructor(name) {
311
- super();
312
- this.name = 'server-search-activation';
313
- this.timing = 'after';
314
- this.metadata = 'readonly'; // Reads metadata for server activation
315
- this.operations = ['search', 'addNoun'];
316
- this.priority = 20;
317
- this.conduitAugmentation = null;
318
- this.connections = new Map();
319
- if (name) {
320
- // Keep constructor parameter for API compatibility but ignore it
321
- }
322
- }
323
- async onInitialize() {
324
- // Initialization logic if needed
325
- }
326
- async onShutdown() {
327
- // Cleanup connections
328
- this.connections.clear();
329
- }
330
- async execute(operation, params, next) {
331
- // Execute the operation first
332
- const result = await next();
333
- // Handle server search operations
334
- if (operation === 'search' && this.conduitAugmentation) {
335
- // Trigger server search when local search happens
336
- const connectionId = this.connections.keys().next().value;
337
- if (connectionId && params.query) {
338
- await this.conduitAugmentation.searchServer(connectionId, params.query, params.limit || 10);
339
- }
340
- }
341
- return result;
342
- }
343
- /**
344
- * Set the conduit augmentation to use for server search
345
- * @param conduit The ServerSearchConduitAugmentation to use
346
- */
347
- setConduitAugmentation(conduit) {
348
- this.conduitAugmentation = conduit;
349
- }
350
- /**
351
- * Store a connection for later use
352
- * @param connectionId The ID to use for the connection
353
- * @param connection The WebSocket connection
354
- */
355
- storeConnection(connectionId, connection) {
356
- this.connections.set(connectionId, connection);
357
- }
358
- /**
359
- * Get a stored connection
360
- * @param connectionId The ID of the connection to retrieve
361
- * @returns The WebSocket connection
362
- */
363
- getConnection(connectionId) {
364
- return this.connections.get(connectionId);
365
- }
366
- /**
367
- * Trigger an action based on a processed command or internal state
368
- * @param actionName The name of the action to trigger
369
- * @param parameters Optional parameters for the action
370
- */
371
- triggerAction(actionName, parameters) {
372
- if (!this.conduitAugmentation) {
373
- return {
374
- success: false,
375
- data: null,
376
- error: 'Conduit augmentation not set'
377
- };
378
- }
379
- // Handle different actions
380
- switch (actionName) {
381
- case 'connectToServer':
382
- return this.handleConnectToServer(parameters || {});
383
- case 'searchServer':
384
- return this.handleSearchServer(parameters || {});
385
- case 'searchLocal':
386
- return this.handleSearchLocal(parameters || {});
387
- case 'searchCombined':
388
- return this.handleSearchCombined(parameters || {});
389
- case 'addToBoth':
390
- return this.handleAddToBoth(parameters || {});
391
- default:
392
- return {
393
- success: false,
394
- data: null,
395
- error: `Unknown action: ${actionName}`
396
- };
397
- }
398
- }
399
- /**
400
- * Handle the connectToServer action
401
- * @param parameters Action parameters
402
- */
403
- handleConnectToServer(parameters) {
404
- const serverUrl = parameters.serverUrl;
405
- const protocols = parameters.protocols;
406
- if (!serverUrl) {
407
- return {
408
- success: false,
409
- data: null,
410
- error: 'serverUrl parameter is required'
411
- };
412
- }
413
- // Return a promise that will be resolved when the connection is established
414
- return {
415
- success: true,
416
- data: this.conduitAugmentation.establishConnection(serverUrl, {
417
- protocols
418
- })
419
- };
420
- }
421
- /**
422
- * Handle the searchServer action
423
- * @param parameters Action parameters
424
- */
425
- handleSearchServer(parameters) {
426
- const connectionId = parameters.connectionId;
427
- const query = parameters.query;
428
- const limit = parameters.limit || 10;
429
- if (!connectionId) {
430
- return {
431
- success: false,
432
- data: null,
433
- error: 'connectionId parameter is required'
434
- };
435
- }
436
- if (!query) {
437
- return {
438
- success: false,
439
- data: null,
440
- error: 'query parameter is required'
441
- };
442
- }
443
- // Return a promise that will be resolved when the search is complete
444
- return {
445
- success: true,
446
- data: this.conduitAugmentation.searchServer(connectionId, query, limit)
447
- };
448
- }
449
- /**
450
- * Handle the searchLocal action
451
- * @param parameters Action parameters
452
- */
453
- handleSearchLocal(parameters) {
454
- const query = parameters.query;
455
- const limit = parameters.limit || 10;
456
- if (!query) {
457
- return {
458
- success: false,
459
- data: null,
460
- error: 'query parameter is required'
461
- };
462
- }
463
- // Return a promise that will be resolved when the search is complete
464
- return {
465
- success: true,
466
- data: this.conduitAugmentation.searchLocal(query, limit)
467
- };
468
- }
469
- /**
470
- * Handle the searchCombined action
471
- * @param parameters Action parameters
472
- */
473
- handleSearchCombined(parameters) {
474
- const connectionId = parameters.connectionId;
475
- const query = parameters.query;
476
- const limit = parameters.limit || 10;
477
- if (!connectionId) {
478
- return {
479
- success: false,
480
- data: null,
481
- error: 'connectionId parameter is required'
482
- };
483
- }
484
- if (!query) {
485
- return {
486
- success: false,
487
- data: null,
488
- error: 'query parameter is required'
489
- };
490
- }
491
- // Return a promise that will be resolved when the search is complete
492
- return {
493
- success: true,
494
- data: this.conduitAugmentation.searchCombined(connectionId, query, limit)
495
- };
496
- }
497
- /**
498
- * Handle the addToBoth action
499
- * @param parameters Action parameters
500
- */
501
- handleAddToBoth(parameters) {
502
- const connectionId = parameters.connectionId;
503
- const data = parameters.data;
504
- const metadata = parameters.metadata || {};
505
- if (!connectionId) {
506
- return {
507
- success: false,
508
- data: null,
509
- error: 'connectionId parameter is required'
510
- };
511
- }
512
- if (!data) {
513
- return {
514
- success: false,
515
- data: null,
516
- error: 'data parameter is required'
517
- };
518
- }
519
- // Return a promise that will be resolved when the add is complete
520
- return {
521
- success: true,
522
- data: this.conduitAugmentation.addToBoth(connectionId, data, metadata)
523
- };
524
- }
525
- /**
526
- * Generates an expressive output or response from Brainy
527
- * @param knowledgeId The identifier of the knowledge to express
528
- * @param format The desired output format (e.g., 'text', 'json')
529
- */
530
- generateOutput(knowledgeId, format) {
531
- // This method is not used for server search functionality
532
- return {
533
- success: false,
534
- data: '',
535
- error: 'generateOutput is not implemented for ServerSearchActivationAugmentation'
536
- };
537
- }
538
- /**
539
- * Interacts with an external system or API
540
- * @param systemId The identifier of the external system
541
- * @param payload The data to send to the external system
542
- */
543
- interactExternal(systemId, payload) {
544
- // This method is not used for server search functionality
545
- return {
546
- success: false,
547
- data: null,
548
- error: 'interactExternal is not implemented for ServerSearchActivationAugmentation'
549
- };
550
- }
551
- }
552
- /**
553
- * Factory function to create server search augmentations
554
- * @param serverUrl The URL of the server to connect to
555
- * @param options Additional options
556
- * @returns An object containing the created augmentations
557
- */
558
- export async function createServerSearchAugmentations(serverUrl, options = {}) {
559
- // Create the conduit augmentation
560
- const conduit = new ServerSearchConduitAugmentation(options.conduitName);
561
- // Set the local database if provided
562
- if (options.localDb) {
563
- conduit.setLocalDb(options.localDb);
564
- }
565
- // Create the activation augmentation
566
- const activation = new ServerSearchActivationAugmentation(options.activationName);
567
- // Note: Augmentations will be initialized when added to BrainyData
568
- // Link the augmentations
569
- activation.setConduitAugmentation(conduit);
570
- // TODO: Connect to the server (stub implementation for now)
571
- const connection = {
572
- connectionId: `stub-connection-${Date.now()}`,
573
- url: serverUrl,
574
- status: 'connected',
575
- close: async () => { },
576
- send: async (data) => { }
577
- };
578
- // Store the connection in the activation augmentation
579
- activation.storeConnection(connection.connectionId, connection);
580
- return {
581
- conduit,
582
- activation,
583
- connection
584
- };
585
- }
586
- //# sourceMappingURL=serverSearchAugmentations.js.map
@@ -1,106 +0,0 @@
1
- /**
2
- * 🧠 Brainy 3.0 - UNIFIED FIND IMPLEMENTATION
3
- *
4
- * REAL CODE - NO MOCKS - NO STUBS - PRODUCTION READY
5
- * O(log n) performance with Triple Intelligence
6
- */
7
- import { Vector } from './coreTypes.js';
8
- /**
9
- * Core types
10
- */
11
- export interface Entity<T = any> {
12
- id: string;
13
- data: T;
14
- vector?: Vector;
15
- metadata?: Record<string, any>;
16
- type?: string;
17
- service?: string;
18
- }
19
- export interface Result<T = any> {
20
- id: string;
21
- score: number;
22
- entity: Entity<T>;
23
- }
24
- export interface FindParams<T = any> {
25
- id?: string;
26
- ids?: string[];
27
- query?: string;
28
- vector?: Vector;
29
- near?: {
30
- id?: string;
31
- vector?: Vector;
32
- threshold?: number;
33
- limit?: number;
34
- };
35
- where?: Record<string, any>;
36
- type?: string | string[];
37
- service?: string;
38
- connected?: {
39
- from: string;
40
- to?: string;
41
- type?: string;
42
- direction?: 'in' | 'out' | 'both';
43
- maxDepth?: number;
44
- };
45
- limit?: number;
46
- offset?: number;
47
- }
48
- /**
49
- * UNIFIED BRAINY CLASS - REAL IMPLEMENTATION
50
- */
51
- export declare class Brainy<T = any> {
52
- private index;
53
- private storage;
54
- private embedder;
55
- private initialized;
56
- constructor(config?: any);
57
- /**
58
- * Initialize Brainy
59
- */
60
- init(): Promise<void>;
61
- /**
62
- * Add entity
63
- */
64
- add(params: {
65
- data: T;
66
- metadata?: any;
67
- type?: string;
68
- }): Promise<string>;
69
- /**
70
- * Get entity by ID
71
- */
72
- get(id: string): Promise<Entity<T> | null>;
73
- /**
74
- * UNIFIED FIND - Real Triple Intelligence Implementation
75
- * O(log n) performance with Reciprocal Rank Fusion
76
- */
77
- find(params: string | FindParams<T>): Promise<Result<T>[]>;
78
- /**
79
- * Search method for NLP compatibility
80
- */
81
- search(query: string | any, limit?: number, options?: any): Promise<Result<T>[]>;
82
- /**
83
- * Parse natural language query
84
- */
85
- private parseNaturalLanguage;
86
- /**
87
- * Vector Search - O(log n) via HNSW
88
- */
89
- private vectorSearch;
90
- /**
91
- * Metadata Search - O(n) for now, but could be indexed
92
- */
93
- private metadataSearch;
94
- /**
95
- * Graph Traversal - O(k) where k = edges traversed
96
- */
97
- private graphTraversal;
98
- /**
99
- * Reciprocal Rank Fusion - Google's algorithm
100
- */
101
- private reciprocalRankFusion;
102
- /**
103
- * Ensure initialized
104
- */
105
- private ensureInitialized;
106
- }