universal-bot-core

Crates.iouniversal-bot-core
lib.rsuniversal-bot-core
version1.0.0
created_at2025-08-17 21:22:24.923775+00
updated_at2025-08-17 21:22:24.923775+00
descriptionCore functionality for Universal Bot AI automation framework with AWS Bedrock
homepagehttps://github.com/paiml/universal-bot
repositoryhttps://github.com/paiml/universal-bot
max_upload_size
id1799719
size278,129
Noah Gift (noahgift)

documentation

https://docs.rs/universal-bot-core

README

Universal Bot - Enterprise AI Automation Framework

Crates.io Documentation Build Status Coverage License Rust AWS Bedrock Downloads

Enterprise-grade AI automation framework integrating AWS Bedrock, PDMT templating, and AssetGen content generation into a unified, production-ready platform.

๐Ÿš€ Overview

Universal Bot is a comprehensive AI-powered automation framework that combines cutting-edge technologies from production systems:

  • AWS Bedrock Integration: Enterprise-grade AI model orchestration with Claude Opus 4.1, Sonnet 4, and more
  • PDMT Templating: Deterministic, reproducible content generation with quality gates
  • AssetGen Engine: Automated educational and marketing content creation
  • MCP Protocol: Native Model Context Protocol support for AI assistants
  • Production-Ready: 85%+ test coverage, property testing, and comprehensive validation

๐Ÿ—๏ธ Core Technologies

AWS Bedrock Runtime

  • Connection Pooling: Enterprise-grade connection management with retry logic
  • Model Orchestra: Claude Opus 4.1, Sonnet 4, Llama, Titan multi-model support
  • Token Management: Automatic usage tracking and cost optimization
  • Streaming: Real-time response streaming for interactive applications
  • Metrics: Comprehensive observability with latency and success tracking

PDMT (Pragmatic Deterministic MCP Templating)

  • Zero-Temperature Generation: Reproducible outputs with deterministic templates
  • Quality Gates: PMAT enforcement with coverage, complexity, and SATD detection
  • Todo Validation: Actionability scoring and dependency analysis
  • MCP Native: Full Model Context Protocol support via PMCP SDK

AssetGen Content Engine

  • Multi-Format Generation: Quizzes, labs, blog posts, marketing content
  • Platform-Specific: MailChimp, LinkedIn, Discord, Bluesky optimized content
  • Meta-Aware Validation: Automatic detection and removal of transcript artifacts
  • GitHub Integration: Automated publishing pipeline with issue tracking

๐Ÿ“ฆ Key Features

AI Model Integration

  • โœ… AWS Bedrock Runtime: Production-ready with retry logic and pooling
  • โœ… Multi-Model Support: Claude, Llama, Titan, Jurassic orchestration
  • โœ… Token Optimization: Automatic counting and cost tracking
  • โœ… Streaming Responses: Real-time token generation

Content Generation

  • โœ… Educational Materials: Automated quiz, lab, and reflection creation
  • โœ… Marketing Content: Platform-specific for MailChimp, LinkedIn, Discord
  • โœ… Blog Generation: Technical blogs with Zola/Hugo support
  • โœ… Transcription Processing: Whisper.cpp integration

Quality Assurance

  • โœ… Property Testing: 100+ property tests ensuring robustness
  • โœ… Coverage Tracking: 85%+ test coverage with reporting
  • โœ… Validation Pipeline: Multi-stage validation with quality gates
  • โœ… CI/CD Integration: GitHub Actions and self-hosted runners

๐Ÿ—๏ธ Architecture

universal-bot/
โ”œโ”€โ”€ core/                    # Core Rust components
โ”‚   โ”œโ”€โ”€ bedrock/            # AWS Bedrock client implementation
โ”‚   โ”‚   โ”œโ”€โ”€ client.rs       # Connection pooling & retry logic
โ”‚   โ”‚   โ”œโ”€โ”€ models.rs       # Model configuration & selection
โ”‚   โ”‚   โ””โ”€โ”€ metrics.rs      # Token usage & cost tracking
โ”‚   โ”œโ”€โ”€ pdmt/               # Template engine
โ”‚   โ”‚   โ”œโ”€โ”€ engine.rs       # Handlebars-based generation
โ”‚   โ”‚   โ”œโ”€โ”€ validators.rs   # Todo validation & scoring
โ”‚   โ”‚   โ””โ”€โ”€ quality.rs      # Quality gate enforcement
โ”‚   โ””โ”€โ”€ providers/          # AI provider abstractions
โ”‚       โ”œโ”€โ”€ bedrock.rs      # AWS Bedrock provider
โ”‚       โ””โ”€โ”€ mcp.rs          # MCP protocol provider
โ”œโ”€โ”€ generators/             # Content generation modules
โ”‚   โ”œโ”€โ”€ quiz/              # Quiz generation with validation
โ”‚   โ”œโ”€โ”€ blog/              # Blog post generation
โ”‚   โ”œโ”€โ”€ marketing/         # Multi-platform marketing
โ”‚   โ””โ”€โ”€ educational/       # Labs, reflections, key terms
โ”œโ”€โ”€ validators/            # Validation components
โ”‚   โ”œโ”€โ”€ content.rs        # Meta-aware content validation
โ”‚   โ”œโ”€โ”€ quality.rs        # Quality gate checks
โ”‚   โ””โ”€โ”€ structure.rs      # Course structure validation
โ””โ”€โ”€ integrations/         # External integrations
    โ”œโ”€โ”€ github/          # GitHub API & Actions
    โ”œโ”€โ”€ aws/             # S3, Bedrock services
    โ””โ”€โ”€ mcp/             # Model Context Protocol

