UNPKG

@symindx/cli

Version:

SYMindX - AI Agent Framework CLI with NyX agent

75 lines 2.73 kB
import { input } from '@inquirer/prompts'; import chalk from 'chalk'; import gradient from 'gradient-string'; import ora from 'ora'; export class ChatInterface { agent; characterGradient; constructor(agent) { this.agent = agent; // Create character-specific gradient const character = agent.getCharacter(); if (character.id === 'nyx') { this.characterGradient = gradient(['#FF006E', '#8338EC']); } else if (character.id === 'aria') { this.characterGradient = gradient(['#FFB700', '#FF006E']); } else { this.characterGradient = gradient(['#3A86FF', '#8338EC']); } // Listen for emotion changes this.agent.on('emotion', (emotion) => { this.displayEmotion(emotion); }); } async start() { let chatting = true; const character = this.agent.getCharacter(); while (chatting) { const message = await input({ message: chalk.cyan('You:'), validate: (input) => input.trim().length > 0 || 'Please enter a message' }); if (message.toLowerCase() === 'exit') { chatting = false; continue; } // Show thinking spinner const spinner = ora({ text: `${character.name} is thinking...`, spinner: 'dots12', color: 'magenta' }).start(); try { const response = await this.agent.chat(message); spinner.stop(); console.log(this.characterGradient(`\n${character.name}:`), chalk.white(response)); console.log(); // Empty line for readability } catch (error) { spinner.fail('Failed to get response'); console.error(chalk.red('Error:'), error); } } await this.agent.shutdown(); } displayEmotion(emotion) { const emotionColors = { confident: chalk.magenta, excited: chalk.yellow, defiant: chalk.red, proud: chalk.green, focused: chalk.cyan, inspired: chalk.blue, passionate: chalk.redBright, caring: chalk.greenBright, joyful: chalk.yellowBright, neutral: chalk.gray }; const color = emotionColors[emotion.current] || chalk.gray; const intensity = '●'.repeat(Math.round(emotion.intensity * 5)); console.log(chalk.gray('\n['), color(`${emotion.current}`), chalk.gray(`${intensity}`), chalk.gray(']')); } } //# sourceMappingURL=chat-interface.js.map