mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix: Hive Mind status and sessions now show real metrics (fixes #762)
- Created HiveMindMetricsReader utility class to read real data from database - Updated showStatus() to use MetricsReader instead of raw queries - Updated showSessions() to use MetricsReader for real progress data - Fixed in-memory mode in session-manager to track real agent/task counts - Now shows actual agent counts, task progress, and completion percentages - Version bump to 2.0.0-alpha.113 Verified: - hive-mind status shows 4 real agents, real memory entries - hive-mind sessions shows real agent count and task progress - Completion percentages calculated from actual data, not hardcoded zeros
This commit is contained in:
1 parent
6a93136128
commit
6477cc7951
8 files changed
+5216
-89
No files matched your search
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"startTime": 1758297007212,
|
||||
"startTime": 1758309084968,
|
||||
"totalTasks": 1,
|
||||
"successfulTasks": 1,
|
||||
"failedTasks": 0,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{
|
||||
"id": "cmd-hooks-1758297007320",
|
||||
"id": "cmd-hooks-1758309085068",
|
||||
"type": "hooks",
|
||||
"success": true,
|
||||
"duration": 9.737476000000015,
|
||||
"timestamp": 1758297007329,
|
||||
"duration": 10.828915999999992,
|
||||
"timestamp": 1758309085079,
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Claude-Flow Smart Dispatcher - Detects and uses the best available runtime
|
||||
|
||||
VERSION="2.0.0-alpha.111"
|
||||
VERSION="2.0.0-alpha.112"
|
||||
|
||||
# Determine the correct path based on how the script is invoked
|
||||
if [ -L "$0" ]; then
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "claude-flow",
|
||||
"version": "2.0.0-alpha.112",
|
||||
"version": "2.0.0-alpha.113",
|
||||
"description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)",
|
||||
"mcpName": "io.github.ruvnet/claude-flow",
|
||||
"main": "cli.mjs",
|
||||
|
||||
@@ -38,6 +38,7 @@ import { CollectiveMemory } from './hive-mind/memory.js';
|
||||
import { SwarmCommunication } from './hive-mind/communication.js';
|
||||
import { HiveMindSessionManager } from './hive-mind/session-manager.js';
|
||||
import { createAutoSaveMiddleware } from './hive-mind/auto-save-middleware.js';
|
||||
import { HiveMindMetricsReader } from './hive-mind/metrics-reader.js';
|
||||
|
||||
function showHiveMindHelp() {
|
||||
console.log(`
|
||||
@@ -925,22 +926,13 @@ async function showStatus(flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
const db = new Database(dbPath);
|
||||
|
||||
// Get active swarms
|
||||
const swarms = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT * FROM swarms
|
||||
WHERE status = 'active'
|
||||
ORDER BY created_at DESC
|
||||
`,
|
||||
)
|
||||
.all();
|
||||
// Use the metrics reader for real data
|
||||
const metricsReader = new HiveMindMetricsReader(dbPath);
|
||||
const swarms = metricsReader.getActiveSwarms();
|
||||
|
||||
if (swarms.length === 0) {
|
||||
console.log(chalk.gray('No active swarms found'));
|
||||
db.close();
|
||||
metricsReader.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -954,85 +946,62 @@ async function showStatus(flags) {
|
||||
console.log(chalk.cyan('Queen Type:'), swarm.queen_type);
|
||||
console.log(chalk.cyan('Status:'), chalk.green(swarm.status));
|
||||
console.log(chalk.cyan('Created:'), new Date(swarm.created_at).toLocaleString());
|
||||
|
||||
// Get agents
|
||||
const agents = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT * FROM agents
|
||||
WHERE swarm_id = ?
|
||||
`,
|
||||
)
|
||||
.all(swarm.id);
|
||||
|
||||
// Show real agent count
|
||||
console.log(chalk.cyan('Total Agents:'), swarm.agent_count || 0);
|
||||
|
||||
console.log('\n' + chalk.bold('Agents:'));
|
||||
|
||||
// Group by role
|
||||
// Group by role using real agent data
|
||||
const agents = swarm.agents || [];
|
||||
const queen = agents.find((a) => a.role === 'queen');
|
||||
const workers = agents.filter((a) => a.role === 'worker');
|
||||
|
||||
if (queen) {
|
||||
console.log(' ' + chalk.magenta('👑 Queen:'), queen.name, chalk.gray(`(${queen.status})`));
|
||||
} else {
|
||||
console.log(' ' + chalk.gray('No queen assigned yet'));
|
||||
}
|
||||
|
||||
console.log(' ' + chalk.blue('🐝 Workers:'));
|
||||
workers.forEach((worker) => {
|
||||
const statusColor =
|
||||
worker.status === 'active' ? 'green' : worker.status === 'busy' ? 'yellow' : 'gray';
|
||||
console.log(` - ${worker.name} (${worker.type}) ${chalk[statusColor](worker.status)}`);
|
||||
});
|
||||
if (workers.length > 0) {
|
||||
workers.forEach((worker) => {
|
||||
const statusColor =
|
||||
worker.status === 'active' ? 'green' : worker.status === 'busy' ? 'yellow' : 'gray';
|
||||
console.log(` - ${worker.name} (${worker.type}) ${chalk[statusColor](worker.status)}`);
|
||||
});
|
||||
} else {
|
||||
console.log(' ' + chalk.gray('No workers spawned yet'));
|
||||
}
|
||||
|
||||
// Get task statistics
|
||||
const taskStats = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed,
|
||||
SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) as in_progress,
|
||||
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending
|
||||
FROM tasks
|
||||
WHERE swarm_id = ?
|
||||
`,
|
||||
)
|
||||
.get(swarm.id);
|
||||
// Get real task statistics
|
||||
const taskStats = swarm.task_metrics || {
|
||||
total: 0,
|
||||
completed: 0,
|
||||
in_progress: 0,
|
||||
pending: 0,
|
||||
failed: 0
|
||||
};
|
||||
|
||||
console.log('\n' + chalk.bold('Tasks:'));
|
||||
console.log(` Total: ${taskStats.total}`);
|
||||
console.log(` Completed: ${chalk.green(taskStats.completed)}`);
|
||||
console.log(` In Progress: ${chalk.yellow(taskStats.in_progress)}`);
|
||||
console.log(` Pending: ${chalk.gray(taskStats.pending)}`);
|
||||
|
||||
// Get memory stats
|
||||
const memoryCount = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT COUNT(*) as count FROM collective_memory
|
||||
WHERE swarm_id = ?
|
||||
`,
|
||||
)
|
||||
.get(swarm.id);
|
||||
console.log(` Completed: ${chalk.green(taskStats.completed || 0)}`);
|
||||
console.log(` In Progress: ${chalk.yellow(taskStats.in_progress || 0)}`);
|
||||
console.log(` Pending: ${chalk.gray(taskStats.pending || 0)}`);
|
||||
console.log(` ${chalk.bold('Completion:')} ${swarm.completion_percentage || 0}%`);
|
||||
|
||||
// Show real memory count
|
||||
console.log('\n' + chalk.bold('Collective Memory:'));
|
||||
console.log(` Entries: ${memoryCount.count}`);
|
||||
|
||||
// Get consensus stats
|
||||
const consensusCount = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT COUNT(*) as count FROM consensus_decisions
|
||||
WHERE swarm_id = ?
|
||||
`,
|
||||
)
|
||||
.get(swarm.id);
|
||||
console.log(` Entries: ${swarm.memory_count || 0}`);
|
||||
|
||||
// Show real consensus count
|
||||
console.log('\n' + chalk.bold('Consensus Decisions:'));
|
||||
console.log(` Total: ${consensusCount.count}`);
|
||||
console.log(` Total: ${swarm.consensus_count || 0}`);
|
||||
}
|
||||
|
||||
console.log(chalk.yellow('═'.repeat(60)) + '\n');
|
||||
|
||||
db.close();
|
||||
metricsReader.close();
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Error:'), error.message);
|
||||
exit(1);
|
||||
@@ -2573,12 +2542,20 @@ function getWorkerTypeInstructions(workerType) {
|
||||
*/
|
||||
async function showSessions(flags) {
|
||||
try {
|
||||
const sessionManager = new HiveMindSessionManager();
|
||||
const sessions = await sessionManager.getActiveSessions();
|
||||
// Use metrics reader for real session data
|
||||
const dbPath = path.join(cwd(), '.hive-mind', 'hive.db');
|
||||
|
||||
if (!existsSync(dbPath)) {
|
||||
console.log(chalk.gray('No hive mind database found'));
|
||||
return;
|
||||
}
|
||||
|
||||
const metricsReader = new HiveMindMetricsReader(dbPath);
|
||||
const sessions = metricsReader.getActiveSessions();
|
||||
|
||||
if (sessions.length === 0) {
|
||||
console.log(chalk.gray('No active or paused sessions found'));
|
||||
sessionManager.close();
|
||||
metricsReader.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2591,11 +2568,11 @@ async function showSessions(flags) {
|
||||
session.status === 'active' ? '🟢' : session.status === 'paused' ? '🟡' : '⚫';
|
||||
|
||||
console.log(chalk.yellow('═'.repeat(60)));
|
||||
console.log(`${statusIcon} ${chalk.bold(session.swarm_name)}`);
|
||||
console.log(`${statusIcon} ${chalk.bold(session.swarm_name || session.id)}`);
|
||||
console.log(chalk.cyan('Session ID:'), session.id);
|
||||
console.log(chalk.cyan('Status:'), chalk[statusColor](session.status));
|
||||
console.log(chalk.cyan('Objective:'), session.objective);
|
||||
console.log(chalk.cyan('Progress:'), `${session.completion_percentage}%`);
|
||||
console.log(chalk.cyan('Objective:'), session.objective || 'Not set');
|
||||
console.log(chalk.cyan('Progress:'), `${session.completion_percentage || 0}%`);
|
||||
console.log(chalk.cyan('Created:'), new Date(session.created_at).toLocaleString());
|
||||
console.log(chalk.cyan('Last Updated:'), new Date(session.updated_at).toLocaleString());
|
||||
|
||||
@@ -2603,14 +2580,19 @@ async function showSessions(flags) {
|
||||
console.log(chalk.cyan('Paused At:'), new Date(session.paused_at).toLocaleString());
|
||||
}
|
||||
|
||||
console.log('\n' + chalk.bold('Progress:'));
|
||||
console.log('\n' + chalk.bold('Real Progress:'));
|
||||
console.log(` Agents: ${session.agent_count || 0}`);
|
||||
console.log(` Tasks: ${session.completed_tasks || 0}/${session.task_count || 0}`);
|
||||
console.log(` In Progress: ${session.in_progress_tasks || 0}`);
|
||||
console.log(` Pending: ${session.pending_tasks || 0}`);
|
||||
|
||||
if (session.checkpoint_data) {
|
||||
console.log('\n' + chalk.bold('Last Checkpoint:'));
|
||||
const checkpointStr = typeof session.checkpoint_data === 'string'
|
||||
? session.checkpoint_data
|
||||
: JSON.stringify(session.checkpoint_data, null, 2);
|
||||
console.log(
|
||||
chalk.gray(JSON.stringify(session.checkpoint_data, null, 2).substring(0, 200) + '...'),
|
||||
chalk.gray(checkpointStr.substring(0, 200) + (checkpointStr.length > 200 ? '...' : '')),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -2621,7 +2603,7 @@ async function showSessions(flags) {
|
||||
console.log(' • Resume a session: claude-flow hive-mind resume <session-id>');
|
||||
console.log(' • View session details: claude-flow hive-mind status');
|
||||
|
||||
sessionManager.close();
|
||||
metricsReader.close();
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Error:'), error.message);
|
||||
exit(1);
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* HiveMind Metrics Reader
|
||||
* Reads real metrics from the database instead of returning mock data
|
||||
*/
|
||||
|
||||
import Database from 'better-sqlite3';
|
||||
import { existsSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { cwd } from '../../node-compat.js';
|
||||
|
||||
export class HiveMindMetricsReader {
|
||||
constructor(dbPath = null) {
|
||||
this.dbPath = dbPath || path.join(cwd(), '.hive-mind', 'hive.db');
|
||||
this.db = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize database connection
|
||||
*/
|
||||
init() {
|
||||
if (existsSync(this.dbPath)) {
|
||||
this.db = new Database(this.dbPath, { readonly: true });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close database connection
|
||||
*/
|
||||
close() {
|
||||
if (this.db) {
|
||||
this.db.close();
|
||||
this.db = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get swarm metrics with real data
|
||||
*/
|
||||
getSwarmMetrics(swarmId) {
|
||||
if (!this.db) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get swarm details
|
||||
const swarm = this.db.prepare('SELECT * FROM swarms WHERE id = ?').get(swarmId);
|
||||
|
||||
if (!swarm) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get real agent count
|
||||
const agentCount = this.db
|
||||
.prepare('SELECT COUNT(*) as count FROM agents WHERE swarm_id = ?')
|
||||
.get(swarmId).count;
|
||||
|
||||
// Get real task metrics
|
||||
const taskMetrics = this.db
|
||||
.prepare(`
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed,
|
||||
SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) as in_progress,
|
||||
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending,
|
||||
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed
|
||||
FROM tasks
|
||||
WHERE swarm_id = ?
|
||||
`)
|
||||
.get(swarmId);
|
||||
|
||||
// Get memory entries count
|
||||
const memoryCount = this.db
|
||||
.prepare('SELECT COUNT(*) as count FROM collective_memory WHERE swarm_id = ?')
|
||||
.get(swarmId).count;
|
||||
|
||||
// Get consensus decisions count
|
||||
const consensusCount = this.db
|
||||
.prepare('SELECT COUNT(*) as count FROM consensus_decisions WHERE swarm_id = ?')
|
||||
.get(swarmId).count;
|
||||
|
||||
// Get active agent details
|
||||
const agents = this.db
|
||||
.prepare('SELECT * FROM agents WHERE swarm_id = ? ORDER BY role DESC, created_at ASC')
|
||||
.all(swarmId);
|
||||
|
||||
return {
|
||||
...swarm,
|
||||
agent_count: agentCount,
|
||||
agents: agents,
|
||||
task_metrics: taskMetrics,
|
||||
memory_count: memoryCount,
|
||||
consensus_count: consensusCount,
|
||||
completion_percentage: taskMetrics.total > 0
|
||||
? Math.round((taskMetrics.completed / taskMetrics.total) * 100)
|
||||
: 0
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error reading swarm metrics:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session metrics with real data
|
||||
*/
|
||||
getSessionMetrics(sessionId) {
|
||||
if (!this.db) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get session details
|
||||
const session = this.db.prepare('SELECT * FROM sessions WHERE id = ?').get(sessionId);
|
||||
|
||||
if (!session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get real agent count for this session's swarm
|
||||
const agentCount = this.db
|
||||
.prepare('SELECT COUNT(*) as count FROM agents WHERE swarm_id = ?')
|
||||
.get(session.swarm_id).count;
|
||||
|
||||
// Get real task metrics for this session's swarm
|
||||
const taskMetrics = this.db
|
||||
.prepare(`
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed,
|
||||
SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) as in_progress,
|
||||
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending
|
||||
FROM tasks
|
||||
WHERE swarm_id = ?
|
||||
`)
|
||||
.get(session.swarm_id);
|
||||
|
||||
// Calculate real completion percentage
|
||||
const completionPercentage = taskMetrics.total > 0
|
||||
? Math.round((taskMetrics.completed / taskMetrics.total) * 100)
|
||||
: session.completion_percentage || 0;
|
||||
|
||||
return {
|
||||
...session,
|
||||
agent_count: agentCount,
|
||||
task_count: taskMetrics.total,
|
||||
completed_tasks: taskMetrics.completed,
|
||||
pending_tasks: taskMetrics.pending,
|
||||
in_progress_tasks: taskMetrics.in_progress,
|
||||
completion_percentage: completionPercentage
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error reading session metrics:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active sessions with real metrics
|
||||
*/
|
||||
getActiveSessions() {
|
||||
if (!this.db) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
// Get all active or paused sessions
|
||||
const sessions = this.db
|
||||
.prepare(`
|
||||
SELECT * FROM sessions
|
||||
WHERE status = 'active' OR status = 'paused'
|
||||
ORDER BY updated_at DESC
|
||||
`)
|
||||
.all();
|
||||
|
||||
// Enrich each session with real metrics
|
||||
return sessions.map(session => {
|
||||
const metrics = this.getSessionMetrics(session.id);
|
||||
return metrics || session;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error reading active sessions:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active swarms with real metrics
|
||||
*/
|
||||
getActiveSwarms() {
|
||||
if (!this.db) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
// Get all active swarms
|
||||
const swarms = this.db
|
||||
.prepare(`
|
||||
SELECT * FROM swarms
|
||||
WHERE status = 'active'
|
||||
ORDER BY created_at DESC
|
||||
`)
|
||||
.all();
|
||||
|
||||
// Enrich each swarm with real metrics
|
||||
return swarms.map(swarm => {
|
||||
const metrics = this.getSwarmMetrics(swarm.id);
|
||||
return metrics || swarm;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error reading active swarms:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get performance metrics
|
||||
*/
|
||||
getPerformanceMetrics() {
|
||||
if (!this.db) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get overall task metrics
|
||||
const overallTasks = this.db
|
||||
.prepare(`
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed,
|
||||
AVG(CASE WHEN status = 'completed' AND completion_time IS NOT NULL
|
||||
THEN (julianday(completion_time) - julianday(created_at)) * 24 * 60
|
||||
ELSE NULL END) as avg_completion_minutes
|
||||
FROM tasks
|
||||
`)
|
||||
.get();
|
||||
|
||||
// Get agent performance
|
||||
const agentPerformance = this.db
|
||||
.prepare(`
|
||||
SELECT
|
||||
a.type,
|
||||
COUNT(DISTINCT a.id) as agent_count,
|
||||
COUNT(t.id) as tasks_assigned,
|
||||
SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as tasks_completed
|
||||
FROM agents a
|
||||
LEFT JOIN tasks t ON a.id = t.agent_id
|
||||
GROUP BY a.type
|
||||
ORDER BY tasks_completed DESC
|
||||
`)
|
||||
.all();
|
||||
|
||||
// Get swarm performance
|
||||
const swarmPerformance = this.db
|
||||
.prepare(`
|
||||
SELECT
|
||||
s.name,
|
||||
s.objective,
|
||||
COUNT(DISTINCT a.id) as agent_count,
|
||||
COUNT(DISTINCT t.id) as task_count,
|
||||
SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as completed_count
|
||||
FROM swarms s
|
||||
LEFT JOIN agents a ON s.id = a.swarm_id
|
||||
LEFT JOIN tasks t ON s.id = t.swarm_id
|
||||
WHERE s.status = 'active'
|
||||
GROUP BY s.id
|
||||
ORDER BY s.created_at DESC
|
||||
LIMIT 5
|
||||
`)
|
||||
.all();
|
||||
|
||||
return {
|
||||
overall_tasks: overallTasks,
|
||||
agent_performance: agentPerformance,
|
||||
swarm_performance: swarmPerformance,
|
||||
success_rate: overallTasks.total > 0
|
||||
? (overallTasks.completed / overallTasks.total * 100).toFixed(1)
|
||||
: 0
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error reading performance metrics:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,18 +352,35 @@ To enable persistence, see: https://github.com/ruvnet/claude-code-flow/docs/wind
|
||||
await this.ensureInitialized();
|
||||
|
||||
if (this.isInMemory) {
|
||||
// Use in-memory storage
|
||||
// Use in-memory storage with real counts
|
||||
const sessions = [];
|
||||
for (const [sessionId, session] of this.memoryStore.sessions) {
|
||||
if (session.status === 'active' || session.status === 'paused') {
|
||||
// Get real agent count from memory
|
||||
const agentCount = this.memoryStore.agents
|
||||
? Array.from(this.memoryStore.agents.values()).filter(a => a.swarm_id === session.swarm_id).length
|
||||
: 0;
|
||||
|
||||
// Get real task counts from memory
|
||||
const tasks = this.memoryStore.tasks
|
||||
? Array.from(this.memoryStore.tasks.values()).filter(t => t.swarm_id === session.swarm_id)
|
||||
: [];
|
||||
|
||||
const taskCount = tasks.length;
|
||||
const completedTasks = tasks.filter(t => t.status === 'completed').length;
|
||||
const inProgressTasks = tasks.filter(t => t.status === 'in_progress').length;
|
||||
const pendingTasks = tasks.filter(t => t.status === 'pending').length;
|
||||
|
||||
sessions.push({
|
||||
...session,
|
||||
metadata: session.metadata ? sessionSerializer.deserializeMetadata(session.metadata) : {},
|
||||
checkpoint_data: session.checkpoint_data ? sessionSerializer.deserializeCheckpointData(session.checkpoint_data) : null,
|
||||
agent_count: 0, // Not tracked in memory mode
|
||||
task_count: 0, // Not tracked in memory mode
|
||||
completed_tasks: 0, // Not tracked in memory mode
|
||||
completion_percentage: 0
|
||||
agent_count: agentCount,
|
||||
task_count: taskCount,
|
||||
completed_tasks: completedTasks,
|
||||
in_progress_tasks: inProgressTasks,
|
||||
pending_tasks: pendingTasks,
|
||||
completion_percentage: taskCount > 0 ? Math.round((completedTasks / taskCount) * 100) : 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user