๐Ÿ› ๏ธ Prerequisites

Required

  • Rust 1.75+ (latest stable)
  • AWS Account with Bedrock access
  • 8GB RAM minimum
  • 2GB disk space

Optional

  • Node.js 18+ (for TypeScript integrations)
  • Docker (for containerized deployment)
  • GitHub account (for CI/CD)

๐Ÿ“ฆ Installation

From crates.io

[dependencies]
universal-bot-core = "1.0"

From source

# Clone the repository
git clone https://github.com/paiml/universal-bot
cd universal-bot

# Install dependencies
make install

# Configure AWS credentials
aws configure

# Run tests to verify setup
make test

# Start the bot
cargo run --bin universal-bot

๐Ÿ“ Repository Structure

universal-bot-rust/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ฆ core/                        # The 80% - Universal AI Brain
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ bedrock/               # AWS Bedrock client & models
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ client.rs         # Connection management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ models.rs         # Model orchestration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ streaming.rs      # Real-time responses
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ conversation/         # Conversation engine
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pipeline.rs      # Message processing
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ state.rs         # State machines
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ context.rs       # Memory management
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ plugins/              # Extension system
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ traits.rs        # Plugin interfaces
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ registry.rs      # Plugin management
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ builtin/         # Core plugins
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ””โ”€โ”€ lib.rs               # Public API
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ examples/                 # Runnable demonstrations
โ”‚   โ”‚   โ”œโ”€โ”€ basic_conversation.rs
โ”‚   โ”‚   โ”œโ”€โ”€ multi_model_chat.rs
โ”‚   โ”‚   โ”œโ”€โ”€ stream_conversation.rs
โ”‚   โ”‚   โ””โ”€โ”€ plugin_demo.rs
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ Cargo.toml               # Dependencies
โ”‚
โ”œโ”€โ”€ ๐Ÿ“š adapters/                   # The 20% - Platform Theory
โ”‚   โ”œโ”€โ”€ discord_theory.md        # Discord architecture (no code)
โ”‚   โ”œโ”€โ”€ slack_theory.md          # Slack patterns (conceptual)
โ”‚   โ”œโ”€โ”€ web_api_theory.md        # REST endpoints (theory)
โ”‚   โ””โ”€โ”€ integration_patterns.md  # General adapter design
โ”‚
โ”œโ”€โ”€ ๐ŸŽ“ course/                    # Video course materials
โ”‚   โ”œโ”€โ”€ module_1/                # Foundation videos
โ”‚   โ”œโ”€โ”€ module_2/                # Core engine videos
โ”‚   โ”œโ”€โ”€ module_3/                # Advanced patterns
โ”‚   โ”œโ”€โ”€ module_4/                # Plugin architecture
โ”‚   โ””โ”€โ”€ module_5/                # Platform theory
โ”‚
โ”œโ”€โ”€ ๐Ÿ“– docs/                      # Documentation
โ”‚   โ”œโ”€โ”€ architecture.md          # System design
โ”‚   โ”œโ”€โ”€ bedrock_setup.md        # AWS configuration
โ”‚   โ”œโ”€โ”€ rust_patterns.md        # Rust best practices
โ”‚   โ””โ”€โ”€ deployment.md           # Production guide
โ”‚
โ”œโ”€โ”€ ๐Ÿงช tests/                     # Test suite
โ”‚   โ”œโ”€โ”€ integration/             # End-to-end tests
โ”‚   โ””โ”€โ”€ unit/                    # Component tests
โ”‚
โ””โ”€โ”€ ๐Ÿ”ง scripts/                   # Utility scripts
    โ”œโ”€โ”€ setup.sh                 # Environment setup
    โ”œโ”€โ”€ test.sh                  # Run all tests
    โ””โ”€โ”€ deploy.sh                # Deployment helper

