UNPKG

tlnt

Version:

TLNT - HMS-Powered Multi-Agent Platform with Government Agency Analysis, Deep Research, and Enterprise-Ready Deployment. Self-optimizing multi-domain AI agent with continuous learning and enterprise-grade performance monitoring.

168 lines 7.02 kB
import chalk from 'chalk'; import readline from 'readline'; export class SimpleTUI { agentHub; hubAdapter; rl; constructor(agentHub, hubAdapter) { this.agentHub = agentHub; this.hubAdapter = hubAdapter; this.rl = readline.createInterface({ input: process.stdin, output: process.stdout }); } async start() { // Clear screen and show header console.clear(); console.log(chalk.cyan.bold('🦾 blax - Powerful Terminal Agent')); console.log(chalk.gray('Type "help" for commands, "exit" to quit\n')); // Show connection status const status = this.hubAdapter.getConnectionStatus(); const statusColor = status.connected ? chalk.green : chalk.red; console.log(`Hub Status: ${statusColor(status.connected ? 'Connected' : 'Disconnected')}`); console.log(`Hub URL: ${chalk.gray(status.url)}\n`); // Start interactive loop this.startInteractiveLoop(); } startInteractiveLoop() { this.rl.question(chalk.cyan('> '), async (input) => { const command = input.trim().toLowerCase(); switch (command) { case 'help': this.showHelp(); break; case 'exit': case 'quit': console.log(chalk.yellow('Goodbye! 👋')); this.rl.close(); return; case 'status': await this.showStatus(); break; case 'skills': this.showSkills(); break; case 'agents': await this.showAgents(); break; case 'deals': await this.showDeals(); break; default: if (input.trim()) { await this.handleChat(input.trim()); } break; } // Continue the loop this.startInteractiveLoop(); }); } showHelp() { console.log(chalk.cyan.bold('\nAvailable Commands:')); console.log(chalk.white(' help - Show this help message')); console.log(chalk.white(' status - Show system status')); console.log(chalk.white(' skills - List available skills')); console.log(chalk.white(' agents - List connected agents')); console.log(chalk.white(' deals - List active deals')); console.log(chalk.white(' exit - Exit tlnt')); console.log(chalk.gray(' <message> - Chat with the agent\n')); } async showStatus() { console.log(chalk.cyan.bold('\nSystem Status:')); const health = await this.agentHub.healthCheck(); console.log(` Health: ${health.status === 'healthy' ? chalk.green('Healthy') : chalk.red('Unhealthy')}`); console.log(` Skills: ${chalk.white(health.details.skillCount)}`); console.log(` Uptime: ${chalk.white(Math.round(health.details.uptime))}s`); const hubStatus = this.hubAdapter.getConnectionStatus(); console.log(` Hub: ${hubStatus.connected ? chalk.green('Connected') : chalk.red('Disconnected')}`); console.log(` Hub URL: ${chalk.gray(hubStatus.url)}\n`); } showSkills() { const skills = this.agentHub.listSkills(); console.log(chalk.cyan.bold('\nAvailable Skills:')); if (skills.length === 0) { console.log(chalk.gray(' No skills loaded\n')); return; } skills.forEach(skill => { console.log(` ${chalk.green('•')} ${chalk.white(skill.name)} v${chalk.gray(skill.version)}`); console.log(` ${chalk.gray(skill.description)}`); }); console.log(); } async showAgents() { console.log(chalk.cyan.bold('\nConnected Agents:')); try { if (!this.hubAdapter.isConnected()) { console.log(chalk.yellow(' Hub not connected - run in online mode to see agents\n')); return; } const agents = await this.hubAdapter.listAgents(); if (agents.length === 0) { console.log(chalk.gray(' No agents available\n')); return; } agents.forEach(agent => { const statusColor = agent.status === 'active' ? chalk.green : agent.status === 'error' ? chalk.red : chalk.yellow; console.log(` ${statusColor('•')} ${chalk.white(agent.name)} (${chalk.gray(agent.id)})`); console.log(` Status: ${statusColor(agent.status)}`); }); console.log(); } catch (error) { console.log(chalk.red(` Error: ${error instanceof Error ? error.message : String(error)}\n`)); } } async showDeals() { console.log(chalk.cyan.bold('\nActive Deals:')); try { if (!this.hubAdapter.isConnected()) { console.log(chalk.yellow(' Hub not connected - run in online mode to see deals\n')); return; } const deals = await this.hubAdapter.listDeals(); if (deals.length === 0) { console.log(chalk.gray(' No deals available\n')); return; } deals.forEach(deal => { const statusColor = deal.status === 'completed' ? chalk.green : deal.status === 'failed' ? chalk.red : chalk.yellow; console.log(` ${statusColor('•')} ${chalk.white(deal.name)}`); console.log(` Status: ${statusColor(deal.status)}`); console.log(` Participants: ${chalk.gray(deal.participants.join(', '))}`); }); console.log(); } catch (error) { console.log(chalk.red(` Error: ${error instanceof Error ? error.message : String(error)}\n`)); } } async handleChat(message) { console.log(chalk.blue('🤔 Thinking...')); try { const result = await this.agentHub.execute('chat', { sessionId: `simple-tui-${Date.now()}`, userId: 'tui-user', workspacePath: process.cwd(), environment: 'development', capabilities: ['chat'], metadata: {} }, { prompt: message }); if (result.success) { console.log(chalk.green('🤖 Assistant:'), String(result.data)); } else { console.log(chalk.red('❌ Error:'), result.error?.message || 'Unknown error'); } } catch (error) { console.log(chalk.red('❌ Error:'), error instanceof Error ? error.message : String(error)); } console.log(); } } //# sourceMappingURL=simpleTui.js.map