claude-flow 2.0.0-alpha.62 → 2.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/token-efficiency.md +2 -1
- package/.claude/commands/automation/self-healing.md +47 -2
- package/.claude/commands/automation/session-memory.md +39 -10
- package/.claude/commands/automation/smart-agents.md +36 -8
- package/.claude/commands/github/code-review-swarm.md +80 -15
- package/.claude/commands/github/github-modes.md +14 -14
- package/.claude/commands/github/issue-tracker.md +19 -16
- package/.claude/commands/github/multi-repo-swarm.md +114 -16
- package/.claude/commands/github/pr-manager.md +5 -4
- package/.claude/commands/github/project-board-sync.md +38 -5
- package/.claude/commands/github/release-manager.md +19 -19
- package/.claude/commands/github/release-swarm.md +102 -13
- package/.claude/commands/github/repo-architect.md +6 -6
- package/.claude/commands/github/swarm-issue.md +139 -17
- package/.claude/commands/github/swarm-pr.md +49 -15
- package/.claude/commands/github/sync-coordinator.md +33 -33
- package/.claude/commands/github/workflow-automation.md +37 -10
- package/.claude/commands/hooks/overview.md +2 -2
- package/.claude/commands/hooks/setup.md +7 -7
- package/.claude/commands/memory/neural.md +10 -5
- package/.claude/commands/memory/usage.md +9 -5
- package/.claude/commands/monitoring/agents.md +7 -5
- package/.claude/commands/monitoring/status.md +8 -5
- package/.claude/commands/optimization/auto-topology.md +13 -1
- package/.claude/commands/optimization/parallel-execution.md +7 -1
- package/.claude/commands/sparc/analyzer.md +28 -2
- package/.claude/commands/sparc/architect.md +27 -1
- package/.claude/commands/sparc/batch-executor.md +27 -1
- package/.claude/commands/sparc/coder.md +27 -1
- package/.claude/commands/sparc/debugger.md +27 -1
- package/.claude/commands/sparc/designer.md +27 -1
- package/.claude/commands/sparc/documenter.md +27 -1
- package/.claude/commands/sparc/innovator.md +27 -1
- package/.claude/commands/sparc/memory-manager.md +27 -1
- package/.claude/commands/sparc/optimizer.md +27 -1
- package/.claude/commands/sparc/orchestrator.md +106 -2
- package/.claude/commands/sparc/researcher.md +27 -1
- package/.claude/commands/sparc/reviewer.md +27 -1
- package/.claude/commands/sparc/sparc-modes.md +137 -5
- package/.claude/commands/sparc/swarm-coordinator.md +27 -1
- package/.claude/commands/sparc/tdd.md +27 -1
- package/.claude/commands/sparc/tester.md +27 -1
- package/.claude/commands/sparc/workflow-manager.md +27 -1
- package/.claude/commands/swarm/analysis.md +82 -5
- package/.claude/commands/swarm/development.md +83 -6
- package/.claude/commands/swarm/examples.md +141 -3
- package/.claude/commands/swarm/maintenance.md +92 -8
- package/.claude/commands/swarm/optimization.md +107 -9
- package/.claude/commands/swarm/research.md +126 -8
- package/.claude/commands/swarm/testing.md +121 -9
- package/.claude/commands/training/neural-patterns.md +27 -2
- package/.claude/commands/training/specialization.md +13 -3
- package/.claude/commands/workflows/development.md +43 -4
- package/.claude/commands/workflows/research.md +26 -2
- package/README.md +8 -0
- package/bin/claude-flow +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts +66 -0
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +220 -2
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +1 -1
- package/dist/cli/simple-commands/hive-mind.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind.js +83 -5
- package/dist/cli/simple-commands/hive-mind.js.map +1 -1
- package/dist/memory/fallback-store.d.ts +1 -0
- package/dist/memory/fallback-store.d.ts.map +1 -1
- package/dist/memory/fallback-store.js +25 -3
- package/dist/memory/fallback-store.js.map +1 -1
- package/dist/memory/sqlite-store.d.ts +34 -0
- package/dist/memory/sqlite-store.d.ts.map +1 -0
- package/dist/memory/sqlite-store.js +2 -3
- package/dist/memory/sqlite-store.js.map +1 -1
- package/dist/memory/sqlite-wrapper.d.ts +38 -0
- package/dist/memory/sqlite-wrapper.d.ts.map +1 -0
- package/dist/memory/sqlite-wrapper.js +157 -0
- package/dist/memory/sqlite-wrapper.js.map +1 -0
- package/package.json +1 -1
- package/src/api/claude-api-errors.ts +248 -0
- package/src/api/claude-client-enhanced.ts +616 -0
- package/src/api/claude-client.ts +282 -14
- package/src/cli/help-text.js +2 -1
- package/src/cli/simple-commands/coordination.js +73 -49
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +6 -6
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +327 -8
- package/src/cli/simple-commands/hive-mind/session-manager.js +330 -108
- package/src/cli/simple-commands/hive-mind.js +192 -11
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +53 -28
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +36 -14
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +107 -30
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/index.js +156 -235
- package/src/cli/simple-commands/init/template-copier.js +583 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +634 -23
- package/src/hive-mind/core/DatabaseManager.ts +75 -16
- package/src/memory/backends/sqlite.ts +21 -3
- package/src/memory/fallback-store.js +35 -3
- package/src/memory/sqlite-store.js +2 -3
- package/src/memory/sqlite-wrapper.js +173 -0
|
@@ -131,6 +131,9 @@ export class MCPToolWrapper {
|
|
|
131
131
|
|
|
132
132
|
/** @type {import('better-sqlite3').Database | null} */
|
|
133
133
|
this.memoryDb = null;
|
|
134
|
+
|
|
135
|
+
// Initialize memory store for fallback
|
|
136
|
+
this.memoryStore = new Map();
|
|
134
137
|
|
|
135
138
|
// Initialize real memory storage
|
|
136
139
|
this.initializeMemoryStorage();
|
|
@@ -141,10 +144,16 @@ export class MCPToolWrapper {
|
|
|
141
144
|
*/
|
|
142
145
|
async initializeMemoryStorage() {
|
|
143
146
|
try {
|
|
144
|
-
const
|
|
147
|
+
const { createDatabase, isSQLiteAvailable } = await import('../../../memory/sqlite-wrapper.js');
|
|
145
148
|
const path = await import('path');
|
|
146
149
|
const fs = await import('fs');
|
|
147
150
|
|
|
151
|
+
// Check if SQLite is available
|
|
152
|
+
const sqliteAvailable = await isSQLiteAvailable();
|
|
153
|
+
if (!sqliteAvailable) {
|
|
154
|
+
throw new Error('SQLite not available');
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
// Create .hive-mind directory if it doesn't exist
|
|
149
158
|
const hiveMindDir = path.join(process.cwd(), '.hive-mind');
|
|
150
159
|
if (!fs.existsSync(hiveMindDir)) {
|
|
@@ -153,7 +162,7 @@ export class MCPToolWrapper {
|
|
|
153
162
|
|
|
154
163
|
// Initialize SQLite database
|
|
155
164
|
const dbPath = path.join(hiveMindDir, 'memory.db');
|
|
156
|
-
this.memoryDb =
|
|
165
|
+
this.memoryDb = await createDatabase(dbPath);
|
|
157
166
|
|
|
158
167
|
// Create memories table
|
|
159
168
|
this.memoryDb.exec(`
|
|
@@ -177,6 +186,14 @@ export class MCPToolWrapper {
|
|
|
177
186
|
);
|
|
178
187
|
this.memoryDb = null;
|
|
179
188
|
this.memoryStore = new Map(); // Fallback to in-memory storage
|
|
189
|
+
|
|
190
|
+
// Log Windows-specific help if applicable
|
|
191
|
+
if (process.platform === 'win32') {
|
|
192
|
+
console.info(`
|
|
193
|
+
Windows users: For persistent storage, please see installation guide:
|
|
194
|
+
https://github.com/ruvnet/claude-code-flow/docs/windows-installation.md
|
|
195
|
+
`);
|
|
196
|
+
}
|
|
180
197
|
}
|
|
181
198
|
}
|
|
182
199
|
|
|
@@ -396,6 +413,8 @@ export class MCPToolWrapper {
|
|
|
396
413
|
}
|
|
397
414
|
} else if (toolName === 'memory_search') {
|
|
398
415
|
return await this.searchMemory(params.namespace, params.pattern);
|
|
416
|
+
} else if (toolName === 'swarm_status') {
|
|
417
|
+
return await this.getSwarmStatus(params);
|
|
399
418
|
}
|
|
400
419
|
|
|
401
420
|
// For other tools, use mock responses
|
|
@@ -609,13 +628,34 @@ export class MCPToolWrapper {
|
|
|
609
628
|
'init_performance',
|
|
610
629
|
{
|
|
611
630
|
initTime,
|
|
612
|
-
topology: config.topology,
|
|
613
|
-
maxAgents: config.maxAgents,
|
|
631
|
+
topology: config.topology || 'hierarchical',
|
|
632
|
+
maxAgents: config.maxAgents || 8,
|
|
614
633
|
timestamp: Date.now(),
|
|
615
634
|
},
|
|
616
635
|
'metrics',
|
|
617
636
|
);
|
|
618
637
|
|
|
638
|
+
// Store swarm status
|
|
639
|
+
await this.storeMemory(
|
|
640
|
+
swarmId,
|
|
641
|
+
'status',
|
|
642
|
+
'active',
|
|
643
|
+
'status',
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
// Store swarm config
|
|
647
|
+
await this.storeMemory(
|
|
648
|
+
swarmId,
|
|
649
|
+
'config',
|
|
650
|
+
{
|
|
651
|
+
topology: config.topology || 'hierarchical',
|
|
652
|
+
maxAgents: config.maxAgents || 8,
|
|
653
|
+
strategy: config.strategy || 'auto',
|
|
654
|
+
createdAt: Date.now(),
|
|
655
|
+
},
|
|
656
|
+
'config',
|
|
657
|
+
);
|
|
658
|
+
|
|
619
659
|
return [swarmInitResult, ...supportingResults];
|
|
620
660
|
} catch (error) {
|
|
621
661
|
console.error('Swarm initialization failed:', error);
|
|
@@ -652,6 +692,23 @@ export class MCPToolWrapper {
|
|
|
652
692
|
|
|
653
693
|
const groupResults = await this.executeParallel(batch);
|
|
654
694
|
allResults.push(...groupResults);
|
|
695
|
+
|
|
696
|
+
// Store agent information in memory
|
|
697
|
+
for (const result of groupResults) {
|
|
698
|
+
if (result && result.agentId && !result.error) {
|
|
699
|
+
await this.storeMemory(
|
|
700
|
+
swarmId,
|
|
701
|
+
`agent-${result.agentId}`,
|
|
702
|
+
{
|
|
703
|
+
id: result.agentId,
|
|
704
|
+
type: result.type,
|
|
705
|
+
status: result.status || 'active',
|
|
706
|
+
createdAt: Date.now(),
|
|
707
|
+
},
|
|
708
|
+
'agent',
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
655
712
|
}
|
|
656
713
|
|
|
657
714
|
// Track spawn performance
|
|
@@ -726,7 +783,8 @@ export class MCPToolWrapper {
|
|
|
726
783
|
*/
|
|
727
784
|
async storeMemory(swarmId, key, value, type = 'knowledge') {
|
|
728
785
|
try {
|
|
729
|
-
if
|
|
786
|
+
// Don't reinitialize if we already have storage
|
|
787
|
+
if (!this.memoryDb && !this.memoryStore) {
|
|
730
788
|
await this.initializeMemoryStorage();
|
|
731
789
|
}
|
|
732
790
|
|
|
@@ -782,7 +840,8 @@ export class MCPToolWrapper {
|
|
|
782
840
|
*/
|
|
783
841
|
async retrieveMemory(swarmId, key) {
|
|
784
842
|
try {
|
|
785
|
-
if
|
|
843
|
+
// Don't reinitialize if we already have storage
|
|
844
|
+
if (!this.memoryDb && !this.memoryStore) {
|
|
786
845
|
await this.initializeMemoryStorage();
|
|
787
846
|
}
|
|
788
847
|
|
|
@@ -831,7 +890,8 @@ export class MCPToolWrapper {
|
|
|
831
890
|
*/
|
|
832
891
|
async searchMemory(swarmId, pattern) {
|
|
833
892
|
try {
|
|
834
|
-
if
|
|
893
|
+
// Don't reinitialize if we already have storage
|
|
894
|
+
if (!this.memoryDb && !this.memoryStore) {
|
|
835
895
|
await this.initializeMemoryStorage();
|
|
836
896
|
}
|
|
837
897
|
|
|
@@ -921,8 +981,25 @@ export class MCPToolWrapper {
|
|
|
921
981
|
*/
|
|
922
982
|
async orchestrateTask(task, strategy = 'parallel', metadata = {}) {
|
|
923
983
|
const taskId = metadata.taskId || `task-${Date.now()}`;
|
|
984
|
+
const swarmId = metadata.swarmId || 'default-swarm';
|
|
924
985
|
const complexity = metadata.complexity || 'medium';
|
|
925
986
|
|
|
987
|
+
// Store task information
|
|
988
|
+
await this.storeMemory(
|
|
989
|
+
swarmId,
|
|
990
|
+
`task-${taskId}`,
|
|
991
|
+
{
|
|
992
|
+
id: taskId,
|
|
993
|
+
task,
|
|
994
|
+
strategy,
|
|
995
|
+
status: 'pending',
|
|
996
|
+
priority: metadata.priority || 5,
|
|
997
|
+
complexity,
|
|
998
|
+
createdAt: Date.now(),
|
|
999
|
+
},
|
|
1000
|
+
'task',
|
|
1001
|
+
);
|
|
1002
|
+
|
|
926
1003
|
// Adjust monitoring frequency based on task complexity
|
|
927
1004
|
const monitoringInterval =
|
|
928
1005
|
{
|
|
@@ -961,7 +1038,25 @@ export class MCPToolWrapper {
|
|
|
961
1038
|
: []),
|
|
962
1039
|
];
|
|
963
1040
|
|
|
964
|
-
|
|
1041
|
+
const results = await this.executeParallel(batch);
|
|
1042
|
+
|
|
1043
|
+
// Update task status
|
|
1044
|
+
await this.storeMemory(
|
|
1045
|
+
swarmId,
|
|
1046
|
+
`task-${taskId}`,
|
|
1047
|
+
{
|
|
1048
|
+
id: taskId,
|
|
1049
|
+
task,
|
|
1050
|
+
strategy,
|
|
1051
|
+
status: 'in_progress',
|
|
1052
|
+
priority: metadata.priority || 5,
|
|
1053
|
+
complexity,
|
|
1054
|
+
createdAt: Date.now(),
|
|
1055
|
+
},
|
|
1056
|
+
'task',
|
|
1057
|
+
);
|
|
1058
|
+
|
|
1059
|
+
return results;
|
|
965
1060
|
}
|
|
966
1061
|
|
|
967
1062
|
/**
|
|
@@ -1039,6 +1134,230 @@ export class MCPToolWrapper {
|
|
|
1039
1134
|
|
|
1040
1135
|
return await this.executeParallel(batch);
|
|
1041
1136
|
}
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Get real swarm status from memory storage
|
|
1140
|
+
*/
|
|
1141
|
+
async getSwarmStatus(params = {}) {
|
|
1142
|
+
try {
|
|
1143
|
+
// Don't reinitialize if we already have storage
|
|
1144
|
+
if (!this.memoryDb && !this.memoryStore) {
|
|
1145
|
+
await this.initializeMemoryStorage();
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
const swarms = [];
|
|
1149
|
+
let activeAgents = 0;
|
|
1150
|
+
let totalTasks = 0;
|
|
1151
|
+
let completedTasks = 0;
|
|
1152
|
+
|
|
1153
|
+
if (this.memoryDb) {
|
|
1154
|
+
// Get all unique swarm namespaces
|
|
1155
|
+
const namespacesQuery = this.memoryDb.prepare(`
|
|
1156
|
+
SELECT DISTINCT namespace FROM memories
|
|
1157
|
+
WHERE namespace LIKE 'swarm-%' OR namespace LIKE 'hive-%'
|
|
1158
|
+
ORDER BY timestamp DESC
|
|
1159
|
+
`);
|
|
1160
|
+
const namespaces = namespacesQuery.all();
|
|
1161
|
+
|
|
1162
|
+
// For each swarm, gather its information
|
|
1163
|
+
for (const { namespace } of namespaces) {
|
|
1164
|
+
const swarmId = namespace;
|
|
1165
|
+
|
|
1166
|
+
// Get swarm metadata
|
|
1167
|
+
const metadataQuery = this.memoryDb.prepare(`
|
|
1168
|
+
SELECT key, value, type, timestamp FROM memories
|
|
1169
|
+
WHERE namespace = ? AND (
|
|
1170
|
+
key IN ('init_performance', 'config', 'status', 'agents', 'tasks', 'topology')
|
|
1171
|
+
OR key LIKE 'agent-%'
|
|
1172
|
+
OR key LIKE 'task-%'
|
|
1173
|
+
)
|
|
1174
|
+
`);
|
|
1175
|
+
const swarmData = metadataQuery.all(swarmId);
|
|
1176
|
+
|
|
1177
|
+
// Parse swarm information
|
|
1178
|
+
let swarmInfo = {
|
|
1179
|
+
id: swarmId,
|
|
1180
|
+
name: swarmId,
|
|
1181
|
+
status: 'unknown',
|
|
1182
|
+
agents: 0,
|
|
1183
|
+
tasks: { total: 0, completed: 0, pending: 0, failed: 0 },
|
|
1184
|
+
topology: 'hierarchical',
|
|
1185
|
+
createdAt: null,
|
|
1186
|
+
lastActivity: null,
|
|
1187
|
+
memoryUsage: swarmData.length
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
// Process swarm data
|
|
1191
|
+
for (const record of swarmData) {
|
|
1192
|
+
try {
|
|
1193
|
+
const value = typeof record.value === 'string' ? JSON.parse(record.value) : record.value;
|
|
1194
|
+
|
|
1195
|
+
switch (record.key) {
|
|
1196
|
+
case 'init_performance':
|
|
1197
|
+
swarmInfo.createdAt = value.timestamp;
|
|
1198
|
+
swarmInfo.topology = value.topology || 'hierarchical';
|
|
1199
|
+
break;
|
|
1200
|
+
case 'status':
|
|
1201
|
+
swarmInfo.status = value;
|
|
1202
|
+
break;
|
|
1203
|
+
case 'config':
|
|
1204
|
+
swarmInfo.topology = value.topology || swarmInfo.topology;
|
|
1205
|
+
break;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// Count agents
|
|
1209
|
+
if (record.key.startsWith('agent-')) {
|
|
1210
|
+
swarmInfo.agents++;
|
|
1211
|
+
activeAgents++;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// Count tasks
|
|
1215
|
+
if (record.key.startsWith('task-')) {
|
|
1216
|
+
swarmInfo.tasks.total++;
|
|
1217
|
+
totalTasks++;
|
|
1218
|
+
if (value.status === 'completed') {
|
|
1219
|
+
swarmInfo.tasks.completed++;
|
|
1220
|
+
completedTasks++;
|
|
1221
|
+
} else if (value.status === 'failed') {
|
|
1222
|
+
swarmInfo.tasks.failed++;
|
|
1223
|
+
} else if (value.status === 'pending' || value.status === 'in_progress') {
|
|
1224
|
+
swarmInfo.tasks.pending++;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// Track last activity
|
|
1229
|
+
if (record.timestamp > (swarmInfo.lastActivity || 0)) {
|
|
1230
|
+
swarmInfo.lastActivity = record.timestamp;
|
|
1231
|
+
}
|
|
1232
|
+
} catch (e) {
|
|
1233
|
+
// Skip invalid JSON values
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// Determine swarm status based on activity
|
|
1238
|
+
if (swarmInfo.status === 'unknown') {
|
|
1239
|
+
const now = Date.now();
|
|
1240
|
+
const lastActivityAge = now - (swarmInfo.lastActivity || 0);
|
|
1241
|
+
|
|
1242
|
+
if (lastActivityAge < 60000) { // Active within last minute
|
|
1243
|
+
swarmInfo.status = 'active';
|
|
1244
|
+
} else if (lastActivityAge < 300000) { // Active within last 5 minutes
|
|
1245
|
+
swarmInfo.status = 'idle';
|
|
1246
|
+
} else {
|
|
1247
|
+
swarmInfo.status = 'inactive';
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
swarms.push(swarmInfo);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// Get recent activity logs
|
|
1255
|
+
const activityQuery = this.memoryDb.prepare(`
|
|
1256
|
+
SELECT namespace, key, type, timestamp FROM memories
|
|
1257
|
+
WHERE (namespace LIKE 'swarm-%' OR namespace LIKE 'hive-%')
|
|
1258
|
+
AND timestamp > ?
|
|
1259
|
+
ORDER BY timestamp DESC
|
|
1260
|
+
LIMIT 10
|
|
1261
|
+
`);
|
|
1262
|
+
const recentActivity = activityQuery.all(Date.now() - 300000); // Last 5 minutes
|
|
1263
|
+
|
|
1264
|
+
return {
|
|
1265
|
+
swarms,
|
|
1266
|
+
activeAgents,
|
|
1267
|
+
totalTasks,
|
|
1268
|
+
completedTasks,
|
|
1269
|
+
pendingTasks: totalTasks - completedTasks,
|
|
1270
|
+
recentActivity: recentActivity.map(r => ({
|
|
1271
|
+
swarmId: r.namespace,
|
|
1272
|
+
action: r.key,
|
|
1273
|
+
type: r.type,
|
|
1274
|
+
timestamp: r.timestamp
|
|
1275
|
+
})),
|
|
1276
|
+
summary: {
|
|
1277
|
+
totalSwarms: swarms.length,
|
|
1278
|
+
activeSwarms: swarms.filter(s => s.status === 'active').length,
|
|
1279
|
+
idleSwarms: swarms.filter(s => s.status === 'idle').length,
|
|
1280
|
+
inactiveSwarms: swarms.filter(s => s.status === 'inactive').length
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
} else {
|
|
1284
|
+
// Fallback to in-memory storage
|
|
1285
|
+
const swarmMap = new Map();
|
|
1286
|
+
|
|
1287
|
+
for (const [key, memory] of this.memoryStore) {
|
|
1288
|
+
const namespace = memory.namespace;
|
|
1289
|
+
if (namespace && (namespace.startsWith('swarm-') || namespace.startsWith('hive-'))) {
|
|
1290
|
+
if (!swarmMap.has(namespace)) {
|
|
1291
|
+
swarmMap.set(namespace, {
|
|
1292
|
+
id: namespace,
|
|
1293
|
+
name: namespace,
|
|
1294
|
+
status: 'active',
|
|
1295
|
+
agents: 0,
|
|
1296
|
+
tasks: { total: 0, completed: 0, pending: 0, failed: 0 },
|
|
1297
|
+
memoryUsage: 0
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
const swarm = swarmMap.get(namespace);
|
|
1302
|
+
swarm.memoryUsage++;
|
|
1303
|
+
|
|
1304
|
+
if (memory.key.startsWith('agent-')) {
|
|
1305
|
+
swarm.agents++;
|
|
1306
|
+
activeAgents++;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if (memory.key.startsWith('task-')) {
|
|
1310
|
+
swarm.tasks.total++;
|
|
1311
|
+
totalTasks++;
|
|
1312
|
+
try {
|
|
1313
|
+
const taskData = JSON.parse(memory.value);
|
|
1314
|
+
if (taskData.status === 'completed') {
|
|
1315
|
+
swarm.tasks.completed++;
|
|
1316
|
+
completedTasks++;
|
|
1317
|
+
} else if (taskData.status === 'failed') {
|
|
1318
|
+
swarm.tasks.failed++;
|
|
1319
|
+
} else if (taskData.status === 'pending' || taskData.status === 'in_progress') {
|
|
1320
|
+
swarm.tasks.pending++;
|
|
1321
|
+
}
|
|
1322
|
+
} catch (e) {
|
|
1323
|
+
// Skip invalid JSON
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
return {
|
|
1330
|
+
swarms: Array.from(swarmMap.values()),
|
|
1331
|
+
activeAgents,
|
|
1332
|
+
totalTasks,
|
|
1333
|
+
completedTasks,
|
|
1334
|
+
pendingTasks: totalTasks - completedTasks,
|
|
1335
|
+
summary: {
|
|
1336
|
+
totalSwarms: swarmMap.size,
|
|
1337
|
+
activeSwarms: swarmMap.size
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
} catch (error) {
|
|
1342
|
+
console.error('Error getting swarm status:', error);
|
|
1343
|
+
// Return empty status on error
|
|
1344
|
+
return {
|
|
1345
|
+
swarms: [],
|
|
1346
|
+
activeAgents: 0,
|
|
1347
|
+
totalTasks: 0,
|
|
1348
|
+
completedTasks: 0,
|
|
1349
|
+
pendingTasks: 0,
|
|
1350
|
+
recentActivity: [],
|
|
1351
|
+
summary: {
|
|
1352
|
+
totalSwarms: 0,
|
|
1353
|
+
activeSwarms: 0,
|
|
1354
|
+
idleSwarms: 0,
|
|
1355
|
+
inactiveSwarms: 0
|
|
1356
|
+
},
|
|
1357
|
+
error: error.message
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1042
1361
|
}
|
|
1043
1362
|
|
|
1044
1363
|
// Export tool categories for reference
|