@soulcraft/brainy 1.4.0 → 2.0.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 (141) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/LICENSE +2 -2
  3. package/README.md +201 -596
  4. package/bin/brainy-interactive.js +564 -0
  5. package/bin/brainy-ts.js +18 -0
  6. package/bin/brainy.js +672 -81
  7. package/dist/augmentationPipeline.d.ts +48 -220
  8. package/dist/augmentationPipeline.js +60 -508
  9. package/dist/augmentationRegistry.d.ts +22 -31
  10. package/dist/augmentationRegistry.js +28 -79
  11. package/dist/augmentations/apiServerAugmentation.d.ts +108 -0
  12. package/dist/augmentations/apiServerAugmentation.js +502 -0
  13. package/dist/augmentations/batchProcessingAugmentation.d.ts +95 -0
  14. package/dist/augmentations/batchProcessingAugmentation.js +567 -0
  15. package/dist/augmentations/brainyAugmentation.d.ts +153 -0
  16. package/dist/augmentations/brainyAugmentation.js +145 -0
  17. package/dist/augmentations/cacheAugmentation.d.ts +105 -0
  18. package/dist/augmentations/cacheAugmentation.js +238 -0
  19. package/dist/augmentations/conduitAugmentations.d.ts +54 -156
  20. package/dist/augmentations/conduitAugmentations.js +156 -1082
  21. package/dist/augmentations/connectionPoolAugmentation.d.ts +62 -0
  22. package/dist/augmentations/connectionPoolAugmentation.js +316 -0
  23. package/dist/augmentations/defaultAugmentations.d.ts +53 -0
  24. package/dist/augmentations/defaultAugmentations.js +88 -0
  25. package/dist/augmentations/entityRegistryAugmentation.d.ts +126 -0
  26. package/dist/augmentations/entityRegistryAugmentation.js +386 -0
  27. package/dist/augmentations/indexAugmentation.d.ts +117 -0
  28. package/dist/augmentations/indexAugmentation.js +284 -0
  29. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +152 -0
  30. package/dist/augmentations/intelligentVerbScoringAugmentation.js +554 -0
  31. package/dist/augmentations/metricsAugmentation.d.ts +202 -0
  32. package/dist/augmentations/metricsAugmentation.js +291 -0
  33. package/dist/augmentations/monitoringAugmentation.d.ts +94 -0
  34. package/dist/augmentations/monitoringAugmentation.js +227 -0
  35. package/dist/augmentations/neuralImport.d.ts +50 -117
  36. package/dist/augmentations/neuralImport.js +255 -629
  37. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +52 -0
  38. package/dist/augmentations/requestDeduplicatorAugmentation.js +162 -0
  39. package/dist/augmentations/serverSearchAugmentations.d.ts +43 -22
  40. package/dist/augmentations/serverSearchAugmentations.js +125 -72
  41. package/dist/augmentations/storageAugmentation.d.ts +54 -0
  42. package/dist/augmentations/storageAugmentation.js +93 -0
  43. package/dist/augmentations/storageAugmentations.d.ts +96 -0
  44. package/dist/augmentations/storageAugmentations.js +182 -0
  45. package/dist/augmentations/synapseAugmentation.d.ts +156 -0
  46. package/dist/augmentations/synapseAugmentation.js +312 -0
  47. package/dist/augmentations/walAugmentation.d.ts +108 -0
  48. package/dist/augmentations/walAugmentation.js +515 -0
  49. package/dist/brainyData.d.ts +404 -130
  50. package/dist/brainyData.js +1336 -855
  51. package/dist/chat/BrainyChat.d.ts +16 -8
  52. package/dist/chat/BrainyChat.js +60 -32
  53. package/dist/chat/ChatCLI.d.ts +1 -1
  54. package/dist/chat/ChatCLI.js +6 -6
  55. package/dist/cli/catalog.d.ts +3 -3
  56. package/dist/cli/catalog.js +116 -70
  57. package/dist/cli/commands/core.d.ts +61 -0
  58. package/dist/cli/commands/core.js +348 -0
  59. package/dist/cli/commands/neural.d.ts +25 -0
  60. package/dist/cli/commands/neural.js +508 -0
  61. package/dist/cli/commands/utility.d.ts +37 -0
  62. package/dist/cli/commands/utility.js +276 -0
  63. package/dist/cli/index.d.ts +7 -0
  64. package/dist/cli/index.js +167 -0
  65. package/dist/cli/interactive.d.ts +164 -0
  66. package/dist/cli/interactive.js +542 -0
  67. package/dist/cortex/neuralImport.js +5 -5
  68. package/dist/critical/model-guardian.js +11 -4
  69. package/dist/embeddings/lightweight-embedder.d.ts +23 -0
  70. package/dist/embeddings/lightweight-embedder.js +136 -0
  71. package/dist/embeddings/universal-memory-manager.d.ts +38 -0
  72. package/dist/embeddings/universal-memory-manager.js +206 -0
  73. package/dist/embeddings/worker-embedding.d.ts +7 -0
  74. package/dist/embeddings/worker-embedding.js +77 -0
  75. package/dist/embeddings/worker-manager.d.ts +28 -0
  76. package/dist/embeddings/worker-manager.js +162 -0
  77. package/dist/examples/basicUsage.js +7 -7
  78. package/dist/graph/pathfinding.d.ts +78 -0
  79. package/dist/graph/pathfinding.js +393 -0
  80. package/dist/hnsw/hnswIndex.d.ts +13 -0
  81. package/dist/hnsw/hnswIndex.js +35 -0
  82. package/dist/hnsw/hnswIndexOptimized.d.ts +1 -0
  83. package/dist/hnsw/hnswIndexOptimized.js +3 -0
  84. package/dist/index.d.ts +9 -11
  85. package/dist/index.js +21 -11
  86. package/dist/indices/fieldIndex.d.ts +76 -0
  87. package/dist/indices/fieldIndex.js +357 -0
  88. package/dist/mcp/brainyMCPAdapter.js +3 -2
  89. package/dist/mcp/mcpAugmentationToolset.js +11 -17
  90. package/dist/neural/embeddedPatterns.d.ts +41 -0
  91. package/dist/neural/embeddedPatterns.js +4044 -0
  92. package/dist/neural/naturalLanguageProcessor.d.ts +94 -0
  93. package/dist/neural/naturalLanguageProcessor.js +317 -0
  94. package/dist/neural/naturalLanguageProcessorStatic.d.ts +64 -0
  95. package/dist/neural/naturalLanguageProcessorStatic.js +151 -0
  96. package/dist/neural/neuralAPI.d.ts +255 -0
  97. package/dist/neural/neuralAPI.js +612 -0
  98. package/dist/neural/patternLibrary.d.ts +101 -0
  99. package/dist/neural/patternLibrary.js +313 -0
  100. package/dist/neural/patterns.d.ts +27 -0
  101. package/dist/neural/patterns.js +68 -0
  102. package/dist/neural/staticPatternMatcher.d.ts +35 -0
  103. package/dist/neural/staticPatternMatcher.js +153 -0
  104. package/dist/scripts/precomputePatternEmbeddings.d.ts +19 -0
  105. package/dist/scripts/precomputePatternEmbeddings.js +100 -0
  106. package/dist/storage/adapters/fileSystemStorage.d.ts +5 -0
  107. package/dist/storage/adapters/fileSystemStorage.js +20 -0
  108. package/dist/storage/adapters/s3CompatibleStorage.d.ts +5 -0
  109. package/dist/storage/adapters/s3CompatibleStorage.js +16 -0
  110. package/dist/storage/enhancedClearOperations.d.ts +83 -0
  111. package/dist/storage/enhancedClearOperations.js +345 -0
  112. package/dist/storage/storageFactory.js +31 -27
  113. package/dist/triple/TripleIntelligence.d.ts +134 -0
  114. package/dist/triple/TripleIntelligence.js +548 -0
  115. package/dist/types/augmentations.d.ts +45 -344
  116. package/dist/types/augmentations.js +5 -2
  117. package/dist/types/brainyDataInterface.d.ts +20 -10
  118. package/dist/types/graphTypes.d.ts +46 -0
  119. package/dist/types/graphTypes.js +16 -2
  120. package/dist/utils/BoundedRegistry.d.ts +29 -0
  121. package/dist/utils/BoundedRegistry.js +54 -0
  122. package/dist/utils/embedding.js +20 -3
  123. package/dist/utils/hybridModelManager.js +10 -5
  124. package/dist/utils/metadataFilter.d.ts +33 -19
  125. package/dist/utils/metadataFilter.js +58 -23
  126. package/dist/utils/metadataIndex.d.ts +37 -6
  127. package/dist/utils/metadataIndex.js +427 -64
  128. package/dist/utils/requestDeduplicator.d.ts +10 -0
  129. package/dist/utils/requestDeduplicator.js +24 -0
  130. package/dist/utils/unifiedCache.d.ts +103 -0
  131. package/dist/utils/unifiedCache.js +311 -0
  132. package/package.json +43 -128
  133. package/scripts/ensure-models.js +108 -0
  134. package/scripts/prepare-models.js +387 -0
  135. package/OFFLINE_MODELS.md +0 -56
  136. package/dist/intelligence/neuralEngine.d.ts +0 -207
  137. package/dist/intelligence/neuralEngine.js +0 -706
  138. package/dist/utils/modelLoader.d.ts +0 -32
  139. package/dist/utils/modelLoader.js +0 -219
  140. package/dist/utils/modelManager.d.ts +0 -77
  141. package/dist/utils/modelManager.js +0 -219
