Skip to content

armgit / ruflo

Public Imported from GitHub
0

๐ŸŒŠ The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

๐Ÿ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/concurrent-display.js

rUv705a476ec42d
diff --git a/.claude/checkpoints/task-1754339336.json b/.claude/checkpoints/task-1754339336.json
new file mode 100644
index 0000000000..aa32cc3491
--- /dev/null
+++ b/.claude/checkpoints/task-1754339336.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250804-202856", "task": "{{user_prompt}} ", "timestamp": "2025-08-04T20:28:56Z", "commit": "e43395bc79b97ebbadc405064d4f518bafd26342", "github_release": "true"}
diff --git a/src/cli/simple-commands/concurrent-display.js b/src/cli/simple-commands/concurrent-display.js
new file mode 100644
index 0000000000..a3e7fff40e
--- /dev/null
+++ b/src/cli/simple-commands/concurrent-display.js
@@ -0,0 +1,322 @@
+/**
+ * Concurrent Agent Display Manager
+ * Provides a threaded view of multiple agents running in parallel
+ */
+
+export class ConcurrentDisplay {
+ constructor(agents = [], options = {}) {
+ this.agents = new Map();
+ this.options = {
+ maxWidth: process.stdout.columns || 120,
+ updateInterval: 100,
+ showTools: true,
+ showTimers: true,
+ ...options
+ };
+
+ // Initialize agent states
+ agents.forEach(agent => {
+ this.agents.set(agent.id, {
+ ...agent,
+ status: 'pending',
+ currentTool: null,
+ lastActivity: '',
+ startTime: null,
+ events: 0,
+ progress: 0
+ });
+ });
+
+ this.displayBuffer = [];
+ this.lastRender = Date.now();
+ this.spinnerFrames = ['โ ‹', 'โ ™', 'โ น', 'โ ธ', 'โ ผ', 'โ ด', 'โ ฆ', 'โ ง', 'โ ‡', 'โ '];
+ this.spinnerIndex = 0;
+ }
+
+ /**
+ * Start the display update loop
+ */
+ start() {
+ // Clear screen and hide cursor
+ console.log('\x1B[2J\x1B[H\x1B[?25l');
+
+ this.interval = setInterval(() => {
+ this.render();
+ }, this.options.updateInterval);
+
+ // Restore cursor on exit
+ process.on('exit', () => {
+ console.log('\x1B[?25h'); // Show cursor
+ this.stop();
+ });
+ }
+
+ /**
+ * Stop the display updates
+ */
+ stop() {
+ if (this.interval) {
+ clearInterval(this.interval);
+ this.interval = null;
+ }
+ console.log('\x1B[?25h'); // Show cursor
+ }
+
+ /**
+ * Update agent status
+ */
+ updateAgent(agentId, updates) {
+ const agent = this.agents.get(agentId);
+ if (agent) {
+ Object.assign(agent, updates);
+ if (updates.status === 'active' && !agent.startTime) {
+ agent.startTime = Date.now();
+ }
+ }
+ }
+
+ /**
+ * Add activity to agent
+ */
+ addActivity(agentId, activity, tool = null) {
+ const agent = this.agents.get(agentId);
+ if (agent) {
+ agent.lastActivity = activity.substring(0, 50) + (activity.length > 50 ? '...' : '');
+ agent.currentTool = tool;
+ agent.events++;
+
+ // Update progress based on activity
+ if (activity.includes('completed') || activity.includes('finished')) {
+ agent.progress = 100;
+ } else if (agent.progress < 90) {
+ agent.progress = Math.min(agent.progress + 5, 90);
+ }
+ }
+ }
+
+ /**
+ * Render the display
+ */
+ render() {
+ const now = Date.now();
+ this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;
+ const spinner = this.spinnerFrames[this.spinnerIndex];
+
+ // Clear screen and reset cursor
+ process.stdout.write('\x1B[H\x1B[2J');
+
+ // Header
+ this.renderHeader();
+
+ // Agent panels
+ this.renderAgentPanels(spinner);
+
+ // Summary footer
+ this.renderFooter();
+
+ this.lastRender = now;
+ }
+
+ /**
+ * Render header
+ */
+ renderHeader() {
+ const width = this.options.maxWidth;
+ console.log('โ•”' + 'โ•'.repeat(width - 2) + 'โ•—');
+ console.log('โ•‘' + this.center('๐Ÿค– MLE-STAR CONCURRENT AGENT EXECUTION', width - 2) + 'โ•‘');
+ console.log('โ• ' + 'โ•'.repeat(width - 2) + 'โ•ฃ');
+ }
+
+ /**
+ * Render agent panels in columns
+ */
+ renderAgentPanels(spinner) {
+ const agentArray = Array.from(this.agents.values());
+ const columns = Math.min(3, agentArray.length); // Max 3 columns
+ const columnWidth = Math.floor((this.options.maxWidth - 4) / columns) - 2;
+
+ // Group agents by rows
+ const rows = Math.ceil(agentArray.length / columns);
+
+ for (let row = 0; row < rows; row++) {
+ let line = 'โ•‘ ';
+
+ for (let col = 0; col < columns; col++) {
+ const agentIndex = row * columns + col;
+ if (agentIndex < agentArray.length) {
+ const agent = agentArray[agentIndex];
+ line += this.renderAgentPanel(agent, columnWidth, spinner);
+ if (col < columns - 1) line += ' โ”‚ ';
+ } else {
+ line += ' '.repeat(columnWidth);
+ if (col < columns - 1) line += ' โ”‚ ';
+ }
+ }
+
+ line += ' โ•‘';
+ console.log(line);
+
+ // Add separator between rows
+ if (row < rows - 1) {
+ let separator = 'โ•‘ ';
+ for (let col = 0; col < columns; col++) {
+ separator += 'โ”€'.repeat(columnWidth);
+ if (col < columns - 1) separator += ' โ”‚ ';
+ }
+ separator += ' โ•‘';
+ console.log(separator);
+ }
+ }
+ }
+
+ /**
+ * Render individual agent panel
+ */
+ renderAgentPanel(agent, width, spinner) {
+ const lines = [];
+
+ // Agent header with icon and name
+ const icon = this.getAgentIcon(agent.type);
+ const statusIcon = this.getStatusIcon(agent.status, spinner);
+ const header = `${icon} ${agent.name}`;
+ lines.push(this.truncate(`${statusIcon} ${header}`, width));
+
+ // Status line
+ const status = this.getStatusText(agent.status);
+ const elapsed = agent.startTime ? this.formatDuration(Date.now() - agent.startTime) : '--:--';
+ lines.push(this.truncate(`Status: ${status} โ”‚ ${elapsed}`, width));
+
+ // Progress bar
+ if (agent.status === 'active') {
+ lines.push(this.renderProgressBar(agent.progress, width));
+ } else {
+ lines.push(' '.repeat(width));
+ }
+
+ // Current activity
+ if (agent.lastActivity) {
+ lines.push(this.truncate(`โ†’ ${agent.lastActivity}`, width));
+ } else {
+ lines.push(this.truncate('โ†’ Waiting...', width));
+ }
+
+ // Tool usage
+ if (agent.currentTool && this.options.showTools) {
+ lines.push(this.truncate(`๐Ÿ”ง ${agent.currentTool}`, width));
+ } else {
+ lines.push(' '.repeat(width));
+ }
+
+ // Stats
+ lines.push(this.truncate(`Events: ${agent.events}`, width));
+
+ // Pad to consistent height
+ while (lines.length < 6) {
+ lines.push(' '.repeat(width));
+ }
+
+ return lines.join('\nโ•‘ ').split('\n').map(l => l.substring(2)).join('\nโ•‘ ');
+ }
+
+ /**
+ * Render footer with summary
+ */
+ renderFooter() {
+ const width = this.options.maxWidth;
+ const agents = Array.from(this.agents.values());
+ const active = agents.filter(a => a.status === 'active').length;
+ const completed = agents.filter(a => a.status === 'completed').length;
+ const failed = agents.filter(a => a.status === 'failed').length;
+ const total = agents.length;
+
+ console.log('โ• ' + 'โ•'.repeat(width - 2) + 'โ•ฃ');
+
+ const progress = total > 0 ? Math.floor((completed + failed) / total * 100) : 0;
+ const summary = `๐Ÿ“Š Progress: ${progress}% (${completed}/${total}) โ”‚ โšก Active: ${active} โ”‚ โœ… Done: ${completed} โ”‚ โŒ Failed: ${failed}`;
+ console.log('โ•‘' + this.center(summary, width - 2) + 'โ•‘');
+
+ console.log('โ•š' + 'โ•'.repeat(width - 2) + 'โ•');
+ }
+
+ /**
+ * Helper methods
+ */
+ getAgentIcon(type) {
+ const icons = {
+ 'search': '๐Ÿ”',
+ 'foundation': '๐Ÿ—๏ธ',
+ 'refinement': '๐Ÿ”ง',
+ 'ensemble': '๐ŸŽฏ',
+ 'validation': 'โœ…',
+ 'coordinator': '๐ŸŽฎ',
+ 'researcher': '๐Ÿ”ฌ',
+ 'coder': '๐Ÿ’ป',
+ 'optimizer': 'โšก',
+ 'architect': '๐Ÿ›๏ธ',
+ 'tester': '๐Ÿงช'
+ };
+ return icons[type] || '๐Ÿค–';
+ }
+
+ getStatusIcon(status, spinner) {
+ switch (status) {
+ case 'active': return spinner;
+ case 'completed': return 'โœ…';
+ case 'failed': return 'โŒ';
+ case 'pending': return 'โณ';
+ default: return 'โ€ข';
+ }
+ }
+
+ getStatusText(status) {
+ switch (status) {
+ case 'active': return 'Running';
+ case 'completed': return 'Complete';
+ case 'failed': return 'Failed';
+ case 'pending': return 'Waiting';
+ default: return status;
+ }
+ }
+
+ renderProgressBar(progress, width) {
+ const barWidth = Math.min(20, width - 10);
+ const filled = Math.floor(progress / 100 * barWidth);
+ const empty = barWidth - filled;
+ return `[${'\u2588'.repeat(filled)}${'โ–‘'.repeat(empty)}] ${progress}%`;
+ }
+
+ truncate(text, width) {
+ if (text.length <= width) {
+ return text.padEnd(width);
+ }
+ return text.substring(0, width - 3) + '...';
+ }
+
+ center(text, width) {
+ const padding = Math.max(0, width - text.length);
+ const leftPad = Math.floor(padding / 2);
+ const rightPad = padding - leftPad;
+ return ' '.repeat(leftPad) + text + ' '.repeat(rightPad);
+ }
+
+ formatDuration(ms) {
+ const seconds = Math.floor(ms / 1000);
+ const minutes = Math.floor(seconds / 60);
+ const hours = Math.floor(minutes / 60);
+
+ if (hours > 0) {
+ return `${hours}h ${minutes % 60}m`;
+ } else if (minutes > 0) {
+ return `${minutes}m ${seconds % 60}s`;
+ } else {
+ return `${seconds}s`;
+ }
+ }
+}
+
+/**
+ * Create a display manager for workflow agents
+ */
+export function createConcurrentDisplay(agents, options = {}) {
+ return new ConcurrentDisplay(agents, options);
+}
\ No newline at end of file