UNPKG

capsule-ai-cli

Version:

The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing

120 lines 4.11 kB
import chalk from 'chalk'; import inquirer from 'inquirer'; import { configManager } from '../core/config'; export class ConfigCommand { async execute() { console.log(chalk.cyan('🔧 Capsule CLI Configuration\n')); const choices = [ { name: 'Configure API Keys', value: 'api-keys' }, { name: 'UI Settings', value: 'ui' }, { name: 'Tool Permissions', value: 'tools' }, { name: 'View Current Config', value: 'view' }, { name: 'Exit', value: 'exit' } ]; const { action } = await inquirer.prompt([ { type: 'list', name: 'action', message: 'What would you like to configure?', choices } ]); switch (action) { case 'api-keys': await this.configureApiKeys(); break; case 'ui': await this.configureUI(); break; case 'tools': await this.configureTools(); break; case 'view': this.viewConfig(); break; case 'exit': return; } } async configureApiKeys() { const providers = ['openai', 'anthropic', 'google', 'cohere']; const { provider } = await inquirer.prompt([ { type: 'list', name: 'provider', message: 'Select a provider to configure:', choices: providers } ]); const currentKey = configManager.getApiKey(provider); const { apiKey } = await inquirer.prompt([ { type: 'password', name: 'apiKey', message: `Enter API key for ${provider}:`, default: currentKey ? '(unchanged)' : undefined } ]); if (apiKey && apiKey !== '(unchanged)') { configManager.setConfig(`providers.${provider}.apiKey`, apiKey); console.log(chalk.green(`✓ API key for ${provider} saved successfully!`)); } } async configureUI() { const config = configManager.getConfig(); const answers = await inquirer.prompt([ { type: 'list', name: 'theme', message: 'Select theme:', choices: ['dark', 'light'], default: config.ui.theme }, { type: 'confirm', name: 'showCosts', message: 'Show cost information?', default: config.ui.showCosts }, { type: 'confirm', name: 'animations', message: 'Enable animations?', default: config.ui.animations } ]); configManager.setConfig('ui', answers); console.log(chalk.green('✓ UI settings saved!')); } async configureTools() { const config = configManager.getConfig(); const answers = await inquirer.prompt([ { type: 'confirm', name: 'fileOperations', message: 'Allow file operations?', default: config.tools.fileOperations }, { type: 'confirm', name: 'shellExecution', message: 'Allow shell command execution?', default: config.tools.shellExecution }, { type: 'confirm', name: 'webAccess', message: 'Allow web access?', default: config.tools.webAccess } ]); configManager.setConfig('tools', answers); console.log(chalk.green('✓ Tool permissions saved!')); } viewConfig() { const config = configManager.getConfig(); console.log(chalk.cyan('\nCurrent Configuration:')); console.log(JSON.stringify(config, null, 2)); } } //# sourceMappingURL=config.js.map