@soulcraft/brainy 3.0.0 → 3.0.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 +53 -3
- package/README.md +353 -110
- package/bin/brainy.js +340 -62
- package/dist/api/ConfigAPI.d.ts +67 -0
- package/dist/api/ConfigAPI.js +166 -0
- package/dist/api/DataAPI.d.ts +123 -0
- package/dist/api/DataAPI.js +391 -0
- package/dist/api/SecurityAPI.d.ts +50 -0
- package/dist/api/SecurityAPI.js +139 -0
- package/dist/api/UniversalImportAPI.d.ts +134 -0
- package/dist/api/UniversalImportAPI.js +615 -0
- package/dist/augmentationManager.js +12 -7
- package/dist/augmentationPipeline.d.ts +0 -61
- package/dist/augmentationPipeline.js +0 -87
- package/dist/augmentationRegistry.d.ts +1 -1
- package/dist/augmentationRegistry.js +1 -1
- package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
- package/dist/augmentations/apiServerAugmentation.js +290 -9
- package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
- package/dist/augmentations/auditLogAugmentation.js +358 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
- package/dist/augmentations/batchProcessingAugmentation.js +123 -22
- package/dist/augmentations/brainyAugmentation.d.ts +142 -8
- package/dist/augmentations/brainyAugmentation.js +179 -2
- package/dist/augmentations/cacheAugmentation.d.ts +8 -5
- package/dist/augmentations/cacheAugmentation.js +116 -17
- package/dist/augmentations/conduitAugmentations.d.ts +2 -2
- package/dist/augmentations/conduitAugmentations.js +2 -2
- package/dist/augmentations/configResolver.d.ts +122 -0
- package/dist/augmentations/configResolver.js +440 -0
- package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
- package/dist/augmentations/connectionPoolAugmentation.js +37 -12
- package/dist/augmentations/defaultAugmentations.d.ts +14 -10
- package/dist/augmentations/defaultAugmentations.js +16 -11
- package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
- package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
- package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
- package/dist/augmentations/discovery/localDiscovery.js +246 -0
- package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
- package/dist/augmentations/discovery/runtimeLoader.js +337 -0
- package/dist/augmentations/discovery.d.ts +152 -0
- package/dist/augmentations/discovery.js +441 -0
- package/dist/augmentations/display/cache.d.ts +130 -0
- package/dist/augmentations/display/cache.js +319 -0
- package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
- package/dist/augmentations/display/fieldPatterns.js +393 -0
- package/dist/augmentations/display/iconMappings.d.ts +57 -0
- package/dist/augmentations/display/iconMappings.js +68 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
- package/dist/augmentations/display/intelligentComputation.js +462 -0
- package/dist/augmentations/display/types.d.ts +203 -0
- package/dist/augmentations/display/types.js +7 -0
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +5 -3
- package/dist/augmentations/indexAugmentation.js +5 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +24 -7
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +111 -27
- package/dist/augmentations/manifest.d.ts +176 -0
- package/dist/augmentations/manifest.js +8 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
- package/dist/augmentations/marketplace/cli.d.ts +47 -0
- package/dist/augmentations/marketplace/cli.js +265 -0
- package/dist/augmentations/metricsAugmentation.d.ts +3 -3
- package/dist/augmentations/metricsAugmentation.js +2 -2
- package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
- package/dist/augmentations/monitoringAugmentation.js +2 -2
- package/dist/augmentations/neuralImport.d.ts +1 -1
- package/dist/augmentations/neuralImport.js +4 -4
- package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
- package/dist/augmentations/rateLimitAugmentation.js +321 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
- package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
- package/dist/augmentations/storageAugmentation.d.ts +1 -1
- package/dist/augmentations/storageAugmentation.js +2 -2
- package/dist/augmentations/storageAugmentations.d.ts +37 -8
- package/dist/augmentations/storageAugmentations.js +204 -15
- package/dist/augmentations/synapseAugmentation.d.ts +1 -1
- package/dist/augmentations/synapseAugmentation.js +35 -16
- package/dist/augmentations/typeMatching/brainyTypes.d.ts +83 -0
- package/dist/augmentations/typeMatching/brainyTypes.js +425 -0
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +191 -0
- package/dist/augmentations/universalDisplayAugmentation.js +371 -0
- package/dist/brainy-unified.d.ts +106 -0
- package/dist/brainy-unified.js +327 -0
- package/dist/brainy.d.ts +273 -0
- package/dist/brainy.js +1181 -0
- package/dist/brainyData.d.ts +56 -111
- package/dist/brainyData.js +912 -756
- package/dist/brainyDataV3.d.ts +186 -0
- package/dist/brainyDataV3.js +337 -0
- package/dist/browserFramework.d.ts +6 -6
- package/dist/browserFramework.js +11 -8
- package/dist/browserFramework.minimal.d.ts +5 -5
- package/dist/browserFramework.minimal.js +11 -8
- package/dist/config/distributedPresets-new.d.ts +118 -0
- package/dist/config/distributedPresets-new.js +318 -0
- package/dist/config/distributedPresets.d.ts +118 -0
- package/dist/config/distributedPresets.js +318 -0
- package/dist/config/extensibleConfig.d.ts +99 -0
- package/dist/config/extensibleConfig.js +268 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +35 -0
- package/dist/config/modelAutoConfig.d.ts +32 -0
- package/dist/config/modelAutoConfig.js +139 -0
- package/dist/config/modelPrecisionManager.d.ts +42 -0
- package/dist/config/modelPrecisionManager.js +98 -0
- package/dist/config/sharedConfigManager.d.ts +67 -0
- package/dist/config/sharedConfigManager.js +215 -0
- package/dist/config/storageAutoConfig.d.ts +41 -0
- package/dist/config/storageAutoConfig.js +328 -0
- package/dist/config/zeroConfig.d.ts +68 -0
- package/dist/config/zeroConfig.js +301 -0
- package/dist/cortex/backupRestore.d.ts +2 -2
- package/dist/cortex/backupRestore.js +85 -27
- package/dist/cortex/healthCheck.d.ts +2 -2
- package/dist/cortex/neuralImport.d.ts +2 -2
- package/dist/cortex/neuralImport.js +18 -13
- package/dist/cortex/performanceMonitor.d.ts +2 -2
- package/dist/critical/model-guardian.d.ts +4 -0
- package/dist/critical/model-guardian.js +31 -11
- package/dist/demo.d.ts +4 -4
- package/dist/demo.js +7 -7
- package/dist/distributed/cacheSync.d.ts +112 -0
- package/dist/distributed/cacheSync.js +265 -0
- package/dist/distributed/coordinator.d.ts +193 -0
- package/dist/distributed/coordinator.js +548 -0
- package/dist/distributed/httpTransport.d.ts +120 -0
- package/dist/distributed/httpTransport.js +446 -0
- package/dist/distributed/index.d.ts +8 -0
- package/dist/distributed/index.js +5 -0
- package/dist/distributed/networkTransport.d.ts +132 -0
- package/dist/distributed/networkTransport.js +633 -0
- package/dist/distributed/queryPlanner.d.ts +104 -0
- package/dist/distributed/queryPlanner.js +327 -0
- package/dist/distributed/readWriteSeparation.d.ts +134 -0
- package/dist/distributed/readWriteSeparation.js +350 -0
- package/dist/distributed/shardManager.d.ts +114 -0
- package/dist/distributed/shardManager.js +357 -0
- package/dist/distributed/shardMigration.d.ts +110 -0
- package/dist/distributed/shardMigration.js +289 -0
- package/dist/distributed/storageDiscovery.d.ts +160 -0
- package/dist/distributed/storageDiscovery.js +551 -0
- package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
- package/dist/embeddings/CachedEmbeddings.js +146 -0
- package/dist/embeddings/EmbeddingManager.d.ts +102 -0
- package/dist/embeddings/EmbeddingManager.js +291 -0
- package/dist/embeddings/SingletonModelManager.d.ts +95 -0
- package/dist/embeddings/SingletonModelManager.js +220 -0
- package/dist/embeddings/index.d.ts +12 -0
- package/dist/embeddings/index.js +16 -0
- package/dist/embeddings/lightweight-embedder.d.ts +0 -1
- package/dist/embeddings/lightweight-embedder.js +4 -12
- package/dist/embeddings/model-manager.d.ts +11 -0
- package/dist/embeddings/model-manager.js +43 -7
- package/dist/embeddings/universal-memory-manager.d.ts +1 -1
- package/dist/embeddings/universal-memory-manager.js +27 -67
- package/dist/embeddings/worker-embedding.js +4 -8
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +7 -4
- package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
- package/dist/graph/graphAdjacencyIndex.js +288 -0
- package/dist/graph/pathfinding.js +4 -2
- package/dist/hnsw/scaledHNSWSystem.js +11 -2
- package/dist/importManager.js +8 -5
- package/dist/index.d.ts +17 -22
- package/dist/index.js +37 -23
- package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
- package/dist/mcp/brainyMCPAdapter.js +5 -5
- package/dist/mcp/brainyMCPService.d.ts +3 -3
- package/dist/mcp/brainyMCPService.js +3 -11
- package/dist/mcp/mcpAugmentationToolset.js +20 -30
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +2 -2
- package/dist/neural/entityExtractor.d.ts +65 -0
- package/dist/neural/entityExtractor.js +316 -0
- package/dist/neural/improvedNeuralAPI.d.ts +357 -0
- package/dist/neural/improvedNeuralAPI.js +2628 -0
- package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
- package/dist/neural/naturalLanguageProcessor.js +941 -66
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
- package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
- package/dist/neural/neuralAPI.js +8 -2
- package/dist/neural/patternLibrary.d.ts +57 -3
- package/dist/neural/patternLibrary.js +348 -13
- package/dist/neural/staticPatternMatcher.d.ts +2 -2
- package/dist/neural/staticPatternMatcher.js +2 -2
- package/dist/neural/types.d.ts +287 -0
- package/dist/neural/types.js +24 -0
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
- package/dist/storage/adapters/fileSystemStorage.js +218 -15
- package/dist/storage/adapters/memoryStorage.d.ts +4 -4
- package/dist/storage/adapters/memoryStorage.js +17 -12
- package/dist/storage/adapters/opfsStorage.d.ts +2 -2
- package/dist/storage/adapters/opfsStorage.js +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +18 -2
- package/dist/storage/baseStorage.js +74 -3
- package/dist/storage/cacheManager.js +2 -2
- package/dist/storage/readOnlyOptimizations.js +8 -3
- package/dist/streaming/pipeline.d.ts +154 -0
- package/dist/streaming/pipeline.js +551 -0
- package/dist/triple/TripleIntelligence.d.ts +25 -110
- package/dist/triple/TripleIntelligence.js +4 -574
- package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
- package/dist/triple/TripleIntelligenceSystem.js +519 -0
- package/dist/types/apiTypes.d.ts +278 -0
- package/dist/types/apiTypes.js +33 -0
- package/dist/types/brainy.types.d.ts +308 -0
- package/dist/types/brainy.types.js +8 -0
- package/dist/types/brainyDataInterface.d.ts +5 -8
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/brainyTypes.d.ts +217 -0
- package/dist/utils/brainyTypes.js +261 -0
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.d.ts +9 -4
- package/dist/utils/embedding.js +89 -26
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- package/dist/utils/hybridModelManager.d.ts +19 -28
- package/dist/utils/hybridModelManager.js +36 -200
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/intelligentTypeMapper.d.ts +60 -0
- package/dist/utils/intelligentTypeMapper.js +349 -0
- package/dist/utils/metadataIndex.d.ts +118 -1
- package/dist/utils/metadataIndex.js +539 -16
- package/dist/utils/nodeVersionCheck.d.ts +24 -0
- package/dist/utils/nodeVersionCheck.js +65 -0
- package/dist/utils/paramValidation.d.ts +39 -0
- package/dist/utils/paramValidation.js +192 -0
- package/dist/utils/rateLimiter.d.ts +160 -0
- package/dist/utils/rateLimiter.js +271 -0
- package/dist/utils/statistics.d.ts +4 -4
- package/dist/utils/statistics.js +3 -3
- package/dist/utils/structuredLogger.d.ts +146 -0
- package/dist/utils/structuredLogger.js +394 -0
- package/dist/utils/textEncoding.js +2 -1
- package/dist/utils/typeValidation.d.ts +59 -0
- package/dist/utils/typeValidation.js +374 -0
- package/dist/utils/version.js +19 -3
- package/package.json +15 -4
- package/scripts/download-models.cjs +94 -20
- package/dist/augmentations/walAugmentation.d.ts +0 -109
- package/dist/augmentations/walAugmentation.js +0 -516
- package/dist/chat/BrainyChat.d.ts +0 -121
- package/dist/chat/BrainyChat.js +0 -396
- package/dist/chat/ChatCLI.d.ts +0 -61
- package/dist/chat/ChatCLI.js +0 -351
package/dist/chat/ChatCLI.js
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
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
|
-
* - Full conversation history and context
|
|
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('Additional Features:'));
|
|
208
|
-
console.log(' 🤝 Multi-agent coordination');
|
|
209
|
-
console.log(' ☁️ Cross-device sync via augmentations');
|
|
210
|
-
console.log(' 🎨 Web UI integration possible');
|
|
211
|
-
console.log(' 🔄 Real-time collaboration via WebSocket');
|
|
212
|
-
console.log();
|
|
213
|
-
console.log(colors.blue('All features included - MIT Licensed'));
|
|
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
|