bamboo-agent 0.2.2

A fully self-contained AI agent backend framework with built-in web services, multi-LLM provider support, and comprehensive tool execution
Documentation
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# Bamboo Agent πŸŽ‹

[![Crates.io](https://img.shields.io/crates/v/bamboo-agent.svg)](https://crates.io/crates/bamboo-agent)
[![Documentation](https://docs.rs/bamboo-agent/badge.svg)](https://docs.rs/bamboo-agent)
[![License](https://img.shields.io/crates/l/bamboo-agent.svg)](https://crates.io/crates/bamboo-agent)
[![Build Status](https://github.com/bigduu/Bamboo-agent/workflows/CI/badge.svg)](https://github.com/bigduu/Bamboo-agent/actions/workflows/ci.yml)
[![Documentation](https://github.com/bigduu/Bamboo-agent/workflows/Documentation/badge.svg)](https://github.com/bigduu/Bamboo-agent/actions/workflows/docs.yml)
[![Test Coverage](https://img.shields.io/badge/tests-867%20passing-brightgreen)](https://github.com/bigduu/Bamboo-agent)

**πŸš€ A Complete, Self-Contained AI Agent Backend Framework Built with Rust** πŸ¦€

Bamboo is a **production-ready**, **high-performance** AI agent framework that runs **entirely locally** with zero external dependencies. Built from the ground up in **Rust** for maximum efficiency and safety, it provides everything you need to build, deploy, and scale AI-powered applications.

## 🎯 Why Bamboo?

- ⚑ **Blazingly Fast** - Native Rust performance with zero-cost abstractions
- πŸ”’ **Privacy-First** - Runs 100% locally, your data never leaves your machine
- 🎯 **All-in-One** - Complete agent system with built-in HTTP server, no microservices needed
- πŸ¦€ **Rust-Native** - Leverages Rust's safety guarantees and async ecosystem
- πŸ“¦ **Zero Config** - Works out of the box with sensible defaults
- 🏭 **Production-Ready** - Battle-tested with 867+ tests, CORS, rate limiting, security headers

πŸ“– **[Full Documentation]docs/README.md** | πŸš€ **[Getting Started]#quick-start** | πŸ“š **[API Docs]https://docs.rs/bamboo-agent**

## ✨ Key Features

### πŸ€– Complete Agent System
- **Tool Execution** πŸ”§ - Execute shell commands, read/write files, search code
- **Skill Management** 🎯 - Create and manage reusable prompt templates
- **Workflow Engine** πŸ”„ - Automate complex tasks with YAML-defined workflows
- **Todo Tracking** βœ… - Built-in task management and progress tracking
- **External Memory** 🧠 - Automatic conversation summarization for long sessions

### 🌐 Built-in HTTP Server
- **Actix-web Powered** ⚑ - High-performance async HTTP server
- **REST API** πŸ”Œ - Complete RESTful API for all operations
- **Streaming Support** πŸ“‘ - Real-time event streaming via Server-Sent Events
- **CORS & Security** πŸ” - Production-ready security headers and CORS configuration
- **Rate Limiting** πŸ›‘οΈ - Built-in protection against abuse

### 🧠 Multi-LLM Provider Support
- **OpenAI** πŸ’¬ - Full support for GPT-4, GPT-3.5, and custom models
- **Anthropic** 🎭 - Claude 3.5 Sonnet, Claude 3 Opus, and more
- **Google Gemini** ✨ - Gemini 2.0 Flash and Pro models
- **GitHub Copilot** πŸ‘¨β€πŸ’» - OAuth device flow authentication with token caching

### ⚑ Performance & Efficiency
- **Native Rust** πŸ¦€ - Zero-cost abstractions, no GC pauses
- **Async/Await** πŸš€ - Tokio-based async runtime for maximum concurrency
- **Connection Pooling** πŸ”— - Efficient HTTP connection reuse
- **Streaming** πŸ“Š - Stream large responses without buffering
- **Memory Efficient** πŸ’Ύ - Minimal allocations, efficient data structures

### πŸ—οΈ Architecture
- **Modular Design** 🧩 - Clean separation of concerns
- **Dual Mode** 🎭 - Use as standalone binary or embedded library
- **XDG-Compliant** πŸ“ - Standard Linux directory layout
- **Hot Reload** πŸ”„ - Reload configuration without restart
- **Plugin System** πŸ”Œ - MCP (Model Context Protocol) for external tools

### πŸ§ͺ Quality & Testing
- **867 Tests** βœ… - Comprehensive test coverage with 100% pass rate
- **Unit Tests** πŸ§ͺ - Every module thoroughly tested
- **Integration Tests** πŸ”— - End-to-end API testing
- **Documentation Tests** πŸ“š - Code examples verified in docs

### πŸ”’ Security & Privacy
- **Local-First** 🏠 - Everything runs on your machine
- **No Cloud Dependencies** ☁️ - Works offline, no API keys stored externally
- **Encrypted Storage** πŸ” - Sensitive data encrypted at rest
- **Keyword Masking** 🎭 - Automatically mask sensitive information

## πŸš€ Installation & Quick Start

### πŸ“¦ Installation

#### Option 1: Install from crates.io (Recommended)

```bash
cargo install bamboo-agent
```

#### Option 2: Build from source

```bash
# Clone the repository
git clone https://github.com/bigduu/Bamboo-agent.git
cd Bamboo-agent

# Build in release mode for best performance
cargo build --release

# Install locally
cargo install --path .
```

### 🎯 Quick Start Guide

#### πŸ–₯️ Binary Mode (Standalone Server)

```bash
# Start server with default settings on port 8080
bamboo serve

# Custom configuration
bamboo serve --port 9000 --bind 0.0.0.0 --data-dir /var/lib/bamboo

# With specific config file
bamboo serve --config /path/to/config.toml

# Enable debug logging
RUST_LOG=debug bamboo serve
```

#### πŸ“¦ Library Mode (Embedded in Your App)

```rust
use bamboo_agent::{BambooBuilder, BambooConfig};

#[tokio::main]
async fn main() {
    // Build your custom server with fluent API
    let server = BambooBuilder::new()
        .port(3000)
        .bind("0.0.0.0")
        .data_dir(std::path::PathBuf::from("/var/lib/myapp"))
        .build()
        .unwrap();

    // Start the server (blocking)
    server.start().await.unwrap();
}
```

## βš™οΈ Configuration

Bamboo follows the [XDG Base Directory specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) for clean, standards-compliant configuration management.

### πŸ“ Default Paths

- **Config**: `$XDG_CONFIG_HOME/bamboo/config.json` (default: `~/.config/bamboo/`)
- **Data**: `$XDG_DATA_HOME/bamboo/` (default: `~/.local/share/bamboo/`)
- **Cache**: `$XDG_CACHE_HOME/bamboo/` (default: `~/.cache/bamboo/`)
- **Runtime**: `$XDG_RUNTIME_DIR/bamboo/` (default: `/tmp/bamboo-$UID/`)

### πŸ“ Configuration File

Edit `~/.config/bamboo/config.json` (JSON format):

```json
{
  "http_proxy": "",
  "https_proxy": "",
  "provider": "anthropic",
  "providers": {
    "anthropic": {
      "api_key": "sk-ant-...",
      "model": "claude-3-5-sonnet-20241022",
      "max_tokens": 4096
    },
    "openai": {
      "api_key": "sk-...",
      "model": "gpt-4"
    }
  }
}
```

> **πŸ’‘ Tip**: Bamboo automatically migrates legacy `config.toml` files to the new JSON format.

### πŸ”§ Environment Variables

Override configuration with environment variables (higher priority than config file):

| Variable | Description | Example |
|----------|-------------|---------|
| `BAMBOO_PORT` | Server port | `9000` |
| `BAMBOO_BIND` | Bind address | `0.0.0.0` |
| `BAMBOO_DATA_DIR` | Data directory | `/var/lib/bamboo` |
| `BAMBOO_PROVIDER` | Default LLM provider | `anthropic` |
| `RUST_LOG` | Log level | `debug`, `info`, `warn` |

## Migration Guide

### Migrating from v0.1.x to v0.2.0

Version 0.2.0 consolidates `web_service` and `agent::server` into a unified `server` module. If you were using the library API:

#### Before v0.2.0
```rust
use bamboo_agent::agent::server::state::AppState;
use bamboo_agent::agent::server::handlers;
use bamboo_agent::web_service::WebService;
use bamboo_agent::web_service::controllers::*;
```

#### After v0.2.0
```rust
use bamboo_agent::server::AppState;
use bamboo_agent::server::handlers;
use bamboo_agent::server::WebService;
use bamboo_agent::server::controllers::*;
```

All other code works without changes. The old import paths still work but will show deprecation warnings.

### What Changed

**Consolidated Modules:**
- `agent::server::handlers` β†’ `server::handlers`
- `agent::server::state` β†’ `server::app_state`
- `agent::server::workflow` β†’ `server::workflow`
- `web_service::controllers` β†’ `server::controllers`
- `web_service::services` β†’ `server::services`

**Unified State Management:**
- Single `AppState` with direct provider access (no more proxy pattern)
- Consolidated route definitions (eliminated 24 duplicate routes)
- Unified metrics infrastructure

**Breaking Changes:**
- None (all old import paths still work with deprecation warnings)

### Benefits

- βœ… **No route duplication**: Single source of truth for 100+ routes
- βœ… **Direct provider access**: No HTTP callbacks to self
- βœ… **Clearer architecture**: One server module instead of two
- βœ… **Better performance**: Eliminated proxy pattern

## πŸ”Œ API Endpoints

Once running, Bamboo exposes a comprehensive REST API:

### πŸ₯ Health & Status

```bash
# Check server health
GET /api/v1/health
```

### πŸ’¬ Chat Completions

```bash
# OpenAI-compatible chat endpoint
POST /api/v1/chat/completions
Content-Type: application/json

{
  "model": "claude-3-5-sonnet-20241022",
  "messages": [
    {"role": "user", "content": "Hello, world!"}
  ],
  "stream": true
}
```

### πŸ€– Agent Execution

```bash
# Execute agent with tools
POST /api/v1/agent/run
Content-Type: application/json

{
  "session_id": "my-session",
  "message": "Read the README.md file and summarize it"
}
```

### πŸ”„ Workflows

```bash
# List all workflows
GET /api/v1/workflows

# Create new workflow
POST /api/v1/workflows
Content-Type: application/json

{
  "name": "my-workflow",
  "description": "Automated task",
  "composition": {
    "type": "sequence",
    "steps": [...]
  }
}

# Delete workflow
DELETE /api/v1/workflows/{name}
```

### πŸ“š Sessions

```bash
# List all sessions
GET /api/v1/sessions

# Create new session
POST /api/v1/sessions
Content-Type: application/json

{
  "model": "claude-3-5-sonnet-20241022"
}
```

### πŸ“Š Metrics & Monitoring

```bash
# Get usage metrics
GET /api/v1/metrics/summary

# Get session details
GET /api/v1/metrics/sessions/{session_id}
```

> πŸ“– **Full API Documentation**: See [API.md]docs/API.md for complete endpoint reference

## πŸ› οΈ Development

### πŸ”¨ Build & Run

```bash
# Development build (fast compile, slower runtime)
cargo build

# Release build (slower compile, fastest runtime)
cargo build --release

# Run with auto-reload on code changes
cargo watch -x run -- serve

# Run tests
cargo test

# Run tests with coverage
cargo tarpaulin

# Check code formatting
cargo fmt --check

# Fix code formatting
cargo fmt

# Run linter
cargo clippy
```

### πŸ› Debugging

```bash
# Enable debug logging
RUST_LOG=debug cargo run -- serve

# Enable trace logging (very verbose)
RUST_LOG=trace cargo run -- serve

# Run specific test
cargo test test_agent_loop

# Run tests with output
cargo test -- --nocapture
```

## πŸ—οΈ Architecture

Bamboo is built with a clean, modular architecture optimized for performance and maintainability:

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Bamboo Agent πŸŽ‹                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚   🌐 HTTP    β”‚  β”‚  πŸ€– Agent    β”‚  β”‚  🧠 LLM      β”‚     β”‚
β”‚  β”‚   Server     β”‚  β”‚   Loop       β”‚  β”‚  Providers   β”‚     β”‚
β”‚  β”‚              β”‚  β”‚              β”‚  β”‚              β”‚     β”‚
β”‚  β”‚  - Actix-web β”‚  β”‚  - Tools     β”‚  β”‚  - OpenAI    β”‚     β”‚
β”‚  β”‚  - REST API  β”‚  β”‚  - Skills    β”‚  β”‚  - Anthropic β”‚     β”‚
β”‚  β”‚  - SSE       β”‚  β”‚  - Workflow  β”‚  β”‚  - Gemini    β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  - Copilot   β”‚     β”‚
β”‚                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  πŸ“Š Metrics  β”‚  β”‚  πŸ’Ύ Storage  β”‚  β”‚  πŸ”Œ MCP      β”‚     β”‚
β”‚  β”‚              β”‚  β”‚              β”‚  β”‚  Protocol    β”‚     β”‚
β”‚  β”‚  - SQLite    β”‚  β”‚  - JSONL     β”‚  β”‚              β”‚     β”‚
β”‚  β”‚  - Events    β”‚  β”‚  - Sessions  β”‚  β”‚  - Tools     β”‚     β”‚
β”‚  β”‚  - Analytics β”‚  β”‚  - History   β”‚  β”‚  - Servers   β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Core Modules

| Module | Description | Key Features |
|--------|-------------|--------------|
| **`config`** πŸ“ | Configuration management | XDG-compliant, hot-reload, multi-format |
| **`core`** 🎯 | Core types and utilities | Encryption, paths, todo tracking |
| **`agent`** πŸ€– | Agent system | Loop execution, tools, skills, LLM providers |
| **`server`** 🌐 | HTTP server & controllers | REST API, streaming, handlers |
| **`process`** βš™οΈ | Process management | Lifecycle tracking, output buffering |
| **`claude`** 🎭 | Claude Code integration | Binary discovery, version management |
| **`commands`** πŸ“‹ | Command system | Workflows, slash commands, keyword masking |

### Design Principles

- **πŸ¦€ Zero-Cost Abstractions** - Rust's performance guarantees
- **⚑ Async-First** - Tokio-based async runtime
- **πŸ”’ Memory Safe** - No data races or buffer overflows
- **πŸ“¦ Self-Contained** - No external runtime dependencies
- **🎯 Single Responsibility** - Each module has a clear purpose

## πŸ“š Documentation

| Resource | Description |
|----------|-------------|
| πŸ“– **[Full Documentation]docs/README.md** | Comprehensive guides and tutorials |
| πŸ“š **[API Documentation]https://docs.rs/bamboo-agent** | Auto-generated API docs (docs.rs) |
| πŸ”„ **[Migration Guide]MIGRATION_GUIDE.md** | Upgrading from v0.1.x to v0.2.x |
| 🀝 **[Contributing]CONTRIBUTING.md** | How to contribute to Bamboo |
| πŸ“ **[Changelog]CHANGELOG.md** | Version history and release notes |
| πŸ”’ **[Security Policy]SECURITY.md** | Security information and reporting |

## πŸ“ˆ Performance

Bamboo is designed for maximum performance:

- **⚑ Startup Time**: < 100ms to fully operational
- **πŸ’Ύ Memory Usage**: ~10-30MB base, scales with workload
- **πŸ”„ Concurrent Requests**: 1000+ concurrent connections
- **πŸ“Š Throughput**: 10,000+ requests/second (depends on workload)
- **πŸš€ Latency**: < 10ms for local operations

## πŸ—ΊοΈ Roadmap

### Current Version (v0.2.x) βœ…
- [x] Complete agent system
- [x] Multi-LLM provider support
- [x] Workflow automation
- [x] MCP (Model Context Protocol) integration
- [x] Comprehensive metrics & monitoring

### Upcoming Features (v0.3.x) 🚧
- [ ] Webhook support for external integrations
- [ ] Plugin system for custom tool extensions
- [ ] gRPC API for high-performance clients
- [ ] WebSocket support for bidirectional streaming
- [ ] Built-in web UI dashboard

### Future Plans (v1.0+) 🌟
- [ ] Kubernetes deployment guides & Helm charts
- [ ] Distributed agent execution
- [ ] Advanced workflow visualizer
- [ ] Multi-tenant support
- [ ] Cloud deployment templates

---

## πŸ“„ License

This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.

## 🀝 Contributing

We love contributions! Whether you're fixing bugs, improving documentation, or proposing new features, your help is welcome.

**Getting Started:**
1. Read our [Contributing Guidelines]CONTRIBUTING.md
2. Check out [Good First Issues]https://github.com/bigduu/Bamboo-agent/issues?q=is%3Aopen+is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
3. Fork the repo and create a feature branch
4. Submit a Pull Request

**Code of Conduct:** Be respectful, inclusive, and constructive. We're all here to build something great together!

## πŸ’¬ Support & Community

### πŸ› Bug Reports
Found a bug? [Open an issue](https://github.com/bigduu/Bamboo-agent/issues/new?template=bug_report.md)

### πŸ’‘ Feature Requests
Have an idea? [Start a discussion](https://github.com/bigduu/Bamboo-agent/discussions/new?category=ideas)

### πŸ”’ Security Issues
Found a security vulnerability? Please see [SECURITY.md](SECURITY.md) for responsible disclosure.

### πŸ’¬ Get Help
- **GitHub Discussions**: Ask questions and share knowledge
- **Documentation**: Check the [full docs]docs/README.md first
- **Issues**: Search existing issues or create a new one

## 🌟 Star History

If you find Bamboo useful, please consider giving it a ⭐ star on GitHub! It helps the project grow and lets others discover it.

[![Star History Chart](https://api.star-history.com/svg?repos=bigduu/Bamboo-agent&type=Date)](https://star-history.com/#bigduu/Bamboo-agent&Date)

---

<p align="center">
  <strong>Made with ❀️ by the Bamboo Contributors</strong>
</p>

<p align="center">
  <sub>Built with πŸ¦€ Rust β€’ Powered by β˜• Coffee and πŸŽ‹ Bamboo</sub>
</p>