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.

331 lines • 16 kB
/** * Interactive Demo Script for Blax v2.0 * Demonstrates key features through automated scenarios */ import chalk from 'chalk'; import { AgentHub } from '../core/agentHub.js'; import { DealRegistry } from '../deals/dealModel.js'; import { MessageBus } from '../core/messageBus.js'; export class DemoScript { options; launcher; dealRegistry; agentHub; messageBus; currentStep = 0; constructor(options = {}) { this.options = options; } async runDemo() { console.clear(); if (!this.options.skipIntro) { await this.showIntro(); } const steps = this.getDemoSteps(); for (let i = 0; i < steps.length; i++) { this.currentStep = i + 1; const step = steps[i]; await this.executeStep(step, i + 1, steps.length); if (this.options.interactive && i < steps.length - 1) { await this.waitForUser(); } else { await this.wait(1000); } } await this.showOutro(); // Ensure proper cleanup and exit await this.cleanup(); } async showIntro() { console.log(chalk.cyan.bold('\nšŸŽÆ TLNT INTERACTIVE DEMO\n')); console.log(chalk.white('Welcome to the comprehensive demonstration of TLNT\'s self-optimizing capabilities.')); console.log(chalk.gray('This demo will showcase:\n')); const features = [ '🧠 Self-Optimizing Learning Engine', 'šŸ”„ Continuous Performance Adaptation', 'šŸŽÆ Multi-Domain Expertise (Coding, Accounting, Legal)', 'šŸ“Š Real-time Performance Monitoring', 'āš™ļø Intelligent Task Automation' ]; features.forEach(feature => { console.log(chalk.green(` āœ“ ${feature}`)); }); console.log(chalk.yellow('\nā±ļø Estimated duration: 5-8 minutes\n')); if (this.options.interactive) { console.log(chalk.gray('Press ENTER to continue at each step...')); await this.waitForUser(); } else { await this.wait(3000); } } getDemoSteps() { const demoType = this.options.demoType || 'full'; const allSteps = [ { title: 'TLNT Initialization', description: 'Starting self-optimizing AI agent system', duration: 3000, action: async () => { console.log(chalk.blue('🧠 Initializing TLNT Agent System...')); // Initialize message bus this.messageBus = new MessageBus({ redisUrl: 'redis://localhost:6379' }); try { await this.messageBus.connect(); console.log(chalk.green('āœ“ Neural Network Connections Active')); } catch (error) { console.log(chalk.yellow('⚠ Using offline learning mode')); } // Initialize agent hub this.agentHub = new AgentHub(); await this.agentHub.initialize(); console.log(chalk.green('āœ“ Learning Engine Initialized')); // Initialize deal registry this.dealRegistry = new DealRegistry(); await this.dealRegistry.initialize(); console.log(chalk.green('āœ“ Performance Monitor Active')); console.log(chalk.cyan('\nšŸ“Š TLNT Status: Self-optimization enabled\n')); } }, { title: 'Adaptive Learning Demo', description: 'Demonstrating TLNT\'s continuous learning capabilities', duration: 4000, action: async () => { console.log(chalk.blue('🧠 Analyzing Past Performance Data...')); // Simulate learning analysis console.log(chalk.yellow(' šŸ“Š Processing historical task outcomes...')); await this.wait(1500); const learningStats = { taskAnalyzed: 1247, patterns: 'Coding tasks 23% faster, Legal accuracy +15%', adaptations: 'Optimized memory allocation, Enhanced error handling', confidence: '94.2%', improvements: 5 }; console.log(chalk.green(`āœ“ Analyzed ${learningStats.taskAnalyzed} previous tasks`)); console.log(chalk.gray(` Pattern Discovery: ${learningStats.patterns}`)); console.log(chalk.gray(` Auto-Adaptations: ${learningStats.adaptations}`)); console.log(chalk.gray(` Confidence Level: ${learningStats.confidence}`)); console.log(chalk.cyan('\nšŸ’” TLNT continuously learns from every interaction to improve performance\n')); } }, { title: 'Agent Collaboration', description: 'Demonstrating multi-agent skill execution', duration: 5000, action: async () => { console.log(chalk.blue('šŸ¤– Simulating Multi-Agent Collaboration')); if (!this.agentHub) throw new Error('Agent hub not initialized'); // Simulate coding agent work console.log(chalk.yellow(' šŸ”Ø Coding Agent: Generating API scaffold...')); await this.wait(1500); const codeResult = await this.agentHub.execute('generateCode', { sessionId: 'demo-session', userId: 'demo-user', workspacePath: '/tmp/demo', environment: 'development', capabilities: ['coding'], metadata: { demo: true } }, { prompt: 'Create FastAPI authentication endpoint', language: 'python', framework: 'fastapi' }); console.log(chalk.green(' āœ“ API scaffold generated (247 lines)')); // Simulate accounting agent work console.log(chalk.yellow(' šŸ’° Accounting Agent: Budget analysis...')); await this.wait(1200); console.log(chalk.green(' āœ“ Cost projection: $18,500 (within budget)')); // Simulate legal agent work console.log(chalk.yellow(' āš–ļø Legal Agent: Compliance review...')); await this.wait(1800); console.log(chalk.green(' āœ“ GDPR compliance verified')); console.log(chalk.green(' āœ“ OAuth 2.0 security standards met')); console.log(chalk.cyan('\nšŸ”„ Multi-agent collaboration complete - all domains aligned\n')); } }, { title: 'Value Evaluation', description: 'Using deal evaluator for binary YES/NO recommendations', duration: 3000, action: async () => { console.log(chalk.blue('āš–ļø Evaluating Proposed Implementation')); if (!this.dealRegistry) throw new Error('Deal registry not initialized'); // Simulate deal evaluation without complex interfaces console.log(chalk.yellow(' šŸ“Š Analyzing implementation approach...')); await this.wait(2000); // Mock evaluation result const mockEvaluation = { recommendation: 'approve', valueDelta: 7500, reasoning: 'FastAPI approach offers optimal balance of security, performance, and maintainability' }; const color = mockEvaluation.recommendation === 'approve' ? chalk.green : chalk.red; console.log(color(` šŸŽÆ RECOMMENDATION: ${mockEvaluation.recommendation.toUpperCase()}`)); console.log(chalk.gray(` šŸ’° Value Delta: $${mockEvaluation.valueDelta.toLocaleString()}`)); console.log(chalk.gray(` šŸ“ˆ Success Probability: 92.0%`)); console.log(chalk.gray(` 🧠 Reasoning: ${mockEvaluation.reasoning}`)); console.log(chalk.cyan('\n✨ Value-driven decision making eliminates reward hacking\n')); } }, { title: 'Human-in-the-Loop Supervision', description: 'Demonstrating agent control and escalation', duration: 4000, action: async () => { console.log(chalk.blue('šŸ‘ļø Human-in-the-Loop Supervision Demo')); // Simulate agent requiring oversight console.log(chalk.yellow(' šŸ¤– Agent: Executing database migration...')); await this.wait(1000); console.log(chalk.yellow(' āøļø PAUSED: Agent requires approval for schema changes')); console.log(chalk.gray(' Reason: High-risk operation detected')); await this.wait(1500); console.log(chalk.blue(' šŸ‘¤ Human Operator: Reviewing migration plan...')); await this.wait(2000); console.log(chalk.green(' āœ… APPROVED: Migration plan validated')); console.log(chalk.green(' ā–¶ļø RESUMED: Agent continuing execution')); await this.wait(1000); console.log(chalk.red(' 🚨 ESCALATED: Complex architectural decision required')); console.log(chalk.gray(' Reason: Performance vs. security trade-off')); console.log(chalk.blue(' šŸ‘„ Senior Architect: Making design decision...')); console.log(chalk.cyan('\nšŸŽ® Complete human oversight with pause/resume/escalate controls\n')); } }, { title: 'Real-time Monitoring', description: 'Showing system metrics and health monitoring', duration: 3000, action: async () => { console.log(chalk.blue('šŸ“Š Real-time System Monitoring')); // Simulate metrics display const metrics = { 'Active Agents': '12', 'Deals in Progress': '3', 'API Response Time': '127ms', 'Success Rate': '94.2%', 'Error Rate': '0.8%', 'Human Interventions': '2' }; console.log(chalk.cyan('\n šŸ“ˆ Live System Metrics:')); Object.entries(metrics).forEach(([key, value]) => { const color = key.includes('Error') ? chalk.red : key.includes('Success') ? chalk.green : chalk.white; console.log(` ${chalk.gray(key + ':')} ${color(value)}`); }); console.log(chalk.yellow('\n šŸ”” Recent Alerts:')); console.log(chalk.yellow(' ⚠ Agent "legal_agent" high memory usage (85%)')); console.log(chalk.green(' āœ“ Deal "API_Integration" milestone completed')); console.log(chalk.blue(' ℹ New agent "compliance_specialist" registered')); console.log(chalk.cyan('\nšŸ“± Dashboard available at http://localhost:8090\n')); } } ]; // Filter steps based on demo type switch (demoType) { case 'quick': return allSteps.slice(0, 3); case 'advanced': return allSteps; default: return allSteps.slice(0, 5); } } async executeStep(step, stepNum, totalSteps) { console.log(chalk.magenta(`\n[${stepNum}/${totalSteps}] ${step.title}`)); console.log(chalk.gray(`${step.description}\n`)); try { await step.action(); } catch (error) { console.log(chalk.red(`āŒ Step failed: ${error instanceof Error ? error.message : 'Unknown error'}`)); console.log(chalk.yellow('ā­ļø Continuing with demo...\n')); } } async showOutro() { console.log(chalk.cyan.bold('\nšŸŽ‰ TLNT DEMO COMPLETE!\n')); console.log(chalk.white('You\'ve experienced TLNT\'s self-optimizing capabilities:')); const completed = [ 'āœ… Adaptive learning engine analyzing past performance', 'āœ… Multi-domain expertise coordination', 'āœ… Continuous performance optimization', 'āœ… Intelligent task automation', 'āœ… Real-time learning and adaptation', 'āœ… Enterprise-grade monitoring and metrics' ]; completed.forEach(item => console.log(chalk.green(` ${item}`))); console.log(chalk.yellow.bold('\nšŸš€ Ready to get started?\n')); const commands = [ 'tlnt ask "Help me code this" # Get intelligent coding assistance', 'tlnt ask "Review my finances" # Get accounting help', 'tlnt ask "Draft a contract" # Get legal document help', 'tlnt system start # Start full system monitoring' ]; commands.forEach(cmd => console.log(chalk.cyan(` ${cmd}`))); console.log(chalk.gray('\nšŸ“š Full documentation: https://docs.hms-dev.com')); console.log(chalk.gray('šŸ› Issues & feedback: https://github.com/HMS-OPM/tlnt/issues')); console.log(chalk.magenta.bold('\nThank you for exploring TLNT! šŸ™\n')); // Force exit to prevent hanging if (!this.options.interactive) { process.exit(0); } } async waitForUser() { return new Promise((resolve) => { console.log(chalk.dim('\nPress ENTER to continue...')); // Set raw mode for immediate input if (process.stdin.isTTY) { process.stdin.setRawMode(true); } process.stdin.once('data', (data) => { // Reset raw mode if (process.stdin.isTTY) { process.stdin.setRawMode(false); } // Check for Enter key (13) or 'q' to quit if (data[0] === 13 || data[0] === 10) { resolve(); } else if (data[0] === 113) { // 'q' key console.log(chalk.yellow('\nšŸ‘‹ Demo interrupted by user')); process.exit(0); } else { resolve(); } }); }); } async wait(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async cleanup() { try { // Reset stdin if it was modified if (process.stdin.isTTY) { process.stdin.setRawMode(false); } if (this.messageBus) { this.messageBus.disconnect(); } if (this.launcher) { // Cleanup launcher if needed } // Force exit after cleanup for non-interactive mode if (!this.options.interactive) { setTimeout(() => process.exit(0), 100); } } catch (error) { // Silent cleanup process.exit(0); } } } //# sourceMappingURL=demoScript.js.map