@@ -5,13 +5,13 @@
5
5
  import { HNSWIndex } from './hnsw/hnswIndex.js';
6
6
  import { HNSWIndexOptimized, HNSWOptimizedConfig } from './hnsw/hnswIndexOptimized.js';
7
7
  import { DistanceFunction, GraphVerb, EmbeddingFunction, HNSWConfig, SearchResult, SearchCursor, PaginatedSearchResult, StorageAdapter, Vector, VectorDocument } from './coreTypes.js';
8
- import { MetadataIndexManager, MetadataIndexConfig } from './utils/metadataIndex.js';
8
+ import { MetadataIndexConfig } from './utils/metadataIndex.js';
9
9
  import { NounType, VerbType } from './types/graphTypes.js';
10
- import { WebSocketConnection, IAugmentation } from './types/augmentations.js';
10
+ import { WebSocketConnection } from './types/augmentations.js';
11
11
  import { BrainyDataInterface } from './types/brainyDataInterface.js';
12
12
  import { DistributedConfig } from './types/distributedTypes.js';
13
13
  import { SearchCacheConfig } from './utils/searchCache.js';
14
- import { AugmentationManager } from './augmentationManager.js';
14
+ import { TripleQuery, TripleResult } from './triple/TripleIntelligence.js';
15
15
  export interface BrainyDataConfig {
16
16
  /**
17
17
  * HNSW index configuration
@@ -296,10 +296,37 @@ export interface BrainyDataConfig {
296
296
  prefetchStrategy?: 'conservative' | 'moderate' | 'aggressive';
297
297
  };
298
298
  };
299
+ /**
300
+ * Batch processing configuration for enterprise-scale throughput
301
+ * Automatically batches operations for 10-50x performance improvement
302
+ * Critical for processing millions of operations efficiently
303
+ */
304
+ batchSize?: number;
305
+ batchWaitTime?: number;
306
+ /**
307
+ * Real-time streaming configuration for WebSocket/WebRTC
308
+ * Enables live data broadcasting to thousands of connected clients
309
+ * Essential for real-time applications like Bluesky firehose
310
+ */
311
+ realtime?: {
312
+ websocket?: {
313
+ enabled?: boolean;
314
+ port?: number;
315
+ maxConnections?: number;
316
+ };
317
+ webrtc?: {
318
+ enabled?: boolean;
319
+ maxPeers?: number;
320
+ };
321
+ broadcasting?: {
322
+ operations?: string[];
323
+ includeData?: boolean;
324
+ };
325
+ };
299
326
  /**
300
327
  * Intelligent verb scoring configuration
301
328
  * Automatically generates weight and confidence scores for verb relationships
302
- * Off by default - enable by setting enabled: true
329
+ * Enabled by default for better relationship quality
303
330
  */
304
331
  intelligentVerbScoring?: {
305
332
  /**
@@ -348,11 +375,28 @@ export interface BrainyDataConfig {
348
375
  */
349
376
  learningRate?: number;
350
377
  };
378
+ /**
379
+ * Entity registry configuration for fast external-ID to UUID mapping
380
+ * Provides lightning-fast lookups for streaming data processing
381
+ */
382
+ entityCacheSize?: number;
383
+ entityCacheTTL?: number;
384
+ /**
385
+ * Statistics collection configuration
386
+ * When false, disables metrics collection. When true or config object, enables with options.
387
+ * Default: true
388
+ */
389
+ statistics?: boolean;
390
+ /**
391
+ * Health monitoring configuration
392
+ * When false, disables health monitoring. When true or config object, enables with options.
393
+ * Default: false (enabled automatically for distributed setups)
394
+ */
395
+ health?: boolean;
351
396
  }
