claude-flow 2.0.0-alpha.98 → 2.0.0
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/agents/MIGRATION_SUMMARY.md +7 -0
- package/.claude/agents/README.md +7 -0
- package/.claude/agents/consensus/README.md +7 -0
- package/.claude/agents/flow-nexus/app-store.md +88 -0
- package/.claude/agents/flow-nexus/authentication.md +69 -0
- package/.claude/agents/flow-nexus/challenges.md +81 -0
- package/.claude/agents/flow-nexus/neural-network.md +88 -0
- package/.claude/agents/flow-nexus/payments.md +83 -0
- package/.claude/agents/flow-nexus/sandbox.md +76 -0
- package/.claude/agents/flow-nexus/swarm.md +76 -0
- package/.claude/agents/flow-nexus/user-tools.md +96 -0
- package/.claude/agents/flow-nexus/workflow.md +84 -0
- package/.claude/agents/optimization/README.md +7 -0
- package/.claude/agents/optimization/benchmark-suite.md +7 -0
- package/.claude/agents/optimization/load-balancer.md +7 -0
- package/.claude/agents/optimization/performance-monitor.md +7 -0
- package/.claude/agents/optimization/resource-allocator.md +7 -0
- package/.claude/agents/optimization/topology-optimizer.md +7 -0
- package/.claude/agents/swarm/README.md +7 -0
- package/.claude/checkpoints/1756227204.json +1 -0
- package/.claude/checkpoints/1756227205.json +1 -0
- package/.claude/checkpoints/1756227276.json +1 -0
- package/.claude/checkpoints/1756227278.json +1 -0
- package/.claude/checkpoints/1756227280.json +1 -0
- package/.claude/checkpoints/1756227282.json +1 -0
- package/.claude/checkpoints/1756227652.json +1 -0
- package/.claude/checkpoints/1756227653.json +1 -0
- package/.claude/checkpoints/1756227666.json +1 -0
- package/.claude/checkpoints/1756227668.json +1 -0
- package/.claude/checkpoints/1756227723.json +1 -0
- package/.claude/checkpoints/1756227725.json +1 -0
- package/.claude/checkpoints/1756227731.json +1 -0
- package/.claude/checkpoints/1756227733.json +1 -0
- package/.claude/checkpoints/1756231330.json +1 -0
- package/.claude/checkpoints/1756231331.json +1 -0
- package/.claude/checkpoints/1756231342.json +1 -0
- package/.claude/checkpoints/1756231344.json +1 -0
- package/.claude/checkpoints/1756231355.json +1 -0
- package/.claude/checkpoints/1756231357.json +1 -0
- package/.claude/checkpoints/1756231367.json +1 -0
- package/.claude/checkpoints/1756231368.json +1 -0
- package/.claude/checkpoints/1756231458.json +1 -0
- package/.claude/checkpoints/1756231459.json +1 -0
- package/.claude/checkpoints/1756231477.json +1 -0
- package/.claude/checkpoints/1756231479.json +1 -0
- package/.claude/checkpoints/1756233026.json +1 -0
- package/.claude/checkpoints/1756233028.json +1 -0
- package/.claude/checkpoints/1756233040.json +1 -0
- package/.claude/checkpoints/1756233041.json +1 -0
- package/.claude/checkpoints/1756233057.json +1 -0
- package/.claude/checkpoints/1756233059.json +1 -0
- package/.claude/checkpoints/1756233090.json +1 -0
- package/.claude/checkpoints/1756233092.json +1 -0
- package/.claude/checkpoints/1756233141.json +1 -0
- package/.claude/checkpoints/1756233143.json +1 -0
- package/.claude/checkpoints/1756475935.json +1 -0
- package/.claude/checkpoints/1756475936.json +1 -0
- package/.claude/checkpoints/1756475996.json +1 -0
- package/.claude/checkpoints/1756475998.json +1 -0
- package/.claude/checkpoints/1756476093.json +1 -0
- package/.claude/checkpoints/1756476098.json +1 -0
- package/.claude/checkpoints/1756476100.json +1 -0
- package/.claude/checkpoints/1756476101.json +1 -0
- package/.claude/checkpoints/1756476161.json +1 -0
- package/.claude/checkpoints/1756476163.json +1 -0
- package/.claude/checkpoints/1756476183.json +1 -0
- package/.claude/checkpoints/1756476184.json +1 -0
- package/.claude/checkpoints/1756476193.json +1 -0
- package/.claude/checkpoints/1756476194.json +1 -0
- package/.claude/checkpoints/1756476202.json +1 -0
- package/.claude/checkpoints/1756476204.json +1 -0
- package/.claude/checkpoints/1756476268.json +1 -0
- package/.claude/checkpoints/1756476269.json +1 -0
- package/.claude/checkpoints/1756476287.json +1 -0
- package/.claude/checkpoints/1756476288.json +1 -0
- package/.claude/checkpoints/1756997935.json +1 -0
- package/.claude/checkpoints/1756997937.json +1 -0
- package/.claude/checkpoints/1756997938.json +1 -0
- package/.claude/checkpoints/1756997940.json +1 -0
- package/.claude/checkpoints/1756997942.json +1 -0
- package/.claude/checkpoints/1756997944.json +1 -0
- package/.claude/checkpoints/1756997945.json +1 -0
- package/.claude/checkpoints/1756997947.json +1 -0
- package/.claude/checkpoints/1756997949.json +1 -0
- package/.claude/checkpoints/1756997951.json +1 -0
- package/.claude/checkpoints/1756997953.json +1 -0
- package/.claude/checkpoints/1756997955.json +1 -0
- package/.claude/checkpoints/1756997956.json +1 -0
- package/.claude/checkpoints/1756997958.json +1 -0
- package/.claude/checkpoints/1756997960.json +1 -0
- package/.claude/checkpoints/1756997962.json +1 -0
- package/.claude/checkpoints/1756997964.json +1 -0
- package/.claude/checkpoints/1756997966.json +1 -0
- package/.claude/checkpoints/1756997968.json +1 -0
- package/.claude/checkpoints/1756997970.json +1 -0
- package/.claude/checkpoints/1757190213.json +1 -0
- package/.claude/checkpoints/1757190215.json +1 -0
- package/.claude/checkpoints/1757190217.json +1 -0
- package/.claude/checkpoints/1757190219.json +1 -0
- package/.claude/checkpoints/1757190220.json +1 -0
- package/.claude/checkpoints/1757190222.json +1 -0
- package/.claude/checkpoints/1757190224.json +1 -0
- package/.claude/checkpoints/1757190225.json +1 -0
- package/.claude/checkpoints/1757190227.json +1 -0
- package/.claude/checkpoints/1757190229.json +1 -0
- package/.claude/checkpoints/1757190231.json +1 -0
- package/.claude/checkpoints/1757190232.json +1 -0
- package/.claude/checkpoints/1757190234.json +1 -0
- package/.claude/checkpoints/1757190236.json +1 -0
- package/.claude/checkpoints/1757190238.json +1 -0
- package/.claude/checkpoints/1757190240.json +1 -0
- package/.claude/checkpoints/1757190241.json +1 -0
- package/.claude/checkpoints/1757190243.json +1 -0
- package/.claude/checkpoints/1757190245.json +1 -0
- package/.claude/checkpoints/1757190247.json +1 -0
- package/.claude/checkpoints/1757190608.json +1 -0
- package/.claude/checkpoints/1757190610.json +1 -0
- package/.claude/checkpoints/1757190626.json +1 -0
- package/.claude/checkpoints/1757190628.json +1 -0
- package/.claude/checkpoints/1757190993.json +1 -0
- package/.claude/checkpoints/1757190997.json +1 -0
- package/.claude/checkpoints/1757191001.json +1 -0
- package/.claude/checkpoints/1757191004.json +1 -0
- package/.claude/checkpoints/1757191007.json +1 -0
- package/.claude/checkpoints/1757191009.json +1 -0
- package/.claude/checkpoints/1757191012.json +1 -0
- package/.claude/checkpoints/1757191014.json +1 -0
- package/.claude/checkpoints/1757191016.json +1 -0
- package/.claude/checkpoints/1757191019.json +1 -0
- package/.claude/checkpoints/1757191022.json +1 -0
- package/.claude/checkpoints/1757191024.json +1 -0
- package/.claude/checkpoints/1757191027.json +1 -0
- package/.claude/checkpoints/1757191029.json +1 -0
- package/.claude/checkpoints/1757191032.json +1 -0
- package/.claude/checkpoints/1757191034.json +1 -0
- package/.claude/checkpoints/1757191037.json +1 -0
- package/.claude/checkpoints/1757191040.json +1 -0
- package/.claude/checkpoints/1757191061.json +1 -0
- package/.claude/checkpoints/1757191063.json +1 -0
- package/.claude/checkpoints/1757191084.json +1 -0
- package/.claude/checkpoints/1757191086.json +1 -0
- package/.claude/checkpoints/1757192316.json +1 -0
- package/.claude/checkpoints/1757192318.json +1 -0
- package/.claude/checkpoints/1757192389.json +1 -0
- package/.claude/checkpoints/1757192391.json +1 -0
- package/.claude/checkpoints/1757192489.json +1 -0
- package/.claude/checkpoints/1757192491.json +1 -0
- package/.claude/checkpoints/1757192521.json +1 -0
- package/.claude/checkpoints/1757192523.json +1 -0
- package/.claude/checkpoints/1757192541.json +1 -0
- package/.claude/checkpoints/1757192543.json +1 -0
- package/.claude/checkpoints/1757193796.json +1 -0
- package/.claude/checkpoints/summary-session-20250826-164827.md +1342 -0
- package/.claude/checkpoints/summary-session-20250826-165852.md +1351 -0
- package/.claude/checkpoints/summary-session-20250826-170402.md +1367 -0
- package/.claude/checkpoints/summary-session-20250826-175112.md +1327 -0
- package/.claude/checkpoints/summary-session-20250826-175609.md +1324 -0
- package/.claude/checkpoints/summary-session-20250826-175743.md +1327 -0
- package/.claude/checkpoints/summary-session-20250826-180554.md +1340 -0
- package/.claude/checkpoints/summary-session-20250826-181530.md +1344 -0
- package/.claude/checkpoints/summary-session-20250826-181633.md +1347 -0
- package/.claude/checkpoints/summary-session-20250826-182235.md +1350 -0
- package/.claude/checkpoints/summary-session-20250826-182618.md +1353 -0
- package/.claude/checkpoints/summary-session-20250826-183200.md +1372 -0
- package/.claude/checkpoints/summary-session-20250826-183232.md +1379 -0
- package/.claude/checkpoints/summary-session-20250829-133605.md +38 -0
- package/.claude/checkpoints/summary-session-20250829-134121.md +41 -0
- package/.claude/checkpoints/summary-session-20250829-134400.md +46 -0
- package/.claude/checkpoints/summary-session-20250829-134858.md +49 -0
- package/.claude/checkpoints/summary-session-20250829-135402.md +52 -0
- package/.claude/checkpoints/summary-session-20250829-135640.md +58 -0
- package/.claude/checkpoints/summary-session-20250829-135754.md +65 -0
- package/.claude/checkpoints/summary-session-20250829-135902.md +71 -0
- package/.claude/checkpoints/summary-session-20250829-140629.md +119 -0
- package/.claude/checkpoints/summary-session-20250829-140733.md +121 -0
- package/.claude/checkpoints/summary-session-20250902-190126.md +38 -0
- package/.claude/checkpoints/summary-session-20250904-150003.md +87 -0
- package/.claude/checkpoints/summary-session-20250906-202218.md +2757 -0
- package/.claude/checkpoints/summary-session-20250906-202622.md +2814 -0
- package/.claude/checkpoints/summary-session-20250906-203037.md +2826 -0
- package/.claude/checkpoints/task-1756227096.json +1 -0
- package/.claude/checkpoints/task-1756227619.json +1 -0
- package/.claude/checkpoints/task-1756230633.json +1 -0
- package/.claude/checkpoints/task-1756230902.json +1 -0
- package/.claude/checkpoints/task-1756230993.json +1 -0
- package/.claude/checkpoints/task-1756231253.json +1 -0
- package/.claude/checkpoints/task-1756232070.json +1 -0
- package/.claude/checkpoints/task-1756232144.json +1 -0
- package/.claude/checkpoints/task-1756232251.json +1 -0
- package/.claude/checkpoints/task-1756232564.json +1 -0
- package/.claude/checkpoints/task-1756232982.json +1 -0
- package/.claude/checkpoints/task-1756233131.json +1 -0
- package/.claude/checkpoints/task-1756474562.json +1 -0
- package/.claude/checkpoints/task-1756474754.json +1 -0
- package/.claude/checkpoints/task-1756474922.json +1 -0
- package/.claude/checkpoints/task-1756475028.json +1 -0
- package/.claude/checkpoints/task-1756475307.json +1 -0
- package/.claude/checkpoints/task-1756475349.json +1 -0
- package/.claude/checkpoints/task-1756475699.json +1 -0
- package/.claude/checkpoints/task-1756475719.json +1 -0
- package/.claude/checkpoints/task-1756475828.json +1 -0
- package/.claude/checkpoints/task-1756475858.json +1 -0
- package/.claude/checkpoints/task-1756475868.json +1 -0
- package/.claude/checkpoints/task-1756476373.json +1 -0
- package/.claude/checkpoints/task-1756839595.json +1 -0
- package/.claude/checkpoints/task-1756997821.json +1 -0
- package/.claude/checkpoints/task-1757189936.json +1 -0
- package/.claude/checkpoints/task-1757190154.json +1 -0
- package/.claude/checkpoints/task-1757190301.json +1 -0
- package/.claude/checkpoints/task-1757190369.json +1 -0
- package/.claude/checkpoints/task-1757190483.json +1 -0
- package/.claude/checkpoints/task-1757190841.json +1 -0
- package/.claude/checkpoints/task-1757191219.json +1 -0
- package/.claude/checkpoints/task-1757192639.json +1 -0
- package/.claude/checkpoints/task-1757194091.json +1 -0
- package/.claude/commands/flow-nexus/app-store.md +124 -0
- package/.claude/commands/flow-nexus/challenges.md +120 -0
- package/.claude/commands/flow-nexus/login-registration.md +65 -0
- package/.claude/commands/flow-nexus/neural-network.md +134 -0
- package/.claude/commands/flow-nexus/payments.md +116 -0
- package/.claude/commands/flow-nexus/sandbox.md +83 -0
- package/.claude/commands/flow-nexus/swarm.md +87 -0
- package/.claude/commands/flow-nexus/user-tools.md +152 -0
- package/.claude/commands/flow-nexus/workflow.md +115 -0
- package/bin/claude-flow +1 -1
- package/package.json +1 -1
- package/src/api/auth-service.ts +644 -0
- package/src/api/database-schema.sql +366 -0
- package/src/api/database-service.ts +788 -0
- package/src/api/swarm-api.ts +741 -0
- package/src/cli/commands/index.ts +711 -1
- package/src/cli/simple-commands/hive-mind/session-manager.js +12 -0
- package/src/cli/simple-commands/init/agent-copier.js +129 -1
- package/src/cli/simple-commands/init/hive-mind-init.js +12 -7
- package/src/cli/simple-commands/init/index.js +116 -1
- package/src/cli/simple-commands/init/templates/claude-md.js +295 -1
- package/src/core/version.js +1 -1
- package/src/ui/console/index.html +4 -0
- package/src/ui/console/js/real-time-dashboard.js +715 -0
- package/src/ui/console/js/swarm-integration.js +485 -0
- package/src/ui/console/js/swarm-visualizer.js +879 -0
- package/src/ui/console/styles/swarm-visualizer.css +487 -0
- package/src/cli/simple-commands/init/.claude-flow/metrics/agent-metrics.json +0 -1
- package/src/cli/simple-commands/init/.claude-flow/metrics/performance.json +0 -9
- package/src/cli/simple-commands/init/.claude-flow/metrics/task-metrics.json +0 -10
- package/src/cli/simple-commands/init/.swarm/memory.db +0 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwarmIntegration - Integrates swarm visualizer with existing console
|
|
3
|
+
* Adds swarm monitoring commands and UI elements to the Claude Flow console
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { SwarmVisualizer } from './swarm-visualizer.js';
|
|
7
|
+
import { RealTimeDashboard } from './real-time-dashboard.js';
|
|
8
|
+
import ComponentLibrary from '../web-ui/components/ComponentLibrary.js';
|
|
9
|
+
|
|
10
|
+
export class SwarmIntegration {
|
|
11
|
+
constructor(consoleInstance) {
|
|
12
|
+
this.console = consoleInstance;
|
|
13
|
+
this.components = new ComponentLibrary();
|
|
14
|
+
this.swarmVisualizer = null;
|
|
15
|
+
this.dashboard = null;
|
|
16
|
+
this.isSwarmMode = false;
|
|
17
|
+
|
|
18
|
+
this.init();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Initialize swarm integration
|
|
23
|
+
*/
|
|
24
|
+
init() {
|
|
25
|
+
this.components.initialize();
|
|
26
|
+
this.addSwarmCommands();
|
|
27
|
+
this.addSwarmUI();
|
|
28
|
+
this.setupSwarmEventHandlers();
|
|
29
|
+
console.log('🔗 Swarm Integration initialized');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add swarm-specific commands to the console
|
|
34
|
+
*/
|
|
35
|
+
addSwarmCommands() {
|
|
36
|
+
const swarmCommands = {
|
|
37
|
+
'swarm': {
|
|
38
|
+
description: 'Enter swarm visualization mode',
|
|
39
|
+
handler: () => this.enterSwarmMode(),
|
|
40
|
+
usage: 'swarm'
|
|
41
|
+
},
|
|
42
|
+
'swarm-status': {
|
|
43
|
+
description: 'Show current swarm status',
|
|
44
|
+
handler: () => this.showSwarmStatus(),
|
|
45
|
+
usage: 'swarm-status'
|
|
46
|
+
},
|
|
47
|
+
'swarm-monitor': {
|
|
48
|
+
description: 'Start real-time swarm monitoring',
|
|
49
|
+
handler: (args) => this.startSwarmMonitoring(args),
|
|
50
|
+
usage: 'swarm-monitor [topology]'
|
|
51
|
+
},
|
|
52
|
+
'swarm-stop': {
|
|
53
|
+
description: 'Stop swarm monitoring',
|
|
54
|
+
handler: () => this.stopSwarmMonitoring(),
|
|
55
|
+
usage: 'swarm-stop'
|
|
56
|
+
},
|
|
57
|
+
'dashboard': {
|
|
58
|
+
description: 'Open real-time dashboard',
|
|
59
|
+
handler: () => this.openDashboard(),
|
|
60
|
+
usage: 'dashboard'
|
|
61
|
+
},
|
|
62
|
+
'agents': {
|
|
63
|
+
description: 'List active agents',
|
|
64
|
+
handler: () => this.listAgents(),
|
|
65
|
+
usage: 'agents'
|
|
66
|
+
},
|
|
67
|
+
'topology': {
|
|
68
|
+
description: 'Change swarm topology',
|
|
69
|
+
handler: (args) => this.changeTopology(args),
|
|
70
|
+
usage: 'topology [mesh|hierarchical|ring|star]'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Register commands with the console's command handler
|
|
75
|
+
if (this.console.commandHandler) {
|
|
76
|
+
Object.entries(swarmCommands).forEach(([command, config]) => {
|
|
77
|
+
this.console.commandHandler.registerCommand(command, config);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add swarm UI elements to the console
|
|
84
|
+
*/
|
|
85
|
+
addSwarmUI() {
|
|
86
|
+
// Add swarm mode toggle to header
|
|
87
|
+
const headerRight = document.querySelector('.header-right');
|
|
88
|
+
if (headerRight) {
|
|
89
|
+
const swarmToggle = this.components.createActionButton({
|
|
90
|
+
type: 'secondary',
|
|
91
|
+
text: 'Swarm Mode',
|
|
92
|
+
icon: '🌊',
|
|
93
|
+
onclick: () => this.toggleSwarmMode()
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
headerRight.insertBefore(swarmToggle.element, headerRight.firstChild);
|
|
97
|
+
this.swarmToggleButton = swarmToggle;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Add swarm status to status bar
|
|
101
|
+
const statusLeft = document.querySelector('.status-left');
|
|
102
|
+
if (statusLeft) {
|
|
103
|
+
const swarmStatus = document.createElement('span');
|
|
104
|
+
swarmStatus.className = 'status-item';
|
|
105
|
+
swarmStatus.id = 'swarm-status';
|
|
106
|
+
swarmStatus.textContent = 'Swarm: Inactive';
|
|
107
|
+
statusLeft.appendChild(swarmStatus);
|
|
108
|
+
this.swarmStatusElement = swarmStatus;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Setup event handlers for swarm integration
|
|
114
|
+
*/
|
|
115
|
+
setupSwarmEventHandlers() {
|
|
116
|
+
// Listen for swarm-related WebSocket messages
|
|
117
|
+
if (this.console.wsClient) {
|
|
118
|
+
this.console.wsClient.on('swarm_update', (data) => {
|
|
119
|
+
this.handleSwarmUpdate(data);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
this.console.wsClient.on('agent_status', (data) => {
|
|
123
|
+
this.handleAgentStatus(data);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Listen for console commands
|
|
128
|
+
if (this.console.terminal) {
|
|
129
|
+
this.console.terminal.on('command', (command) => {
|
|
130
|
+
if (command.startsWith('swarm')) {
|
|
131
|
+
this.handleSwarmCommand(command);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Enter swarm visualization mode
|
|
139
|
+
*/
|
|
140
|
+
enterSwarmMode() {
|
|
141
|
+
if (this.isSwarmMode) {
|
|
142
|
+
this.console.terminal.writeWarning('Already in swarm mode');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.isSwarmMode = true;
|
|
147
|
+
|
|
148
|
+
// Create swarm container
|
|
149
|
+
const swarmContainer = document.createElement('div');
|
|
150
|
+
swarmContainer.id = 'swarm-visualization-container';
|
|
151
|
+
swarmContainer.style.cssText = `
|
|
152
|
+
position: fixed;
|
|
153
|
+
top: 0;
|
|
154
|
+
left: 0;
|
|
155
|
+
width: 100vw;
|
|
156
|
+
height: 100vh;
|
|
157
|
+
background: rgba(0, 0, 0, 0.95);
|
|
158
|
+
z-index: 10000;
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-direction: column;
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
// Create close button
|
|
164
|
+
const closeButton = this.components.createActionButton({
|
|
165
|
+
type: 'secondary',
|
|
166
|
+
text: 'Exit Swarm Mode',
|
|
167
|
+
icon: '❌',
|
|
168
|
+
onclick: () => this.exitSwarmMode()
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
closeButton.element.style.cssText = `
|
|
172
|
+
position: absolute;
|
|
173
|
+
top: 20px;
|
|
174
|
+
right: 20px;
|
|
175
|
+
z-index: 10001;
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
swarmContainer.appendChild(closeButton.element);
|
|
179
|
+
|
|
180
|
+
// Create swarm visualizer
|
|
181
|
+
const visualizerContainer = document.createElement('div');
|
|
182
|
+
visualizerContainer.style.cssText = `
|
|
183
|
+
flex: 1;
|
|
184
|
+
padding: 80px 20px 20px 20px;
|
|
185
|
+
overflow: auto;
|
|
186
|
+
`;
|
|
187
|
+
|
|
188
|
+
this.swarmVisualizer = new SwarmVisualizer(visualizerContainer, this.components);
|
|
189
|
+
swarmContainer.appendChild(visualizerContainer);
|
|
190
|
+
|
|
191
|
+
document.body.appendChild(swarmContainer);
|
|
192
|
+
this.swarmContainer = swarmContainer;
|
|
193
|
+
|
|
194
|
+
// Update UI
|
|
195
|
+
this.updateSwarmStatus('Active');
|
|
196
|
+
this.swarmToggleButton.setText('Exit Swarm');
|
|
197
|
+
|
|
198
|
+
this.console.terminal.writeSuccess('Entered swarm visualization mode');
|
|
199
|
+
this.console.terminal.writeInfo('Use "swarm-monitor" to start real-time monitoring');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Exit swarm visualization mode
|
|
204
|
+
*/
|
|
205
|
+
exitSwarmMode() {
|
|
206
|
+
if (!this.isSwarmMode) return;
|
|
207
|
+
|
|
208
|
+
this.isSwarmMode = false;
|
|
209
|
+
|
|
210
|
+
// Clean up swarm visualizer
|
|
211
|
+
if (this.swarmVisualizer) {
|
|
212
|
+
this.swarmVisualizer.destroy();
|
|
213
|
+
this.swarmVisualizer = null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Remove swarm container
|
|
217
|
+
if (this.swarmContainer) {
|
|
218
|
+
this.swarmContainer.remove();
|
|
219
|
+
this.swarmContainer = null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Update UI
|
|
223
|
+
this.updateSwarmStatus('Inactive');
|
|
224
|
+
this.swarmToggleButton.setText('Swarm Mode');
|
|
225
|
+
|
|
226
|
+
this.console.terminal.writeInfo('Exited swarm visualization mode');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Toggle swarm mode
|
|
231
|
+
*/
|
|
232
|
+
toggleSwarmMode() {
|
|
233
|
+
if (this.isSwarmMode) {
|
|
234
|
+
this.exitSwarmMode();
|
|
235
|
+
} else {
|
|
236
|
+
this.enterSwarmMode();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Show swarm status
|
|
242
|
+
*/
|
|
243
|
+
showSwarmStatus() {
|
|
244
|
+
this.console.terminal.writeInfo('📊 Swarm Status:');
|
|
245
|
+
|
|
246
|
+
// Mock status data - would normally fetch from API
|
|
247
|
+
const status = {
|
|
248
|
+
active: this.isSwarmMode,
|
|
249
|
+
agents: Math.floor(Math.random() * 8) + 2,
|
|
250
|
+
topology: 'mesh',
|
|
251
|
+
uptime: '2h 34m',
|
|
252
|
+
tasksCompleted: Math.floor(Math.random() * 100) + 50,
|
|
253
|
+
averageResponseTime: Math.floor(Math.random() * 500) + 200
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
this.console.terminal.write(` Mode: ${status.active ? 'Active' : 'Inactive'}`, 'info');
|
|
257
|
+
this.console.terminal.write(` Agents: ${status.agents}`, 'info');
|
|
258
|
+
this.console.terminal.write(` Topology: ${status.topology}`, 'info');
|
|
259
|
+
this.console.terminal.write(` Uptime: ${status.uptime}`, 'info');
|
|
260
|
+
this.console.terminal.write(` Tasks Completed: ${status.tasksCompleted}`, 'info');
|
|
261
|
+
this.console.terminal.write(` Avg Response Time: ${status.averageResponseTime}ms`, 'info');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Start swarm monitoring
|
|
266
|
+
*/
|
|
267
|
+
startSwarmMonitoring(args) {
|
|
268
|
+
if (!this.swarmVisualizer) {
|
|
269
|
+
this.console.terminal.writeError('Not in swarm mode. Use "swarm" command first.');
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const topology = args && args[0] ? args[0] : 'mesh';
|
|
274
|
+
|
|
275
|
+
if (this.swarmVisualizer) {
|
|
276
|
+
this.swarmVisualizer.topology = topology;
|
|
277
|
+
this.swarmVisualizer.startMonitoring();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this.console.terminal.writeSuccess(`Started swarm monitoring with ${topology} topology`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Stop swarm monitoring
|
|
285
|
+
*/
|
|
286
|
+
stopSwarmMonitoring() {
|
|
287
|
+
if (this.swarmVisualizer) {
|
|
288
|
+
this.swarmVisualizer.stopMonitoring();
|
|
289
|
+
this.console.terminal.writeInfo('Stopped swarm monitoring');
|
|
290
|
+
} else {
|
|
291
|
+
this.console.terminal.writeWarning('Swarm monitoring not active');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Open dashboard
|
|
297
|
+
*/
|
|
298
|
+
openDashboard() {
|
|
299
|
+
if (this.dashboard) {
|
|
300
|
+
this.console.terminal.writeWarning('Dashboard already open');
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Create dashboard container
|
|
305
|
+
const dashboardContainer = document.createElement('div');
|
|
306
|
+
dashboardContainer.id = 'dashboard-container';
|
|
307
|
+
dashboardContainer.style.cssText = `
|
|
308
|
+
position: fixed;
|
|
309
|
+
top: 0;
|
|
310
|
+
left: 0;
|
|
311
|
+
width: 100vw;
|
|
312
|
+
height: 100vh;
|
|
313
|
+
background: rgba(0, 0, 0, 0.98);
|
|
314
|
+
z-index: 20000;
|
|
315
|
+
`;
|
|
316
|
+
|
|
317
|
+
// Create close button
|
|
318
|
+
const closeButton = this.components.createActionButton({
|
|
319
|
+
type: 'secondary',
|
|
320
|
+
text: 'Close Dashboard',
|
|
321
|
+
icon: '❌',
|
|
322
|
+
onclick: () => this.closeDashboard()
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
closeButton.element.style.cssText = `
|
|
326
|
+
position: absolute;
|
|
327
|
+
top: 20px;
|
|
328
|
+
right: 20px;
|
|
329
|
+
z-index: 20001;
|
|
330
|
+
`;
|
|
331
|
+
|
|
332
|
+
dashboardContainer.appendChild(closeButton.element);
|
|
333
|
+
|
|
334
|
+
// Create dashboard
|
|
335
|
+
this.dashboard = new RealTimeDashboard(dashboardContainer, this.components);
|
|
336
|
+
document.body.appendChild(dashboardContainer);
|
|
337
|
+
this.dashboardContainer = dashboardContainer;
|
|
338
|
+
|
|
339
|
+
this.console.terminal.writeSuccess('Opened real-time dashboard');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Close dashboard
|
|
344
|
+
*/
|
|
345
|
+
closeDashboard() {
|
|
346
|
+
if (this.dashboard) {
|
|
347
|
+
this.dashboard.destroy();
|
|
348
|
+
this.dashboard = null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (this.dashboardContainer) {
|
|
352
|
+
this.dashboardContainer.remove();
|
|
353
|
+
this.dashboardContainer = null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
this.console.terminal.writeInfo('Closed dashboard');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* List agents
|
|
361
|
+
*/
|
|
362
|
+
listAgents() {
|
|
363
|
+
this.console.terminal.writeInfo('🤖 Active Agents:');
|
|
364
|
+
|
|
365
|
+
// Mock agent data
|
|
366
|
+
const agents = [
|
|
367
|
+
{ id: 'coder_01', type: 'coder', status: 'active', task: 'Implementing API endpoints' },
|
|
368
|
+
{ id: 'researcher_02', type: 'researcher', status: 'busy', task: 'Analyzing data patterns' },
|
|
369
|
+
{ id: 'reviewer_03', type: 'reviewer', status: 'idle', task: null },
|
|
370
|
+
{ id: 'tester_04', type: 'tester', status: 'active', task: 'Running test suite' }
|
|
371
|
+
];
|
|
372
|
+
|
|
373
|
+
agents.forEach(agent => {
|
|
374
|
+
const statusColor = agent.status === 'active' ? 'success' :
|
|
375
|
+
agent.status === 'busy' ? 'warning' : 'info';
|
|
376
|
+
const taskText = agent.task ? ` | Task: ${agent.task}` : ' | No active task';
|
|
377
|
+
|
|
378
|
+
this.console.terminal.write(
|
|
379
|
+
` ${agent.id} (${agent.type}) - ${agent.status}${taskText}`,
|
|
380
|
+
statusColor
|
|
381
|
+
);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Change topology
|
|
387
|
+
*/
|
|
388
|
+
changeTopology(args) {
|
|
389
|
+
if (!args || args.length === 0) {
|
|
390
|
+
this.console.terminal.writeError('Usage: topology [mesh|hierarchical|ring|star]');
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const topology = args[0];
|
|
395
|
+
const validTopologies = ['mesh', 'hierarchical', 'ring', 'star'];
|
|
396
|
+
|
|
397
|
+
if (!validTopologies.includes(topology)) {
|
|
398
|
+
this.console.terminal.writeError(`Invalid topology. Valid options: ${validTopologies.join(', ')}`);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (this.swarmVisualizer) {
|
|
403
|
+
this.swarmVisualizer.topology = topology;
|
|
404
|
+
this.swarmVisualizer.redrawTopology();
|
|
405
|
+
this.console.terminal.writeSuccess(`Changed topology to ${topology}`);
|
|
406
|
+
} else {
|
|
407
|
+
this.console.terminal.writeWarning('Swarm visualizer not active');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Handle swarm update messages
|
|
413
|
+
*/
|
|
414
|
+
handleSwarmUpdate(data) {
|
|
415
|
+
if (this.swarmVisualizer) {
|
|
416
|
+
this.swarmVisualizer.swarmData = data;
|
|
417
|
+
this.swarmVisualizer.processSwarmData();
|
|
418
|
+
this.swarmVisualizer.updateStats();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (this.dashboard) {
|
|
422
|
+
this.dashboard.handleWebSocketMessage({
|
|
423
|
+
type: 'swarm_update',
|
|
424
|
+
payload: data
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Handle agent status messages
|
|
431
|
+
*/
|
|
432
|
+
handleAgentStatus(data) {
|
|
433
|
+
if (data.active !== undefined) {
|
|
434
|
+
this.updateSwarmStatus(`${data.active} agents active`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Update swarm status in UI
|
|
440
|
+
*/
|
|
441
|
+
updateSwarmStatus(status) {
|
|
442
|
+
if (this.swarmStatusElement) {
|
|
443
|
+
this.swarmStatusElement.textContent = `Swarm: ${status}`;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Handle swarm command
|
|
449
|
+
*/
|
|
450
|
+
handleSwarmCommand(command) {
|
|
451
|
+
// Commands are already handled by the registered handlers
|
|
452
|
+
// This could be used for additional processing if needed
|
|
453
|
+
console.log('Swarm command processed:', command);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Get integration status
|
|
458
|
+
*/
|
|
459
|
+
getStatus() {
|
|
460
|
+
return {
|
|
461
|
+
swarmMode: this.isSwarmMode,
|
|
462
|
+
visualizerActive: this.swarmVisualizer?.isActive || false,
|
|
463
|
+
dashboardOpen: !!this.dashboard,
|
|
464
|
+
componentsLoaded: this.components.isInitialized
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Cleanup integration
|
|
470
|
+
*/
|
|
471
|
+
destroy() {
|
|
472
|
+
this.exitSwarmMode();
|
|
473
|
+
this.closeDashboard();
|
|
474
|
+
|
|
475
|
+
if (this.swarmToggleButton) {
|
|
476
|
+
this.swarmToggleButton.element.remove();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (this.swarmStatusElement) {
|
|
480
|
+
this.swarmStatusElement.remove();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export default SwarmIntegration;
|