Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

pi-multi-agent-collaboration

npm version License: MIT

Enterprise-grade multi-agent collaboration system for pi coding agents

WebSocket-based agent-to-agent communication with distributed context synchronization, cryptographic authentication, and task delegation.

Features

πŸ” Cryptographic Identity

  • Ed25519 digital signatures for agent authentication
  • Self-signed identity verification
  • Automatic key generation and secure storage

🌐 WebSocket Communication

  • Server Mode: Listen on port 9999 (configurable)
  • Client Mode: Connect to remote agents
  • Federation: Server-to-server agent network
  • Heartbeat mechanism for connection health

πŸ’¬ Message Protocol

  • MessagePack binary serialization (efficient & compact)
  • Signed message envelopes (tamper-proof)
  • 15+ message types (HELLO, PING, TASK_REQUEST, etc.)
  • Priority-based message handling

πŸ”„ Distributed Context Sync

  • Vector clocks for causal consistency
  • CRDT-style merge strategies
  • Automatic conflict resolution
  • Session management with metadata

Installation

# Via npm
npm install pi-multi-agent-collaboration
# Or install directly in pi
pi install npm:pi-multi-agent-collaboration

Usage

Start as Server:

pi --agent-server --agent-name "Coordinator"

Connect as Client:

pi --agent-client ws://192.168.1.50:9999 --agent-name "Worker1"

Available Commands:

  • /agents - List connected agents
  • /agent-broadcast <message> - Send to all agents
  • /agent-session-create - Create shared workspace
  • /agent-status - Show system status

Tools for LLM:

  • send_to_agent - Send messages between agents
  • delegate_task - Delegate coding tasks to capable agents
  • list_agents - Find agents by capability

System Requirements

  • Node.js >= 18.0.0
  • pi coding agent >= 0.60.0

How It Works

  1. Agent Identity: Each agent gets a unique Ed25519 keypair for signing messages
  2. Discovery: Agents register on WebSocket server or connect to existing servers
  3. Communication: Signed messages flow between agents via WebSocket
  4. Context Sync: Vector clocks ensure causal consistency of shared state
  5. Task Delegation: LLM can delegate tasks to agents with matching capabilities

Configuration

Command-Line Flags:

  • --agent-server - Start WebSocket server
  • --agent-port 9999 - Server port (default: 9999)
  • --agent-host 0.0.0.0 - Server host
  • --agent-client ws://host:port - Connect to server
  • --agent-name "MyAgent" - Agent identity name
  • --agent-capabilities "coding,review" - Comma-separated capabilities
  • --agent-federation - Enable server-to-server federation

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ pi Multi-Agent System β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚ β”‚ Identity β”‚ β”‚ Protocol β”‚ β”‚ Context β”‚β”‚
β”‚ β”‚ Manager β”‚ β”‚ Handler β”‚ β”‚ Sync β”‚β”‚
β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜β”‚
β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”β”‚
β”‚ β”‚ Server β”‚ β”‚ Client β”‚ β”‚ State β”‚β”‚
β”‚ β”‚(Port 9999)β”‚ β”‚(WS Conn) β”‚ β”‚ Manager β”‚β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Links

License

MIT License - See LICENSE file for details.


Author: Dr. Olu (Seyi Akin)
Version: 1.0.0

About

Enterprise-grade multi-agent collaboration system for pi coding agents - WebSocket-based agent-to-agent communication

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /