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
JavaScript
/**
* 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