#![warn(missing_docs)]
#[cfg(feature = "ast-validator")]
pub mod ast_validator;
pub mod audit;
pub mod error;
pub mod executor;
pub mod groups;
pub mod host;
pub mod ipc;
#[cfg(feature = "metrics")]
pub mod metrics;
pub mod ops;
pub mod pool;
pub mod redact;
pub mod stash;
pub mod validator;
pub use error::SandboxError;
pub use executor::{ExecutionMode, SandboxConfig, SandboxExecutor};
#[async_trait::async_trait]
pub trait ToolDispatcher: Send + Sync {
async fn call_tool(
&self,
server: &str,
tool: &str,
args: serde_json::Value,
) -> Result<serde_json::Value, forge_error::DispatchError>;
}
#[async_trait::async_trait]
pub trait ResourceDispatcher: Send + Sync {
async fn read_resource(
&self,
server: &str,
uri: &str,
) -> Result<serde_json::Value, forge_error::DispatchError>;
}
#[async_trait::async_trait]
pub trait StashDispatcher: Send + Sync {
async fn put(
&self,
key: &str,
value: serde_json::Value,
ttl_secs: Option<u32>,
current_group: Option<String>,
) -> Result<serde_json::Value, forge_error::DispatchError>;
async fn get(
&self,
key: &str,
current_group: Option<String>,
) -> Result<serde_json::Value, forge_error::DispatchError>;
async fn delete(
&self,
key: &str,
current_group: Option<String>,
) -> Result<serde_json::Value, forge_error::DispatchError>;
async fn keys(
&self,
current_group: Option<String>,
) -> Result<serde_json::Value, forge_error::DispatchError>;
}
#[cfg(test)]
mod feature_tests {
#[test]
#[cfg(feature = "ast-validator")]
fn ff_01_default_features_include_ast_validator() {
let result = crate::ast_validator::validate_ast("async () => { return 1; }");
assert!(result.is_ok());
}
#[test]
#[cfg(feature = "worker-pool")]
fn ff_02_worker_pool_is_default() {
let _ = std::any::type_name::<crate::pool::WorkerPool>();
let _ = std::any::type_name::<crate::pool::PoolConfig>();
}
#[test]
#[cfg(feature = "metrics")]
fn ff_03_metrics_is_default() {
let _ = std::any::type_name::<crate::metrics::ForgeMetrics>();
}
#[test]
fn ff_04_core_modules_always_available() {
let _ = std::any::type_name::<crate::SandboxError>();
let _ = std::any::type_name::<crate::SandboxConfig>();
let _ = std::any::type_name::<crate::ExecutionMode>();
}
#[test]
#[cfg(not(feature = "worker-pool"))]
fn ff_05_minimal_disables_pool() {
}
#[test]
#[cfg(not(feature = "metrics"))]
fn ff_06_minimal_disables_metrics() {
}
}