@soulcraft/brainy 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -315,10 +315,10 @@ const results = await brain.find({
315
315
 
316
316
  ```javascript
317
317
  // Create entities (nouns)
318
- const id = await brain.addNoun(data, nounType, metadata)
318
+ const id = await brain.add(data, { nounType: nounType, ...metadata })
319
319
 
320
320
  // Create relationships (verbs)
321
- const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
321
+ const verbId = await brain.relate(sourceId, targetId, "relationType", {
322
322
  strength: 0.9,
323
323
  bidirectional: false
324
324
  })
@@ -377,7 +377,8 @@ const ingestionNode = new Brainy({
377
377
 
378
378
  // Process Bluesky firehose
379
379
  blueskyStream.on('post', async (post) => {
380
- await ingestionNode.addNoun(post, 'social-post', {
380
+ await ingestionNode.add(post, {
381
+ nounType: 'social-post',
381
382
  platform: 'bluesky',
382
383
  author: post.author,
383
384
  timestamp: post.createdAt
@@ -415,27 +416,30 @@ const trending = await searchNode.find('trending AI topics', {
415
416
 
416
417
  ```javascript
417
418
  // Store documentation with rich relationships
418
- const apiGuide = await brain.addNoun("REST API Guide", 'document', {
419
+ const apiGuide = await brain.add("REST API Guide", {
420
+ nounType: 'document',
419
421
  title: "API Guide",
420
422
  category: "documentation",
421
423
  version: "2.0"
422
424
  })
423
425
 
424
- const author = await brain.addNoun("Jane Developer", 'person', {
426
+ const author = await brain.add("Jane Developer", {
427
+ nounType: 'person',
425
428
  type: "person",
426
429
  role: "tech-lead"
427
430
  })
428
431
 
429
- const project = await brain.addNoun("E-commerce Platform", 'project', {
432
+ const project = await brain.add("E-commerce Platform", {
433
+ nounType: 'project',
430
434
  type: "project",
431
435
  status: "active"
432
436
  })
433
437
 
434
438
  // Create knowledge graph
435
- await brain.addVerb(author, apiGuide, "authored", {
439
+ await brain.relate(author, apiGuide, "authored", {
436
440
  date: "2024-03-15"
437
441
  })
438
- await brain.addVerb(apiGuide, project, "documents", {
442
+ await brain.relate(apiGuide, project, "documents", {
439
443
  coverage: "complete"
440
444
  })
441
445
 
@@ -457,25 +461,28 @@ const similar = await brain.search(existingContent, {
457
461
 
458
462
  ```javascript
459
463
  // Store conversation with relationships
460
- const userId = await brain.addNoun("User 123", 'user', {
464
+ const userId = await brain.add("User 123", {
465
+ nounType: 'user',
461
466
  type: "user",
462
467
  tier: "premium"
463
468
  })
464
469
 
465
- const messageId = await brain.addNoun(userMessage, 'message', {
470
+ const messageId = await brain.add(userMessage, {
471
+ nounType: 'message',
466
472
  type: "message",
467
473
  timestamp: Date.now(),
468
474
  session: "abc"
469
475
  })
470
476
 
471
- const topicId = await brain.addNoun("Product Support", 'topic', {
477
+ const topicId = await brain.add("Product Support", {
478
+ nounType: 'topic',
472
479
  type: "topic",
473
480
  category: "support"
474
481
  })
475
482
 
476
483
  // Link conversation elements
477
- await brain.addVerb(userId, messageId, "sent")
478
- await brain.addVerb(messageId, topicId, "about")
484
+ await brain.relate(userId, messageId, "sent")
485
+ await brain.relate(messageId, topicId, "about")
479
486
 
480
487
  // Retrieve context with relationships
481
488
  const context = await brain.find({
@@ -595,7 +602,7 @@ for (const cluster of feedbackClusters) {
595
602
  }
596
603
 
597
604
  // Find related documents
598
- const docId = await brain.addNoun("Machine learning guide", 'document')
605
+ const docId = await brain.add("Machine learning guide", { nounType: 'document' })
599
606
  const similar = await neural.neighbors(docId, 5)
600
607
  // Returns 5 most similar documents
601
608
 
@@ -16,6 +16,7 @@ export interface CacheConfig {
16
16
  ttl?: number;
17
17
  enabled?: boolean;
18
18
  invalidateOnWrite?: boolean;
19
+ silent?: boolean;
19
20
  }
20
21
  /**
21
22
  * CacheAugmentation - Makes search caching optional and pluggable
@@ -65,6 +65,11 @@ export class CacheAugmentation extends BaseAugmentation {
65
65
  type: 'boolean',
66
66
  default: true,
67
67
  description: 'Automatically invalidate cache on data modifications'
68
+ },
69
+ silent: {
70
+ type: 'boolean',
71
+ default: false,
72
+ description: 'Suppress all console output'
68
73
  }
69
74
  },
70
75
  additionalProperties: false
@@ -18,6 +18,8 @@ export interface DisplayConfig {
18
18
  batchSize: number;
19
19
  /** Minimum confidence threshold for AI type detection */
20
20
  confidenceThreshold: number;
21
+ /** Silent mode - suppress all console output */
22
+ silent?: boolean;
21
23
  /** Custom field mappings (userField -> displayField) */
22
24
  customFieldMappings: Record<string, string>;
23
25
  /** Type-specific priority fields for intelligent detection */
@@ -24,6 +24,7 @@ export interface MetricsConfig {
24
24
  trackStorageSizes?: boolean;
25
25
  persistMetrics?: boolean;
26
26
  metricsInterval?: number;
27
+ silent?: boolean;
27
28
  }
28
29
  /**
29
30
  * MetricsAugmentation - Makes metrics collection optional and pluggable
@@ -234,6 +234,10 @@ export class UniversalDisplayAugmentation extends BaseAugmentation {
234
234
  */
235
235
  createExploreMethod(entity) {
236
236
  return async () => {
237
+ // Respect silent mode
238
+ if (this.config.silent) {
239
+ return;
240
+ }
237
241
  console.log(`\n📋 Entity Exploration: ${entity.id || 'unknown'}`);
238
242
  console.log('━'.repeat(50));
239
243
  // Show user data
package/dist/brainy.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare class Brainy<T = any> {
22
22
  private distance;
23
23
  private augmentationRegistry;
24
24
  private config;
25
+ private originalConsole?;
25
26
  private _neural?;
26
27
  private _nlp?;
27
28
  private _tripleIntelligence?;
package/dist/brainy.js CHANGED
@@ -63,7 +63,20 @@ export class Brainy {
63
63
  }
64
64
  // Configure logging based on config options
65
65
  if (this.config.silent) {
66
- configureLogger({ level: -1 }); // Suppress all logs
66
+ // Store original console methods for restoration
67
+ this.originalConsole = {
68
+ log: console.log,
69
+ info: console.info,
70
+ warn: console.warn,
71
+ error: console.error
72
+ };
73
+ // Override all console methods to completely silence output
74
+ console.log = () => { };
75
+ console.info = () => { };
76
+ console.warn = () => { };
77
+ console.error = () => { };
78
+ // Also configure logger for silent mode
79
+ configureLogger({ level: LogLevel.SILENT }); // Suppress all logs
67
80
  }
68
81
  else if (this.config.verbose) {
69
82
  configureLogger({ level: LogLevel.DEBUG }); // Enable verbose logging
@@ -1408,8 +1421,18 @@ export class Brainy {
1408
1421
  */
1409
1422
  setupAugmentations() {
1410
1423
  const registry = new AugmentationRegistry();
1411
- // Register default augmentations
1412
- const defaults = createDefaultAugmentations(this.config.augmentations);
1424
+ // Register default augmentations with silent mode support
1425
+ const augmentationConfig = {
1426
+ ...this.config.augmentations,
1427
+ // Pass silent mode to all augmentations
1428
+ ...(this.config.silent && {
1429
+ cache: this.config.augmentations?.cache !== false ? { ...this.config.augmentations?.cache, silent: true } : false,
1430
+ metrics: this.config.augmentations?.metrics !== false ? { ...this.config.augmentations?.metrics, silent: true } : false,
1431
+ display: this.config.augmentations?.display !== false ? { ...this.config.augmentations?.display, silent: true } : false,
1432
+ monitoring: this.config.augmentations?.monitoring !== false ? { ...this.config.augmentations?.monitoring, silent: true } : false
1433
+ })
1434
+ };
1435
+ const defaults = createDefaultAugmentations(augmentationConfig);
1413
1436
  for (const aug of defaults) {
1414
1437
  registry.register(aug);
1415
1438
  }
@@ -1488,6 +1511,14 @@ export class Brainy {
1488
1511
  await aug.shutdown();
1489
1512
  }
1490
1513
  }
1514
+ // Restore console methods if silent mode was enabled
1515
+ if (this.config.silent && this.originalConsole) {
1516
+ console.log = this.originalConsole.log;
1517
+ console.info = this.originalConsole.info;
1518
+ console.warn = this.originalConsole.warn;
1519
+ console.error = this.originalConsole.error;
1520
+ this.originalConsole = undefined;
1521
+ }
1491
1522
  // Storage doesn't have close in current interface
1492
1523
  // We'll just mark as not initialized
1493
1524
  this.initialized = false;
@@ -1468,6 +1468,7 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1468
1468
  * @returns Created noun ID
1469
1469
  */
1470
1470
  /**
1471
+ * @deprecated Use add() instead - it's smart by default now
1471
1472
  * Add a noun to the database with required type
1472
1473
  * Clean 2.0 API - primary method for adding data
1473
1474
  *
@@ -1484,6 +1485,7 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
1484
1485
  process?: 'auto' | 'literal' | 'neural';
1485
1486
  }): Promise<string>;
1486
1487
  /**
1488
+ * @deprecated Use relate() instead
1487
1489
  * Add Verb - Unified relationship creation between nouns
1488
1490
  * Creates typed relationships with proper vector embeddings from metadata
1489
1491
  * @param sourceId Source noun ID
@@ -16,6 +16,7 @@ export interface BrainyInterface<T = unknown> {
16
16
  */
17
17
  getNoun(id: string): Promise<unknown>;
18
18
  /**
19
+ * @deprecated Use add() instead - it's smart by default now
19
20
  * Add a noun (entity with vector and metadata) to the database
20
21
  * @param data Text string or vector representation (will auto-embed strings)
21
22
  * @param nounType Required noun type (one of 31 types)
@@ -31,6 +32,7 @@ export interface BrainyInterface<T = unknown> {
31
32
  */
32
33
  searchText(text: string, limit?: number): Promise<unknown[]>;
33
34
  /**
35
+ * @deprecated Use relate() instead
34
36
  * Create a relationship (verb) between two entities
35
37
  * @param sourceId The ID of the source entity
36
38
  * @param targetId The ID of the target entity
@@ -4,6 +4,7 @@
4
4
  * Automatically reduces logging in production environments to minimize costs
5
5
  */
6
6
  export declare enum LogLevel {
7
+ SILENT = -1,// New: Completely silent mode
7
8
  ERROR = 0,
8
9
  WARN = 1,
9
10
  INFO = 2,
@@ -6,6 +6,7 @@
6
6
  import { isProductionEnvironment, getLogLevel } from './environment.js';
7
7
  export var LogLevel;
8
8
  (function (LogLevel) {
9
+ LogLevel[LogLevel["SILENT"] = -1] = "SILENT";
9
10
  LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
10
11
  LogLevel[LogLevel["WARN"] = 1] = "WARN";
11
12
  LogLevel[LogLevel["INFO"] = 2] = "INFO";
@@ -45,7 +46,7 @@ class Logger {
45
46
  // Convert environment log level to Logger LogLevel
46
47
  switch (envLogLevel) {
47
48
  case 'silent':
48
- this.config.level = -1; // Below ERROR to silence all logs
49
+ this.config.level = LogLevel.SILENT;
49
50
  break;
50
51
  case 'error':
51
52
  this.config.level = LogLevel.ERROR;
@@ -81,6 +82,10 @@ class Logger {
81
82
  this.config = { ...this.config, ...config };
82
83
  }
83
84
  shouldLog(level, module) {
85
+ // Silent mode - never log anything
86
+ if (this.config.level === LogLevel.SILENT) {
87
+ return false;
88
+ }
84
89
  // Check module-specific level first
85
90
  if (this.config.modules && this.config.modules[module] !== undefined) {
86
91
  return level <= this.config.modules[module];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",