|
| 1 | +#!/usr/bin/env npx tsx |
| 2 | + |
| 3 | +/** |
| 4 | + * Simple Ralph Swarm Demo - Minimal database dependencies |
| 5 | + * Demonstrates basic swarm coordination without complex SessionManager setup |
| 6 | + */ |
| 7 | + |
| 8 | +import 'dotenv/config'; |
| 9 | +import { SwarmCoordinator } from '../src/integrations/ralph/swarm/swarm-coordinator.js'; |
| 10 | +import { SwarmRegistry } from '../src/integrations/ralph/monitoring/swarm-registry.js'; |
| 11 | +import { logger } from '../src/core/monitoring/logger.js'; |
| 12 | + |
| 13 | +async function runSimpleSwarm() { |
| 14 | + try { |
| 15 | + console.log('🦾 Starting Simple Ralph Swarm Demo...'); |
| 16 | + |
| 17 | + // Initialize registry |
| 18 | + const registry = SwarmRegistry.getInstance(); |
| 19 | + |
| 20 | + // Create a basic swarm coordinator without complex dependencies |
| 21 | + const coordinator = new SwarmCoordinator({ |
| 22 | + maxAgents: 2, |
| 23 | + timeout: 30000, |
| 24 | + enableGitWorkflow: false, // Disable git workflow to avoid branch conflicts |
| 25 | + enableStackMemoryBridge: false, // Disable StackMemory integration temporarily |
| 26 | + }); |
| 27 | + |
| 28 | + // Initialize coordinator |
| 29 | + await coordinator.initialize(); |
| 30 | + |
| 31 | + console.log('✅ Swarm coordinator initialized'); |
| 32 | + |
| 33 | + // Define a simple task |
| 34 | + const task = { |
| 35 | + id: 'simple-demo-task', |
| 36 | + description: |
| 37 | + 'Demonstrate basic swarm functionality without database dependencies', |
| 38 | + type: 'demonstration' as const, |
| 39 | + priority: 'medium' as const, |
| 40 | + estimatedDuration: 30000, |
| 41 | + requirements: [ |
| 42 | + 'Show swarm initialization', |
| 43 | + 'Demonstrate agent coordination', |
| 44 | + 'Validate basic functionality', |
| 45 | + ], |
| 46 | + }; |
| 47 | + |
| 48 | + console.log('📋 Task defined:', task.description); |
| 49 | + |
| 50 | + // Register the swarm |
| 51 | + const swarmId = registry.registerSwarm( |
| 52 | + coordinator, |
| 53 | + 'Simple Demo Swarm - No Database Dependencies' |
| 54 | + ); |
| 55 | + |
| 56 | + console.log('🆔 Swarm registered:', swarmId); |
| 57 | + |
| 58 | + // Launch with minimal configuration |
| 59 | + const result = await coordinator.launchSwarm({ |
| 60 | + agents: [ |
| 61 | + { |
| 62 | + role: 'demonstrator', |
| 63 | + specialization: 'basic-functionality', |
| 64 | + task: 'Show basic swarm operations', |
| 65 | + }, |
| 66 | + ], |
| 67 | + task: task.description, |
| 68 | + enableRalphBridge: false, // Disable Ralph bridge to avoid database issues |
| 69 | + }); |
| 70 | + |
| 71 | + console.log('🚀 Swarm launched successfully!'); |
| 72 | + console.log('📊 Result:', { |
| 73 | + swarmId: result.swarmId, |
| 74 | + agentCount: result.agents?.length || 0, |
| 75 | + status: result.status, |
| 76 | + }); |
| 77 | + |
| 78 | + // Show registry status |
| 79 | + const activeSwarms = registry.listActiveSwarms(); |
| 80 | + console.log('📈 Active swarms:', activeSwarms.length); |
| 81 | + |
| 82 | + // Simulate some work |
| 83 | + console.log('⏳ Simulating swarm work for 5 seconds...'); |
| 84 | + await new Promise((resolve) => setTimeout(resolve, 5000)); |
| 85 | + |
| 86 | + // Stop the swarm |
| 87 | + console.log('🛑 Stopping swarm...'); |
| 88 | + await coordinator.stopSwarm(); |
| 89 | + |
| 90 | + console.log(''); |
| 91 | + console.log('🎉 Simple swarm demo completed successfully!'); |
| 92 | + console.log(''); |
| 93 | + console.log('✅ Demonstrated:'); |
| 94 | + console.log(' - Basic swarm coordinator initialization'); |
| 95 | + console.log(' - Swarm registry management'); |
| 96 | + console.log(' - Agent configuration without database dependencies'); |
| 97 | + console.log(' - Simple task execution workflow'); |
| 98 | + console.log(''); |
| 99 | + console.log('🔧 This approach bypasses:'); |
| 100 | + console.log(' - Complex SessionManager database setup'); |
| 101 | + console.log(' - StackMemory FrameManager initialization'); |
| 102 | + console.log(' - Git workflow branch conflicts'); |
| 103 | + console.log(' - Ralph-StackMemory bridge complications'); |
| 104 | + } catch (error: unknown) { |
| 105 | + console.error('❌ Simple swarm demo failed:', (error as Error).message); |
| 106 | + logger.error('Simple swarm demo error', error as Error); |
| 107 | + process.exit(1); |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +// Run the demo |
| 112 | +runSimpleSwarm(); |
0 commit comments