π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix: add workaround for ruv-swarm v1.0.8 logger error
rUve8cc5082eff9
diff --git a/docs/known-issues.md b/docs/known-issues.mdnew file mode 100644index 0000000000..dccf3e7613--- /dev/null+++ b/docs/known-issues.md@@ -0,0 +1,48 @@+# Known Issues++## ruv-swarm v1.0.8 Logger Error++### Issue+When running `npx ruv-swarm mcp start`, you may encounter:+```+β Uncaught Exception: logger.logMemoryUsage is not a function+```++### Impact+- The error occurs after successful initialization+- The MCP server continues to work despite the error+- This is a non-critical error that doesn't affect functionality++### Workaround+Use claude-flow's integrated MCP server instead:++```bash+# Option 1: Use claude-flow MCP server (recommended)+npx claude-flow@alpha mcp start++# Option 2: Configure claude-flow with MCP integration+claude mcp add claude-flow npx claude-flow@alpha mcp start+```++### Fix Status+- **Affected Version**: ruv-swarm v1.0.8+- **Status**: Known issue in external package+- **Claude-Flow**: Provides integrated MCP server as alternative++### Technical Details+The error occurs because ruv-swarm attempts to call `logger.logMemoryUsage()` in a monitoring interval, but the method isn't properly bound to the logger instance in certain contexts.++## Anthropic API 500 Errors++### Issue+When Anthropic's API experiences issues, you may see:+```+API Error: 500 {"type":"error","error":{"type":"api_error","message":"Internal server error"}}+```++### Workaround+1. Check https://status.anthropic.com/ for service status+2. Use `--claude` flag to generate commands without API calls+3. Use `--executor` for local execution++See issue #183 for more details.\ No newline at end of filediff --git a/package.json b/package.jsonindex 57c29db56a..1f48f5945e 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "claude-flow",- "version": "2.0.0-alpha.36",+ "version": "2.0.0-alpha.37","description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)","main": "cli.mjs","bin": {diff --git a/scripts/ruv-swarm-safe.js b/scripts/ruv-swarm-safe.jsnew file mode 100755index 0000000000..751d9fbf7d--- /dev/null+++ b/scripts/ruv-swarm-safe.js@@ -0,0 +1,74 @@+#!/usr/bin/env node++/**+ * Safe wrapper for ruv-swarm MCP server+ * Handles known logger issue in v1.0.8+ */++import { spawn } from 'child_process';+import { createInterface } from 'readline';++console.log('π Starting ruv-swarm MCP server with error handling...');++const ruvSwarmProcess = spawn('npx', ['ruv-swarm', 'mcp', 'start'], {+ stdio: ['pipe', 'pipe', 'pipe'],+ env: {+ ...process.env,+ MCP_MODE: 'stdio',+ LOG_LEVEL: 'WARN'+ }+});++// Forward stdin to ruv-swarm+process.stdin.pipe(ruvSwarmProcess.stdin);++// Handle stdout (JSON-RPC messages)+ruvSwarmProcess.stdout.pipe(process.stdout);++// Handle stderr with filtering+const rlErr = createInterface({+ input: ruvSwarmProcess.stderr,+ crlfDelay: Infinity+});++let errorHandled = false;++rlErr.on('line', (line) => {+ // Filter out the known logger error+ if (line.includes('logger.logMemoryUsage is not a function')) {+ if (!errorHandled) {+ console.error('β οΈ Known ruv-swarm v1.0.8 logger issue detected - continuing normally');+ console.error('π‘ This error does not affect functionality');+ errorHandled = true;+ }+ return;+ }++ // Forward other stderr output+ process.stderr.write(line + '\n');+});++// Handle process exit+ruvSwarmProcess.on('exit', (code, signal) => {+ if (code !== null && code !== 0) {+ console.error(`\nβ ruv-swarm exited with code ${code}`);+ console.error('π‘ Try using: npx claude-flow@alpha mcp start');+ }+ process.exit(code || 0);+});++// Handle errors+ruvSwarmProcess.on('error', (error) => {+ console.error('β Failed to start ruv-swarm:', error.message);+ console.error('π‘ Try using: npx claude-flow@alpha mcp start');+ process.exit(1);+});++// Handle termination signals+process.on('SIGTERM', () => {+ ruvSwarmProcess.kill('SIGTERM');+});++process.on('SIGINT', () => {+ ruvSwarmProcess.kill('SIGINT');+});\ No newline at end of filediff --git a/src/mcp/ruv-swarm-wrapper.js b/src/mcp/ruv-swarm-wrapper.jsnew file mode 100644index 0000000000..1f9963c16f--- /dev/null+++ b/src/mcp/ruv-swarm-wrapper.js@@ -0,0 +1,202 @@+/**+ * Wrapper for ruv-swarm MCP server to handle logger issues+ * This wrapper ensures compatibility and handles known issues in ruv-swarm+ */++import { spawn } from 'child_process';+import { createInterface } from 'readline';++export class RuvSwarmWrapper {+ constructor(options = {}) {+ this.options = {+ silent: options.silent || false,+ autoRestart: options.autoRestart !== false,+ maxRestarts: options.maxRestarts || 3,+ restartDelay: options.restartDelay || 1000,+ ...options+ };++ this.process = null;+ this.restartCount = 0;+ this.isShuttingDown = false;+ }++ async start() {+ if (this.process) {+ throw new Error('RuvSwarm MCP server is already running');+ }++ return new Promise((resolve, reject) => {+ try {+ // Spawn ruv-swarm MCP server+ this.process = spawn('npx', ['ruv-swarm', 'mcp', 'start'], {+ stdio: ['pipe', 'pipe', 'pipe'],+ env: {+ ...process.env,+ // Ensure stdio mode for MCP+ MCP_MODE: 'stdio',+ // Set log level to reduce noise+ LOG_LEVEL: 'WARN'+ }+ });++ let initialized = false;+ let initTimeout;++ // Handle stdout (JSON-RPC messages)+ const rlOut = createInterface({+ input: this.process.stdout,+ crlfDelay: Infinity+ });++ rlOut.on('line', (line) => {+ try {+ const message = JSON.parse(line);++ // Check for initialization+ if (message.method === 'server.initialized' && !initialized) {+ initialized = true;+ clearTimeout(initTimeout);+ resolve({+ process: this.process,+ stdout: this.process.stdout,+ stdin: this.process.stdin+ });+ }++ // Forward JSON-RPC messages+ process.stdout.write(line + '\n');+ } catch (err) {+ // Not JSON, ignore+ }+ });++ // Handle stderr (logs and errors)+ const rlErr = createInterface({+ input: this.process.stderr,+ crlfDelay: Infinity+ });++ rlErr.on('line', (line) => {+ // Filter out known harmless errors+ if (line.includes('logger.logMemoryUsage is not a function')) {+ // This is a known issue in ruv-swarm v1.0.8+ // The server continues to work despite this error+ if (!this.options.silent) {+ console.error('β οΈ Known ruv-swarm logger issue detected (continuing normally)');+ }+ return;+ }++ // Filter out initialization messages if silent+ if (this.options.silent) {+ if (line.includes('β ') || line.includes('π§ ') || line.includes('π')) {+ return;+ }+ }++ // Forward other stderr output+ if (!this.options.silent) {+ process.stderr.write(line + '\n');+ }+ });++ // Handle process errors+ this.process.on('error', (error) => {+ if (!initialized) {+ clearTimeout(initTimeout);+ reject(new Error(`Failed to start ruv-swarm: ${error.message}`));+ } else {+ console.error('RuvSwarm process error:', error);+ this.handleProcessExit(error.code || 1);+ }+ });++ // Handle process exit+ this.process.on('exit', (code, signal) => {+ if (!initialized) {+ clearTimeout(initTimeout);+ reject(new Error(`RuvSwarm exited before initialization: code ${code}, signal ${signal}`));+ } else {+ this.handleProcessExit(code || 0);+ }+ });++ // Set initialization timeout+ initTimeout = setTimeout(() => {+ if (!initialized) {+ this.stop();+ reject(new Error('RuvSwarm initialization timeout'));+ }+ }, 30000); // 30 second timeout++ } catch (error) {+ reject(error);+ }+ });+ }++ handleProcessExit(code) {+ this.process = null;++ if (this.isShuttingDown) {+ return;+ }++ console.error(`RuvSwarm MCP server exited with code ${code}`);++ // Auto-restart if enabled and under limit+ if (this.options.autoRestart && this.restartCount < this.options.maxRestarts) {+ this.restartCount++;+ console.log(`Attempting to restart RuvSwarm (attempt ${this.restartCount}/${this.options.maxRestarts})...`);++ setTimeout(() => {+ this.start().catch(err => {+ console.error('Failed to restart RuvSwarm:', err);+ });+ }, this.options.restartDelay);+ }+ }++ async stop() {+ this.isShuttingDown = true;++ if (!this.process) {+ return;+ }++ return new Promise((resolve) => {+ const killTimeout = setTimeout(() => {+ console.warn('RuvSwarm did not exit gracefully, forcing kill...');+ this.process.kill('SIGKILL');+ }, 5000);++ this.process.on('exit', () => {+ clearTimeout(killTimeout);+ this.process = null;+ resolve();+ });++ // Send graceful shutdown signal+ this.process.kill('SIGTERM');+ });+ }++ isRunning() {+ return this.process !== null && !this.process.killed;+ }+}++// Export a function to start ruv-swarm with error handling+export async function startRuvSwarmMCP(options = {}) {+ const wrapper = new RuvSwarmWrapper(options);++ try {+ const result = await wrapper.start();+ console.log('β RuvSwarm MCP server started successfully');+ return { wrapper, ...result };+ } catch (error) {+ console.error('β Failed to start RuvSwarm MCP server:', error.message);+ throw error;+ }+}\ No newline at end of file