@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.
- package/CHANGELOG.md +4 -0
- package/README.md +52 -3
- 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 +19 -1
- package/dist/brainy.js +24 -0
- 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/conversation/conversationManager.d.ts +176 -0
- package/dist/conversation/conversationManager.js +666 -0
- package/dist/conversation/index.d.ts +8 -0
- package/dist/conversation/index.js +8 -0
- package/dist/conversation/types.d.ts +231 -0
- package/dist/conversation/types.js +8 -0
- package/dist/hnsw/hnswIndexOptimized.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/mcp/brainyMCPBroadcast.d.ts +2 -2
- package/dist/mcp/brainyMCPBroadcast.js +1 -1
- package/dist/mcp/brainyMCPClient.js +8 -4
- package/dist/mcp/conversationTools.d.ts +88 -0
- package/dist/mcp/conversationTools.js +470 -0
- package/dist/neural/types.d.ts +2 -2
- package/dist/streaming/pipeline.d.ts +1 -1
- package/dist/types/mcpTypes.d.ts +7 -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
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConversationManager - Infinite Agent Memory
|
|
3
|
+
*
|
|
4
|
+
* Production-ready conversation and context management for AI agents.
|
|
5
|
+
* Built on Brainy's existing infrastructure: Triple Intelligence, Neural API, VFS.
|
|
6
|
+
*
|
|
7
|
+
* REAL IMPLEMENTATION - No stubs, no mocks, no TODOs
|
|
8
|
+
*/
|
|
9
|
+
import { Brainy } from '../brainy.js';
|
|
10
|
+
import { MessageRole, ConversationThread, ConversationContext, SaveMessageOptions, ContextRetrievalOptions, ConversationSearchOptions, ConversationSearchResult, ConversationTheme, ArtifactOptions, ConversationStats } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* ConversationManager - High-level API for conversation operations
|
|
13
|
+
*
|
|
14
|
+
* Uses existing Brainy infrastructure:
|
|
15
|
+
* - brain.add() for messages
|
|
16
|
+
* - brain.relate() for threading
|
|
17
|
+
* - brain.find() with Triple Intelligence for context
|
|
18
|
+
* - brain.neural for clustering and similarity
|
|
19
|
+
* - brain.vfs() for artifacts
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConversationManager {
|
|
22
|
+
private brain;
|
|
23
|
+
private initialized;
|
|
24
|
+
private _vfs;
|
|
25
|
+
/**
|
|
26
|
+
* Create a ConversationManager instance
|
|
27
|
+
* @param brain Brainy instance to use
|
|
28
|
+
*/
|
|
29
|
+
constructor(brain: Brainy);
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the conversation manager
|
|
32
|
+
* Lazy initialization pattern - only called when first used
|
|
33
|
+
*/
|
|
34
|
+
init(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Save a message to the conversation history
|
|
37
|
+
*
|
|
38
|
+
* Uses: brain.add() with NounType.Message
|
|
39
|
+
* Real implementation - stores message with embedding
|
|
40
|
+
*
|
|
41
|
+
* @param content Message content
|
|
42
|
+
* @param role Message role (user, assistant, system, tool)
|
|
43
|
+
* @param options Save options (conversationId, metadata, etc.)
|
|
44
|
+
* @returns Message ID
|
|
45
|
+
*/
|
|
46
|
+
saveMessage(content: string, role: MessageRole, options?: SaveMessageOptions): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Link two messages in temporal sequence
|
|
49
|
+
*
|
|
50
|
+
* Uses: brain.relate() with VerbType.Precedes
|
|
51
|
+
* Real implementation - creates graph relationship
|
|
52
|
+
*
|
|
53
|
+
* @param prevMessageId ID of previous message
|
|
54
|
+
* @param nextMessageId ID of next message
|
|
55
|
+
* @returns Relationship ID
|
|
56
|
+
*/
|
|
57
|
+
linkMessages(prevMessageId: string, nextMessageId: string): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Get a full conversation thread
|
|
60
|
+
*
|
|
61
|
+
* Uses: brain.getNoun() and brain.getConnections()
|
|
62
|
+
* Real implementation - traverses graph relationships
|
|
63
|
+
*
|
|
64
|
+
* @param conversationId Conversation ID
|
|
65
|
+
* @param options Options (includeArtifacts, etc.)
|
|
66
|
+
* @returns Complete conversation thread
|
|
67
|
+
*/
|
|
68
|
+
getConversationThread(conversationId: string, options?: {
|
|
69
|
+
includeArtifacts?: boolean;
|
|
70
|
+
}): Promise<ConversationThread>;
|
|
71
|
+
/**
|
|
72
|
+
* Get relevant context for a query
|
|
73
|
+
*
|
|
74
|
+
* Uses: brain.find() with Triple Intelligence
|
|
75
|
+
* Real implementation - semantic + temporal + graph ranking
|
|
76
|
+
*
|
|
77
|
+
* @param query Query string or context options
|
|
78
|
+
* @param options Retrieval options
|
|
79
|
+
* @returns Ranked context messages with artifacts
|
|
80
|
+
*/
|
|
81
|
+
getRelevantContext(query: string | ContextRetrievalOptions, options?: ContextRetrievalOptions): Promise<ConversationContext>;
|
|
82
|
+
/**
|
|
83
|
+
* Search messages semantically
|
|
84
|
+
*
|
|
85
|
+
* Uses: brain.find() with semantic search
|
|
86
|
+
* Real implementation - vector similarity search
|
|
87
|
+
*
|
|
88
|
+
* @param options Search options
|
|
89
|
+
* @returns Search results with scores
|
|
90
|
+
*/
|
|
91
|
+
searchMessages(options: ConversationSearchOptions): Promise<ConversationSearchResult[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Find similar conversations using Neural API
|
|
94
|
+
*
|
|
95
|
+
* Uses: brain.neural.neighbors()
|
|
96
|
+
* Real implementation - semantic similarity with embeddings
|
|
97
|
+
*
|
|
98
|
+
* @param conversationId Conversation ID to find similar to
|
|
99
|
+
* @param limit Maximum number of similar conversations
|
|
100
|
+
* @param threshold Minimum similarity threshold
|
|
101
|
+
* @returns Similar conversations with relevance scores
|
|
102
|
+
*/
|
|
103
|
+
findSimilarConversations(conversationId: string, limit?: number, threshold?: number): Promise<Array<{
|
|
104
|
+
id: string;
|
|
105
|
+
relevance: number;
|
|
106
|
+
metadata?: any;
|
|
107
|
+
}>>;
|
|
108
|
+
/**
|
|
109
|
+
* Get conversation themes via clustering
|
|
110
|
+
*
|
|
111
|
+
* Uses: brain.neural.clusters()
|
|
112
|
+
* Real implementation - semantic clustering
|
|
113
|
+
*
|
|
114
|
+
* @param conversationId Conversation ID
|
|
115
|
+
* @returns Discovered themes
|
|
116
|
+
*/
|
|
117
|
+
getConversationThemes(conversationId: string): Promise<ConversationTheme[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Save an artifact (code, file, etc.) to VFS
|
|
120
|
+
*
|
|
121
|
+
* Uses: brain.vfs()
|
|
122
|
+
* Real implementation - stores in virtual filesystem
|
|
123
|
+
*
|
|
124
|
+
* @param path VFS path
|
|
125
|
+
* @param content File content
|
|
126
|
+
* @param options Artifact options
|
|
127
|
+
* @returns Artifact entity ID
|
|
128
|
+
*/
|
|
129
|
+
saveArtifact(path: string, content: string | Buffer, options: ArtifactOptions): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Get conversation statistics
|
|
132
|
+
*
|
|
133
|
+
* Uses: brain.find() with aggregations
|
|
134
|
+
* Real implementation - queries and aggregates data
|
|
135
|
+
*
|
|
136
|
+
* @param conversationId Optional conversation ID to filter
|
|
137
|
+
* @returns Conversation statistics
|
|
138
|
+
*/
|
|
139
|
+
getConversationStats(conversationId?: string): Promise<ConversationStats>;
|
|
140
|
+
/**
|
|
141
|
+
* Delete a message
|
|
142
|
+
*
|
|
143
|
+
* Uses: brain.deleteNoun()
|
|
144
|
+
* Real implementation - removes from graph
|
|
145
|
+
*
|
|
146
|
+
* @param messageId Message ID to delete
|
|
147
|
+
*/
|
|
148
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Export conversation to JSON
|
|
151
|
+
*
|
|
152
|
+
* Uses: getConversationThread()
|
|
153
|
+
* Real implementation - serializes conversation
|
|
154
|
+
*
|
|
155
|
+
* @param conversationId Conversation ID
|
|
156
|
+
* @returns JSON-serializable conversation object
|
|
157
|
+
*/
|
|
158
|
+
exportConversation(conversationId: string): Promise<any>;
|
|
159
|
+
/**
|
|
160
|
+
* Import conversation from JSON
|
|
161
|
+
*
|
|
162
|
+
* Uses: saveMessage() and linkMessages()
|
|
163
|
+
* Real implementation - recreates conversation
|
|
164
|
+
*
|
|
165
|
+
* @param data Exported conversation data
|
|
166
|
+
* @returns New conversation ID
|
|
167
|
+
*/
|
|
168
|
+
importConversation(data: any): Promise<string>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Create a ConversationManager instance
|
|
172
|
+
*
|
|
173
|
+
* @param brain Brainy instance
|
|
174
|
+
* @returns ConversationManager instance
|
|
175
|
+
*/
|
|
176
|
+
export declare function createConversationManager(brain: Brainy): ConversationManager;
|