ISEK icon indicating copy to clipboard operation
ISEK copied to clipboard

[Feature Request] Add P2P Communication Support via JS libp2p

Open SparkssL opened this issue 1 year ago โ€ข 0 comments

๐Ÿงฉ Motivation

To make the agent network more decentralized and resilient, we need to support peer-to-peer (P2P) communication as a core protocol layer. This allows agents and nodes to communicate directly without requiring centralized message brokers or RPC servers.

๐Ÿš€ Proposal

Integrate libp2p (JavaScript) into the framework to provide the following capabilities:

โœ… Goals

  • Support P2P transport layer using libp2p
  • Each Node instance can:
    • Generate or load a PeerId
    • Connect to other peers using multiaddr
    • Expose a protocol handler (e.g., /a2a/1.0.0)
    • Send/receive messages to/from other nodes

๐Ÿ”ง Tasks

  1. Initialize libp2p node in our P2PTransport class
  2. Implement basic stream handling (libp2p.handle() and libp2p.dialProtocol())
  3. Enable dynamic peer discovery (mDNS or Bootstrap)
  4. Define a custom protocol for A2A messaging (/a2a/1.0.0)
  5. Expose P2PTransport as a pluggable transport for A2AProtocol

๐Ÿงช Example

const node = await createLibp2p({
  peerId,
  addresses: { listen: ['/webrtc'] },
  transports: [webSockets(), webRTC()],
  connectionEncryption: [noise()],
  streamMuxers: [yamux()],
  services: {
    identify: identifyService(),
    ping: pingService(),
  },
});

node.handle('/a2a/1.0.0', ({ stream }) => {
  // handle incoming A2A message
});

๐Ÿ“ฆ Benefits

  • Enable decentralized coordination between nodes
  • Eliminate dependency on centralized messaging infrastructure
  • Prepare foundation for MCP (Multi-node Coordination Protocol)

๐Ÿง  References


We welcome feedback, design input, and implementation help ๐Ÿ™Œ

SparkssL avatar Jun 01 '25 14:06 SparkssL