mixtape_server/lib.rs
1//! HTTP server and AG-UI protocol support for mixtape agents.
2//!
3//! This crate provides HTTP endpoints for running mixtape agents via web services,
4//! with optional support for the AG-UI protocol used by CopilotKit.
5//!
6//! # Features
7//!
8//! - `agui` - Enable AG-UI protocol support for CopilotKit integration
9//!
10//! # Example
11//!
12//! ```rust,no_run
13//! use mixtape_server::MixtapeRouter;
14//! use mixtape_core::Agent;
15//!
16//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
17//! // Create your agent (requires provider feature in mixtape-core)
18//! # let agent: Agent = todo!();
19//!
20//! // Build the router with AG-UI support
21//! let app = MixtapeRouter::new(agent)
22//! .with_agui("/api/copilotkit")
23//! .build()?;
24//!
25//! // Serve with axum
26//! let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
27//! axum::serve(listener, app).await?;
28//! # Ok(())
29//! # }
30//! ```
31
32pub mod error;
33pub mod router;
34pub(crate) mod state;
35
36#[cfg(feature = "agui")]
37pub(crate) mod agui;
38
39// Re-exports
40pub use error::{BuildError, ServerError, ServerResult};
41pub use router::MixtapeRouter;
42
43// AG-UI protocol types (for consumers who need to reference the event types)
44#[cfg(feature = "agui")]
45pub use agui::events::{
46 AguiEvent, GrantScope, InterruptData, InterruptResponse, InterruptType, MessageRole,
47};