@soulcraft/brainy 3.19.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.
- package/CHANGELOG.md +2 -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.js +61 -17
- package/dist/cli/commands/neural.js +4 -5
- package/dist/cli/commands/types.d.ts +30 -0
- package/dist/cli/commands/types.js +194 -0
- package/dist/cli/commands/utility.js +2 -3
- package/dist/cli/index.js +44 -2
- package/dist/cli/interactive.d.ts +3 -3
- package/dist/cli/interactive.js +5 -5
- 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 +2 -2
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import inquirer from 'inquirer';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import ora from 'ora';
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import {
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { Brainy } from '../../brainyData.js';
|
|
12
12
|
import { NeuralAPI } from '../../neural/neuralAPI.js';
|
|
13
13
|
export const neuralCommand = {
|
|
14
14
|
command: 'neural [action]',
|
|
@@ -79,7 +79,7 @@ export const neuralCommand = {
|
|
|
79
79
|
console.log(chalk.cyan('\n🧠 NEURAL SIMILARITY API'));
|
|
80
80
|
console.log(chalk.gray('━'.repeat(50)));
|
|
81
81
|
// Initialize Brainy and Neural API
|
|
82
|
-
const brain = new
|
|
82
|
+
const brain = new Brainy();
|
|
83
83
|
const neural = new NeuralAPI(brain);
|
|
84
84
|
try {
|
|
85
85
|
const action = argv.action || await promptForAction();
|
|
@@ -505,4 +505,3 @@ function showHelp() {
|
|
|
505
505
|
console.log('');
|
|
506
506
|
}
|
|
507
507
|
export default neuralCommand;
|
|
508
|
-
//# sourceMappingURL=neural.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Commands for Type Management
|
|
3
|
+
* Consistent with BrainyTypes public API
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* List types - matches BrainyTypes.nouns and BrainyTypes.verbs
|
|
7
|
+
* Usage: brainy types
|
|
8
|
+
*/
|
|
9
|
+
export declare function types(options: {
|
|
10
|
+
json?: boolean;
|
|
11
|
+
noun?: boolean;
|
|
12
|
+
verb?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Suggest type - matches BrainyTypes.suggestNoun() and suggestVerb()
|
|
16
|
+
* Usage: brainy suggest <data>
|
|
17
|
+
* Interactive if data not provided
|
|
18
|
+
*/
|
|
19
|
+
export declare function suggest(data?: string, options?: {
|
|
20
|
+
verb?: boolean;
|
|
21
|
+
json?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Validate type - matches BrainyTypes.isValidNoun() and isValidVerb()
|
|
25
|
+
* Usage: brainy validate <type>
|
|
26
|
+
*/
|
|
27
|
+
export declare function validate(type?: string, options?: {
|
|
28
|
+
verb?: boolean;
|
|
29
|
+
json?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Commands for Type Management
|
|
3
|
+
* Consistent with BrainyTypes public API
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import { BrainyTypes } from '../../index.js';
|
|
9
|
+
/**
|
|
10
|
+
* List types - matches BrainyTypes.nouns and BrainyTypes.verbs
|
|
11
|
+
* Usage: brainy types
|
|
12
|
+
*/
|
|
13
|
+
export async function types(options) {
|
|
14
|
+
try {
|
|
15
|
+
// Default to showing both if neither flag specified
|
|
16
|
+
const showNouns = options.noun || (!options.noun && !options.verb);
|
|
17
|
+
const showVerbs = options.verb || (!options.noun && !options.verb);
|
|
18
|
+
const result = {};
|
|
19
|
+
if (showNouns)
|
|
20
|
+
result.nouns = BrainyTypes.nouns;
|
|
21
|
+
if (showVerbs)
|
|
22
|
+
result.verbs = BrainyTypes.verbs;
|
|
23
|
+
if (options.json) {
|
|
24
|
+
console.log(JSON.stringify(result, null, 2));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Display nouns
|
|
28
|
+
if (showNouns) {
|
|
29
|
+
console.log(chalk.bold.cyan('\n📚 Noun Types (31):\n'));
|
|
30
|
+
const nounChunks = [];
|
|
31
|
+
for (let i = 0; i < BrainyTypes.nouns.length; i += 3) {
|
|
32
|
+
nounChunks.push(BrainyTypes.nouns.slice(i, i + 3));
|
|
33
|
+
}
|
|
34
|
+
for (const chunk of nounChunks) {
|
|
35
|
+
console.log(' ' + chunk.map(n => chalk.green(n.padEnd(20))).join(''));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Display verbs
|
|
39
|
+
if (showVerbs) {
|
|
40
|
+
console.log(chalk.bold.cyan('\n🔗 Verb Types (40):\n'));
|
|
41
|
+
const verbChunks = [];
|
|
42
|
+
for (let i = 0; i < BrainyTypes.verbs.length; i += 3) {
|
|
43
|
+
verbChunks.push(BrainyTypes.verbs.slice(i, i + 3));
|
|
44
|
+
}
|
|
45
|
+
for (const chunk of verbChunks) {
|
|
46
|
+
console.log(' ' + chunk.map(v => chalk.blue(v.padEnd(20))).join(''));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
console.log(chalk.dim('\n💡 Use "brainy suggest <data>" to get AI-powered type suggestions'));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(chalk.red('Error:', error.message));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Suggest type - matches BrainyTypes.suggestNoun() and suggestVerb()
|
|
58
|
+
* Usage: brainy suggest <data>
|
|
59
|
+
* Interactive if data not provided
|
|
60
|
+
*/
|
|
61
|
+
export async function suggest(data, options = {}) {
|
|
62
|
+
try {
|
|
63
|
+
// Interactive mode if no data provided
|
|
64
|
+
if (!data) {
|
|
65
|
+
const answers = await inquirer.prompt([
|
|
66
|
+
{
|
|
67
|
+
type: 'list',
|
|
68
|
+
name: 'kind',
|
|
69
|
+
message: 'What type do you want to suggest?',
|
|
70
|
+
choices: ['Noun', 'Verb'],
|
|
71
|
+
default: 'Noun'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'data',
|
|
76
|
+
message: 'Enter data (JSON or text):',
|
|
77
|
+
validate: (input) => input.length > 0 || 'Data is required'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: 'input',
|
|
81
|
+
name: 'hint',
|
|
82
|
+
message: 'Relationship hint (optional):',
|
|
83
|
+
when: (answers) => answers.kind === 'Verb'
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
data = answers.data;
|
|
87
|
+
options.verb = answers.kind === 'Verb';
|
|
88
|
+
// For verbs, parse source/target if provided as JSON
|
|
89
|
+
if (options.verb && answers.hint) {
|
|
90
|
+
data = JSON.stringify({ hint: answers.hint });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const spinner = ora('Analyzing with AI...').start();
|
|
94
|
+
let parsedData;
|
|
95
|
+
try {
|
|
96
|
+
parsedData = JSON.parse(data);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
parsedData = { content: data };
|
|
100
|
+
}
|
|
101
|
+
let suggestion;
|
|
102
|
+
if (options.verb) {
|
|
103
|
+
// For verb suggestions, need source and target
|
|
104
|
+
const source = parsedData.source || { type: 'unknown' };
|
|
105
|
+
const target = parsedData.target || { type: 'unknown' };
|
|
106
|
+
const hint = parsedData.hint || parsedData.relationship || parsedData.verb;
|
|
107
|
+
suggestion = await BrainyTypes.suggestVerb(source, target, hint);
|
|
108
|
+
spinner.succeed('Verb type analyzed');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
suggestion = await BrainyTypes.suggestNoun(parsedData);
|
|
112
|
+
spinner.succeed('Noun type analyzed');
|
|
113
|
+
}
|
|
114
|
+
if (options.json) {
|
|
115
|
+
console.log(JSON.stringify(suggestion, null, 2));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// Display results
|
|
119
|
+
console.log(chalk.bold.green(`\n✨ Suggested: ${suggestion.type}`));
|
|
120
|
+
console.log(chalk.cyan(`Confidence: ${(suggestion.confidence * 100).toFixed(1)}%`));
|
|
121
|
+
if (suggestion.alternatives && suggestion.alternatives.length > 0) {
|
|
122
|
+
console.log(chalk.yellow('\nAlternatives:'));
|
|
123
|
+
for (const alt of suggestion.alternatives.slice(0, 3)) {
|
|
124
|
+
console.log(` ${alt.type} (${(alt.confidence * 100).toFixed(1)}%)`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error(chalk.red('Error:', error.message));
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Validate type - matches BrainyTypes.isValidNoun() and isValidVerb()
|
|
135
|
+
* Usage: brainy validate <type>
|
|
136
|
+
*/
|
|
137
|
+
export async function validate(type, options = {}) {
|
|
138
|
+
try {
|
|
139
|
+
// Interactive mode if no type provided
|
|
140
|
+
if (!type) {
|
|
141
|
+
const answers = await inquirer.prompt([
|
|
142
|
+
{
|
|
143
|
+
type: 'list',
|
|
144
|
+
name: 'kind',
|
|
145
|
+
message: 'Validate as:',
|
|
146
|
+
choices: ['Noun Type', 'Verb Type'],
|
|
147
|
+
default: 'Noun Type'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'input',
|
|
151
|
+
name: 'type',
|
|
152
|
+
message: 'Enter type to validate:',
|
|
153
|
+
validate: (input) => input.length > 0 || 'Type is required'
|
|
154
|
+
}
|
|
155
|
+
]);
|
|
156
|
+
type = answers.type;
|
|
157
|
+
options.verb = answers.kind === 'Verb Type';
|
|
158
|
+
}
|
|
159
|
+
const isValid = options.verb
|
|
160
|
+
? BrainyTypes.isValidVerb(type)
|
|
161
|
+
: BrainyTypes.isValidNoun(type);
|
|
162
|
+
if (options.json) {
|
|
163
|
+
console.log(JSON.stringify({
|
|
164
|
+
type,
|
|
165
|
+
kind: options.verb ? 'verb' : 'noun',
|
|
166
|
+
valid: isValid
|
|
167
|
+
}, null, 2));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (isValid) {
|
|
171
|
+
console.log(chalk.green(`✅ "${type}" is valid`));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log(chalk.red(`❌ "${type}" is invalid`));
|
|
175
|
+
// Show valid options
|
|
176
|
+
const validTypes = options.verb ? BrainyTypes.verbs : BrainyTypes.nouns;
|
|
177
|
+
const similar = validTypes.filter(t => t.toLowerCase().includes(type.toLowerCase()) ||
|
|
178
|
+
type.toLowerCase().includes(t.toLowerCase())).slice(0, 5);
|
|
179
|
+
if (similar.length > 0) {
|
|
180
|
+
console.log(chalk.yellow('\nDid you mean:'));
|
|
181
|
+
similar.forEach(s => console.log(` ${s}`));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
console.log(chalk.dim(`\nRun "brainy types" to see all valid types`));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
process.exit(isValid ? 0 : 1);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error(chalk.red('Error:', error.message));
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import ora from 'ora';
|
|
8
8
|
import Table from 'cli-table3';
|
|
9
|
-
import {
|
|
9
|
+
import { Brainy } from '../../brainyData.js';
|
|
10
10
|
let brainyInstance = null;
|
|
11
11
|
const getBrainy = async () => {
|
|
12
12
|
if (!brainyInstance) {
|
|
13
|
-
brainyInstance = new
|
|
13
|
+
brainyInstance = new Brainy();
|
|
14
14
|
await brainyInstance.init();
|
|
15
15
|
}
|
|
16
16
|
return brainyInstance;
|
|
@@ -273,4 +273,3 @@ export const utilityCommands = {
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
//# sourceMappingURL=utility.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -9,7 +9,13 @@ import chalk from 'chalk';
|
|
|
9
9
|
import { neuralCommands } from './commands/neural.js';
|
|
10
10
|
import { coreCommands } from './commands/core.js';
|
|
11
11
|
import { utilityCommands } from './commands/utility.js';
|
|
12
|
-
import
|
|
12
|
+
import conversationCommand from './commands/conversation.js';
|
|
13
|
+
import { readFileSync } from 'fs';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import { dirname, join } from 'path';
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
18
|
+
const version = packageJson.version;
|
|
13
19
|
// CLI Configuration
|
|
14
20
|
const program = new Command();
|
|
15
21
|
program
|
|
@@ -115,6 +121,43 @@ program
|
|
|
115
121
|
.option('--dimensions <number>', '2D or 3D', '2')
|
|
116
122
|
.option('-o, --output <file>', 'Output file')
|
|
117
123
|
.action(neuralCommands.visualize);
|
|
124
|
+
// ===== Conversation Commands (Infinite Memory) =====
|
|
125
|
+
program
|
|
126
|
+
.command('conversation')
|
|
127
|
+
.alias('conv')
|
|
128
|
+
.description('💬 Infinite agent memory and context management')
|
|
129
|
+
.addCommand(new Command('setup')
|
|
130
|
+
.description('Set up MCP server for Claude Code integration')
|
|
131
|
+
.action(async () => {
|
|
132
|
+
await conversationCommand.handler({ action: 'setup', _: [] });
|
|
133
|
+
}))
|
|
134
|
+
.addCommand(new Command('search')
|
|
135
|
+
.description('Search messages across conversations')
|
|
136
|
+
.requiredOption('-q, --query <query>', 'Search query')
|
|
137
|
+
.option('-c, --conversation-id <id>', 'Filter by conversation')
|
|
138
|
+
.option('-r, --role <role>', 'Filter by role')
|
|
139
|
+
.option('-l, --limit <number>', 'Maximum results', '10')
|
|
140
|
+
.action(async (options) => {
|
|
141
|
+
await conversationCommand.handler({ action: 'search', ...options, _: [] });
|
|
142
|
+
}))
|
|
143
|
+
.addCommand(new Command('context')
|
|
144
|
+
.description('Get relevant context for a query')
|
|
145
|
+
.requiredOption('-q, --query <query>', 'Context query')
|
|
146
|
+
.option('-l, --limit <number>', 'Maximum messages', '10')
|
|
147
|
+
.action(async (options) => {
|
|
148
|
+
await conversationCommand.handler({ action: 'context', ...options, _: [] });
|
|
149
|
+
}))
|
|
150
|
+
.addCommand(new Command('thread')
|
|
151
|
+
.description('Get full conversation thread')
|
|
152
|
+
.requiredOption('-c, --conversation-id <id>', 'Conversation ID')
|
|
153
|
+
.action(async (options) => {
|
|
154
|
+
await conversationCommand.handler({ action: 'thread', ...options, _: [] });
|
|
155
|
+
}))
|
|
156
|
+
.addCommand(new Command('stats')
|
|
157
|
+
.description('Show conversation statistics')
|
|
158
|
+
.action(async () => {
|
|
159
|
+
await conversationCommand.handler({ action: 'stats', _: [] });
|
|
160
|
+
}));
|
|
118
161
|
// ===== Utility Commands =====
|
|
119
162
|
program
|
|
120
163
|
.command('stats')
|
|
@@ -164,4 +207,3 @@ catch (error) {
|
|
|
164
207
|
if (!process.argv.slice(2).length) {
|
|
165
208
|
program.outputHelp();
|
|
166
209
|
}
|
|
167
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -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;
|
package/dist/cli/interactive.js
CHANGED
|
@@ -8,6 +8,7 @@ import chalk from 'chalk';
|
|
|
8
8
|
import inquirer from 'inquirer';
|
|
9
9
|
import fuzzy from 'fuzzy';
|
|
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,7 +108,7 @@ export async function promptItemId(action, brain, allowMultiple = false) {
|
|
|
107
108
|
let choices = [];
|
|
108
109
|
if (brain) {
|
|
109
110
|
try {
|
|
110
|
-
const recent = await brain.search('*', 10,
|
|
111
|
+
const recent = await brain.search('*', { limit: 10,
|
|
111
112
|
sortBy: 'timestamp',
|
|
112
113
|
descending: true
|
|
113
114
|
});
|
|
@@ -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
|
}
|
|
@@ -489,7 +490,7 @@ export function showWelcome() {
|
|
|
489
490
|
║ ║
|
|
490
491
|
╚══════════════════════════════════════════════╝
|
|
491
492
|
`));
|
|
492
|
-
console.log(colors.dim(
|
|
493
|
+
console.log(colors.dim(`Version ${getBrainyVersion()} • Type "help" for commands`));
|
|
493
494
|
console.log();
|
|
494
495
|
}
|
|
495
496
|
/**
|
|
@@ -539,4 +540,3 @@ export default {
|
|
|
539
540
|
showWelcome,
|
|
540
541
|
promptCommand
|
|
541
542
|
};
|
|
542
|
-
//# 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.19.
|
|
3
|
+
"version": "3.19.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",
|
|
@@ -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",
|