Skip to main content

Crate bamboo_server

Crate bamboo_server 

Source
Expand description

Unified HTTP server consolidating web_service and agent/server

This module provides a single, consolidated server implementation that:

  • Eliminates the proxy pattern from web_service
  • Provides direct provider access without HTTP callbacks
  • Unifies state management across all endpoints
  • Supports all API routes (agent, OpenAI, Anthropic, Gemini)

§Architecture

The server is organized into several key components:

  • app_state: Unified state management with direct provider access
  • config: CORS and security header configuration
  • metrics: Unified metrics infrastructure
  • handlers: Agent API handlers (chat, execute, events, etc.)
  • controllers: Multi-provider API controllers (OpenAI, Anthropic, Gemini)
  • services: Business logic services
  • routes: Route configuration for all API endpoints
  • server: Entry points for running the server

§Quick Start

use std::path::PathBuf;
use bamboo_server::run;

#[tokio::main]
async fn main() -> Result<(), String> {
    let app_data_dir = PathBuf::from("/path/to/bamboo-data-dir");
    run(app_data_dir, 3456).await
}

§Server Modes

The server supports three modes:

§1. Desktop Mode (Default)

Binds to localhost only, No rate limiting. Perfect for local development.

use std::path::PathBuf;
use bamboo_server::run;

#[tokio::main]
async fn main() -> Result<(), String> {
    let data_dir = PathBuf::from("./.bamboo");
    run(data_dir, 9562).await
}

§2. Docker Mode

Custom bind address with rate limiting. For containerized deployments.

use std::path::PathBuf;
use bamboo_server::run_with_bind;

#[tokio::main]
async fn main() -> Result<(), String> {
    let data_dir = PathBuf::from("./.bamboo");
    run_with_bind(data_dir, 9562, "0.0.0.0").await
}

§3. Production Mode with Frontend

Serves static files alongside API. Full production setup.

use std::path::PathBuf;
use bamboo_server::run_with_bind_and_static;

#[tokio::main]
async fn main() -> Result<(), String> {
    let data_dir = PathBuf::from("./.bamboo");
    run_with_bind_and_static(
        data_dir,
        9562,
        "0.0.0.0",
        Some(PathBuf::from("./dist")),
    )
    .await
}

§Route Organization

§Agent Routes (/api/v1/*)

Core agent functionality: chat, execute, events, metrics, MCP.

§OpenAI Routes (/v1/*)

OpenAI-compatible API for tool integration.

§Anthropic Routes (/anthropic/v1/*)

Anthropic Claude API compatible endpoints.

§Gemini Routes (/gemini/v1beta/*)

Google Gemini API compatible endpoints.

Re-exports§

pub use app_state::AppState;
pub use config::build_cors;
pub use config::build_security_headers;
pub use error::AppError;
pub use routes::agent_routes;
pub use routes::anthropic_routes;
pub use routes::bamboo_v1_routes;
pub use routes::configure_routes;
pub use routes::configure_routes_with_rate_limiting;
pub use routes::gemini_routes;
pub use routes::openai_prefixed_routes;
pub use server::run;
pub use server::run_with_bind;
pub use server::run_with_bind_and_static;
pub use server::WebService;

Modules§

app_state
Unified application state management for the Bamboo server
claude_runner
Claude Code binary discovery and management
config
Server configuration utilities
config_manager
Configuration patching helpers.
error
Server error types and HTTP response handling
handlers
HTTP API handlers for the Bamboo agent server.
logging
message_hooks
Message preflight hooks.
metrics_service
model_config_helper
prompt_defaults
Global prompt template defaults used by new sessions.
reloadable_provider
request_hooks
Request preflight hooks.
routes
Unified route configuration for all API endpoints
schedule_app
Schedule management application logic.
schedules
Schedule system (timed tasks that create/run sessions).
server
Unified HTTP server entry points
server_tools
Server-side tool implementations.
services
Business services for the Bamboo server
session_app
Session management application logic.
spawn_scheduler
Sub-session spawn scheduler — re-exported from bamboo-application-runtime.
tools
Server-only tools and tool executors.
workflow
Workflow system for defining and executing agent workflows

Structs§

AgentRunner
Runner that manages agent execution for a session.

Enums§

AgentStatus
Status of an agent execution runner.