Agent swarm orchestrator inspired by Moonshot AI's Kimi K2.5 model. Lightweight toolkit for coordinating autonomous agent swarms with 256K context window support.
This Node.js implementation of AgentSwarm Orchestrator was inspired by https://kimik25.com. It provides an async-first, event-driven approach to agent management with EventEmitter-based messaging.
- Promise-based API: Seamless async/await integration
- EventEmitter architecture: Reactive message passing between agents
- 256K context support: Inspired by Kimi K2.5's extended context window
- Multiple topologies: Hierarchical, mesh, and hybrid patterns
- Type-safe: JSDoc annotations for better IDE support
``bash`
npm install kimi25-opensource
`javascript
const { AgentSwarm } = require('kimi25-opensource');
// Initialize swarm with 256K context window
const swarm = new AgentSwarm({
maxAgents: 100,
contextWindow: 256000,
topology: 'mesh'
});
// Spawn specialized agents
const agent = swarm.spawnAgent('data-processor', 'analysis', 'transform');
// Dispatch messages
await agent.dispatchMessage({
type: 'process',
payload: { data: 'example' }
});
// Get swarm statistics
console.log(swarm.getStats());
// Clean shutdown
await swarm.shutdown();
`
#### AgentSwarm
Main swarm coordinator class.
Constructor Options:
- maxAgents (number): Maximum number of agents (default: 100)contextWindow
- (number): Token context limit (default: 256000)topology
- (string): Swarm topology - 'hierarchical', 'mesh', 'hybrid' (default: 'mesh')
Methods:
- spawnAgent(id, ...capabilities) - Create and register a new agentbroadcastMessage(from, type, payload)
- - Send message to all agentsgetAgent(id)
- - Retrieve agent by IDgetStats()
- - Get current swarm statisticsshutdown()
- - Gracefully shutdown the swarm
Events:
- agent-spawned - Emitted when a new agent is createdagent-message
- - Emitted when any agent dispatches a messagebroadcast
- - Emitted on broadcast messagescontext-warning
- - Emitted when context window is nearly fullshutdown
- - Emitted when swarm is shut down
#### Agent
Individual agent class extending EventEmitter.
Methods:
- dispatchMessage(msg) - Send a message from this agentprocessMessages(handler)
- - Process queued messages asynchronously
#### createSwarm(config)
Factory function to create a new AgentSwarm instance.
`javascript
const swarm = new AgentSwarm();
swarm.on('agent-spawned', ({ id, capabilities }) => {
console.log(New agent: ${id} with ${capabilities.join(', ')});
});
swarm.on('context-warning', ({ used, limit }) => {
console.warn(Context at ${used}/${limit} tokens);
});
const agent = swarm.spawnAgent('worker', 'processing');
`
`javascript
const agent = swarm.spawnAgent('processor');
await agent.processMessages(async (msg) => {
console.log(Processing ${msg.type});``
// Handle message
return { result: 'processed' };
});
The Node.js implementation is optimized for:
- Non-blocking I/O: Async operations don't block the event loop
- Memory efficiency: Minimal memory overhead per agent
- Scalability: Handles 100+ concurrent agents efficiently
- Source: https://kimik25.com
- Repository: https://onedao/wddaily/kimi25-opensource
- Documentation: https://onedao/wddaily/kimi25-opensource#readme
- NPM Package: https://www.npmjs.com/package/kimi25-opensource
MIT License - See LICENSE file for details.