๐Ÿ’ก Key Concepts Visualized

The Message Pipeline

Think of messages flowing through a factory assembly line:

     Raw Input                  Enriched                   Routed
         โ”‚                         โ”‚                         โ”‚
         โ–ผ                         โ–ผ                         โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Sanitizeโ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Context โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  Model  โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                           โ”‚
                                                           โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Display โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ Format  โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚   AI    โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     Final Output             Structured               Response

The Plugin System

Like LEGO blocks with standardized connectors:

pub trait BotPlugin {
    async fn process(&self, input: Message) -> Result<Message>;
    fn capabilities(&self) -> Vec<Capability>;
}

// Any plugin can connect if it fits the trait
impl BotPlugin for WeatherPlugin { ... }
impl BotPlugin for DatabasePlugin { ... }
impl BotPlugin for CustomPlugin { ... }

๐Ÿงช Testing

# Run all tests
make test

# Run specific test suite
cargo test --package universal-bot-core

# Run property tests
cargo test --features property-testing

# Run integration tests
cargo test --test integration

# Generate coverage report
make coverage

# Run linting and formatting
make lint
cargo fmt --check
cargo clippy -- -D warnings

๐Ÿš€ Example: Your First Universal Bot

use universal_bot::{BotCore, BedrockConfig, Message};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the universal brain
    let config = BedrockConfig::from_env()?;
    let bot = BotCore::new(config).await?;
    
    // Process a message (platform-agnostic)
    let input = Message::text("Hello, what can you do?");
    let response = bot.process(input).await?;
    
    println!("๐Ÿค– {}", response.content);
    
    // This same bot core could connect to:
    // - Discord (with adapter)
    // - Slack (with adapter)
    // - Web API (with adapter)
    // - Any platform (with adapter)
    
    Ok(())
}

๐ŸŽ“ Course Philosophy

Why 80/20?

  • 80% Universal: The AI logic, conversation management, and business logic remain constant
  • 20% Specific: Only the platform connection changes

Why Rust?

  • Memory Safety: No null pointer exceptions in production
  • Performance: Near C++ speed with high-level abstractions
  • Concurrency: True parallel processing with Tokio
  • Type Safety: Catch errors at compile time, not runtime

Why AWS Bedrock?

  • Multi-Model: Access to Claude, Llama, and more
  • Enterprise Ready: Built for production scale
  • Streaming: Real-time token generation
  • Managed: No model hosting headaches

๐Ÿค Community & Support

Get Help

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Office Hours

  • Tuesdays: 2 PM EST - Rust basics
  • Thursdays: 3 PM EST - AWS Bedrock deep dive
  • Fridays: 1 PM EST - Architecture review

๐Ÿ“ˆ Progress Tracking

Track your learning journey:

- [x] Module 1: Foundation
- [x] Module 2: Core Engine
- [ ] Module 3: Advanced AI
- [ ] Module 4: Plugins
- [ ] Module 5: Platform Theory
- [ ] Final Project: Custom Bot Brain

๐Ÿ† Certification Path

Complete all modules and build a custom bot brain to earn:

  • Certificate of Completion
  • Portfolio Project for GitHub
  • LinkedIn Badge for your profile
  • Community Recognition as a Universal Bot Architect

๐Ÿ“Š Success Metrics

What Success Looks Like

Week 1: "I can connect to AWS Bedrock from Rust"
Week 2: "I built a conversation engine"
Week 3: "My bot uses multiple AI models"
Week 4: "I created custom plugins"
Week 5: "I understand how to adapt this anywhere"
Final:  "I have a production-ready AI brain"

๐Ÿ”ฎ Beyond the Course

Where This Leads

  • Senior Positions: Architect-level thinking
  • Startup Ready: Build AI products quickly
  • Open Source: Contribute to major projects
  • Consulting: Help others modernize their bots

Next Steps After Completion

  1. Build a production bot for a real use case
  2. Create your own platform adapter
  3. Contribute plugins to the community
  4. Teach others the 80/20 approach

๐Ÿ“ License

This project is licensed under the MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • AWS Bedrock Team for the powerful AI platform
  • Rust Community for the amazing ecosystem
  • Tokio Project for async runtime excellence
  • You for choosing to think differently about bots

๐Ÿง  Stop Building Bots. Start Building Brains. ๐Ÿง 

The future isn't platform-specific. It's universally intelligent.

Start Course โ€ข Watch Videos โ€ข Join Community

Commit count: 0

cargo fmt