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§
- Agent
Runner - Runner that manages agent execution for a session.
Enums§
- Agent
Status - Status of an agent execution runner.