@soulcraft/brainy 3.19.0 → 3.20.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/CHANGELOG.md +2 -0
- package/bin/brainy-minimal.js +82 -0
- package/bin/brainy.js +9 -2335
- package/dist/api/DataAPI.d.ts +1 -1
- package/dist/augmentations/cacheAugmentation.d.ts +1 -1
- package/dist/augmentations/metricsAugmentation.d.ts +20 -20
- package/dist/brainy.d.ts +1 -1
- package/dist/brainyData.js +1 -2
- package/dist/cli/catalog.js +8 -12
- package/dist/cli/commands/conversation.d.ts +22 -0
- package/dist/cli/commands/conversation.js +528 -0
- package/dist/cli/commands/core.d.ts +14 -2
- package/dist/cli/commands/core.js +195 -35
- package/dist/cli/commands/data.d.ts +29 -0
- package/dist/cli/commands/data.js +139 -0
- package/dist/cli/commands/neural.d.ts +14 -0
- package/dist/cli/commands/neural.js +18 -8
- package/dist/cli/commands/types.d.ts +30 -0
- package/dist/cli/commands/types.js +194 -0
- package/dist/cli/commands/utility.js +39 -98
- package/dist/cli/commands/vfs.d.ts +73 -0
- package/dist/cli/commands/vfs.js +372 -0
- package/dist/cli/index.js +244 -7
- package/dist/cli/interactive.d.ts +8 -3
- package/dist/cli/interactive.js +35 -11
- package/dist/hnsw/hnswIndexOptimized.d.ts +1 -1
- package/dist/mcp/brainyMCPBroadcast.d.ts +2 -2
- package/dist/mcp/brainyMCPBroadcast.js +1 -1
- package/dist/mcp/brainyMCPClient.js +8 -4
- package/dist/neural/types.d.ts +2 -2
- package/dist/streaming/pipeline.d.ts +1 -1
- package/dist/universal/fs.d.ts +24 -66
- package/package.json +5 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides consistent, delightful interactive prompts for all commands
|
|
5
5
|
* with smart defaults, validation, and helpful examples
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Brainy } from '../brainy.js';
|
|
8
8
|
export declare const colors: {
|
|
9
9
|
primary: import("chalk").ChalkInstance;
|
|
10
10
|
success: import("chalk").ChalkInstance;
|
|
@@ -50,7 +50,7 @@ export declare function promptSearchQuery(previousSearches?: string[]): Promise<
|
|
|
50
50
|
/**
|
|
51
51
|
* Interactive prompt for item ID with fuzzy search
|
|
52
52
|
*/
|
|
53
|
-
export declare function promptItemId(action: string, brain?:
|
|
53
|
+
export declare function promptItemId(action: string, brain?: Brainy, allowMultiple?: boolean): Promise<string | string[]>;
|
|
54
54
|
/**
|
|
55
55
|
* Confirm destructive action with preview
|
|
56
56
|
*/
|
|
@@ -74,7 +74,7 @@ export declare function promptFileOrUrl(action?: string): Promise<string>;
|
|
|
74
74
|
/**
|
|
75
75
|
* Interactive relationship builder
|
|
76
76
|
*/
|
|
77
|
-
export declare function promptRelationship(brain?:
|
|
77
|
+
export declare function promptRelationship(brain?: Brainy): Promise<{
|
|
78
78
|
source: string;
|
|
79
79
|
verb: string;
|
|
80
80
|
target: string;
|
|
@@ -108,6 +108,10 @@ export declare function showWelcome(): void;
|
|
|
108
108
|
* Interactive command selector for beginners
|
|
109
109
|
*/
|
|
110
110
|
export declare function promptCommand(): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Start interactive REPL mode
|
|
113
|
+
*/
|
|
114
|
+
export declare function startInteractiveMode(): Promise<void>;
|
|
111
115
|
/**
|
|
112
116
|
* Export all interactive components
|
|
113
117
|
*/
|
|
@@ -160,5 +164,6 @@ declare const _default: {
|
|
|
160
164
|
ProgressTracker: typeof ProgressTracker;
|
|
161
165
|
showWelcome: typeof showWelcome;
|
|
162
166
|
promptCommand: typeof promptCommand;
|
|
167
|
+
startInteractiveMode: typeof startInteractiveMode;
|
|
163
168
|
};
|
|
164
169
|
export default _default;
|
package/dist/cli/interactive.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import inquirer from 'inquirer';
|
|
9
|
-
import fuzzy from 'fuzzy'
|
|
9
|
+
// import fuzzy from 'fuzzy' // TODO: Install fuzzy package or remove dependency
|
|
10
10
|
import ora from 'ora';
|
|
11
|
+
import { getBrainyVersion } from '../utils/version.js';
|
|
11
12
|
// Professional color scheme
|
|
12
13
|
export const colors = {
|
|
13
14
|
primary: chalk.hex('#3A5F4A'), // Teal (from logo)
|
|
@@ -107,12 +108,12 @@ export async function promptItemId(action, brain, allowMultiple = false) {
|
|
|
107
108
|
let choices = [];
|
|
108
109
|
if (brain) {
|
|
109
110
|
try {
|
|
110
|
-
const recent = await brain.
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
const recent = await brain.find({
|
|
112
|
+
query: '*',
|
|
113
|
+
limit: 10
|
|
113
114
|
});
|
|
114
115
|
choices = recent.map(item => ({
|
|
115
|
-
name: `${item.id} - ${item.content?.substring(0, 50)}...`,
|
|
116
|
+
name: `${item.id} - ${item.content?.substring(0, 50) || 'No content'}...`,
|
|
116
117
|
value: item.id,
|
|
117
118
|
short: item.id
|
|
118
119
|
}));
|
|
@@ -312,7 +313,7 @@ export async function promptFileOrUrl(action = 'import') {
|
|
|
312
313
|
const data = await promptDataInput('import');
|
|
313
314
|
// Save to temp file and return path
|
|
314
315
|
const tmpFile = `/tmp/brainy-import-${Date.now()}.json`;
|
|
315
|
-
const { writeFileSync } = await import('fs');
|
|
316
|
+
const { writeFileSync } = await import('node:fs');
|
|
316
317
|
writeFileSync(tmpFile, data);
|
|
317
318
|
return tmpFile;
|
|
318
319
|
default:
|
|
@@ -331,7 +332,7 @@ async function promptFilePath(action) {
|
|
|
331
332
|
if (!input.trim()) {
|
|
332
333
|
return 'Please enter a file path';
|
|
333
334
|
}
|
|
334
|
-
const { existsSync } = await import('fs');
|
|
335
|
+
const { existsSync } = await import('node:fs');
|
|
335
336
|
if (action === 'import' && !existsSync(input)) {
|
|
336
337
|
return `File not found: ${input}`;
|
|
337
338
|
}
|
|
@@ -419,8 +420,21 @@ export async function promptRelationship(brain) {
|
|
|
419
420
|
* Smart command suggestions when user types wrong command
|
|
420
421
|
*/
|
|
421
422
|
export function suggestCommand(input, availableCommands) {
|
|
422
|
-
|
|
423
|
-
|
|
423
|
+
// Simple fuzzy matching without external dependency
|
|
424
|
+
// Filter commands that start with or contain the input
|
|
425
|
+
const matches = availableCommands
|
|
426
|
+
.filter(cmd => cmd.toLowerCase().includes(input.toLowerCase()))
|
|
427
|
+
.sort((a, b) => {
|
|
428
|
+
// Prefer commands that start with the input
|
|
429
|
+
const aStarts = a.toLowerCase().startsWith(input.toLowerCase());
|
|
430
|
+
const bStarts = b.toLowerCase().startsWith(input.toLowerCase());
|
|
431
|
+
if (aStarts && !bStarts)
|
|
432
|
+
return -1;
|
|
433
|
+
if (!aStarts && bStarts)
|
|
434
|
+
return 1;
|
|
435
|
+
return 0;
|
|
436
|
+
});
|
|
437
|
+
return matches.slice(0, 3);
|
|
424
438
|
}
|
|
425
439
|
/**
|
|
426
440
|
* Beautiful error display with helpful context
|
|
@@ -489,7 +503,7 @@ export function showWelcome() {
|
|
|
489
503
|
║ ║
|
|
490
504
|
╚══════════════════════════════════════════════╝
|
|
491
505
|
`));
|
|
492
|
-
console.log(colors.dim(
|
|
506
|
+
console.log(colors.dim(`Version ${getBrainyVersion()} • Type "help" for commands`));
|
|
493
507
|
console.log();
|
|
494
508
|
}
|
|
495
509
|
/**
|
|
@@ -518,6 +532,15 @@ export async function promptCommand() {
|
|
|
518
532
|
});
|
|
519
533
|
return command;
|
|
520
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Start interactive REPL mode
|
|
537
|
+
*/
|
|
538
|
+
export async function startInteractiveMode() {
|
|
539
|
+
console.log(chalk.cyan('\n🧠 Brainy Interactive Mode\n'));
|
|
540
|
+
console.log(chalk.yellow('Interactive REPL mode coming in v3.20.0\n'));
|
|
541
|
+
console.log(chalk.dim('Use specific commands for now: brainy add, brainy search, etc.'));
|
|
542
|
+
process.exit(0);
|
|
543
|
+
}
|
|
521
544
|
/**
|
|
522
545
|
* Export all interactive components
|
|
523
546
|
*/
|
|
@@ -537,6 +560,7 @@ export default {
|
|
|
537
560
|
showError,
|
|
538
561
|
ProgressTracker,
|
|
539
562
|
showWelcome,
|
|
540
|
-
promptCommand
|
|
563
|
+
promptCommand,
|
|
564
|
+
startInteractiveMode
|
|
541
565
|
};
|
|
542
566
|
//# sourceMappingURL=interactive.js.map
|
|
@@ -96,7 +96,7 @@ export declare class HNSWIndexOptimized extends HNSWIndex {
|
|
|
96
96
|
private vectorCount;
|
|
97
97
|
private memoryUpdateLock;
|
|
98
98
|
private unifiedCache;
|
|
99
|
-
constructor(config: Partial<HNSWOptimizedConfig
|
|
99
|
+
constructor(config: Partial<HNSWOptimizedConfig>, distanceFunction: DistanceFunction, storage?: StorageAdapter | null);
|
|
100
100
|
/**
|
|
101
101
|
* Thread-safe method to update memory usage
|
|
102
102
|
* @param memoryDelta Change in memory usage (can be negative)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Works both locally and with cloud deployment
|
|
12
12
|
*/
|
|
13
13
|
import { BrainyMCPService } from './brainyMCPService.js';
|
|
14
|
-
import {
|
|
14
|
+
import { BrainyInterface } from '../types/brainyDataInterface.js';
|
|
15
15
|
import { MCPServiceOptions } from '../types/mcpTypes.js';
|
|
16
16
|
interface BroadcastMessage {
|
|
17
17
|
id: string;
|
|
@@ -28,7 +28,7 @@ export declare class BrainyMCPBroadcast extends BrainyMCPService {
|
|
|
28
28
|
private agents;
|
|
29
29
|
private messageHistory;
|
|
30
30
|
private maxHistorySize;
|
|
31
|
-
constructor(brainyData:
|
|
31
|
+
constructor(brainyData: BrainyInterface, options?: MCPServiceOptions & {
|
|
32
32
|
broadcastPort?: number;
|
|
33
33
|
cloudUrl?: string;
|
|
34
34
|
});
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Works both locally and with cloud deployment
|
|
12
12
|
*/
|
|
13
13
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
14
|
-
import { createServer } from 'http';
|
|
14
|
+
import { createServer } from 'node:http';
|
|
15
15
|
import { BrainyMCPService } from './brainyMCPService.js';
|
|
16
16
|
import { v4 as uuidv4 } from '../universal/uuid.js';
|
|
17
17
|
export class BrainyMCPBroadcast extends BrainyMCPService {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Utilizes Brainy for persistent memory and vector search capabilities
|
|
6
6
|
*/
|
|
7
7
|
import WebSocket from 'ws';
|
|
8
|
-
import {
|
|
8
|
+
import { Brainy } from '../brainy.js';
|
|
9
9
|
import { v4 as uuidv4 } from '../universal/uuid.js';
|
|
10
10
|
export class BrainyMCPClient {
|
|
11
11
|
constructor(options) {
|
|
@@ -23,7 +23,7 @@ export class BrainyMCPClient {
|
|
|
23
23
|
*/
|
|
24
24
|
async initBrainy() {
|
|
25
25
|
if (this.options.useBrainyMemory && !this.brainy) {
|
|
26
|
-
this.brainy = new
|
|
26
|
+
this.brainy = new Brainy({
|
|
27
27
|
storage: {
|
|
28
28
|
requestPersistentStorage: true
|
|
29
29
|
}
|
|
@@ -95,7 +95,8 @@ export class BrainyMCPClient {
|
|
|
95
95
|
to: message.to,
|
|
96
96
|
timestamp: message.timestamp,
|
|
97
97
|
type: message.type,
|
|
98
|
-
event: message.event
|
|
98
|
+
event: message.event,
|
|
99
|
+
category: 'Message'
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
@@ -111,7 +112,10 @@ export class BrainyMCPClient {
|
|
|
111
112
|
for (const histMsg of message.data.history) {
|
|
112
113
|
await this.brainy.add({
|
|
113
114
|
text: `${histMsg.from}: ${JSON.stringify(histMsg.data)}`,
|
|
114
|
-
metadata:
|
|
115
|
+
metadata: {
|
|
116
|
+
...histMsg,
|
|
117
|
+
category: 'Message'
|
|
118
|
+
}
|
|
115
119
|
});
|
|
116
120
|
}
|
|
117
121
|
}
|
package/dist/neural/types.d.ts
CHANGED
|
@@ -267,8 +267,8 @@ export interface StreamingBatch<T = SemanticCluster> {
|
|
|
267
267
|
}
|
|
268
268
|
export declare class NeuralAPIError extends Error {
|
|
269
269
|
code: string;
|
|
270
|
-
context?: Record<string, any
|
|
271
|
-
constructor(message: string, code: string, context?: Record<string, any>
|
|
270
|
+
context?: Record<string, any>;
|
|
271
|
+
constructor(message: string, code: string, context?: Record<string, any>);
|
|
272
272
|
}
|
|
273
273
|
export declare class ClusteringError extends NeuralAPIError {
|
|
274
274
|
constructor(message: string, context?: Record<string, any>);
|
|
@@ -43,7 +43,7 @@ export declare class Pipeline<T = any> {
|
|
|
43
43
|
private running;
|
|
44
44
|
private abortController?;
|
|
45
45
|
private metrics;
|
|
46
|
-
constructor(brainyInstance?:
|
|
46
|
+
constructor(brainyInstance?: Brainy | Brainy<any>);
|
|
47
47
|
/**
|
|
48
48
|
* Add a data source
|
|
49
49
|
*/
|
package/dist/universal/fs.d.ts
CHANGED
|
@@ -28,74 +28,32 @@ export interface UniversalFS {
|
|
|
28
28
|
}>;
|
|
29
29
|
access(path: string, mode?: number): Promise<void>;
|
|
30
30
|
}
|
|
31
|
-
export declare const readFile:
|
|
32
|
-
export declare const writeFile:
|
|
33
|
-
export declare const mkdir:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
38
|
-
|
|
39
|
-
(path: string, options: {
|
|
40
|
-
withFileTypes: true;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
name: string;
|
|
43
|
-
isDirectory(): boolean;
|
|
44
|
-
isFile(): boolean;
|
|
45
|
-
}[]>;
|
|
46
|
-
};
|
|
47
|
-
export declare const unlink: (path: string) => Promise<void>;
|
|
48
|
-
export declare const stat: (path: string) => Promise<{
|
|
49
|
-
isFile(): boolean;
|
|
50
|
-
isDirectory(): boolean;
|
|
51
|
-
}>;
|
|
52
|
-
export declare const access: (path: string, mode?: number) => Promise<void>;
|
|
31
|
+
export declare const readFile: any;
|
|
32
|
+
export declare const writeFile: any;
|
|
33
|
+
export declare const mkdir: any;
|
|
34
|
+
export declare const exists: any;
|
|
35
|
+
export declare const readdir: any;
|
|
36
|
+
export declare const unlink: any;
|
|
37
|
+
export declare const stat: any;
|
|
38
|
+
export declare const access: any;
|
|
53
39
|
declare const _default: {
|
|
54
|
-
readFile:
|
|
55
|
-
writeFile:
|
|
56
|
-
mkdir:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(path: string, options: {
|
|
63
|
-
withFileTypes: true;
|
|
64
|
-
}): Promise<{
|
|
65
|
-
name: string;
|
|
66
|
-
isDirectory(): boolean;
|
|
67
|
-
isFile(): boolean;
|
|
68
|
-
}[]>;
|
|
69
|
-
};
|
|
70
|
-
unlink: (path: string) => Promise<void>;
|
|
71
|
-
stat: (path: string) => Promise<{
|
|
72
|
-
isFile(): boolean;
|
|
73
|
-
isDirectory(): boolean;
|
|
74
|
-
}>;
|
|
75
|
-
access: (path: string, mode?: number) => Promise<void>;
|
|
40
|
+
readFile: any;
|
|
41
|
+
writeFile: any;
|
|
42
|
+
mkdir: any;
|
|
43
|
+
exists: any;
|
|
44
|
+
readdir: any;
|
|
45
|
+
unlink: any;
|
|
46
|
+
stat: any;
|
|
47
|
+
access: any;
|
|
76
48
|
};
|
|
77
49
|
export default _default;
|
|
78
50
|
export declare const promises: {
|
|
79
|
-
readFile:
|
|
80
|
-
writeFile:
|
|
81
|
-
mkdir:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(path: string, options: {
|
|
88
|
-
withFileTypes: true;
|
|
89
|
-
}): Promise<{
|
|
90
|
-
name: string;
|
|
91
|
-
isDirectory(): boolean;
|
|
92
|
-
isFile(): boolean;
|
|
93
|
-
}[]>;
|
|
94
|
-
};
|
|
95
|
-
unlink: (path: string) => Promise<void>;
|
|
96
|
-
stat: (path: string) => Promise<{
|
|
97
|
-
isFile(): boolean;
|
|
98
|
-
isDirectory(): boolean;
|
|
99
|
-
}>;
|
|
100
|
-
access: (path: string, mode?: number) => Promise<void>;
|
|
51
|
+
readFile: any;
|
|
52
|
+
writeFile: any;
|
|
53
|
+
mkdir: any;
|
|
54
|
+
exists: any;
|
|
55
|
+
readdir: any;
|
|
56
|
+
unlink: any;
|
|
57
|
+
stat: any;
|
|
58
|
+
access: any;
|
|
101
59
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"node": "22.x"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
-
"build": "npm run build:patterns:if-needed && tsc",
|
|
58
|
+
"build": "npm run build:patterns:if-needed && tsc && tsc -p tsconfig.cli.json",
|
|
59
59
|
"build:patterns": "tsx scripts/buildEmbeddedPatterns.ts",
|
|
60
60
|
"build:patterns:if-needed": "node scripts/check-patterns.cjs || npm run build:patterns",
|
|
61
61
|
"build:patterns:force": "npm run build:patterns",
|
|
@@ -128,6 +128,9 @@
|
|
|
128
128
|
"README.md",
|
|
129
129
|
"CHANGELOG.md"
|
|
130
130
|
],
|
|
131
|
+
"overrides": {
|
|
132
|
+
"boolean": "3.2.0"
|
|
133
|
+
},
|
|
131
134
|
"devDependencies": {
|
|
132
135
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
133
136
|
"@rollup/plugin-node-resolve": "^16.0.1",
|