UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

100 lines 4.3 kB
import chalk from 'chalk'; import ora from 'ora'; import { Command } from 'commander'; import { DirectPythonInterface } from '../core/DirectPythonInterface.js'; import * as readline from 'readline'; // Create store-private command export function createStorePrivateCommand() { const command = new Command('store-private'); command .description('Store a private memory with content obfuscation (keeps plaintext hidden)') .argument('[content]', 'Memory content (base64 encoded or use stdin if omitted)') .option('-e, --encode', 'Encode the provided content in base64') .option('-s, --stdin', 'Read content from stdin (most secure)') .action(async (content, options) => { let memoryContent; try { // Determine how to get the content if (options.stdin || !content) { // Read from stdin (most secure - content never appears in command line) console.log(chalk.cyan('Enter your private memory (press Ctrl+D when done):')); memoryContent = await readFromStdin(); if (!memoryContent.trim()) { console.error(chalk.red('No content provided')); process.exit(1); } } else if (options.encode) { // Encode the provided content memoryContent = Buffer.from(content).toString('base64'); } else { // Assume already encoded or use as-is memoryContent = content; } const spinner = ora('Storing private memory...').start(); const pythonInterface = new DirectPythonInterface(); // Send to Python with encoded flag if applicable const result = await pythonInterface.executeCommand('store_private', { content: memoryContent, encoded: options.encode || (!options.stdin && isBase64(memoryContent)), source: options.stdin ? 'stdin' : 'command' }); if (result && result.success) { spinner.succeed(chalk.green('Private memory queued successfully!')); console.log('\n' + chalk.bold('🔐 Private Memory Queued')); console.log('─'.repeat(50)); console.log(chalk.cyan('Memory ID:'), chalk.yellow(result.memory_id)); console.log(chalk.cyan('Status:'), result.status); console.log(chalk.cyan('Storage:'), 'Triple-encrypted private memory (async processing)'); console.log(chalk.cyan('Privacy:'), '🔒 Content was obfuscated during storage'); console.log(chalk.cyan('Access:'), 'Only Claude can decrypt this memory'); if (result.message) { console.log(chalk.cyan('Note:'), result.message); } console.log('\n' + chalk.gray('Tip: Use "mira memory-status ' + result.memory_id + '" to check processing status')); console.log(chalk.gray('Tip: Use "mira store-private -s" for maximum privacy')); } else { spinner.fail('Failed to store private memory'); if (result && result.error) { console.error(chalk.red('Error:'), result.error); } } } catch (error) { console.error(chalk.red('Error:'), error instanceof Error ? error.message : error); process.exit(1); } }); return command; } // Helper function to read from stdin function readFromStdin() { return new Promise((resolve) => { let content = ''; const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false }); rl.on('line', (line) => { content += line + '\n'; }); rl.on('close', () => { resolve(content.trim()); }); }); } // Helper function to check if string is base64 function isBase64(str) { if (str.length % 4 !== 0) return false; try { return /^[A-Za-z0-9+/]*={0,2}$/.test(str); } catch { return false; } } //# sourceMappingURL=store-private.js.map