352
397
  export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
353
- index: HNSWIndex | HNSWIndexOptimized;
398
+ hnswIndex: HNSWIndex | HNSWIndexOptimized;
354
399
  private storage;
355
- metadataIndex: MetadataIndexManager | null;
356
400
  private isInitialized;
357
401
  private isInitializing;
358
402
  private embeddingFunction;
@@ -369,12 +413,17 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
369
413
  private _dimensions;
370
414
  private loggingConfig;
371
415
  private defaultService;
372
- private searchCache;
373
416
  /**
374
- * Type-safe augmentation management
375
- * Access all augmentation operations through this property
417
+ * Enterprise augmentation system
418
+ * Handles WAL, connection pooling, batching, streaming, and intelligent scoring
419
+ */
420
+ private augmentations;
421
+ /**
422
+ * Neural similarity API for semantic operations
376
423
  */
377
- readonly augmentations: AugmentationManager;
424
+ private _neural?;
425
+ private _tripleEngine?;
426
+ private _nlpProcessor?;
378
427
  private cacheAutoConfigurator;
379
428
  private timeoutConfig;
380
429
  private retryConfig;
@@ -385,16 +434,17 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
385
434
  private lastUpdateTime;
386
435
  private lastKnownNounCount;
387
436
  private remoteServerConfig;
388
- private serverSearchConduit;
389
- private serverConnection;
390
437
  private intelligentVerbScoring;
391
438
  private distributedConfig;
392
439
  private configManager;
393
440
  private partitioner;
394
441
  private operationalMode;
395
442
  private domainDetector;
