@soulcraft/brainy 3.18.0 → 3.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +52 -3
  3. package/bin/brainy.js +9 -2335
  4. package/dist/api/DataAPI.d.ts +1 -1
  5. package/dist/augmentations/cacheAugmentation.d.ts +1 -1
  6. package/dist/augmentations/metricsAugmentation.d.ts +20 -20
  7. package/dist/brainy.d.ts +19 -1
  8. package/dist/brainy.js +24 -0
  9. package/dist/brainyData.js +1 -2
  10. package/dist/cli/catalog.js +8 -12
  11. package/dist/cli/commands/conversation.d.ts +22 -0
  12. package/dist/cli/commands/conversation.js +528 -0
  13. package/dist/cli/commands/core.js +61 -17
  14. package/dist/cli/commands/neural.js +4 -5
  15. package/dist/cli/commands/types.d.ts +30 -0
  16. package/dist/cli/commands/types.js +194 -0
  17. package/dist/cli/commands/utility.js +2 -3
  18. package/dist/cli/index.js +44 -2
  19. package/dist/cli/interactive.d.ts +3 -3
  20. package/dist/cli/interactive.js +5 -5
  21. package/dist/conversation/conversationManager.d.ts +176 -0
  22. package/dist/conversation/conversationManager.js +666 -0
  23. package/dist/conversation/index.d.ts +8 -0
  24. package/dist/conversation/index.js +8 -0
  25. package/dist/conversation/types.d.ts +231 -0
  26. package/dist/conversation/types.js +8 -0
  27. package/dist/hnsw/hnswIndexOptimized.d.ts +1 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +3 -0
  30. package/dist/mcp/brainyMCPBroadcast.d.ts +2 -2
  31. package/dist/mcp/brainyMCPBroadcast.js +1 -1
  32. package/dist/mcp/brainyMCPClient.js +8 -4
  33. package/dist/mcp/conversationTools.d.ts +88 -0
  34. package/dist/mcp/conversationTools.js +470 -0
  35. package/dist/neural/types.d.ts +2 -2
  36. package/dist/streaming/pipeline.d.ts +1 -1
  37. package/dist/types/mcpTypes.d.ts +7 -1
  38. package/dist/universal/fs.d.ts +24 -66
  39. package/package.json +2 -2
@@ -69,7 +69,7 @@ export declare class DataAPI {
69
69
  private getEntity;
70
70
  private getRelation?;
71
71
  private brain;
72
- constructor(storage: StorageAdapter, getEntity: (id: string) => Promise<Entity | null>, getRelation?: ((id: string) => Promise<Relation | null>) | undefined, brain?: any);
72
+ constructor(storage: StorageAdapter, getEntity: (id: string) => Promise<Entity | null>, getRelation?: (id: string) => Promise<Relation | null>, brain?: any);
73
73
  /**
74
74
  * Create a backup of all data
75
75
  */
@@ -98,7 +98,7 @@ export declare class CacheAugmentation extends BaseAugmentation {
98
98
  /**
99
99
  * Get the underlying SearchCache instance (for compatibility)
100
100
  */
101
- getSearchCache(): SearchCache<GraphNoun> | null;
101
+ getSearchCache(): SearchCache<GraphNoun>;
102
102
  /**
103
103
  * Get memory usage
104
104
  */
@@ -100,13 +100,13 @@ export declare class MetricsAugmentation extends BaseAugmentation {
100
100
  p99Latency: number;
101
101
  };
102
102
  } | {
103
- nounCount?: Record<string, number> | undefined;
104
- verbCount?: Record<string, number> | undefined;
105
- metadataCount?: Record<string, number> | undefined;
106
- hnswIndexSize?: number | undefined;
107
- totalNodes?: number | undefined;
108
- totalEdges?: number | undefined;
109
- totalMetadata?: number | undefined;
103
+ nounCount?: Record<string, number>;
104
+ verbCount?: Record<string, number>;
105
+ metadataCount?: Record<string, number>;
106
+ hnswIndexSize?: number;
107
+ totalNodes?: number;
108
+ totalEdges?: number;
109
+ totalMetadata?: number;
110
110
  operations?: {
111
111
  add: number;
112
112
  search: number;
@@ -114,10 +114,10 @@ export declare class MetricsAugmentation extends BaseAugmentation {
114
114
  update: number;
115
115
  relate: number;
116
116
  total: number;
117
- } | undefined;
118
- fieldNames?: Record<string, string[]> | undefined;
119
- standardFieldMappings?: Record<string, Record<string, string[]>> | undefined;
120
- contentTypes?: Record<string, number> | undefined;
117
+ };
118
+ fieldNames?: Record<string, string[]>;
119
+ standardFieldMappings?: Record<string, Record<string, string[]>>;
120
+ contentTypes?: Record<string, number>;
121
121
  dataFreshness?: {
122
122
  oldestEntry: string;
123
123
  newestEntry: string;
@@ -129,32 +129,32 @@ export declare class MetricsAugmentation extends BaseAugmentation {
129
129
  last30d: number;
130
130
  older: number;
131
131
  };
132
- } | undefined;
132
+ };
133
133
  storageMetrics?: {
134
134
  totalSizeBytes: number;
135
135
  nounsSizeBytes: number;
136
136
  verbsSizeBytes: number;
137
137
  metadataSizeBytes: number;
138
138
  indexSizeBytes: number;
139
- } | undefined;
139
+ };
140
140
  searchMetrics?: {
141
141
  totalSearches: number;
142
142
  averageSearchTimeMs: number;
143
143
  searchesLastHour: number;
144
144
  searchesLastDay: number;
145
145
  topSearchTerms?: string[];
146
- } | undefined;
146
+ };
147
147
  verbStatistics?: {
148
148
  totalVerbs: number;
149
149
  verbTypes: Record<string, number>;
150
150
  averageConnectionsPerVerb: number;
151
- } | undefined;
151
+ };
152
152
  serviceActivity?: Record<string, {
153
153
  firstActivity: string;
154
154
  lastActivity: string;
155
155
  totalOperations: number;
156
- }> | undefined;
157
- services?: import("../coreTypes.js").ServiceStatistics[] | undefined;
156
+ }>;
157
+ services?: import("../coreTypes.js").ServiceStatistics[];
158
158
  throttlingMetrics?: {
159
159
  storage?: {
160
160
  currentlyThrottled: boolean;
@@ -177,9 +177,9 @@ export declare class MetricsAugmentation extends BaseAugmentation {
177
177
  lastThrottle: string;
178
178
  status: "normal" | "throttled" | "recovering";
179
179
  }>;
180
- } | undefined;
181
- lastUpdated?: string | undefined;
182
- distributedConfig?: import("../types/distributedTypes.js").SharedConfig | undefined;
180
+ };
181
+ lastUpdated?: string;
182
+ distributedConfig?: import("../types/distributedTypes.js").SharedConfig;
183
183
  enabled: boolean;
