mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
- Reorganize v3/ into implementation/ subfolders: - planning/, architecture/, migration/, integration/ - security/, adrs/, research/, swarm-plans/ - Add 15-agent concurrent swarm implementation plans: - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x) - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies - Update .claude/settings.json with proper hooks format - Add bash aliases for claude --dangerously-skip-permissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
124 lines
3.6 KiB
TypeScript
124 lines
3.6 KiB
TypeScript
#!/usr/bin/env ts-node
|
|
|
|
/**
|
|
* Coordinator Agent Test - Designed for parallel execution
|
|
* This agent orchestrates and manages other agents
|
|
*/
|
|
|
|
export class CoordinatorAgent {
|
|
private agentId: string;
|
|
private startTime: number;
|
|
private managedAgents: Set<string>;
|
|
|
|
constructor(id: string = 'coordinator-001') {
|
|
this.agentId = id;
|
|
this.startTime = Date.now();
|
|
this.managedAgents = new Set();
|
|
}
|
|
|
|
async orchestrateSwarmTask(taskDescription: string, agentCount: number = 3): Promise<any> {
|
|
console.log(`[${this.agentId}] Orchestrating swarm task: ${taskDescription}`);
|
|
console.log(`[${this.agentId}] Deploying ${agentCount} agents...`);
|
|
|
|
// Simulate agent deployment
|
|
await this.simulateWork(500);
|
|
|
|
const agents = [];
|
|
for (let i = 0; i < agentCount; i++) {
|
|
const agentId = `agent-${Date.now()}-${i}`;
|
|
this.managedAgents.add(agentId);
|
|
agents.push({
|
|
id: agentId,
|
|
type: this.selectAgentType(i),
|
|
status: 'active',
|
|
task: this.assignTask(taskDescription, i)
|
|
});
|
|
}
|
|
|
|
console.log(`[${this.agentId}] Swarm deployed successfully`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
swarmSize: agents.length,
|
|
agents
|
|
};
|
|
}
|
|
|
|
async monitorProgress(): Promise<any> {
|
|
console.log(`[${this.agentId}] Monitoring swarm progress...`);
|
|
|
|
await this.simulateWork(1000);
|
|
|
|
const progress = {
|
|
totalAgents: this.managedAgents.size,
|
|
activeAgents: Math.floor(this.managedAgents.size * 0.8),
|
|
completedTasks: Math.floor(Math.random() * 10) + 5,
|
|
pendingTasks: Math.floor(Math.random() * 5),
|
|
avgCompletionTime: Math.floor(Math.random() * 1000) + 500,
|
|
healthStatus: 'optimal'
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Progress update generated`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
progress
|
|
};
|
|
}
|
|
|
|
async rebalanceWorkload(): Promise<any> {
|
|
console.log(`[${this.agentId}] Rebalancing workload across agents...`);
|
|
|
|
await this.simulateWork(700);
|
|
|
|
const rebalancing = {
|
|
agentsRebalanced: Math.floor(this.managedAgents.size / 2),
|
|
tasksRedistributed: Math.floor(Math.random() * 10) + 3,
|
|
efficiencyGain: `${Math.floor(Math.random() * 20) + 10}%`,
|
|
newDistribution: Array.from(this.managedAgents).map(id => ({
|
|
agentId: id,
|
|
workload: Math.floor(Math.random() * 100)
|
|
}))
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Workload rebalancing completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
rebalancing
|
|
};
|
|
}
|
|
|
|
private selectAgentType(index: number): string {
|
|
const types = ['researcher', 'developer', 'analyzer', 'reviewer', 'tester'];
|
|
return types[index % types.length];
|
|
}
|
|
|
|
private assignTask(description: string, index: number): string {
|
|
const tasks = [
|
|
`Research ${description}`,
|
|
`Implement ${description}`,
|
|
`Analyze ${description}`,
|
|
`Review ${description}`,
|
|
`Test ${description}`
|
|
];
|
|
return tasks[index % tasks.length];
|
|
}
|
|
|
|
private async simulateWork(ms: number): Promise<void> {
|
|
await new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
}
|
|
|
|
// Allow direct execution
|
|
if (require.main === module) {
|
|
const coordinator = new CoordinatorAgent();
|
|
|
|
Promise.all([
|
|
coordinator.orchestrateSwarmTask('Build authentication system', 5),
|
|
coordinator.monitorProgress(),
|
|
coordinator.rebalanceWorkload()
|
|
]).then(results => {
|
|
console.log('\nCoordinator Agent Results:', JSON.stringify(results, null, 2));
|
|
});
|
|
} |