396
- private healthMonitor;
397
- private statisticsCollector;
443
+ private get cache();
444
+ private get index();
445
+ private get metadataIndex();
446
+ private get metrics();
447
+ private get monitoring();
398
448
  /**
399
449
  * Get the vector dimensions
400
450
  */
@@ -407,6 +457,10 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
407
457
  * Get the efConstruction parameter from HNSW configuration
408
458
  */
409
459
  get efConstruction(): number;
460
+ /**
461
+ * Check if BrainyData has been initialized
462
+ */
463
+ get initialized(): boolean;
410
464
  /**
411
465
  * Create a new vector database
412
466
  */
@@ -415,6 +469,21 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
415
469
  * Check if the database is in read-only mode and throw an error if it is
416
470
  * @throws Error if the database is in read-only mode
417
471
  */
472
+ /**
473
+ * Register default augmentations without initializing them
474
+ * Phase 1 of two-phase initialization
475
+ */
476
+ private registerDefaultAugmentations;
477
+ /**
478
+ * Resolve storage from augmentation or config
479
+ * Phase 2 of two-phase initialization
480
+ */
481
+ private resolveStorage;
482
+ /**
483
+ * Initialize the augmentation system with full context
484
+ * Phase 3 of two-phase initialization
485
+ */
486
+ private initializeAugmentations;
418
487
  private checkReadOnly;
419
488
  /**
420
489
  * Check if the database is frozen and throw an error if it is
@@ -564,28 +633,6 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
564
633
  service?: string;
565
634
  process?: 'auto' | 'literal' | 'neural';
566
635
  }): Promise<string>;
567
- /**
568
- * Add a text item to the database with automatic embedding
569
- * This is a convenience method for adding text data with metadata
570
- * @param text Text data to add
571
- * @param metadata Metadata to associate with the text
572
- * @param options Additional options
573
- * @returns The ID of the added item
574
- */
575
- addItem(text: string, metadata?: T, options?: {
576
- addToRemote?: boolean;
577
- id?: string;
578
- }): Promise<string>;
579
- /**
580
- * Add data to both local and remote Brainy instances
581
- * @param vectorOrData Vector or data to add
582
- * @param metadata Optional metadata to associate with the vector
583
- * @param options Additional options
584
- * @returns The ID of the added vector
585
- */
586
- addToBoth(vectorOrData: Vector | any, metadata?: T, options?: {
587
- forceEmbed?: boolean;
588
- }): Promise<string>;
589
636
  /**
590
637
  * Add a vector to the remote server
591
638
  * @param id ID of the vector to add
@@ -601,7 +648,13 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
601
648
  * @param options Additional options
602
649
  * @returns Array of IDs for the added items
603
650
  */
