agent_proxy_rust_core/lib.rs
1//! `agent-proxy-rust-core` — middleware trait, axum server engine, and upstream forwarding.
2//!
3//! This crate provides the foundation for the `agent-proxy-rust` project.
4//! It defines the [`ProxyMiddleware`] trait (the central extension point),
5//! core domain types, error handling, configuration, an authentication layer,
6//! and the axum-based HTTP proxy engine.
7//!
8//! # Architecture
9//!
10//! ```text
11//! Client → Auth Layer → Router → handle_proxy_request
12//! ├── on_request chain (registration order)
13//! ├── forward to upstream
14//! └── on_response chain (reverse order)
15//! ```
16//!
17//! Middleware crates (`compress`, `bridge`, `model-router`, `cost`)
18//! implement [`ProxyMiddleware`] and are composed via the builder.
19
20#![forbid(unsafe_code)]
21#![warn(missing_docs, missing_debug_implementations)]
22
23pub mod auth;
24pub mod compression;
25pub mod config;
26pub mod error;
27pub mod extensions;
28pub mod middleware;
29pub mod report;
30pub mod server;
31pub mod testing;
32pub mod types;
33
34// Re-export key types for convenience
35pub use compression::{CompressionStats, read_tokenless_stats};
36pub use config::ProxyConfig;
37pub use error::ProxyError;
38pub use middleware::CostRecorder;
39pub use middleware::ProxyMiddleware;
40pub use server::{AgentProxy, AgentProxyBuilder};
41pub use types::{
42 AgentType, ApiFormat, ChannelConfig, ConnectionContext, ProxyRequest, ProxyResponse,
43 detect_api_format,
44};