Skip to main content

bamboo_agent/
lib.rs

1//! Bamboo - A fully self-contained AI agent backend framework
2//!
3//! Bamboo provides a complete backend system for AI agents, including:
4//! - Built-in HTTP/HTTPS server (Actix-web)
5//! - Agent execution loop with tool support
6//! - LLM provider integrations (OpenAI, Anthropic, Google Gemini, GitHub Copilot)
7//! - Session management and persistence
8//! - Workflow and slash command systems
9//! - Process management for external tools
10//! - Claude Code integration
11//!
12//! # Features
13//!
14//! - **Dual mode**: Binary (standalone server) or library (embedded)
15//! - **XDG-compliant**: Follows XDG Base Directory specification
16//! - **Production-ready**: Built-in CORS, rate limiting, security headers
17//!
18//! # Quick Start
19//!
20//! ## Binary Mode
21//!
22//! ```bash
23//! bamboo serve --port 8080 --data-dir ~/.local/share/bamboo
24//! ```
25//!
26//! ## Library Mode
27//!
28//! ```rust,ignore
29//! use bamboo::{BambooServer, BambooConfig};
30//!
31//! #[tokio::main]
32//! async fn main() {
33//!     let config = BambooConfig::default();
34//!     let server = BambooServer::new(config);
35//!     // server.start().await.unwrap(); // Not yet implemented
36//! }
37//! ```
38
39use std::path::PathBuf;
40
41pub mod config;
42pub mod error;
43
44// Placeholder modules (will be populated during migration)
45pub mod agent;
46pub mod claude;
47pub mod commands;
48pub mod core;
49pub mod process;
50pub mod server;
51pub mod web_service;
52
53pub use config::{BambooConfig, ServerConfig};
54pub use error::{BambooError, Result};
55pub use process::ProcessRegistry;
56
57/// Main Bamboo server instance
58pub struct BambooServer {
59    config: BambooConfig,
60}
61
62impl BambooServer {
63    /// Create a new Bamboo server with configuration
64    pub fn new(config: BambooConfig) -> Self {
65        Self { config }
66    }
67
68    /// Start the HTTP server (blocking)
69    pub async fn start(self) -> Result<()> {
70        // TODO: Implement server startup
71        todo!("Server startup not yet implemented")
72    }
73
74    /// Get the server address
75    pub fn server_addr(&self) -> String {
76        self.config.server_addr()
77    }
78}
79
80/// Builder pattern for creating BambooServer
81pub struct BambooBuilder {
82    config: BambooConfig,
83}
84
85impl BambooBuilder {
86    pub fn new() -> Self {
87        Self {
88            config: BambooConfig::default(),
89        }
90    }
91
92    pub fn port(mut self, port: u16) -> Self {
93        self.config.server.port = port;
94        self
95    }
96
97    pub fn bind(mut self, addr: &str) -> Self {
98        self.config.server.bind = addr.to_string();
99        self
100    }
101
102    pub fn data_dir(mut self, dir: PathBuf) -> Self {
103        self.config.data_dir = dir;
104        self
105    }
106
107    pub fn build(self) -> Result<BambooServer> {
108        Ok(BambooServer::new(self.config))
109    }
110}
111
112impl Default for BambooBuilder {
113    fn default() -> Self {
114        Self::new()
115    }
116}