runagent 0.1.0

RunAgent SDK for Rust - Deploy and manage AI agents easily
Documentation

Here is your full README.md file in proper markdown format, cleaned up and properly structured so you can copy and paste directly:

# RunAgent Rust SDK

[![Crates.io](https://img.shields.io/crates/v/runagent.svg)](https://crates.io/crates/runagent)
[![Documentation](https://docs.rs/runagent/badge.svg)](https://docs.rs/runagent)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://github.com/runagent-dev/runagent/workflows/CI/badge.svg)](https://github.com/runagent-dev/runagent/actions)

---

## ๐ŸŽฏ What is RunAgent?

RunAgent is a comprehensive Rust SDK for deploying and managing AI agents with support for multiple frameworks including **LangChain**, **LangGraph**, **LlamaIndex**, and more. Whether you're building chatbots, autonomous agents, or complex AI workflows, RunAgent provides the tools you need to deploy, test, and scale your AI applications.

---

## โœจ Features

- ๐Ÿค– **Multi-Framework Support**: LangChain, LangGraph, LlamaIndex, Letta, CrewAI, AutoGen
- ๐Ÿš€ **Local & Remote Deployment**: Deploy agents locally or to remote servers
- โšก **Real-time Streaming**: WebSocket-based streaming for real-time interactions
- ๐Ÿ’พ **Database Management**: SQLite-based agent metadata and history
- ๐Ÿ“‹ **Template System**: Pre-built templates for rapid setup
- ๐Ÿ›ก๏ธ **Type Safety**: Full Rust type safety with error handling
- ๐Ÿ”„ **Async/Await**: Powered by Tokio for async ops

---

## ๐Ÿ“ฆ Installation

```bash
cargo add runagent tokio

Or add manually to Cargo.toml:

[dependencies]
runagent = "0.1.0"
tokio = { version = "1.35", features = ["full"] }

๐Ÿƒ Quick Start

โœ… Basic Agent Interaction

use runagent::prelude::*;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    runagent::init_logging();
    let client = RunAgentClient::new("my-agent-id", "generic", true).await?;

    let response = client.run(&[
        ("message", json!("Hello, world!")),
        ("temperature", json!(0.7))
    ]).await?;

    println!("Response: {}", response);
    Ok(())
}

๐Ÿ” Streaming Agent Interaction

use runagent::prelude::*;
use futures::StreamExt;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RunAgentClient::new("my-agent-id", "generic_stream", true).await?;

    let mut stream = client.run_stream(&[
        ("message", json!("Tell me a story"))
    ]).await?;

    while let Some(chunk) = stream.next().await {
        match chunk {
            Ok(data) => println!("Chunk: {}", data),
            Err(e) => eprintln!("Stream error: {}", e),
        }
    }

    Ok(())
}

๐Ÿ”ง Configuration

โœ… Environment Variables

# API Configuration
export RUNAGENT_API_KEY="your-api-key"
export RUNAGENT_BASE_URL="https://api.runagent.ai"

# Local Configuration
export RUNAGENT_CACHE_DIR="~/.runagent"
export RUNAGENT_LOGGING_LEVEL="info"

โœ… Configuration Builder

use runagent::RunAgentConfig;

let config = RunAgentConfig::new()
    .with_api_key("your-api-key")
    .with_base_url("https://api.runagent.ai")
    .with_logging()
    .build();

๐ŸŽฏ Framework-Specific Examples

LangChain Integration

use runagent::prelude::*;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RunAgentClient::new("langchain-agent", "invoke", true).await?;

    let response = client.run(&[
        ("input", json!({
            "messages": [
                {"role": "user", "content": "What is the weather like?"}
            ]
        }))
    ]).await?;

    println!("LangChain response: {}", response);
    Ok(())
}

LangGraph Workflows

use runagent::prelude::*;
use serde_json::json;
use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RunAgentClient::new("langgraph-agent", "stream", true).await?;

    let mut stream = client.run_stream(&[
        ("input", json!({
            "messages": [{"role": "user", "content": "Analyze this data"}]
        }))
    ]).await?;

    while let Some(chunk) = stream.next().await {
        match chunk {
            Ok(data) => {
                if let Some(node) = data.get("node") {
                    println!("Executing node: {}", node);
                }
            }
            Err(e) => eprintln!("Error: {}", e),
        }
    }

    Ok(())
}

๐Ÿ—๏ธ Architecture

Core Components

  • Client: High-level client for agent interaction
  • Server: FastAPI-like local server for testing
  • Database: SQLite-based agent history store
  • Framework Executors: Executors for LangChain, LangGraph, etc.
  • Serialization: Safe messaging via WebSocket

Optional Features

Enable or disable features in Cargo.toml:

[dependencies]
runagent = { version = "0.1.0", features = ["db", "server"] }

Available:

  • db (default): Enable database support
  • server (default): Enable local server

๐Ÿ“š API Reference

RunAgentClient

  • new(agent_id, entrypoint_tag, local)
  • run(input_kwargs)
  • run_stream(input_kwargs)
  • health_check()

LocalServer

  • new(agent_id, agent_path, host, port)
  • from_path(agent_path, host, port)
  • start()
  • get_info()

DatabaseService

  • new(db_path)
  • add_agent(agent)
  • list_agents()
  • get_capacity_info()

๐Ÿ” Error Handling

use runagent::{RunAgentError, RunAgentResult};

fn handle_errors() -> RunAgentResult<()> {
    match some_operation() {
        Ok(result) => Ok(result),
        Err(RunAgentError::Authentication { message }) => {
            eprintln!("Auth error: {}", message);
            Err(RunAgentError::authentication("Invalid credentials"))
        }
        Err(RunAgentError::Connection { message }) => {
            eprintln!("Connection error: {}", message);
            if err.is_retryable() {
                retry_operation()
            } else {
                Err(err)
            }
        }
        Err(e) => Err(e),
    }
}

๐Ÿงช Testing

cargo test
cargo test --all-features
cargo test --test integration

๐Ÿ“– Examples

See examples/ folder for:

  • โœ… Basic usage
  • ๐Ÿ” Streaming
  • ๐Ÿ’พ Database
  • ๐ŸŒ Server setup
  • ๐ŸŽฏ Framework integrations

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/runagent-dev/runagent.git
cd runagent/runagent-rust
cargo build
cargo test

๐Ÿ“‹ Roadmap

  • Python interop via PyO3
  • Additional framework support
  • Enhanced streaming
  • Production deployment tools
  • Monitoring & observability
  • CLI tool integration

๐Ÿ”— Links


๐Ÿ“„ License

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


๐Ÿ™ Acknowledgments


Need help? Join our Discord or check the documentation!