demo-api-key-tui.js•1.56 kB
#!/usr/bin/env node
// Demo script showing the API key management TUI functionality
// This simulates the TUI flow for demonstration purposes
import { getCurrentEnvValues, maskApiKey } from './build/core/envManager.js';
console.log('🔧 Agent-MCP TUI - API Key Management Demo\n');
// Show current environment status
const currentEnv = getCurrentEnvValues();
console.log('📊 Current API Key Status:');
const keysToCheck = ['OPENAI_API_KEY', 'ANTHROPIC_API_KEY', 'HUGGINGFACE_API_KEY', 'GEMINI_API_KEY'];
for (const key of keysToCheck) {
const value = currentEnv.get(key);
if (value) {
console.log(` ✅ ${key}: Set (${maskApiKey(value)})`);
} else {
console.log(` ❌ ${key}: Not set`);
}
}
console.log('\n🎯 TUI Features Added:');
console.log(' • 🔑 Direct API key configuration through TUI');
console.log(' • 🛡️ Secure input with password masking');
console.log(' • ✅ Real-time validation of API key formats');
console.log(' • 💾 Automatic .env file management');
console.log(' • 🔄 Immediate environment variable reloading');
console.log(' • 🤖 SwarmCode CLI now has MCP support');
console.log('\n📋 How It Works:');
console.log(' 1. Select embedding provider (OpenAI, Ollama, etc.)');
console.log(' 2. TUI automatically detects required API keys');
console.log(' 3. Secure password input with validation');
console.log(' 4. Keys saved to .env and loaded immediately');
console.log(' 5. No server restart needed - works instantly');
console.log('\n🚀 Ready to use! Run: npm run server');