184
184
  note: string;
185
185
  totalSearches?: undefined;
package/dist/brainy.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
38
38
  private _extractor?;
39
39
  private _tripleIntelligence?;
40
40
  private _vfs?;
41
+ private _conversation?;
41
42
  private initialized;
42
43
  private dimensions?;
43
44
  constructor(config?: BrainyConfig);
@@ -644,6 +645,23 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
644
645
  * Virtual File System API - Knowledge Operating System
645
646
  */
646
647
  vfs(): VirtualFileSystem;
648
+ /**
649
+ * Conversation Manager API - Infinite Agent Memory
650
+ *
651
+ * Provides conversation and context management for AI agents:
652
+ * - Save and retrieve conversation messages
653
+ * - Semantic search across conversation history
654
+ * - Smart context retrieval with relevance ranking
655
+ * - Artifact management (code, files, documents)
656
+ * - Conversation themes and clustering
657
+ *
658
+ * @returns ConversationManager instance
659
+ * @example
660
+ * const conv = brain.conversation
661
+ * await conv.saveMessage("How do I implement auth?", "user", { conversationId: "conv_123" })
662
+ * const context = await conv.getRelevantContext("authentication implementation")
663
+ */
664
+ conversation(): any;
647
665
  /**
648
666
  * Data Management API - backup, restore, import, export
649
667
  */
@@ -806,7 +824,7 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
806
824
  */
807
825
  get augmentations(): {
808
826
  list: () => string[];
809
- get: (name: string) => import("./augmentations/brainyAugmentation.js").BrainyAugmentation | undefined;
827
+ get: (name: string) => import("./augmentations/brainyAugmentation.js").BrainyAugmentation;
810
828
  has: (name: string) => boolean;
811
829
  };
812
830
  /**
package/dist/brainy.js CHANGED
@@ -1419,6 +1419,30 @@ export class Brainy {
1419
1419
  }
1420
1420
  return this._vfs;
1421
1421
  }
1422
+ /**
1423
+ * Conversation Manager API - Infinite Agent Memory
1424
+ *
1425
+ * Provides conversation and context management for AI agents:
1426
+ * - Save and retrieve conversation messages
1427
+ * - Semantic search across conversation history
1428
+ * - Smart context retrieval with relevance ranking
1429
+ * - Artifact management (code, files, documents)
1430
+ * - Conversation themes and clustering
1431
+ *
1432
+ * @returns ConversationManager instance
1433
+ * @example
1434
+ * const conv = brain.conversation
1435
+ * await conv.saveMessage("How do I implement auth?", "user", { conversationId: "conv_123" })
1436
+ * const context = await conv.getRelevantContext("authentication implementation")
1437
+ */
1438
+ conversation() {
1439
+ if (!this._conversation) {
1440
+ // Lazy-load ConversationManager to avoid circular dependencies
1441
+ const { ConversationManager } = require('./conversation/conversationManager.js');
1442
+ this._conversation = new ConversationManager(this);
1443
+ }
1444
+ return this._conversation;
1445
+ }
1422
1446
  /**
1423
1447
  * Data Management API - backup, restore, import, export
1424
1448
  */
@@ -20,7 +20,6 @@ import { DistributedConfigManager, HashPartitioner, OperationalModeFactory, Doma
20
20
  import { CacheAutoConfigurator } from './utils/cacheAutoConfig.js';
21
21
  import { RequestDeduplicator } from './utils/requestDeduplicator.js';
22
22
  import { AugmentationRegistry } from './augmentations/brainyAugmentation.js';
23
- import { WALAugmentation } from './augmentations/walAugmentation.js';
24
23
  import { RequestDeduplicatorAugmentation } from './augmentations/requestDeduplicatorAugmentation.js';
25
24
  import { ConnectionPoolAugmentation } from './augmentations/connectionPoolAugmentation.js';
26
25
  import { BatchProcessingAugmentation } from './augmentations/batchProcessingAugmentation.js';
@@ -310,7 +309,7 @@ export class BrainyData {
310
309
  // Priority 100: Critical system operations
311
310
  // Disable WAL in test environments to avoid directory creation issues
312
311
  const isTestEnvironment = process.env.NODE_ENV === 'test' || process.env.VITEST === 'true';
313
- this.augmentations.register(new WALAugmentation({ enabled: !isTestEnvironment }));
312
+ // this.augmentations.register(new WALAugmentation({ enabled: !isTestEnvironment }));
314
313
  this.augmentations.register(new ConnectionPoolAugmentation());
315
314
  // Priority 95: Entity registry for fast external-ID to UUID mapping
316
315
  this.augmentations.register(new EntityRegistryAugmentation({
@@ -5,9 +5,9 @@
5
5
  * Local catalog with caching support
6
6
  */
7
7
  import chalk from 'chalk';
8
- import { readFileSync, writeFileSync, existsSync } from 'fs';
9
- import { join } from 'path';
10
- import { homedir } from 'os';
8
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { homedir } from 'node:os';
11
11
  const CATALOG_API = process.env.BRAINY_CATALOG_URL || null;
12
12
  const CACHE_PATH = join(homedir(), '.brainy', 'catalog-cache.json');
13
13
  const CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours
@@ -237,7 +237,7 @@ function saveCache(catalog) {
237
237
  try {
238
238
  const dir = join(homedir(), '.brainy');
239
239
  if (!existsSync(dir)) {
240
- require('fs').mkdirSync(dir, { recursive: true });
240
+ mkdirSync(dir, { recursive: true });
241
241
  }
242
242
  writeFileSync(CACHE_PATH, JSON.stringify({
243
243
  catalog,
@@ -293,7 +293,10 @@ function readLicenseFile() {
293
293
  return readFileSync(licensePath, 'utf8').trim();
294
294
  }
295
295
  }
296
- catch { }
296
+ catch (error) {
297
+ // License file read failed, return null
298
+ console.debug('Failed to read license file:', error);
299
+ }
297
300
  return null;
298
301
  }
299
302
  function getDefaultCatalog() {
@@ -330,13 +333,6 @@ function getDefaultCatalog() {
330
333
  description: 'Smart relationship scoring with taxonomy understanding',
331
334
  status: 'available'
332
335
  },
333
- {
334
- id: 'wal-augmentation',
335
- name: 'WAL-based Augmentation',
336
- category: 'enterprise',
337
- description: 'Write-ahead log for reliable augmentation processing',
338
- status: 'available'
339
- },
340
336
  {
341
337
  id: 'connection-pooling',
342
338
  name: 'Connection Pooling',
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 💬 Conversation CLI Commands
3
+ *
4
+ * CLI interface for infinite agent memory and conversation management
5
+ */
6
+ interface CommandArguments {
7
+ action?: string;
8
+ conversationId?: string;
9
+ query?: string;
10
+ role?: string;
11
+ limit?: number;
12
+ format?: string;
13
+ output?: string;
14
+ _: string[];
15
+ }
16
+ export declare const conversationCommand: {
17
+ command: string;
18
+ describe: string;
19
+ builder: (yargs: any) => any;
20
+ handler: (argv: CommandArguments) => Promise<void>;
21
+ };
22
+ export default conversationCommand;