Skip to main content

brainwires_network/
lib.rs

1#![deny(missing_docs)]
2//! # Brainwires Agent Network
3//!
4//! Agent-to-agent networking layer for the Brainwires Agent Framework.
5//!
6//! Provides IPC, remote bridge, mesh networking, routing, discovery,
7//! and pluggable transports for agent communication.
8//!
9//! ## Protocol-Layer Stack
10//!
11//! The networking layer is organized as a 5-layer protocol stack:
12//!
13//! 1. **Identity** — agent identity, capability advertisement, credentials
14//! 2. **Transport** — how bytes move (IPC, Remote, TCP, A2A, Pub/Sub)
15//! 3. **Routing** — where messages go (direct, topology, broadcast, content)
16//! 4. **Discovery** — how agents find each other (mDNS, registry, manual)
17//! 5. **Application** — user-facing API (NetworkManager, events)
18
19/// Networking transport layer — pluggable transports for agent communication.
20pub mod transport;
21
22// ============================================================================
23// Agent Communication Backbone (IPC, Auth, Remote)
24// ============================================================================
25/// Authentication for agent network connections.
26pub mod auth;
27/// IPC (inter-process communication) socket protocol.
28pub mod ipc;
29/// Remote bridge and realtime protocol.
30pub mod remote;
31/// Common agent network traits.
32pub mod traits;
33
34// ============================================================================
35// Agent Management (tool registry + lifecycle trait)
36// ============================================================================
37/// Agent lifecycle management.
38pub mod agent_manager;
39/// Pre-built MCP tools for agent operations.
40pub mod agent_tools;
41
42pub use agent_manager::{AgentInfo, AgentManager, AgentResult, SpawnConfig};
43pub use agent_tools::AgentToolRegistry;
44
45// ============================================================================
46// Client
47// ============================================================================
48/// Client for connecting to a remote agent network server.
49#[cfg(feature = "client")]
50pub mod client;
51
52#[cfg(feature = "client")]
53pub use client::{AgentConfig, AgentNetworkClient, AgentNetworkClientError};
54
55// ============================================================================
56// Mesh Networking (topology, routing, discovery, federation)
57// ============================================================================
58/// Distributed agent mesh networking — topology, routing, discovery, federation.
59#[cfg(feature = "mesh")]
60pub mod mesh;
61
62// ============================================================================
63// Protocol-Layer Stack (Identity, Network Core)
64// ============================================================================
65/// Peer discovery — how agents find each other on the network.
66pub mod discovery;
67/// Agent identity, capability advertisement, and credentials.
68pub mod identity;
69/// Core network types: message envelopes, events, and errors.
70pub mod network;
71/// Message routing — direct, broadcast, and content-based routing.
72pub mod routing;
73
74/// Universal messaging channels (absorbed from brainwires-channels).
75pub mod channels;
76
77pub use identity::{AgentCard, AgentIdentity, ProtocolId};
78pub use network::{
79    ConnectionState, MessageEnvelope, MessageTarget, NetworkError, NetworkEvent, NetworkManager,
80    NetworkManagerBuilder, Payload, TransportType,
81};
82pub use transport::{Transport, TransportAddress};
83
84#[cfg(feature = "ipc-transport")]
85pub use transport::IpcTransport;
86#[cfg(feature = "pubsub-transport")]
87pub use transport::PubSubTransport;
88#[cfg(feature = "remote-transport")]
89pub use transport::RemoteTransport;
90#[cfg(feature = "tcp-transport")]
91pub use transport::TcpTransport;
92#[cfg(feature = "a2a-transport")]
93pub use transport::{A2aTransport, a2a_message_to_envelope};