Skip to content

Brainwires/brainwires-framework

Brainwires Framework

CI Crates.io Documentation Tests Lines of Code License Rust

A modular Rust framework for building AI agents with multi-provider support, tool orchestration, MCP integration, and pluggable agent networking.

Overview

The Brainwires Framework is a workspace of 16 framework crates plus 20 extras that provide everything needed to build, train, deploy, and coordinate AI agents. Each framework crate is independently publishable to crates.io and usable standalone, but they compose together through the brainwires facade crate for a batteries-included experience.

Full feature list | Key capabilities:

  • Multi-provider AI — Anthropic, OpenAI, Google, Ollama, and local LLMs behind a unified Provider trait
  • Agent orchestration — hierarchical task decomposition, multi-agent coordination with file locks, MDAP voting
  • MCP protocol — full client and server support via rmcp, exposing agents as MCP tools
  • Agent networking — 5-layer protocol stack (IPC, TCP, A2A, Pub/Sub) with pluggable transports, routing, and discovery
  • Training pipelines — cloud fine-tuning (6 providers) and local LoRA/QLoRA/DoRA via Burn
  • RAG & code search — AST-aware chunking, hybrid vector + keyword search, Git-aware indexing
  • Audio — speech-to-text, text-to-speech, hardware capture/playback
  • Security — encrypted storage (ChaCha20-Poly1305), permission policies, content trust tagging

Crate Map

  ┌────────────────────────────────────────────────────────────┐
  │                        brainwires                          │
  │                      (facade crate)                        │
  │                                                            │
  │  ┌───────────┐ ┌────────────┐ ┌───────────┐ ┌───────────┐  │
  │  │  agents   │ │  providers │ │  storage  │ │    mcp    │  │
  │  │  mdap     │ │   tools    │ │ knowledge │ │  network  │  │
  │  └─────┬─────┘ └──────┬─────┘ └─────┬─────┘ └─────┬─────┘  │
  │        │              │             │             │        │
  │        └──────────────┴─────────────┴─────────────┘        │
  │                            │                               │
  │                     ┌──────▼──────┐                        │
  │                     │    core     │                        │
  │                     │ permissions │                        │
  │                     └─────────────┘                        │
  │                                                            │
  │  ┌──────────┐ ┌────────────┐ ┌───────────┐ ┌───────────┐   │
  │  │reasoning │ │  training  │ │ telemetry │ │   audio   │   │
  │  │ hardware │ │    a2a     │ │mcp-server │ │           │   │
  │  └──────────┘ └────────────┘ └───────────┘ └───────────┘   │
  └────────────────────────────────────────────────────────────┘

Framework Crates

Crate Description
brainwires Facade crate — re-exports all other crates behind feature flags
brainwires-core Core types, traits, and error handling shared by all crates
brainwires-providers Multi-provider AI interface (Anthropic, OpenAI, Google, Ollama, local LLMs)
brainwires-tools Tool definitions, execution, interpreters, and system primitives for AI model interactions
brainwires-agents Multi-agent orchestration, task decomposition, file lock coordination, skills and slash commands
brainwires-knowledge Knowledge (BKS/PKS, entity graphs), prompting (technique library, clustering), and RAG (code search, hybrid retrieval)
brainwires-storage Unified database layer (9 backends), tiered memory, semantic search
brainwires-permissions Permission policies (auto, ask, reject) for tool execution
brainwires-mcp MCP client — connect to external MCP servers and use their tools
brainwires-network Agent networking — MCP server, IPC, remote bridge, channels, WebRTC, 5-layer protocol stack
brainwires-reasoning Reasoning strategies — re-exports from core
brainwires-hardware Hardware I/O — audio (STT/TTS), GPIO, Bluetooth, Matter (experimental PASE), home automation, camera/webcam, raw USB
brainwires-training Training data pipelines, cloud fine-tuning (6 providers), and local LoRA/QLoRA/DoRA via Burn
brainwires-telemetry OutcomeMetrics, Prometheus export, billing hooks
brainwires-a2a Agent-to-Agent protocol — JSON-RPC 2.0, HTTP/REST, and gRPC bindings
brainwires-mcp-server MCP server framework — build MCP tool servers with composable middleware; http feature adds stateless HTTP+SSE transport, Server Cards (SEP-1649), RFC9728, and Tasks (SEP-1686); oauth feature adds JWT validation middleware

Extras

