@soulcraft/brainy 3.3.1 → 3.4.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.
package/bin/brainy.js CHANGED
@@ -546,7 +546,7 @@ program
546
546
  metadata.encrypted = true
547
547
  }
548
548
 
549
- const id = await brainyInstance.addNoun(processedData, metadata)
549
+ const id = await brainyInstance.add({ data: processedData, type: 'content', metadata })
550
550
  console.log(colors.success(`✅ Added successfully! ID: ${id}`))
551
551
  }))
552
552
 
@@ -1337,9 +1337,8 @@ program
1337
1337
  }
1338
1338
 
1339
1339
  try {
1340
- // In 2.0 API, addNoun takes (data, metadata) - type goes in metadata
1341
- metadata.type = options.type
1342
- const id = await brainy.addNoun(name, metadata)
1340
+ // Use modern 3.0 API with parameter object
1341
+ const id = await brainy.add({ data: name, type: options.type, metadata })
1343
1342
 
1344
1343
  console.log(colors.success('✅ Noun added successfully!'))
1345
1344
  console.log(colors.info(`🆔 ID: ${id}`))
@@ -1506,7 +1505,7 @@ program
1506
1505
 
1507
1506
  // Use the provided type or fall back to RelatedTo
1508
1507
  const verbType = VerbType[options.type] || options.type
1509
- const id = await brainy.addVerb(source, target, verbType, metadata)
1508
+ const id = await brainy.relate({ from: source, to: target, type: verbType, metadata })
1510
1509
 
1511
1510
  console.log(colors.success('✅ Relationship added successfully!'))
1512
1511
  console.log(colors.info(`🆔 ID: ${id}`))
@@ -139,7 +139,7 @@ export class APIServerAugmentation extends BaseAugmentation {
139
139
  app.post('/api/add', async (req, res) => {
140
140
  try {
141
141
  const { content, metadata } = req.body;
142
- const id = await this.context.brain.addNoun(content, 'Content', metadata);
142
+ const id = await this.context.brain.add({ data: content, type: 'content', metadata });
143
143
  res.json({ success: true, id });
144
144
  }
145
145
  catch (error) {
@@ -301,7 +301,7 @@ export class APIServerAugmentation extends BaseAugmentation {
301
301
  }));
302
302
  break;
303
303
  case 'add':
304
- const id = await this.context.brain.addNoun(msg.content, 'Content', msg.metadata);
304
+ const id = await this.context.brain.add({ data: msg.content, type: 'content', metadata: msg.metadata });
305
305
  socket.send(JSON.stringify({
306
306
  type: 'addResult',
307
307
  requestId: msg.requestId,
@@ -66,6 +66,6 @@ export {};
66
66
  * await conduit.establishConnection('ws://localhost:3000/ws')
67
67
  *
68
68
  * // Now operations sync automatically!
69
- * await clientBrain.addNoun('synced data', { source: 'client' })
69
+ * await clientBrain.add({ data: 'synced data', type: 'content', metadata: { source: 'client' } })
70
70
  * // This will automatically sync to the server
71
71
  */
@@ -168,13 +168,18 @@ export class WebSocketConduitAugmentation extends BaseConduitAugmentation {
168
168
  try {
169
169
  switch (operation) {
170
170
  case 'addNoun':
171
- await this.context?.brain.addNoun(params.content, params.metadata);
171
+ await this.context?.brain.add({ data: params.content, type: 'content', metadata: params.metadata });
172
172
  break;
173
173
  case 'deleteNoun':
174
174
  await this.context?.brain.deleteNoun(params.id);
175
175
  break;
176
176
  case 'addVerb':
177
- await this.context?.brain.addVerb(params.source, params.target, params.verb, params.metadata);
177
+ await this.context?.brain.relate({
178
+ from: params.source,
179
+ to: params.target,
180
+ type: params.verb,
181
+ metadata: params.metadata
182
+ });
178
183
  break;
179
184
  }
180
185
  }
@@ -227,7 +232,7 @@ export class WebSocketConduitAugmentation extends BaseConduitAugmentation {
227
232
  * await conduit.establishConnection('ws://localhost:3000/ws')
228
233
  *
229
234
  * // Now operations sync automatically!
230
- * await clientBrain.addNoun('synced data', { source: 'client' })
235
+ * await clientBrain.add({ data: 'synced data', type: 'content', metadata: { source: 'client' } })
231
236
  * // This will automatically sync to the server
232
237
  */
233
238
  //# sourceMappingURL=conduitAugmentations.js.map
package/dist/brainy.d.ts CHANGED
@@ -4,16 +4,20 @@
4
4
  * Beautiful, Professional, Planet-Scale, Fun to Use
5
5
  * NO STUBS, NO MOCKS, REAL IMPLEMENTATION
6
6
  */
7
+ import { Vector } from './coreTypes.js';
7
8
  import { ImprovedNeuralAPI } from './neural/improvedNeuralAPI.js';
8
9
  import { NaturalLanguageProcessor } from './neural/naturalLanguageProcessor.js';
9
10
  import { TripleIntelligenceSystem } from './triple/TripleIntelligenceSystem.js';
10
11
  import { Entity, Relation, Result, AddParams, UpdateParams, RelateParams, FindParams, SimilarParams, GetRelationsParams, AddManyParams, DeleteManyParams, RelateManyParams, BatchResult, BrainyConfig } from './types/brainy.types.js';
11
12
  import { NounType } from './types/graphTypes.js';
13
+ import { BrainyInterface } from './types/brainyDataInterface.js';
12
14
  /**
13
15
  * The main Brainy class - Clean, Beautiful, Powerful
14
16
  * REAL IMPLEMENTATION - No stubs, no mocks
17
+ *
18
+ * Implements BrainyInterface to ensure consistency across integrations
15
19
  */
16
- export declare class Brainy<T = any> {
20
+ export declare class Brainy<T = any> implements BrainyInterface<T> {
17
21
  private index;
18
22
  private storage;
19
23
  private metadataIndex;
@@ -316,7 +320,7 @@ export declare class Brainy<T = any> {
316
320
  /**
317
321
  * Embed data into vector
318
322
  */
319
- private embed;
323
+ embed(data: any): Promise<Vector>;
320
324
  /**
321
325
  * Warm up the system
322
326
  */
package/dist/brainy.js CHANGED
@@ -22,6 +22,8 @@ import { NounType } from './types/graphTypes.js';
22
22
  /**
23
23
  * The main Brainy class - Clean, Beautiful, Powerful
24
24
  * REAL IMPLEMENTATION - No stubs, no mocks
25
+ *
26
+ * Implements BrainyInterface to ensure consistency across integrations
25
27
  */
26
28
  export class Brainy {
27
29
  constructor(config) {
@@ -135,8 +135,8 @@ export class ImportManager {
135
135
  _importedAt: new Date().toISOString(),
136
136
  _confidence: item.confidence
137
137
  };
138
- // Add to brain using proper API signature: addNoun(vectorOrData, nounType, metadata)
139
- const id = await this.brain.addNoun(dataToImport, nounType || 'content', metadata);
138
+ // Add to brain using modern API signature
139
+ const id = await this.brain.add({ data: dataToImport, type: nounType || 'content', metadata });
140
140
  result.nouns.push(id);
141
141
  result.stats.imported++;
142
142
  return id;
@@ -165,7 +165,13 @@ export class ImportManager {
165
165
  const match = await this.typeMatcher.matchVerbType({ id: rel.sourceId }, { id: rel.targetId }, rel.verbType);
166
166
  verbType = match.type;
167
167
  }
168
- const verbId = await this.brain.addVerb(rel.sourceId, rel.targetId, verbType, rel.metadata, rel.weight);
168
+ const verbId = await this.brain.relate({
169
+ from: rel.sourceId,
170
+ to: rel.targetId,
171
+ type: verbType,
172
+ metadata: rel.metadata,
173
+ weight: rel.weight
174
+ });
169
175
  result.verbs.push(verbId);
170
176
  result.stats.relationships++;
171
177
  }
@@ -6,6 +6,7 @@
6
6
  * and getting relationships.
7
7
  */
8
8
  import { v4 as uuidv4 } from '../universal/uuid.js';
9
+ import { NounType } from '../types/graphTypes.js';
9
10
  import { MCP_VERSION } from '../types/mcpTypes.js';
10
11
  export class BrainyMCPAdapter {
11
12
  /**
@@ -49,7 +50,7 @@ export class BrainyMCPAdapter {
49
50
  if (!id) {
50
51
  return this.createErrorResponse(request.requestId, 'MISSING_PARAMETER', 'Parameter "id" is required');
51
52
  }
52
- const noun = await this.brainyData.getNoun(id);
53
+ const noun = await this.brainyData.get(id);
53
54
  if (!noun) {
54
55
  return this.createErrorResponse(request.requestId, 'NOT_FOUND', `No noun found with id ${id}`);
55
56
  }
@@ -65,7 +66,7 @@ export class BrainyMCPAdapter {
65
66
  if (!query) {
66
67
  return this.createErrorResponse(request.requestId, 'MISSING_PARAMETER', 'Parameter "query" is required');
67
68
  }
68
- const results = await this.brainyData.searchText(query, k);
69
+ const results = await this.brainyData.find({ query, limit: k });
69
70
  return this.createSuccessResponse(request.requestId, results);
70
71
  }
71
72
  /**
@@ -78,8 +79,8 @@ export class BrainyMCPAdapter {
78
79
  if (!text) {
79
80
  return this.createErrorResponse(request.requestId, 'MISSING_PARAMETER', 'Parameter "text" is required');
80
81
  }
81
- // Add data directly using addNoun
82
- const id = await this.brainyData.addNoun(text, 'document', metadata);
82
+ // Add data using modern API (interface only supports modern methods)
83
+ const id = await this.brainyData.add({ data: text, type: NounType.Document, metadata });
83
84
  return this.createSuccessResponse(request.requestId, { id });
84
85
  }
85
86
  /**
@@ -2602,7 +2602,7 @@ export class ImprovedNeuralAPI {
2602
2602
  if (clusters.length === 0)
2603
2603
  break;
2604
2604
  try {
2605
- const noun = await this.brain.getNoun(itemId);
2605
+ const noun = await this.brain.get(itemId);
2606
2606
  const itemVector = noun?.vector || [];
2607
2607
  if (itemVector.length === 0)
2608
2608
  continue;
@@ -1,55 +1,48 @@
1
1
  /**
2
- * BrainyInterface
2
+ * BrainyInterface - Modern API Only
3
3
  *
4
- * This interface defines the methods from Brainy that are used by serverSearchAugmentations.ts.
5
- * It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
4
+ * This interface defines the MODERN methods from Brainy 3.0.
5
+ * Used to break circular dependencies while enforcing modern API usage.
6
+ *
7
+ * NO DEPRECATED METHODS - Only clean, modern API patterns.
6
8
  */
7
9
  import { Vector } from '../coreTypes.js';
10
+ import { AddParams, RelateParams, Result, Entity, FindParams, SimilarParams } from './brainy.types.js';
8
11
  export interface BrainyInterface<T = unknown> {
9
12
  /**
10
13
  * Initialize the database
11
14
  */
12
15
  init(): Promise<void>;
13
16
  /**
14
- * Get a noun by ID
15
- * @param id The ID of the noun to get
17
+ * Modern add method - unified entity creation
18
+ * @param params Parameters for adding entities
19
+ * @returns The ID of the created entity
16
20
  */
17
- getNoun(id: string): Promise<unknown>;
21
+ add(params: AddParams<T>): Promise<string>;
18
22
  /**
19
- * @deprecated Use add() instead - it's smart by default now
20
- * Add a noun (entity with vector and metadata) to the database
21
- * @param data Text string or vector representation (will auto-embed strings)
22
- * @param nounType Required noun type (one of 31 types)
23
- * @param metadata Optional metadata to associate with the noun
24
- * @returns The ID of the added noun
23
+ * Modern relate method - unified relationship creation
24
+ * @param params Parameters for creating relationships
25
+ * @returns The ID of the created relationship
25
26
  */
26
- addNoun(data: string | Vector, nounType: string, metadata?: T): Promise<string>;
27
+ relate(params: RelateParams<T>): Promise<string>;
27
28
  /**
28
- * Search for text in the database
29
- * @param text The text to search for
30
- * @param limit Maximum number of results to return
31
- * @returns Search results
29
+ * Modern find method - unified search and discovery
30
+ * @param query Search query or parameters object
31
+ * @returns Array of search results
32
32
  */
33
- searchText(text: string, limit?: number): Promise<unknown[]>;
33
+ find(query: string | FindParams<T>): Promise<Result<T>[]>;
34
34
  /**
35
- * @deprecated Use relate() instead
36
- * Create a relationship (verb) between two entities
37
- * @param sourceId The ID of the source entity
38
- * @param targetId The ID of the target entity
39
- * @param verbType The type of relationship
40
- * @param metadata Optional metadata about the relationship
41
- * @returns The ID of the created verb
35
+ * Modern get method - retrieve entities by ID
36
+ * @param id The entity ID to retrieve
37
+ * @returns Entity or null if not found
42
38
  */
43
- addVerb(sourceId: string, targetId: string, verbType: string, metadata?: unknown): Promise<string>;
39
+ get(id: string): Promise<Entity<T> | null>;
44
40
  /**
45
- * Find entities similar to a given entity ID
46
- * @param id ID of the entity to find similar entities for
47
- * @param options Additional options
48
- * @returns Array of search results with similarity scores
41
+ * Modern similar method - find similar entities
42
+ * @param params Parameters for similarity search
43
+ * @returns Array of similar entities with scores
49
44
  */
50
- findSimilar(id: string, options?: {
51
- limit?: number;
52
- }): Promise<unknown[]>;
45
+ similar(params: SimilarParams<T>): Promise<Result<T>[]>;
53
46
  /**
54
47
  * Generate embedding vector from text
55
48
  * @param text The text to embed
@@ -1,8 +1,10 @@
1
1
  /**
2
- * BrainyInterface
2
+ * BrainyInterface - Modern API Only
3
3
  *
4
- * This interface defines the methods from Brainy that are used by serverSearchAugmentations.ts.
5
- * It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
4
+ * This interface defines the MODERN methods from Brainy 3.0.
5
+ * Used to break circular dependencies while enforcing modern API usage.
6
+ *
7
+ * NO DEPRECATED METHODS - Only clean, modern API patterns.
6
8
  */
7
9
  export {};
8
10
  //# sourceMappingURL=brainyDataInterface.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
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",