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
//! # pforge-runtime
//!
//! Core runtime library for pforge - a zero-boilerplate MCP server framework.
//!
//! This crate provides the execution engine for MCP servers defined via YAML configuration,
//! including handler registration, dispatch, middleware, state management, and fault tolerance.
//!
//! ## Quick Start
//!
//! ```rust
//! use pforge_runtime::{Handler, HandlerRegistry, Result};
//! use serde::{Deserialize, Serialize};
//! use schemars::JsonSchema;
//!
//! // Define input/output types
//! #[derive(Debug, Deserialize, JsonSchema)]
//! struct GreetInput {
//! name: String,
//! }
//!
//! #[derive(Debug, Serialize, JsonSchema)]
//! struct GreetOutput {
//! message: String,
//! }
//!
//! // Implement handler
//! struct GreetHandler;
//!
//! #[async_trait::async_trait]
//! impl Handler for GreetHandler {
//! type Input = GreetInput;
//! type Output = GreetOutput;
//! type Error = pforge_runtime::Error;
//!
//! async fn handle(&self, input: Self::Input) -> Result<Self::Output> {
//! Ok(GreetOutput {
//! message: format!("Hello, {}!", input.name),
//! })
//! }
//! }
//!
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! // Register and dispatch
//! let mut registry = HandlerRegistry::new();
//! registry.register("greet", GreetHandler);
//!
//! let input = serde_json::json!({"name": "World"});
//! let input_bytes = serde_json::to_vec(&input)?;
//! let output_bytes = registry.dispatch("greet", &input_bytes).await?;
//! let output: serde_json::Value = serde_json::from_slice(&output_bytes)?;
//!
//! assert_eq!(output["message"], "Hello, World!");
//! # Ok(())
//! # }
//! ```
//!
//! ## Features
//!
//! - **Zero-overhead dispatch**: O(1) average-case handler lookup with FxHash
//! - **Type safety**: Full compile-time type checking with Serde + JsonSchema
//! - **Async-first**: Built on tokio for high-performance async execution
//! - **Fault tolerance**: Circuit breaker, retry with exponential backoff, timeouts
//! - **State management**: In-memory backend (trueno-db KV persistence coming in Phase 6)
//! - **Middleware**: Composable request/response processing chain
//! - **MCP protocol**: Full support for resources, prompts, and tools
pub use ;
pub use Handler;
pub use ;
pub use ;
pub use ;
pub use ;
pub use HandlerRegistry;
pub use ;
pub use McpServer;
pub use ;
// trueno-db KV persistence (Phase 6)
pub use TruenoKvStateManager;
pub use ;
pub use ;