1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! 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
//!
//! ```no_run
//! 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.
//!
//! ```no_run
//! 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.
//!
//! ```no_run
//! 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.
//!
//! ```no_run
//! 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.
pub
// Re-export commonly used types
pub use ;
pub use ;
pub use AppError;
pub use ;
pub use ;