604
- addBatch(items: Array<{
651
+ /**
652
+ * Add multiple nouns in batch
653
+ * @param items Array of nouns to add
654
+ * @param options Batch processing options
655
+ * @returns Array of generated IDs
656
+ */
657
+ addNouns(items: Array<{
605
658
  vectorOrData: Vector | any;
606
659
  metadata?: T;
607
660
  }>, options?: {
@@ -639,6 +692,14 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
639
692
  * @param options Additional options
640
693
  * @returns Array of search results
641
694
  */
695
+ /**
696
+ * @deprecated Use search() with nounTypes option instead
697
+ * @example
698
+ * // Old way (deprecated)
699
+ * await brain.searchByNounTypes(query, 10, ['type1', 'type2'])
700
+ * // New way
701
+ * await brain.search(query, { limit: 10, nounTypes: ['type1', 'type2'] })
702
+ */
642
703
  searchByNounTypes(queryVectorOrData: Vector | any, k?: number, nounTypes?: string[] | null, options?: {
643
704
  forceEmbed?: boolean;
644
705
  service?: string;
@@ -652,24 +713,70 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
652
713
  * @param options Additional options
653
714
  * @returns Array of search results
654
715
  */
655
- search(queryVectorOrData: Vector | any, k?: number, options?: {
656
- forceEmbed?: boolean;
716
+ /**
717
+ * 🔍 SIMPLE VECTOR SEARCH - Clean wrapper around find() for pure vector search
718
+ *
719
+ * @param queryVectorOrData Vector or text to search for
720
+ * @param k Number of results to return
721
+ * @param options Simple search options (metadata filters only)
722
+ * @returns Vector search results
723
+ */
724
+ /**
725
+ * 🔍 Simple Vector Similarity Search - Clean wrapper around find()
726
+ *
727
+ * search(query) = find({like: query}) - Pure vector similarity search
728
+ *
729
+ * @param queryVectorOrData - Query string, vector, or object to search with
730
+ * @param options - Search options for filtering and pagination
731
+ * @returns Array of search results with scores and metadata
732
+ *
733
+ * @example
734
+ * // Simple vector search
735
+ * await brain.search('machine learning')
736
+ *
737
+ * // With filters and pagination
738
+ * await brain.search('AI', {
739
+ * limit: 20,
740
+ * metadata: { type: 'article' },
741
+ * nounTypes: ['document']
742
+ * })
743
+ */
744
+ search(queryVectorOrData: Vector | any, options?: {
745
+ limit?: number;
746
+ offset?: number;
747
+ cursor?: string;
748
+ metadata?: any;
657
749
  nounTypes?: string[];
658
- includeVerbs?: boolean;
659
- searchMode?: 'local' | 'remote' | 'combined';
660
- searchVerbs?: boolean;
661
- verbTypes?: string[];
662
- searchConnectedNouns?: boolean;
663
- verbDirection?: 'outgoing' | 'incoming' | 'both';
664
- service?: string;
665
- searchField?: string;
666
- filter?: {
667
- domain?: string;
668
- };
750
+ itemIds?: string[];
751
+ excludeDeleted?: boolean;
752
+ threshold?: number;
753
+ timeout?: number;
754
+ }): Promise<SearchResult<T>[]>;
755
+ /**
756
+ * Helper method to encode cursor for pagination
757
+ * @internal
758
+ */
759
+ private encodeCursor;
760
+ /**
761
+ * Helper method to decode cursor for pagination
762
+ * @internal
763
+ */
764
+ private decodeCursor;
765
+ /**
766
+ * Internal method for direct HNSW vector search
767
+ * Used by TripleIntelligence to avoid circular dependencies
768
+ * Note: For pure metadata filtering, use metadataIndex.getIdsForFilter() directly - it's O(log n)!
769
+ * This method is for vector similarity search with optional metadata filtering during search
770
+ * @internal
771
+ */
772
+ _internalVectorSearch(queryVectorOrData: Vector | any, k?: number, options?: {
669
773
  metadata?: any;
670
- offset?: number;
671
- skipCache?: boolean;
672
774
  }): Promise<SearchResult<T>[]>;
775
+ /**
776
+ * 🎯 LEGACY: Original search implementation (kept for complex cases)
777
+ * This is the original search method, now used as fallback for edge cases
778
+ */
779
+ private _legacySearch;
673
780
  /**
674
781
  * Search with cursor-based pagination for better performance on large datasets
675
782
  * @param queryVectorOrData Query vector or data to search for
@@ -677,6 +784,14 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
677
784
  * @param options Additional options including cursor for pagination
678
785
  * @returns Paginated search results with cursor for next page
679
786
  */
787
+ /**
788
+ * @deprecated Use search() with cursor option instead
789
+ * @example
790
+ * // Old way (deprecated)
791
+ * await brain.searchWithCursor(query, 10, { cursor: 'abc123' })
792
+ * // New way
793
+ * await brain.search(query, { limit: 10, cursor: 'abc123' })
794
+ */
680
795
  searchWithCursor(queryVectorOrData: Vector | any, k?: number, options?: {
681
796
  forceEmbed?: boolean;
682
797
  nounTypes?: string[];
@@ -726,89 +841,85 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
726
841
  /**
727
842
  * Get a vector by ID
728
843
  */
729
- get(id: string): Promise<VectorDocument<T> | null>;
730
844
  /**
731
845
  * Check if a document with the given ID exists
732
846
  * This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
733
847
  * @param id The ID to check for existence
734
848
  * @returns Promise<boolean> True if the document exists, false otherwise
735
849
  */
736
- has(id: string): Promise<boolean>;
850
+ private has;
737
851
  /**
738
852
  * Check if a document with the given ID exists (alias for has)
739
853
  * This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
740
854
  * @param id The ID to check for existence
741
855
  * @returns Promise<boolean> True if the document exists, false otherwise
742
856
  */
743
- exists(id: string): Promise<boolean>;
857
+ /**
858
+ * Check if a noun exists
859
+ * @param id The noun ID
860
+ * @returns True if exists
861
+ */
862
+ hasNoun(id: string): Promise<boolean>;
744
863
  /**
745
864
  * Get metadata for a document by ID
746
865
  * This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
747
866
  * @param id The ID of the document
748
867
  * @returns Promise<T | null> The metadata object or null if not found
749
868
  */
750
- getMetadata(id: string): Promise<T | null>;
751
869
  /**
752
870
  * Get multiple documents by their IDs
753
871
  * This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
754
872
  * @param ids Array of IDs to retrieve
755
873
  * @returns Promise<Array<VectorDocument<T> | null>> Array of documents (null for missing IDs)
756
874
  */
757
- getBatch(ids: string[]): Promise<Array<VectorDocument<T> | null>>;
758
875
  /**
759
- * Get nouns with pagination and filtering
760
- * @param options Pagination and filtering options
761
- * @returns Paginated result of vector documents
762
- */
763
- getNouns(options?: {
876
+ * Get multiple nouns - by IDs, filters, or pagination
877
+ * @param idsOrOptions Array of IDs or query options
878
+ * @returns Array of noun documents
879
+ *
880
+ * @example
881
+ * // Get by IDs
882
+ * await brain.getNouns(['id1', 'id2'])
883
+ *
884
+ * // Get with filters
885
+ * await brain.getNouns({
886
+ * filter: { type: 'article' },
887
+ * limit: 10
888
+ * })
889
+ *
890
+ * // Get with pagination
891
+ * await brain.getNouns({
892
+ * offset: 20,
893
+ * limit: 10
894
+ * })
895
+ */
896
+ getNouns(idsOrOptions?: string[] | {
897
+ ids?: string[];
898
+ filter?: {
899
+ nounType?: string | string[];
900
+ metadata?: Record<string, any>;
901
+ };
764
902
  pagination?: {
765
903
  offset?: number;
766
904
  limit?: number;
767
905
  cursor?: string;
768
906
  };
769
- filter?: {
770
- nounType?: string | string[];
771
- service?: string | string[];
772
- metadata?: Record<string, any>;
773
- };
774
- }): Promise<{
775
- items: VectorDocument<T>[];
776
- totalCount?: number;
777
- hasMore: boolean;
778
- nextCursor?: string;
779
- }>;
780
- /**
781
- * Delete a vector by ID
782
- * @param id The ID of the vector to delete
783
- * @param options Additional options
784
- * @returns Promise that resolves to true if the vector was deleted, false otherwise
785
- */
786
- delete(id: string, options?: {
787
- service?: string;
788
- hard?: boolean;
789
- cascade?: boolean;
790
- force?: boolean;
791
- }): Promise<boolean>;
907
+ offset?: number;
908
+ limit?: number;
909
+ }): Promise<Array<VectorDocument<T> | null>>;
792
910
  /**
793
- * Update metadata for a vector
794
- * @param id The ID of the vector to update metadata for
795
- * @param metadata The new metadata
796
- * @param options Additional options
797
- * @returns Promise that resolves to true if the metadata was updated, false otherwise
911
+ * Internal: Get nouns by IDs
798
912
  */
799
- updateMetadata(id: string, metadata: T, options?: {
800
- service?: string;
801
- }): Promise<boolean>;
913
+ private getNounsByIds;
802
914
  /**
803
- * Create a relationship between two entities
804
- * This is a convenience wrapper around addVerb
915
+ * Get nouns with pagination and filtering
916
+ * @param options Pagination and filtering options
917
+ * @returns Paginated result of vector documents
805
918
  */
806
- relate(sourceId: string, targetId: string, relationType: string, metadata?: any): Promise<string>;
807
919
  /**
808
- * Create a connection between two entities
809
- * This is an alias for relate() for backward compatibility
920
+ * Internal: Query nouns with filtering and pagination
810
921
  */
811
- connect(sourceId: string, targetId: string, relationType: string, metadata?: any): Promise<string>;
922
+ private queryNounsByFilter;
812
923
  /**
813
924
  * Add a verb between two nouns
814
925
  * If metadata is provided and vector is not, the metadata will be vectorized using the embedding function
@@ -904,13 +1015,27 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
904
1015
  * @param options Additional options
905
1016
  * @returns Promise that resolves to true if the verb was deleted, false otherwise
906
1017
  */
1018
+ /**
1019
+ * Add multiple verbs (relationships) in batch
1020
+ * @param verbs Array of verbs to add
1021
+ * @returns Array of generated verb IDs
1022
+ */
1023
+ addVerbs(verbs: Array<{
1024
+ source: string;
1025
+ target: string;
1026
+ type: string;
1027
+ metadata?: any;
1028
+ }>): Promise<string[]>;
1029
+ /**
1030
+ * Delete multiple verbs by IDs
1031
+ * @param ids Array of verb IDs
1032
+ * @returns Array of success booleans
1033
+ */
1034
+ deleteVerbs(ids: string[]): Promise<boolean[]>;
907
1035
  deleteVerb(id: string, options?: {
908
1036
  service?: string;
1037
+ hard?: boolean;
909
1038
  }): Promise<boolean>;
910
- /**
911
- * Clear the database
912
- */
913
- clear(): Promise<void>;
914
1039
  /**
915
1040
  * Get the number of vectors in the database
916
1041
  */
@@ -920,16 +1045,8 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
920
1045
  * @returns Cache statistics including hit rate and memory usage
921
1046
  */
922
1047
  getCacheStats(): {
923
- search: {
924
- hits: number;
925
- misses: number;
926
- evictions: number;
927
- hitRate: number;
928
- size: number;
929
- maxSize: number;
930
- enabled: boolean;
931
- };
932
- searchMemoryUsage: number;
1048
+ search: any;
1049
+ searchMemoryUsage: any;
933
1050
  };
934
1051
  /**
935
1052
  * Clear search cache manually (useful for testing or memory management)
@@ -1114,6 +1231,14 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1114
1231
  * @param options Additional options
1115
1232
  * @returns Array of search results
1116
1233
  */
1234
+ /**
1235
+ * @deprecated Use search() with itemIds option instead
1236
+ * @example
1237
+ * // Old way (deprecated)
1238
+ * await brain.searchWithinItems(query, itemIds, 10)
1239
+ * // New way
1240
+ * await brain.search(query, { limit: 10, itemIds })
1241
+ */
1117
1242
  searchWithinItems(queryVectorOrData: Vector | any, itemIds: string[], k?: number, options?: {
1118
1243
  forceEmbed?: boolean;
1119
1244
  }): Promise<SearchResult<T>[]>;
@@ -1126,6 +1251,14 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1126
1251
  * @param options Additional options
1127
1252
  * @returns Array of search results
1128
1253
  */
1254
+ /**
1255
+ * @deprecated Use search() directly with text - it auto-detects strings
1256
+ * @example
1257
+ * // Old way (deprecated)
1258
+ * await brain.searchText('query text', 10)
1259
+ * // New way
1260
+ * await brain.search('query text', { limit: 10 })
1261
+ */
1129
1262
  searchText(query: string, k?: number, options?: {
1130
1263
  nounTypes?: string[];
1131
1264
  includeVerbs?: boolean;
@@ -1371,7 +1504,15 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1371
1504
  * @param metadata Additional metadata
1372
1505
  * @returns Created noun ID
1373
1506
  */
1374
- addNoun(data: any, nounType: NounType, metadata?: any): Promise<string>;
1507
+ /**
1508
+ * Add a noun to the database
1509
+ * Clean 2.0 API - primary method for adding data
1510
+ *
1511
+ * @param vectorOrData Vector array or data to embed
1512
+ * @param metadata Metadata to store with the noun
1513
+ * @returns The generated ID
1514
+ */
1515
+ addNoun(vectorOrData: Vector | any, metadata?: T): Promise<string>;
1375
1516
  /**
1376
1517
  * Add Verb - Unified relationship creation between nouns
1377
1518
  * Creates typed relationships with proper vector embeddings from metadata
@@ -1425,11 +1566,6 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1425
1566
  * @param options Update options
1426
1567
  * @returns Success boolean
1427
1568
  */
1428
- update(id: string, data?: any, metadata?: any, options?: {
1429
- merge?: boolean;
1430
- reindex?: boolean;
1431
- cascade?: boolean;
1432
- }): Promise<boolean>;
1433
1569
  /**
1434
1570
  * Preload Transformer Model - Essential for container deployments
1435
1571
  * Downloads and caches models during initialization to avoid runtime delays
@@ -1483,21 +1619,119 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1483
1619
  */
1484
1620
  rebuildMetadataIndex(): Promise<void>;
1485
1621
  /**
1486
- * UNIFIED API METHOD #9: Augment - Register new augmentations
1622
+ * Get a noun by ID
1623
+ * @param id The noun ID
1624
+ * @returns The noun document or null
1625
+ */
1626
+ getNoun(id: string): Promise<VectorDocument<T> | null>;
1627
+ /**
1628
+ * Delete a noun by ID
1629
+ * @param id The noun ID
1630
+ * @returns Success boolean
1631
+ */
1632
+ deleteNoun(id: string): Promise<boolean>;
1633
+ /**
1634
+ * Delete multiple nouns by IDs
1635
+ * @param ids Array of noun IDs
1636
+ * @returns Array of success booleans
1637
+ */
1638
+ deleteNouns(ids: string[]): Promise<boolean[]>;
1639
+ /**
1640
+ * Update a noun
1641
+ * @param id The noun ID
1642
+ * @param data Optional new vector/data
1643
+ * @param metadata Optional new metadata
1644
+ * @returns The updated noun
1645
+ */
1646
+ updateNoun(id: string, data?: any, metadata?: T): Promise<VectorDocument<T>>;
1647
+ /**
1648
+ * Update only the metadata of a noun
1649
+ * @param id The noun ID
1650
+ * @param metadata New metadata
1651
+ */
1652
+ updateNounMetadata(id: string, metadata: T): Promise<void>;
1653
+ /**
1654
+ * Get metadata for a noun
1655
+ * @param id The noun ID
1656
+ * @returns Metadata or null
1657
+ */
1658
+ getNounMetadata(id: string): Promise<T | null>;
1659
+ /**
1660
+ * Neural API - Unified Semantic Intelligence
1661
+ * Best-of-both: Complete functionality + Enterprise performance
1662
+ *
1663
+ * User-friendly methods:
1664
+ * - brain.neural.similar() - Smart similarity detection
1665
+ * - brain.neural.hierarchy() - Semantic hierarchy building
1666
+ * - brain.neural.neighbors() - Neighbor graph generation
1667
+ * - brain.neural.clusters() - Auto-detects best clustering algorithm
1668
+ * - brain.neural.visualize() - Rich visualization data
1669
+ * - brain.neural.outliers() - Outlier detection
1670
+ * - brain.neural.semanticPath() - Path finding
1671
+ *
1672
+ * Enterprise performance methods:
1673
+ * - brain.neural.clusterFast() - O(n) HNSW-based clustering
1674
+ * - brain.neural.clusterLarge() - Million-item clustering
1675
+ * - brain.neural.clusterStream() - Progressive streaming
1676
+ * - brain.neural.getLOD() - Level-of-detail for scale
1677
+ */
1678
+ get neural(): any;
1679
+ /**
1680
+ * Simple similarity check (shorthand for neural.similar)
1681
+ */
1682
+ similar(a: any, b: any): Promise<number>;
1683
+ /**
1684
+ * Get semantic clusters (shorthand for neural.clusters)
1685
+ */
1686
+ clusters(options?: any): Promise<any[]>;
1687
+ /**
1688
+ * Get related items (shorthand for neural.neighbors)
1689
+ */
1690
+ related(id: string, limit?: number): Promise<any[]>;
1691
+ /**
1692
+ * Get visualization data (shorthand for neural.visualize)
1693
+ */
1694
+ visualize(options?: any): Promise<any>;
1695
+ /**
1696
+ * 🚀 TRIPLE INTELLIGENCE SEARCH - Natural Language & Complex Queries
1697
+ * The revolutionary search that combines vector, graph, and metadata intelligence!
1487
1698
  *
1488
- * For registration: brain.augment(new MyAugmentation())
1489
- * For management: Use brain.augmentations.enable(), .disable(), .list() etc.
1699
+ * @param query - Natural language string or structured TripleQuery
1700
+ * @param options - Pagination and performance options
1701
+ * @returns Unified search results with fusion scoring
1490
1702
  *
1491
- * @param action The augmentation to register OR legacy string command
1492
- * @param options Legacy options for string commands (deprecated)
1493
- * @returns this for chaining when registering, various for legacy commands
1703
+ * @example
1704
+ * // Natural language query
1705
+ * await brain.find('frameworks from recent years with high popularity')
1494
1706
  *
1495
- * @deprecated String-based commands are deprecated. Use brain.augmentations.* instead
1707
+ * // Structured query with pagination
1708
+ * await brain.find({
1709
+ * like: 'machine learning',
1710
+ * where: { year: { greaterThan: 2020 } },
1711
+ * connected: { from: 'authorId123' }
1712
+ * }, {
1713
+ * limit: 50,
1714
+ * cursor: lastCursor
1715
+ * })
1716
+ */
1717
+ find(query: TripleQuery | string, options?: {
1718
+ limit?: number;
1719
+ offset?: number;
1720
+ cursor?: string;
1721
+ mode?: 'auto' | 'vector' | 'graph' | 'metadata' | 'fusion';
1722
+ maxDepth?: number;
1723
+ parallel?: boolean;
1724
+ timeout?: number;
1725
+ excludeDeleted?: boolean;
1726
+ }): Promise<TripleResult[]>;
1727
+ /**
1728
+ * 🧠 NATURAL LANGUAGE PROCESSING - Auto-breakdown using all Brainy features
1729
+ * Uses embedding model, neural tools, entity registry, and taxonomy matching
1730
+ */
1731
+ private processNaturalLanguage;
1732
+ /**
1733
+ * LEGACY: Augment method temporarily disabled during new augmentation system implementation
1496
1734
  */
1497
- augment(action: IAugmentation | 'list' | 'enable' | 'disable' | 'unregister' | 'enable-type' | 'disable-type', options?: string | {
1498
- name?: string;
1499
- type?: string;
1500
- }): this | any;
1501
1735
  /**
1502
1736
  * UNIFIED API METHOD #9: Export - Extract your data in various formats
1503
1737
  * Export your brain's knowledge for backup, migration, or integration
@@ -1580,5 +1814,45 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1580
1814
  * @returns Number of augmentations disabled
1581
1815
  */
1582
1816
  disableAugmentationType(type: 'sense' | 'conduit' | 'cognition' | 'memory' | 'perception' | 'dialog' | 'activation' | 'webSocket'): number;
1817
+ /**
1818
+ * Clear only nouns from the database
1819
+ * @param options Clear options requiring force confirmation
1820
+ */
1821
+ /**
1822
+ * Clear all nouns from the database
1823
+ * @param options Options including force flag to skip confirmation
1824
+ */
1825
+ clearNouns(options?: {
1826
+ force?: boolean;
1827
+ }): Promise<void>;
1828
+ /**
1829
+ * Clear only verbs from the database
1830
+ * @param options Clear options requiring force confirmation
1831
+ */
1832
+ /**
1833
+ * Clear all verbs from the database
1834
+ * @param options Options including force flag to skip confirmation
1835
+ */
1836
+ clearVerbs(options?: {
1837
+ force?: boolean;
1838
+ }): Promise<void>;
1839
+ /**
1840
+ * Clear all data from the database (nouns and verbs)
1841
+ * @param options Clear options requiring force confirmation
1842
+ */
1843
+ /**
1844
+ * Clear all data from the database
1845
+ * @param options Options including force flag to skip confirmation
1846
+ */
1847
+ clear(options?: {
1848
+ force?: boolean;
1849
+ }): Promise<void>;
1850
+ /**
1851
+ * Clear all data from the database (alias for clear)
1852
+ * @param options Options including force flag to skip confirmation
1853
+ */
1854
+ clearAll(options?: {
1855
+ force?: boolean;
1856
+ }): Promise<void>;
1583
1857
  }
1584
1858
  export { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistance } from './utils/index.js';