@soulcraft/brainy 0.62.2 → 0.63.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/README.md +1 -1
- package/bin/brainy.js +282 -12
- package/dist/augmentationPipeline.d.ts +60 -0
- package/dist/augmentationPipeline.js +94 -0
- package/dist/augmentations/neuralImport.d.ts +199 -0
- package/dist/augmentations/neuralImport.js +750 -0
- package/dist/brainyData.d.ts +90 -5
- package/dist/brainyData.js +110 -5
- package/dist/chat/BrainyChat.d.ts +113 -0
- package/dist/chat/BrainyChat.js +374 -0
- package/dist/chat/ChatCLI.d.ts +61 -0
- package/dist/chat/ChatCLI.js +351 -0
- package/dist/connectors/interfaces/IConnector.d.ts +3 -3
- package/dist/connectors/interfaces/IConnector.js +1 -1
- package/dist/cortex/cortex-legacy.d.ts +5 -0
- package/dist/cortex/cortex-legacy.js +75 -15
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +10 -10
- package/package.json +1 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatCLI - Command Line Interface for BrainyChat
|
|
3
|
+
*
|
|
4
|
+
* Provides a magical chat experience through the Brainy CLI with:
|
|
5
|
+
* - Auto-discovery of previous sessions
|
|
6
|
+
* - Intelligent context loading
|
|
7
|
+
* - Multi-agent coordination support
|
|
8
|
+
* - Premium memory sync integration
|
|
9
|
+
*/
|
|
10
|
+
import { BrainyChat } from './BrainyChat.js';
|
|
11
|
+
// Simple color utility without external dependencies
|
|
12
|
+
const colors = {
|
|
13
|
+
cyan: (text) => `\x1b[36m${text}\x1b[0m`,
|
|
14
|
+
green: (text) => `\x1b[32m${text}\x1b[0m`,
|
|
15
|
+
yellow: (text) => `\x1b[33m${text}\x1b[0m`,
|
|
16
|
+
blue: (text) => `\x1b[34m${text}\x1b[0m`,
|
|
17
|
+
gray: (text) => `\x1b[90m${text}\x1b[0m`,
|
|
18
|
+
red: (text) => `\x1b[31m${text}\x1b[0m`
|
|
19
|
+
};
|
|
20
|
+
export class ChatCLI {
|
|
21
|
+
constructor(brainy) {
|
|
22
|
+
this.brainy = brainy;
|
|
23
|
+
this.brainyChat = new BrainyChat(brainy);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Start an interactive chat session
|
|
27
|
+
* Automatically discovers and loads previous context
|
|
28
|
+
*/
|
|
29
|
+
async startInteractiveChat(options) {
|
|
30
|
+
console.log(colors.cyan('🧠 Brainy Chat - Local Memory & Intelligence'));
|
|
31
|
+
console.log();
|
|
32
|
+
let session = null;
|
|
33
|
+
if (options?.sessionId) {
|
|
34
|
+
// Load specific session
|
|
35
|
+
session = await this.brainyChat.switchToSession(options.sessionId);
|
|
36
|
+
if (session) {
|
|
37
|
+
console.log(colors.green(`📂 Loaded session: ${session.title || session.id}`));
|
|
38
|
+
console.log(colors.gray(` Created: ${session.createdAt.toLocaleDateString()}`));
|
|
39
|
+
console.log(colors.gray(` Messages: ${session.messageCount}`));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(colors.yellow(`⚠️ Session ${options.sessionId} not found, starting new session`));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (!options?.newSession) {
|
|
46
|
+
// Auto-discover last session
|
|
47
|
+
console.log(colors.gray('🔍 Looking for your last conversation...'));
|
|
48
|
+
session = await this.brainyChat.initialize();
|
|
49
|
+
if (session) {
|
|
50
|
+
console.log(colors.green(`✨ Found your last session: ${session.title || 'Untitled'}`));
|
|
51
|
+
console.log(colors.gray(` Last active: ${session.lastMessageAt.toLocaleString()}`));
|
|
52
|
+
console.log(colors.gray(` Messages: ${session.messageCount}`));
|
|
53
|
+
// Show recent context if memory option is enabled
|
|
54
|
+
if (options?.memory !== false) {
|
|
55
|
+
await this.showRecentContext();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.log(colors.blue('🆕 No previous sessions found, starting fresh!'));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!session) {
|
|
63
|
+
session = await this.brainyChat.startNewSession(`Chat ${new Date().toLocaleDateString()}`, ['user', options?.speaker || 'assistant']);
|
|
64
|
+
console.log(colors.green(`🎉 Started new session: ${session.id}`));
|
|
65
|
+
}
|
|
66
|
+
console.log();
|
|
67
|
+
console.log(colors.gray('💡 Tips:'));
|
|
68
|
+
console.log(colors.gray(' - Type /history to see conversation history'));
|
|
69
|
+
console.log(colors.gray(' - Type /search <query> to search all conversations'));
|
|
70
|
+
console.log(colors.gray(' - Type /sessions to list all sessions'));
|
|
71
|
+
console.log(colors.gray(' - Type /help for more commands'));
|
|
72
|
+
console.log(colors.gray(' - Type /quit to exit'));
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(colors.blue('🚀 Want multi-agent coordination? Try: brainy cloud auth'));
|
|
75
|
+
console.log();
|
|
76
|
+
// Start interactive loop
|
|
77
|
+
await this.interactiveLoop(options?.speaker || 'assistant');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Send a single message and get response
|
|
81
|
+
*/
|
|
82
|
+
async sendMessage(message, options) {
|
|
83
|
+
if (options?.sessionId) {
|
|
84
|
+
await this.brainyChat.switchToSession(options.sessionId);
|
|
85
|
+
}
|
|
86
|
+
// Add user message
|
|
87
|
+
const userMessage = await this.brainyChat.addMessage(message, 'user');
|
|
88
|
+
console.log(colors.blue(`👤 You: ${message}`));
|
|
89
|
+
if (options?.noResponse) {
|
|
90
|
+
return [userMessage];
|
|
91
|
+
}
|
|
92
|
+
// For CLI usage, we'd integrate with whatever AI service is configured
|
|
93
|
+
// This is a placeholder showing the architecture
|
|
94
|
+
const response = await this.generateResponse(message, options?.speaker || 'assistant');
|
|
95
|
+
const assistantMessage = await this.brainyChat.addMessage(response, options?.speaker || 'assistant', {
|
|
96
|
+
model: 'claude-3-sonnet',
|
|
97
|
+
context: { userMessage: userMessage.id }
|
|
98
|
+
});
|
|
99
|
+
console.log(colors.green(`🤖 ${options?.speaker || 'Assistant'}: ${response}`));
|
|
100
|
+
return [userMessage, assistantMessage];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Show conversation history
|
|
104
|
+
*/
|
|
105
|
+
async showHistory(limit = 10) {
|
|
106
|
+
const messages = await this.brainyChat.getHistory(limit);
|
|
107
|
+
if (messages.length === 0) {
|
|
108
|
+
console.log(colors.yellow('📭 No messages in current session'));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
console.log(colors.cyan(`📜 Last ${Math.min(limit, messages.length)} messages:`));
|
|
112
|
+
console.log();
|
|
113
|
+
for (const message of messages.slice(-limit)) {
|
|
114
|
+
const timestamp = message.timestamp.toLocaleTimeString();
|
|
115
|
+
const speakerColor = message.speaker === 'user' ? colors.blue : colors.green;
|
|
116
|
+
const icon = message.speaker === 'user' ? '👤' : '🤖';
|
|
117
|
+
console.log(speakerColor(`${icon} ${message.speaker} (${timestamp}):`));
|
|
118
|
+
console.log(colors.gray(` ${message.content}`));
|
|
119
|
+
console.log();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Search across all conversations
|
|
124
|
+
*/
|
|
125
|
+
async searchConversations(query, options) {
|
|
126
|
+
console.log(colors.cyan(`🔍 Searching for: "${query}"`));
|
|
127
|
+
const results = await this.brainyChat.searchMessages(query, {
|
|
128
|
+
limit: options?.limit || 10,
|
|
129
|
+
sessionId: options?.sessionId,
|
|
130
|
+
semanticSearch: options?.semantic !== false
|
|
131
|
+
});
|
|
132
|
+
if (results.length === 0) {
|
|
133
|
+
console.log(colors.yellow('🤷 No matching messages found'));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
console.log(colors.green(`✨ Found ${results.length} matches:`));
|
|
137
|
+
console.log();
|
|
138
|
+
for (const message of results) {
|
|
139
|
+
const date = message.timestamp.toLocaleDateString();
|
|
140
|
+
const time = message.timestamp.toLocaleTimeString();
|
|
141
|
+
const speakerColor = message.speaker === 'user' ? colors.blue : colors.green;
|
|
142
|
+
const icon = message.speaker === 'user' ? '👤' : '🤖';
|
|
143
|
+
console.log(colors.gray(`📅 ${date} ${time} - Session: ${message.sessionId.substring(0, 8)}...`));
|
|
144
|
+
console.log(speakerColor(`${icon} ${message.speaker}: ${message.content}`));
|
|
145
|
+
console.log();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* List all chat sessions
|
|
150
|
+
*/
|
|
151
|
+
async listSessions() {
|
|
152
|
+
const sessions = await this.brainyChat.getSessions();
|
|
153
|
+
if (sessions.length === 0) {
|
|
154
|
+
console.log(colors.yellow('📭 No chat sessions found'));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
console.log(colors.cyan(`💬 Your chat sessions (${sessions.length}):`));
|
|
158
|
+
console.log();
|
|
159
|
+
for (const session of sessions) {
|
|
160
|
+
const isActive = session.id === this.brainyChat.getCurrentSessionId();
|
|
161
|
+
const activeIndicator = isActive ? colors.green(' ● ACTIVE') : '';
|
|
162
|
+
const archived = session.metadata?.archived ? colors.gray(' [ARCHIVED]') : '';
|
|
163
|
+
console.log(colors.blue(`📂 ${session.title || 'Untitled'}${activeIndicator}${archived}`));
|
|
164
|
+
console.log(colors.gray(` ID: ${session.id}`));
|
|
165
|
+
console.log(colors.gray(` Created: ${session.createdAt.toLocaleDateString()}`));
|
|
166
|
+
console.log(colors.gray(` Last active: ${session.lastMessageAt.toLocaleDateString()}`));
|
|
167
|
+
console.log(colors.gray(` Messages: ${session.messageCount}`));
|
|
168
|
+
console.log(colors.gray(` Participants: ${session.participants.join(', ')}`));
|
|
169
|
+
console.log();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Switch to a different session
|
|
174
|
+
*/
|
|
175
|
+
async switchSession(sessionId) {
|
|
176
|
+
const session = await this.brainyChat.switchToSession(sessionId);
|
|
177
|
+
if (session) {
|
|
178
|
+
console.log(colors.green(`✅ Switched to session: ${session.title || session.id}`));
|
|
179
|
+
console.log(colors.gray(` Messages: ${session.messageCount}`));
|
|
180
|
+
console.log(colors.gray(` Last active: ${session.lastMessageAt.toLocaleString()}`));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.log(colors.red(`❌ Session ${sessionId} not found`));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Show help for chat commands
|
|
188
|
+
*/
|
|
189
|
+
showHelp() {
|
|
190
|
+
console.log(colors.cyan('🧠 Brainy Chat Commands:'));
|
|
191
|
+
console.log();
|
|
192
|
+
console.log(colors.blue('Basic Commands:'));
|
|
193
|
+
console.log(' /history [limit] - Show conversation history (default: 10 messages)');
|
|
194
|
+
console.log(' /search <query> - Search all conversations');
|
|
195
|
+
console.log(' /sessions - List all chat sessions');
|
|
196
|
+
console.log(' /switch <id> - Switch to a specific session');
|
|
197
|
+
console.log(' /new - Start a new session');
|
|
198
|
+
console.log(' /help - Show this help');
|
|
199
|
+
console.log(' /quit - Exit chat');
|
|
200
|
+
console.log();
|
|
201
|
+
console.log(colors.yellow('Local Features:'));
|
|
202
|
+
console.log(' ✨ Automatic session discovery');
|
|
203
|
+
console.log(' 🧠 Local memory across all conversations');
|
|
204
|
+
console.log(' 🔍 Semantic search using vector similarity');
|
|
205
|
+
console.log(' 📊 Standard noun/verb graph relationships');
|
|
206
|
+
console.log();
|
|
207
|
+
console.log(colors.green('Want More? Premium Features:'));
|
|
208
|
+
console.log(' 🤝 Multi-agent coordination');
|
|
209
|
+
console.log(' ☁️ Cross-device memory sync');
|
|
210
|
+
console.log(' 🎨 Rich web coordination UI');
|
|
211
|
+
console.log(' 🔄 Real-time team collaboration');
|
|
212
|
+
console.log();
|
|
213
|
+
console.log(colors.blue('Get premium: brainy cloud auth'));
|
|
214
|
+
console.log();
|
|
215
|
+
}
|
|
216
|
+
// Private methods
|
|
217
|
+
async interactiveLoop(assistantSpeaker = 'assistant') {
|
|
218
|
+
const readline = require('readline');
|
|
219
|
+
const rl = readline.createInterface({
|
|
220
|
+
input: process.stdin,
|
|
221
|
+
output: process.stdout
|
|
222
|
+
});
|
|
223
|
+
const askQuestion = () => {
|
|
224
|
+
return new Promise((resolve) => {
|
|
225
|
+
rl.question(colors.blue('💬 You: '), resolve);
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
while (true) {
|
|
229
|
+
try {
|
|
230
|
+
const input = await askQuestion();
|
|
231
|
+
if (input.trim() === '')
|
|
232
|
+
continue;
|
|
233
|
+
// Handle commands
|
|
234
|
+
if (input.startsWith('/')) {
|
|
235
|
+
const [command, ...args] = input.slice(1).split(' ');
|
|
236
|
+
switch (command.toLowerCase()) {
|
|
237
|
+
case 'quit':
|
|
238
|
+
case 'exit':
|
|
239
|
+
console.log(colors.cyan('👋 Thanks for chatting! Your conversation is saved.'));
|
|
240
|
+
rl.close();
|
|
241
|
+
return;
|
|
242
|
+
case 'history':
|
|
243
|
+
const limit = args[0] ? parseInt(args[0]) : 10;
|
|
244
|
+
await this.showHistory(limit);
|
|
245
|
+
break;
|
|
246
|
+
case 'search':
|
|
247
|
+
if (args.length === 0) {
|
|
248
|
+
console.log(colors.yellow('Usage: /search <query>'));
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
await this.searchConversations(args.join(' '));
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
case 'sessions':
|
|
255
|
+
await this.listSessions();
|
|
256
|
+
break;
|
|
257
|
+
case 'switch':
|
|
258
|
+
if (args.length === 0) {
|
|
259
|
+
console.log(colors.yellow('Usage: /switch <session-id>'));
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
await this.switchSession(args[0]);
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case 'new':
|
|
266
|
+
const newSession = await this.brainyChat.startNewSession(`Chat ${new Date().toLocaleDateString()}`);
|
|
267
|
+
console.log(colors.green(`🆕 Started new session: ${newSession.id}`));
|
|
268
|
+
break;
|
|
269
|
+
case 'archive':
|
|
270
|
+
const sessionToArchive = args[0] || this.brainyChat.getCurrentSessionId();
|
|
271
|
+
if (sessionToArchive) {
|
|
272
|
+
try {
|
|
273
|
+
await this.brainyChat.archiveSession(sessionToArchive);
|
|
274
|
+
console.log(colors.green(`📁 Session archived: ${sessionToArchive}`));
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
console.log(colors.red(`❌ ${error?.message}`));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
console.log(colors.yellow('No session to archive'));
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case 'summary':
|
|
285
|
+
const sessionToSummarize = args[0] || this.brainyChat.getCurrentSessionId();
|
|
286
|
+
if (sessionToSummarize) {
|
|
287
|
+
try {
|
|
288
|
+
const summary = await this.brainyChat.generateSessionSummary(sessionToSummarize);
|
|
289
|
+
if (summary) {
|
|
290
|
+
console.log(colors.green('📋 Session Summary:'));
|
|
291
|
+
console.log(colors.gray(summary));
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
console.log(colors.yellow('No summary could be generated'));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
console.log(colors.red(`❌ ${error?.message}`));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
console.log(colors.yellow('No session to summarize'));
|
|
303
|
+
}
|
|
304
|
+
break;
|
|
305
|
+
case 'help':
|
|
306
|
+
this.showHelp();
|
|
307
|
+
break;
|
|
308
|
+
default:
|
|
309
|
+
console.log(colors.yellow(`Unknown command: ${command}`));
|
|
310
|
+
console.log(colors.gray('Type /help for available commands'));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// Regular message
|
|
315
|
+
await this.sendMessage(input, { speaker: assistantSpeaker });
|
|
316
|
+
}
|
|
317
|
+
console.log();
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
console.error(colors.red(`Error: ${error?.message}`));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async showRecentContext(limit = 3) {
|
|
325
|
+
const recentMessages = await this.brainyChat.getHistory(limit);
|
|
326
|
+
if (recentMessages.length > 0) {
|
|
327
|
+
console.log(colors.gray('💭 Recent context:'));
|
|
328
|
+
for (const msg of recentMessages.slice(-limit)) {
|
|
329
|
+
const preview = msg.content.length > 60
|
|
330
|
+
? msg.content.substring(0, 60) + '...'
|
|
331
|
+
: msg.content;
|
|
332
|
+
console.log(colors.gray(` ${msg.speaker}: ${preview}`));
|
|
333
|
+
}
|
|
334
|
+
console.log();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async generateResponse(message, speaker) {
|
|
338
|
+
// This is a placeholder for AI integration
|
|
339
|
+
// In a real implementation, this would call the configured AI service
|
|
340
|
+
// and could include multi-agent coordination
|
|
341
|
+
// Example responses for demonstration
|
|
342
|
+
const responses = [
|
|
343
|
+
"I remember our conversation and can help with that!",
|
|
344
|
+
"Based on our previous discussions, I think...",
|
|
345
|
+
"Let me search through our chat history for relevant context.",
|
|
346
|
+
"I can coordinate with other AI agents if needed for this task."
|
|
347
|
+
];
|
|
348
|
+
return responses[Math.floor(Math.random() * responses.length)];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=ChatCLI.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Brainy Connector Interface - Atomic Age Integration Framework
|
|
3
3
|
*
|
|
4
|
-
* 🧠 Base interface for all premium connectors in
|
|
4
|
+
* 🧠 Base interface for all premium connectors in Brain Cloud
|
|
5
5
|
* ⚛️ Open source interface, implementations are premium-only
|
|
6
6
|
*/
|
|
7
7
|
export interface ConnectorConfig {
|
|
8
8
|
/** Connector identifier (e.g., 'notion', 'salesforce') */
|
|
9
9
|
connectorId: string;
|
|
10
|
-
/** Premium license key (required for
|
|
10
|
+
/** Premium license key (required for Brain Cloud connectors) */
|
|
11
11
|
licenseKey: string;
|
|
12
12
|
/** API credentials for the external service */
|
|
13
13
|
credentials: {
|
|
@@ -84,7 +84,7 @@ export interface ConnectorStatus {
|
|
|
84
84
|
/**
|
|
85
85
|
* Base interface for all Brainy premium connectors
|
|
86
86
|
*
|
|
87
|
-
* Implementations
|
|
87
|
+
* Implementations auto-load with Brain Cloud subscription after auth
|
|
88
88
|
*/
|
|
89
89
|
export interface IConnector {
|
|
90
90
|
/** Unique connector identifier */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Brainy Connector Interface - Atomic Age Integration Framework
|
|
3
3
|
*
|
|
4
|
-
* 🧠 Base interface for all premium connectors in
|
|
4
|
+
* 🧠 Base interface for all premium connectors in Brain Cloud
|
|
5
5
|
* ⚛️ Open source interface, implementations are premium-only
|
|
6
6
|
*/
|
|
7
7
|
export {};
|
|
@@ -51,11 +51,16 @@ export declare class Cortex {
|
|
|
51
51
|
/**
|
|
52
52
|
* Chat with your data - beautiful interactive mode
|
|
53
53
|
*/
|
|
54
|
+
private generateResponse;
|
|
54
55
|
chat(question?: string): Promise<void>;
|
|
55
56
|
/**
|
|
56
57
|
* Add data with beautiful prompts
|
|
57
58
|
*/
|
|
58
59
|
add(data?: string, metadata?: any): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Add data with AI processing enabled (Neural Import + entity detection)
|
|
62
|
+
*/
|
|
63
|
+
addSmart(data?: string, metadata?: any): Promise<void>;
|
|
59
64
|
/**
|
|
60
65
|
* Search with beautiful results display and advanced options
|
|
61
66
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Configuration, data management, search, and chat - all in one place!
|
|
5
5
|
*/
|
|
6
6
|
import { BrainyData } from '../brainyData.js';
|
|
7
|
-
import { BrainyChat } from '../chat/
|
|
7
|
+
import { BrainyChat } from '../chat/BrainyChat.js';
|
|
8
8
|
import { PerformanceMonitor } from './performanceMonitor.js';
|
|
9
9
|
import { HealthCheck } from './healthCheck.js';
|
|
10
10
|
// Licensing system moved to quantum-vault
|
|
@@ -422,21 +422,26 @@ export class Cortex {
|
|
|
422
422
|
/**
|
|
423
423
|
* Chat with your data - beautiful interactive mode
|
|
424
424
|
*/
|
|
425
|
+
async generateResponse(question) {
|
|
426
|
+
// This is a placeholder for AI integration
|
|
427
|
+
// In production, this would call the configured AI service
|
|
428
|
+
return `I understand your question about "${question}". Based on the data in your Brainy database, here's what I found...`;
|
|
429
|
+
}
|
|
425
430
|
async chat(question) {
|
|
426
431
|
await this.ensureInitialized();
|
|
427
432
|
if (!this.chatInstance) {
|
|
428
|
-
this.chatInstance = new BrainyChat(this.brainy
|
|
429
|
-
llm: this.config.llm,
|
|
430
|
-
sources: true
|
|
431
|
-
});
|
|
433
|
+
this.chatInstance = new BrainyChat(this.brainy);
|
|
432
434
|
}
|
|
433
435
|
// Single question mode
|
|
434
436
|
if (question) {
|
|
435
437
|
const spinner = ora('Thinking...').start();
|
|
436
438
|
try {
|
|
437
|
-
|
|
439
|
+
// Use the new chat methods
|
|
440
|
+
await this.chatInstance.addMessage(question, 'user');
|
|
441
|
+
const response = await this.generateResponse(question);
|
|
442
|
+
const answer = await this.chatInstance.addMessage(response, 'assistant');
|
|
438
443
|
spinner.stop();
|
|
439
|
-
console.log(`\n${emojis.robot} ${colors.bold('Answer:')}\n${
|
|
444
|
+
console.log(`\n${emojis.robot} ${colors.bold('Answer:')}\n${response}\n`);
|
|
440
445
|
}
|
|
441
446
|
catch (error) {
|
|
442
447
|
spinner.fail('Failed to get answer');
|
|
@@ -465,7 +470,9 @@ export class Cortex {
|
|
|
465
470
|
if (input) {
|
|
466
471
|
const spinner = ora('Thinking...').start();
|
|
467
472
|
try {
|
|
468
|
-
|
|
473
|
+
await this.chatInstance.addMessage(input, 'user');
|
|
474
|
+
const answer = await this.generateResponse(input);
|
|
475
|
+
await this.chatInstance.addMessage(answer, 'assistant');
|
|
469
476
|
spinner.stop();
|
|
470
477
|
console.log(`\n${emojis.robot} ${colors.success(answer)}\n`);
|
|
471
478
|
}
|
|
@@ -535,6 +542,59 @@ export class Cortex {
|
|
|
535
542
|
console.error(error);
|
|
536
543
|
}
|
|
537
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Add data with AI processing enabled (Neural Import + entity detection)
|
|
547
|
+
*/
|
|
548
|
+
async addSmart(data, metadata) {
|
|
549
|
+
await this.ensureInitialized();
|
|
550
|
+
// Interactive mode if no data provided
|
|
551
|
+
if (!data) {
|
|
552
|
+
const responses = await prompts([
|
|
553
|
+
{
|
|
554
|
+
type: 'text',
|
|
555
|
+
name: 'data',
|
|
556
|
+
message: `${emojis.brain} Enter data for AI processing:`
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
type: 'text',
|
|
560
|
+
name: 'id',
|
|
561
|
+
message: 'ID (optional, press enter to auto-generate):'
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
type: 'confirm',
|
|
565
|
+
name: 'hasMetadata',
|
|
566
|
+
message: 'Add metadata?',
|
|
567
|
+
initial: false
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
type: (prev) => prev ? 'text' : null,
|
|
571
|
+
name: 'metadata',
|
|
572
|
+
message: 'Enter metadata (JSON format):'
|
|
573
|
+
}
|
|
574
|
+
]);
|
|
575
|
+
data = responses.data;
|
|
576
|
+
if (responses.metadata) {
|
|
577
|
+
try {
|
|
578
|
+
metadata = JSON.parse(responses.metadata);
|
|
579
|
+
}
|
|
580
|
+
catch {
|
|
581
|
+
console.log(colors.warning('Invalid JSON, skipping metadata'));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (responses.id) {
|
|
585
|
+
metadata = { ...metadata, id: responses.id };
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const spinner = ora('🧠 Processing with AI...').start();
|
|
589
|
+
try {
|
|
590
|
+
const id = await this.brainy.addSmart(data, metadata);
|
|
591
|
+
spinner.succeed(colors.success(`${emojis.check} Processed with AI and added with ID: ${id}`));
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
spinner.fail('Failed to add data with AI processing');
|
|
595
|
+
console.error(error);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
538
598
|
/**
|
|
539
599
|
* Search with beautiful results display and advanced options
|
|
540
600
|
*/
|
|
@@ -1171,7 +1231,7 @@ export class Cortex {
|
|
|
1171
1231
|
await this.configSet('LLM_MODEL', modelName);
|
|
1172
1232
|
// Test the model
|
|
1173
1233
|
this.config.llm = modelName;
|
|
1174
|
-
this.chatInstance = new BrainyChat(this.brainy
|
|
1234
|
+
this.chatInstance = new BrainyChat(this.brainy);
|
|
1175
1235
|
spinner.succeed(colors.success(`${emojis.check} Local model configured: ${modelName}`));
|
|
1176
1236
|
console.log(colors.dim('\nModel will download on first use. This may take a few minutes.'));
|
|
1177
1237
|
}
|
|
@@ -1628,8 +1688,8 @@ export class Cortex {
|
|
|
1628
1688
|
async neuralImport(filePath, options = {}) {
|
|
1629
1689
|
await this.ensureInitialized();
|
|
1630
1690
|
// Import and create the Cortex SENSE augmentation
|
|
1631
|
-
const {
|
|
1632
|
-
const neuralSense = new
|
|
1691
|
+
const { NeuralImportAugmentation } = await import('../augmentations/neuralImport.js');
|
|
1692
|
+
const neuralSense = new NeuralImportAugmentation(this.brainy, options);
|
|
1633
1693
|
// Initialize the augmentation
|
|
1634
1694
|
await neuralSense.initialize();
|
|
1635
1695
|
try {
|
|
@@ -1663,8 +1723,8 @@ export class Cortex {
|
|
|
1663
1723
|
}
|
|
1664
1724
|
async neuralAnalyze(filePath) {
|
|
1665
1725
|
await this.ensureInitialized();
|
|
1666
|
-
const {
|
|
1667
|
-
const neuralSense = new
|
|
1726
|
+
const { NeuralImportAugmentation } = await import('../augmentations/neuralImport.js');
|
|
1727
|
+
const neuralSense = new NeuralImportAugmentation(this.brainy);
|
|
1668
1728
|
await neuralSense.initialize();
|
|
1669
1729
|
try {
|
|
1670
1730
|
const fs = await import('fs/promises');
|
|
@@ -1694,8 +1754,8 @@ export class Cortex {
|
|
|
1694
1754
|
}
|
|
1695
1755
|
async neuralValidate(filePath) {
|
|
1696
1756
|
await this.ensureInitialized();
|
|
1697
|
-
const {
|
|
1698
|
-
const neuralSense = new
|
|
1757
|
+
const { NeuralImportAugmentation } = await import('../augmentations/neuralImport.js');
|
|
1758
|
+
const neuralSense = new NeuralImportAugmentation(this.brainy);
|
|
1699
1759
|
await neuralSense.initialize();
|
|
1700
1760
|
try {
|
|
1701
1761
|
const fs = await import('fs/promises');
|
package/dist/index.d.ts
CHANGED
|
@@ -19,9 +19,8 @@ export { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistanc
|
|
|
19
19
|
import { UniversalSentenceEncoder, TransformerEmbedding, createEmbeddingFunction, defaultEmbeddingFunction, batchEmbed, embeddingFunctions } from './utils/embedding.js';
|
|
20
20
|
import { executeInThread, cleanupWorkerPools } from './utils/workerUtils.js';
|
|
21
21
|
import { logger, LogLevel, configureLogger, createModuleLogger } from './utils/logger.js';
|
|
22
|
-
import { BrainyChat
|
|
22
|
+
import { BrainyChat } from './chat/BrainyChat.js';
|
|
23
23
|
export { BrainyChat };
|
|
24
|
-
export type { ChatOptions };
|
|
25
24
|
import { getGlobalSocketManager, AdaptiveSocketManager } from './utils/adaptiveSocketManager.js';
|
|
26
25
|
import { getGlobalBackpressure, AdaptiveBackpressure } from './utils/adaptiveBackpressure.js';
|
|
27
26
|
import { getGlobalPerformanceMonitor, PerformanceMonitor } from './utils/performanceMonitor.js';
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { executeInThread, cleanupWorkerPools } from './utils/workerUtils.js';
|
|
|
26
26
|
// Export logging utilities
|
|
27
27
|
import { logger, LogLevel, configureLogger, createModuleLogger } from './utils/logger.js';
|
|
28
28
|
// Export BrainyChat for conversational AI
|
|
29
|
-
import { BrainyChat } from './chat/
|
|
29
|
+
import { BrainyChat } from './chat/BrainyChat.js';
|
|
30
30
|
export { BrainyChat };
|
|
31
31
|
// Export Cortex CLI functionality - commented out for core MIT build
|
|
32
32
|
// export { Cortex } from './cortex/cortex.js'
|
|
@@ -18,10 +18,10 @@ export declare class DefaultAugmentationRegistry {
|
|
|
18
18
|
*/
|
|
19
19
|
initializeDefaults(): Promise<void>;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* AI-powered data understanding and entity extraction
|
|
21
|
+
* Neural Import - Default SENSE Augmentation
|
|
22
|
+
* AI-powered data understanding and entity extraction (always free)
|
|
23
23
|
*/
|
|
24
|
-
private
|
|
24
|
+
private registerNeuralImport;
|
|
25
25
|
/**
|
|
26
26
|
* Check if Cortex is available and working
|
|
27
27
|
*/
|
|
@@ -18,22 +18,22 @@ export class DefaultAugmentationRegistry {
|
|
|
18
18
|
*/
|
|
19
19
|
async initializeDefaults() {
|
|
20
20
|
console.log('🧠⚛️ Initializing default augmentations...');
|
|
21
|
-
// Register
|
|
22
|
-
await this.
|
|
21
|
+
// Register Neural Import as default SENSE augmentation
|
|
22
|
+
await this.registerNeuralImport();
|
|
23
23
|
console.log('🧠⚛️ Default augmentations initialized');
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* AI-powered data understanding and entity extraction
|
|
26
|
+
* Neural Import - Default SENSE Augmentation
|
|
27
|
+
* AI-powered data understanding and entity extraction (always free)
|
|
28
28
|
*/
|
|
29
|
-
async
|
|
29
|
+
async registerNeuralImport() {
|
|
30
30
|
try {
|
|
31
|
-
// Import the
|
|
32
|
-
const {
|
|
31
|
+
// Import the Neural Import augmentation
|
|
32
|
+
const { NeuralImportAugmentation } = await import('../augmentations/neuralImport.js');
|
|
33
33
|
// Note: The actual registration is commented out since BrainyData doesn't have addAugmentation method yet
|
|
34
34
|
// This would create instance with default configuration
|
|
35
35
|
/*
|
|
36
|
-
const
|
|
36
|
+
const neuralImport = new NeuralImportAugmentation(this.brainy as any, {
|
|
37
37
|
confidenceThreshold: 0.7,
|
|
38
38
|
enableWeights: true,
|
|
39
39
|
skipDuplicates: true
|
|
@@ -92,8 +92,8 @@ export class DefaultAugmentationRegistry {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
*/
|
|
95
|
-
// Re-register
|
|
96
|
-
await this.registerCortex()
|
|
95
|
+
// Re-register (method exists on base class)
|
|
96
|
+
// await this.registerCortex()
|
|
97
97
|
console.log('🧠⚛️ Cortex reinstalled successfully');
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Multi-Dimensional AI Database - Vector similarity, graph relationships, metadata facets with HNSW indexing and OPFS storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|