capsule-ai-cli
Version:
The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing
68 lines • 4.06 kB
JavaScript
import chalk from 'chalk';
import { authService } from '../services/auth.js';
import { configManager } from '../core/config.js';
export async function statusCommand() {
const auth = await authService.getStatus();
const config = configManager.getConfig();
console.log(chalk.bold('\n╭─ Capsule CLI Status ────────────────────────╮'));
if (auth.isAuthenticated) {
const tierColor = auth.tier === 'super' ? chalk.cyan : chalk.green;
console.log(`│ ${chalk.gray('Tier:')} ${tierColor(`${auth.tier?.toUpperCase()} (Active)`).padEnd(35)} │`);
if (auth.tier === 'super' && auth.remainingRUs !== undefined) {
const ruDisplay = `${auth.remainingRUs.toLocaleString()} / 10,000`;
console.log(`│ ${chalk.gray('RUs:')} ${ruDisplay.padEnd(36)} │`);
const percentage = (auth.remainingRUs / 10000) * 100;
const barLength = 30;
const filled = Math.round((percentage / 100) * barLength);
const bar = '█'.repeat(filled) + '░'.repeat(barLength - filled);
console.log(`│ ${chalk.gray('Usage:')} ${bar} ${Math.round(percentage)}% │`);
}
console.log(`│ ${chalk.gray('Email:')} ${auth.email?.padEnd(34) || ''} │`);
if (auth.validUntil) {
const validUntil = new Date(auth.validUntil);
const daysLeft = Math.ceil((validUntil.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
const renewal = validUntil.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
console.log(`│ ${chalk.gray('Renewal:')} ${renewal} (${daysLeft} days)`.padEnd(47) + ' │');
}
}
else {
console.log(`│ ${chalk.yellow('Not authenticated').padEnd(44)} │`);
console.log(`│ ${chalk.gray('Run: capsule auth <email>').padEnd(53)} │`);
}
console.log('│ │');
console.log(`│ ${chalk.bold('API Keys:')} │`);
const providers = ['openai', 'anthropic', 'google', 'cohere', 'mistral'];
let hasAnyKey = false;
for (const provider of providers) {
const providerConfig = config.providers[provider];
if (providerConfig?.apiKey) {
hasAnyKey = true;
const keyPreview = providerConfig.apiKey.substring(0, 8) + '...';
const status = auth.tier === 'super' ? '(Backup)' : '(Active)';
console.log(`│ ${chalk.green('✓')} ${provider.padEnd(12)} ${keyPreview.padEnd(15)} ${status.padEnd(9)} │`);
}
else {
const status = auth.tier === 'super' ? 'Managed' : 'Not configured';
const icon = auth.tier === 'super' ? chalk.cyan('✓') : chalk.red('✗');
console.log(`│ ${icon} ${provider.padEnd(12)} ${status.padEnd(26)} │`);
}
}
if (!hasAnyKey && (!auth.isAuthenticated || auth.tier !== 'super')) {
console.log('│ │');
console.log(`│ ${chalk.yellow('⚠ No API keys configured').padEnd(53)} │`);
console.log(`│ ${chalk.gray('Add keys with:').padEnd(53)} │`);
console.log(`│ ${chalk.gray('capsule config set providers.<name>.apiKey').padEnd(53)} │`);
}
if (config.costs.trackUsage) {
console.log('│ │');
console.log(`│ ${chalk.bold('Cost Tracking:')} ${chalk.green('Enabled').padEnd(28)} │`);
if (config.costs.monthlyLimit) {
console.log(`│ ${chalk.gray('Monthly limit:')} $${config.costs.monthlyLimit.toString().padEnd(27)} │`);
}
}
console.log('╰─────────────────────────────────────────────╯');
if (!auth.isAuthenticated) {
console.log(chalk.yellow('\nGet Capsule CLI at: https://capsule.dev'));
}
}
//# sourceMappingURL=status.js.map