claude-flow-novice 1.5.12 → 1.5.13
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/dist/mcp/auth.js +347 -0
- package/.claude-flow-novice/dist/mcp/claude-code-wrapper.js +717 -0
- package/.claude-flow-novice/dist/mcp/claude-flow-tools.js +1365 -0
- package/.claude-flow-novice/dist/mcp/client.js +201 -0
- package/.claude-flow-novice/dist/mcp/index.js +192 -0
- package/.claude-flow-novice/dist/mcp/integrate-wrapper.js +85 -0
- package/.claude-flow-novice/dist/mcp/lifecycle-manager.js +348 -0
- package/.claude-flow-novice/dist/mcp/load-balancer.js +386 -0
- package/.claude-flow-novice/dist/mcp/mcp-config-manager.js +1362 -0
- package/.claude-flow-novice/dist/mcp/mcp-server-novice-simplified.js +583 -0
- package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +723 -0
- package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +649 -0
- package/.claude-flow-novice/dist/mcp/mcp-server.js +2256 -0
- package/.claude-flow-novice/dist/mcp/orchestration-integration.js +800 -0
- package/.claude-flow-novice/dist/mcp/performance-monitor.js +489 -0
- package/.claude-flow-novice/dist/mcp/protocol-manager.js +376 -0
- package/.claude-flow-novice/dist/mcp/router.js +220 -0
- package/.claude-flow-novice/dist/mcp/ruv-swarm-tools.js +671 -0
- package/.claude-flow-novice/dist/mcp/ruv-swarm-wrapper.js +254 -0
- package/.claude-flow-novice/dist/mcp/server-with-wrapper.js +32 -0
- package/.claude-flow-novice/dist/mcp/server-wrapper-mode.js +26 -0
- package/.claude-flow-novice/dist/mcp/server.js +539 -0
- package/.claude-flow-novice/dist/mcp/session-manager.js +338 -0
- package/.claude-flow-novice/dist/mcp/sparc-modes.js +455 -0
- package/.claude-flow-novice/dist/mcp/swarm-tools.js +903 -0
- package/.claude-flow-novice/dist/mcp/tools.js +426 -0
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js +23 -1
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +40 -101
- package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js +36 -0
- package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js.map +1 -0
- package/.claude-flow-novice/dist/src/validators/index.js +12 -0
- package/.claude-flow-novice/dist/src/validators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js +261 -0
- package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js +204 -0
- package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/validators/todowrite-integration.js +189 -0
- package/.claude-flow-novice/dist/src/validators/todowrite-integration.js.map +1 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server entry point that uses the wrapper by default
|
|
4
|
+
*/ import { ClaudeCodeMCPWrapper } from './claude-code-wrapper.js';
|
|
5
|
+
// Check if we should use the legacy server
|
|
6
|
+
const useLegacy = process.env.CLAUDE_FLOW_LEGACY_MCP === 'true' || process.argv.includes('--legacy');
|
|
7
|
+
async function main() {
|
|
8
|
+
if (useLegacy) {
|
|
9
|
+
console.error('Starting Claude-Flow MCP in legacy mode...');
|
|
10
|
+
// Dynamically import the old server to avoid circular dependencies
|
|
11
|
+
const module = await import('./server.js');
|
|
12
|
+
if (module.runMCPServer) {
|
|
13
|
+
await module.runMCPServer();
|
|
14
|
+
} else if (module.default) {
|
|
15
|
+
await module.default();
|
|
16
|
+
} else {
|
|
17
|
+
console.error('Could not find runMCPServer function in legacy server');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
console.error('Starting Claude-Flow MCP with Claude Code wrapper...');
|
|
22
|
+
const wrapper = new ClaudeCodeMCPWrapper();
|
|
23
|
+
await wrapper.run();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Run the server
|
|
27
|
+
main().catch((error)=>{
|
|
28
|
+
console.error('Fatal error:', error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=server-with-wrapper.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Claude-Flow MCP Server - Wrapper Mode
|
|
4
|
+
*
|
|
5
|
+
* This version uses the Claude Code MCP wrapper approach instead of templates.
|
|
6
|
+
*/ import { ClaudeCodeMCPWrapper } from './claude-code-wrapper.js';
|
|
7
|
+
// Check if running as wrapper mode
|
|
8
|
+
const isWrapperMode = process.env.CLAUDE_FLOW_WRAPPER_MODE === 'true' || process.argv.includes('--wrapper');
|
|
9
|
+
async function main() {
|
|
10
|
+
if (isWrapperMode) {
|
|
11
|
+
console.error('Starting Claude-Flow MCP in wrapper mode...');
|
|
12
|
+
const wrapper = new ClaudeCodeMCPWrapper();
|
|
13
|
+
await wrapper.run();
|
|
14
|
+
} else {
|
|
15
|
+
// Fall back to original server
|
|
16
|
+
console.error('Starting Claude-Flow MCP in direct mode...');
|
|
17
|
+
const { runMCPServer } = await import('./server.js');
|
|
18
|
+
await runMCPServer();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
main().catch((error)=>{
|
|
22
|
+
console.error('Fatal error:', error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=server-wrapper-mode.js.map
|