claude-flow-novice 1.5.6 → 1.5.7
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-flow-novice/.claude/agents/CLAUDE.md +34 -17
- package/.claude-flow-novice/.claude/agents/validate-agent.js +24 -3
- package/.claude-flow-novice/dist/src/mcp/mcp-config-manager.js +1362 -0
- package/.claude-flow-novice/dist/src/mcp/mcp-server-novice-simplified.js +583 -0
- package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +723 -0
- package/.claude-flow-novice/dist/src/mcp/mcp-server-sdk.js +649 -0
- package/.claude-flow-novice/dist/src/mcp/mcp-server.js +2256 -0
- package/.claude-flow-novice/dist/src/mcp/ruv-swarm-wrapper.js +254 -0
- package/package.json +2 -2
- package/examples/sdk-swarm-demo.js +0 -194
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper for ruv-swarm MCP server to handle logger issues
|
|
3
|
+
* This wrapper ensures compatibility and handles known issues in ruv-swarm
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { spawn } from 'child_process';
|
|
7
|
+
import { createInterface } from 'readline';
|
|
8
|
+
|
|
9
|
+
export class RuvSwarmWrapper {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.options = {
|
|
12
|
+
silent: options.silent || false,
|
|
13
|
+
autoRestart: options.autoRestart !== false,
|
|
14
|
+
maxRestarts: options.maxRestarts || 3,
|
|
15
|
+
restartDelay: options.restartDelay || 1000,
|
|
16
|
+
...options,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.process = null;
|
|
20
|
+
this.restartCount = 0;
|
|
21
|
+
this.isShuttingDown = false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async start() {
|
|
25
|
+
if (this.process) {
|
|
26
|
+
throw new Error('RuvSwarm MCP server is already running');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
try {
|
|
31
|
+
// Spawn ruv-swarm MCP server
|
|
32
|
+
this.process = spawn('npx', ['ruv-swarm', 'mcp', 'start'], {
|
|
33
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
34
|
+
env: {
|
|
35
|
+
...process.env,
|
|
36
|
+
// Ensure stdio mode for MCP
|
|
37
|
+
MCP_MODE: 'stdio',
|
|
38
|
+
// Set log level to reduce noise
|
|
39
|
+
LOG_LEVEL: 'WARN',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
let initialized = false;
|
|
44
|
+
let initTimeout;
|
|
45
|
+
|
|
46
|
+
// Handle stdout (JSON-RPC messages)
|
|
47
|
+
const rlOut = createInterface({
|
|
48
|
+
input: this.process.stdout,
|
|
49
|
+
crlfDelay: Infinity,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
rlOut.on('line', (line) => {
|
|
53
|
+
try {
|
|
54
|
+
const message = JSON.parse(line);
|
|
55
|
+
|
|
56
|
+
// Check for initialization
|
|
57
|
+
if (message.method === 'server.initialized' && !initialized) {
|
|
58
|
+
initialized = true;
|
|
59
|
+
clearTimeout(initTimeout);
|
|
60
|
+
resolve({
|
|
61
|
+
process: this.process,
|
|
62
|
+
stdout: this.process.stdout,
|
|
63
|
+
stdin: this.process.stdin,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Forward JSON-RPC messages
|
|
68
|
+
process.stdout.write(line + '\n');
|
|
69
|
+
} catch (err) {
|
|
70
|
+
// Not JSON, ignore
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Handle stderr (logs and errors)
|
|
75
|
+
const rlErr = createInterface({
|
|
76
|
+
input: this.process.stderr,
|
|
77
|
+
crlfDelay: Infinity,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
rlErr.on('line', (line) => {
|
|
81
|
+
// Parse structured error messages if available
|
|
82
|
+
try {
|
|
83
|
+
const errorData = JSON.parse(line);
|
|
84
|
+
if (errorData.error && errorData.error.code) {
|
|
85
|
+
// Handle specific error codes
|
|
86
|
+
switch (errorData.error.code) {
|
|
87
|
+
case 'LOGGER_METHOD_MISSING':
|
|
88
|
+
case 'ERR_LOGGER_MEMORY_USAGE':
|
|
89
|
+
// Known issue with logger.logMemoryUsage in ruv-swarm
|
|
90
|
+
if (!this.options.silent) {
|
|
91
|
+
console.error(
|
|
92
|
+
'⚠️ Known ruv-swarm logger issue detected (continuing normally)',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
case 'ERR_INITIALIZATION':
|
|
97
|
+
console.error('❌ RuvSwarm initialization error:', errorData.error.message);
|
|
98
|
+
return;
|
|
99
|
+
default:
|
|
100
|
+
// Unknown error code, log it
|
|
101
|
+
if (!this.options.silent) {
|
|
102
|
+
console.error(
|
|
103
|
+
`RuvSwarm error [${errorData.error.code}]:`,
|
|
104
|
+
errorData.error.message,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
// Not JSON, check for known text patterns as fallback
|
|
112
|
+
const knownErrorPatterns = [
|
|
113
|
+
{
|
|
114
|
+
pattern: /logger\.logMemoryUsage is not a function/,
|
|
115
|
+
code: 'LOGGER_METHOD_MISSING',
|
|
116
|
+
message: 'Known ruv-swarm logger issue detected (continuing normally)',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
pattern: /Cannot find module/,
|
|
120
|
+
code: 'MODULE_NOT_FOUND',
|
|
121
|
+
message: 'Module not found error',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
pattern: /ECONNREFUSED/,
|
|
125
|
+
code: 'CONNECTION_REFUSED',
|
|
126
|
+
message: 'Connection refused error',
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
for (const errorPattern of knownErrorPatterns) {
|
|
131
|
+
if (errorPattern.pattern.test(line)) {
|
|
132
|
+
if (!this.options.silent || errorPattern.code !== 'LOGGER_METHOD_MISSING') {
|
|
133
|
+
console.error(`⚠️ ${errorPattern.message}`);
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Filter out initialization messages if silent
|
|
141
|
+
if (this.options.silent) {
|
|
142
|
+
if (line.includes('✅') || line.includes('🧠') || line.includes('📊')) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Forward other stderr output
|
|
148
|
+
if (!this.options.silent) {
|
|
149
|
+
process.stderr.write(line + '\n');
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Handle process errors
|
|
154
|
+
this.process.on('error', (error) => {
|
|
155
|
+
if (!initialized) {
|
|
156
|
+
clearTimeout(initTimeout);
|
|
157
|
+
reject(new Error(`Failed to start ruv-swarm: ${error.message}`));
|
|
158
|
+
} else {
|
|
159
|
+
console.error('RuvSwarm process error:', error);
|
|
160
|
+
this.handleProcessExit(error.code || 1);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Handle process exit
|
|
165
|
+
this.process.on('exit', (code, signal) => {
|
|
166
|
+
if (!initialized) {
|
|
167
|
+
clearTimeout(initTimeout);
|
|
168
|
+
reject(
|
|
169
|
+
new Error(`RuvSwarm exited before initialization: code ${code}, signal ${signal}`),
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
this.handleProcessExit(code || 0);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Set initialization timeout
|
|
177
|
+
initTimeout = setTimeout(() => {
|
|
178
|
+
if (!initialized) {
|
|
179
|
+
this.stop();
|
|
180
|
+
reject(new Error('RuvSwarm initialization timeout'));
|
|
181
|
+
}
|
|
182
|
+
}, 30000); // 30 second timeout
|
|
183
|
+
} catch (error) {
|
|
184
|
+
reject(error);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
handleProcessExit(code) {
|
|
190
|
+
this.process = null;
|
|
191
|
+
|
|
192
|
+
if (this.isShuttingDown) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
console.error(`RuvSwarm MCP server exited with code ${code}`);
|
|
197
|
+
|
|
198
|
+
// Auto-restart if enabled and under limit
|
|
199
|
+
if (this.options.autoRestart && this.restartCount < this.options.maxRestarts) {
|
|
200
|
+
this.restartCount++;
|
|
201
|
+
console.log(
|
|
202
|
+
`Attempting to restart RuvSwarm (attempt ${this.restartCount}/${this.options.maxRestarts})...`,
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
this.start().catch((err) => {
|
|
207
|
+
console.error('Failed to restart RuvSwarm:', err);
|
|
208
|
+
});
|
|
209
|
+
}, this.options.restartDelay);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async stop() {
|
|
214
|
+
this.isShuttingDown = true;
|
|
215
|
+
|
|
216
|
+
if (!this.process) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return new Promise((resolve) => {
|
|
221
|
+
const killTimeout = setTimeout(() => {
|
|
222
|
+
console.warn('RuvSwarm did not exit gracefully, forcing kill...');
|
|
223
|
+
this.process.kill('SIGKILL');
|
|
224
|
+
}, 5000);
|
|
225
|
+
|
|
226
|
+
this.process.on('exit', () => {
|
|
227
|
+
clearTimeout(killTimeout);
|
|
228
|
+
this.process = null;
|
|
229
|
+
resolve();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Send graceful shutdown signal
|
|
233
|
+
this.process.kill('SIGTERM');
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
isRunning() {
|
|
238
|
+
return this.process !== null && !this.process.killed;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Export a function to start ruv-swarm with error handling
|
|
243
|
+
export async function startRuvSwarmMCP(options = {}) {
|
|
244
|
+
const wrapper = new RuvSwarmWrapper(options);
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
const result = await wrapper.start();
|
|
248
|
+
console.log('✅ RuvSwarm MCP server started successfully');
|
|
249
|
+
return { wrapper, ...result };
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error('❌ Failed to start RuvSwarm MCP server:', error.message);
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Standalone Claude Flow for beginners - AI agent orchestration made easy with enhanced TDD testing pipeline. Enhanced init command creates complete agent system, MCP configuration with 30 essential tools, and automated hooks with single-file testing, real-time coverage analysis, and advanced validation. Fully standalone with zero external dependencies, complete project setup in one command.",
|
|
5
5
|
"mcpName": "io.github.ruvnet/claude-flow",
|
|
6
6
|
"main": ".claude-flow-novice/dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"optimize:validate:hardware": "node scripts/optimization/config-validator.js validate hardware",
|
|
40
40
|
"optimize:validate:monitoring": "node scripts/optimization/config-validator.js validate monitoring",
|
|
41
41
|
"build": "scripts/build/unified-builder.sh safe",
|
|
42
|
-
"build:swc": "swc src -d .claude-flow-novice/dist --only='**/*.ts' --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init/index.js .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r .claude/agents .claude-flow-novice/.claude/",
|
|
42
|
+
"build:swc": "swc src -d .claude-flow-novice/dist --only='**/*.ts' --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init/index.js .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp src/mcp/*.js .claude-flow-novice/dist/src/mcp/ && cp -r .claude/agents .claude-flow-novice/.claude/",
|
|
43
43
|
"build:types": "tsc --project config/typescript/tsconfig.json --emitDeclarationOnly --outDir .claude-flow-novice/dist --skipLibCheck",
|
|
44
44
|
"build:watch": "swc src -d .claude-flow-novice/dist --watch --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && npm run copy:agents",
|
|
45
45
|
"build:legacy": "scripts/build/unified-builder.sh migration",
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SDK Swarm Integration Demo
|
|
5
|
-
*
|
|
6
|
-
* Demonstrates how to use the SDK Swarm Orchestrator for parallel agent execution
|
|
7
|
-
* with self-validation and Byzantine consensus.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* node examples/sdk-swarm-demo.js
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { SDKSwarmOrchestrator } from '../src/sdk/swarm-integration.js';
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
console.log('🚀 SDK Swarm Integration Demo\n');
|
|
17
|
-
|
|
18
|
-
// Step 1: Create and initialize orchestrator
|
|
19
|
-
console.log('Step 1: Creating SDK Swarm Orchestrator...');
|
|
20
|
-
const orchestrator = new SDKSwarmOrchestrator({
|
|
21
|
-
swarmId: 'demo-swarm',
|
|
22
|
-
maxAgents: 10,
|
|
23
|
-
maxConcurrent: 3,
|
|
24
|
-
consensusProtocol: 'pbft',
|
|
25
|
-
consensusQuorumSize: 2,
|
|
26
|
-
consensusTimeout: 5000,
|
|
27
|
-
parallelExecution: true,
|
|
28
|
-
filterFailedValidations: true,
|
|
29
|
-
minimumValidAgents: 1,
|
|
30
|
-
enableLearning: true,
|
|
31
|
-
enableMetrics: true
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await orchestrator.initialize();
|
|
35
|
-
console.log('✅ Orchestrator initialized\n');
|
|
36
|
-
|
|
37
|
-
// Step 2: Define task with agent configuration
|
|
38
|
-
console.log('Step 2: Defining task with multiple agents...');
|
|
39
|
-
const task = {
|
|
40
|
-
description: 'Implement user authentication feature',
|
|
41
|
-
operation: 'implement',
|
|
42
|
-
file: 'src/auth/user-auth.js',
|
|
43
|
-
content: 'User authentication logic',
|
|
44
|
-
agents: [
|
|
45
|
-
{
|
|
46
|
-
agentId: 'coder-1',
|
|
47
|
-
agentType: 'coder',
|
|
48
|
-
confidenceThreshold: 0.75,
|
|
49
|
-
maxRetries: 3,
|
|
50
|
-
minimumCoverage: 80
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
agentId: 'coder-2',
|
|
54
|
-
agentType: 'coder',
|
|
55
|
-
confidenceThreshold: 0.80,
|
|
56
|
-
maxRetries: 3,
|
|
57
|
-
minimumCoverage: 85
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
agentId: 'tester-1',
|
|
61
|
-
agentType: 'tester',
|
|
62
|
-
confidenceThreshold: 0.80,
|
|
63
|
-
maxRetries: 3,
|
|
64
|
-
minimumCoverage: 90
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
agentId: 'reviewer-1',
|
|
68
|
-
agentType: 'reviewer',
|
|
69
|
-
confidenceThreshold: 0.75,
|
|
70
|
-
maxRetries: 2,
|
|
71
|
-
minimumCoverage: 75
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
|
-
console.log('✅ Task defined with 4 agents\n');
|
|
76
|
-
|
|
77
|
-
// Step 3: Execute with consensus
|
|
78
|
-
console.log('Step 3: Executing task with parallel agents and consensus...');
|
|
79
|
-
console.log('─'.repeat(80));
|
|
80
|
-
|
|
81
|
-
const result = await orchestrator.executeWithConsensus(task);
|
|
82
|
-
|
|
83
|
-
console.log('─'.repeat(80));
|
|
84
|
-
console.log('\n✅ Execution completed!\n');
|
|
85
|
-
|
|
86
|
-
// Step 4: Display results
|
|
87
|
-
console.log('📊 Execution Results:');
|
|
88
|
-
console.log('═'.repeat(80));
|
|
89
|
-
console.log(`Status: ${result.status}`);
|
|
90
|
-
console.log(`Reason: ${result.reason}`);
|
|
91
|
-
console.log(`Execution ID: ${result.executionId}`);
|
|
92
|
-
console.log(`Timestamp: ${new Date(result.timestamp).toISOString()}`);
|
|
93
|
-
|
|
94
|
-
console.log('\n📈 Statistics:');
|
|
95
|
-
console.log('─'.repeat(80));
|
|
96
|
-
console.log(`Agents Spawned: ${result.stats.agentsSpawned}`);
|
|
97
|
-
console.log(`Validations Passed: ${result.stats.validationPassed}`);
|
|
98
|
-
console.log(`Validations Failed: ${result.stats.validationFailed}`);
|
|
99
|
-
console.log(`Validation Rate: ${result.stats.validationRate}`);
|
|
100
|
-
console.log(`Avg Confidence: ${result.stats.avgConfidence}`);
|
|
101
|
-
console.log(`Avg Attempts: ${result.stats.avgAttempts}`);
|
|
102
|
-
console.log(`Total Duration: ${result.stats.totalDuration}`);
|
|
103
|
-
console.log(`Avg Agent Duration: ${result.stats.avgAgentDuration}`);
|
|
104
|
-
|
|
105
|
-
if (result.stats.consensus) {
|
|
106
|
-
console.log('\n🤝 Consensus Results:');
|
|
107
|
-
console.log('─'.repeat(80));
|
|
108
|
-
console.log(`Decision: ${result.stats.consensus.decision}`);
|
|
109
|
-
console.log(`Consensus Time: ${result.stats.consensus.consensusTime}`);
|
|
110
|
-
console.log(`Participation Rate: ${result.stats.consensus.participationRate}`);
|
|
111
|
-
console.log(`Total Votes: ${result.stats.consensus.votes.total}`);
|
|
112
|
-
console.log(`Approved: ${result.stats.consensus.votes.approved}`);
|
|
113
|
-
console.log(`Rejected: ${result.stats.consensus.votes.rejected}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log('\n🎯 Quality Metrics:');
|
|
117
|
-
console.log('─'.repeat(80));
|
|
118
|
-
console.log(`Total Coverage: ${result.stats.metrics.totalCoverage}%`);
|
|
119
|
-
console.log(`Tests Passed: ${result.stats.metrics.totalTestsPassed}`);
|
|
120
|
-
console.log(`Tests Failed: ${result.stats.metrics.totalTestsFailed}`);
|
|
121
|
-
|
|
122
|
-
// Step 5: Display individual agent results
|
|
123
|
-
console.log('\n🤖 Individual Agent Results:');
|
|
124
|
-
console.log('═'.repeat(80));
|
|
125
|
-
|
|
126
|
-
result.results.forEach((agentResult, index) => {
|
|
127
|
-
console.log(`\nAgent ${index + 1}: ${agentResult.agentId} (${agentResult.agentType})`);
|
|
128
|
-
console.log('─'.repeat(80));
|
|
129
|
-
console.log(`Status: ${agentResult.isValid() ? '✅ VALID' : '❌ INVALID'}`);
|
|
130
|
-
console.log(`Confidence: ${(agentResult.getConfidence() * 100).toFixed(1)}%`);
|
|
131
|
-
console.log(`Attempts: ${agentResult.attempts}`);
|
|
132
|
-
console.log(`Duration: ${agentResult.duration.toFixed(2)}ms`);
|
|
133
|
-
|
|
134
|
-
if (agentResult.validation?.metrics) {
|
|
135
|
-
console.log(`Coverage: ${agentResult.validation.metrics.coverage}%`);
|
|
136
|
-
console.log(`Tests Passed: ${agentResult.validation.metrics.testsPassed}`);
|
|
137
|
-
console.log(`Tests Failed: ${agentResult.validation.metrics.testsFailed}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (agentResult.error) {
|
|
141
|
-
console.log(`Error: ${agentResult.error}`);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// Step 6: Get orchestrator metrics
|
|
146
|
-
console.log('\n\n📊 Orchestrator Metrics:');
|
|
147
|
-
console.log('═'.repeat(80));
|
|
148
|
-
|
|
149
|
-
const metrics = orchestrator.getMetrics();
|
|
150
|
-
|
|
151
|
-
console.log('\nSwarm:');
|
|
152
|
-
console.log(` Swarm ID: ${metrics.swarm.swarmId}`);
|
|
153
|
-
console.log(` Agents Registered: ${metrics.swarm.agentsRegistered}`);
|
|
154
|
-
console.log(` Active Executions: ${metrics.swarm.activeExecutions}`);
|
|
155
|
-
console.log(` Parallel Execution: ${metrics.swarm.parallelExecution}`);
|
|
156
|
-
|
|
157
|
-
console.log('\nTasks:');
|
|
158
|
-
console.log(` Total: ${metrics.tasks.total}`);
|
|
159
|
-
console.log(` Successful: ${metrics.tasks.successful}`);
|
|
160
|
-
console.log(` Failed: ${metrics.tasks.failed}`);
|
|
161
|
-
console.log(` Success Rate: ${metrics.tasks.successRate}`);
|
|
162
|
-
|
|
163
|
-
console.log('\nValidation:');
|
|
164
|
-
console.log(` Passed: ${metrics.validation.passed}`);
|
|
165
|
-
console.log(` Failed: ${metrics.validation.failed}`);
|
|
166
|
-
console.log(` Pass Rate: ${metrics.validation.passRate}`);
|
|
167
|
-
console.log(` Avg Duration: ${metrics.validation.avgDuration}`);
|
|
168
|
-
|
|
169
|
-
console.log('\nConsensus:');
|
|
170
|
-
console.log(` Reached: ${metrics.consensus.reached}`);
|
|
171
|
-
console.log(` Failed: ${metrics.consensus.failed}`);
|
|
172
|
-
console.log(` Success Rate: ${metrics.consensus.successRate}`);
|
|
173
|
-
console.log(` Avg Duration: ${metrics.consensus.avgDuration}`);
|
|
174
|
-
console.log(` Protocol: ${metrics.consensus.protocol}`);
|
|
175
|
-
console.log(` Quorum Size: ${metrics.consensus.quorumSize}`);
|
|
176
|
-
|
|
177
|
-
console.log('\nPerformance:');
|
|
178
|
-
console.log(` Avg Task Duration: ${metrics.performance.avgTaskDuration}`);
|
|
179
|
-
console.log(` Tasks Completed: ${metrics.performance.tasksCompleted}`);
|
|
180
|
-
console.log(` Agents Spawned: ${metrics.performance.agentsSpawned}`);
|
|
181
|
-
|
|
182
|
-
// Step 7: Cleanup
|
|
183
|
-
console.log('\n\n🧹 Cleaning up...');
|
|
184
|
-
await orchestrator.shutdown();
|
|
185
|
-
console.log('✅ Orchestrator shut down cleanly');
|
|
186
|
-
|
|
187
|
-
console.log('\n🎉 Demo completed successfully!\n');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Run demo
|
|
191
|
-
main().catch(error => {
|
|
192
|
-
console.error('\n❌ Demo failed:', error);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
});
|