Crate Description
brainwires-proxy HTTP proxy for AI API request routing
brainwires-brain-server MCP server binary for brainwires-brain
brainwires-rag-server MCP server binary for brainwires-rag
agent-chat Simplified AI chat client with TUI and plain modes
reload-daemon MCP server for killing and restarting AI coding clients
audio-demo-ffi UniFFI bindings (cdylib) exposing brainwires-hardware (audio) to C#, Kotlin, Swift, Python
audio-demo Cross-platform Avalonia GUI for TTS/STT demo across all audio providers
brainclaw Self-hosted personal AI assistant daemon — multi-provider, per-user sessions, secure gateway
brainwires-gateway WebSocket/HTTP channel hub — routes channel adapters to AI agent sessions
brainwires-discord-channel Discord channel adapter — reference Channel trait implementation, optional MCP server mode
brainwires-telegram-channel Telegram channel adapter — teloxide-based, optional MCP server mode
brainwires-slack-channel Slack channel adapter — Socket Mode (no public URL), optional MCP server mode
brainwires-skill-registry Skill registry HTTP server — SQLite FTS5, publish/search/download endpoints
brainclaw-mcp-github GitHub channel adapter — webhook receiver, REST API, MCP server mode
brainwires-memory-service Mem0-compatible memory REST API backed by Brainwires storage
matter-tool Brainwires-native Matter CLI (experimental) — PASE pairing, mDNS discovery, basic control
claude-brain Brainwires context management for Claude Code — persistent context across compaction
brainwires-cli AI-powered agentic CLI tool for autonomous coding assistance
brainwires-issues MCP-native issue tracking server
brainwires-scheduler MCP server for cron scheduling
brainwires-autonomy Autonomous agent operations
brainwires-wasm WASM browser bindings

Getting Started

Requirements

  • Rust 1.91+ (edition 2024)
  • Cargo (comes with Rust)

Note: This framework uses edition = "2024" which requires Rust 1.91 or newer. Check your version with rustc --version and update with rustup update stable if needed.

Using the Facade Crate

The simplest way to use the framework is through the brainwires facade crate, which re-exports everything behind feature flags:

[dependencies]
brainwires = "0.10"  # defaults: tools + agents

Enable only what you need:

[dependencies]
brainwires = { version = "0.10", features = ["providers", "rag"] }

Using Individual Crates

Each crate is independently publishable and usable:

[dependencies]
brainwires-core = "0.10"
brainwires-providers = "0.10"
brainwires-agents = "0.10"

Minimal Example

use brainwires::prelude::*;
use brainwires::providers::{ChatProviderFactory, ProviderConfig, ProviderType};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a provider via the factory
    let config = ProviderConfig {
        provider: ProviderType::Anthropic,
        model: "claude-sonnet-4-6".into(),
        api_key: Some("your-api-key".into()),
        base_url: None,
    };
    let provider = ChatProviderFactory::create(&config)?;

    // Send a message
    let messages = vec![Message::user("Hello, what can you do?")];
    let options = ChatOptions::default();
    let response = provider.chat(&messages, None, &options).await?;

    println!("{}", response.message.content);
    Ok(())
}

Feature Flags

The brainwires facade crate exposes feature flags corresponding to each sub-crate:

Feature Default What it enables
core Always Core types and traits (not feature-gated)
tools Yes Tool definitions, execution, and interpreters (brainwires-tools)
agents Yes Multi-agent orchestration, skills (brainwires-agents)
providers No AI provider integrations
storage No Vector storage and semantic search
mcp No MCP client support
agent-network No Agent networking — IPC, remote bridge, channels, 5-layer protocol stack (brainwires-network)
mcp-server-framework No MCP server building blocks (McpServer, McpHandler, middleware pipeline)
rag No RAG engine with code search
audio No Audio capture, STT, TTS
training No Model fine-tuning (cloud + local)
datasets No Training data pipelines (delegates to brainwires-training)
telemetry No OutcomeMetrics, Prometheus export, billing hooks
reasoning No Reasoning strategies (re-exports from core)
mesh No Mesh networking (via agent-network mesh feature)
a2a No Agent-to-Agent protocol
wasm No WASM core bindings
researcher No Bundle: providers + agents + storage + rag + training + datasets

Building

# Build all crates (debug)
cargo build

# Build all crates (release)
cargo build --release

# Build a specific crate
cargo build -p brainwires-agents

# Run all tests
cargo test

# Run tests for a specific crate
cargo test -p brainwires-core

Dependency DAG

  brainwires (facade)
  ├── brainwires-agents
  │   ├── brainwires-core
  │   ├── brainwires-tools
  │   └── brainwires-knowledge (seal-knowledge feature)
  ├── brainwires-knowledge
  │   ├── brainwires-core
  │   └── brainwires-storage (knowledge feature)
  ├── brainwires-storage
  │   └── brainwires-core
  ├── brainwires-mcp
  │   └── brainwires-core
  ├── brainwires-network
  │   ├── brainwires-core
  │   ├── brainwires-mcp
  │   ├── brainwires-mcp-server
  │   └── brainwires-a2a (a2a-transport feature)
  ├── brainwires-mcp-server
  │   └── brainwires-mcp
  ├── brainwires-training
  │   ├── brainwires-core
  │   └── brainwires-providers (cloud feature)
  ├── brainwires-telemetry
  │   └── brainwires-core
  └── brainwires-hardware
      ├── brainwires-providers (audio feature, optional)
      └── (standalone for gpio, bluetooth, matter, home automation)

License

Licensed under either of:

at your option.

About

A modular framework for building complete AI solutions. It's mostly a Rust framework with a subset of it ported to Deno.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors