#![forbid(unsafe_code)]
#![warn(missing_docs)]
pub use agent_mesh_protocol::{Caveats, CountBound, Scope};
mod context;
mod envelope;
mod error;
mod gate;
mod registry;
mod sandbox;
mod tool;
pub use context::ToolContext;
pub use envelope::{Denial, DenialKind, ToolEnvelope};
pub use error::{ToolError, ToolResult};
pub use gate::Gate;
pub use registry::{Registry, RegistryBuilder};
pub use sandbox::{best_available_sandbox, NoopSandbox, Sandbox, SandboxKind};
#[cfg(all(target_os = "linux", feature = "linux-landlock"))]
pub use sandbox::{landlock_is_supported, LandlockSandbox};
pub use tool::Tool;
#[cfg(test)]
mod tests {
use super::*;
struct T;
#[async_trait::async_trait]
impl Tool for T {
fn name(&self) -> &str {
"t"
}
fn schema(&self) -> serde_json::Value {
serde_json::json!({})
}
async fn invoke(
&self,
_args: serde_json::Value,
_cx: &ToolContext,
) -> ToolResult<serde_json::Value> {
Ok(serde_json::Value::Null)
}
}
#[test]
fn context_minted_only_by_gate_and_carries_meet() {
let granted = Caveats {
exec: Scope::only(["echo".to_string()]),
max_calls: CountBound::AtMost(3),
..Caveats::top()
};
let gate = Gate::new(0);
let cx = gate.authorize(&T, &granted).expect("authorize");
assert!(cx.caveats().leq(&granted));
assert_eq!(*cx.caveats(), granted);
}
fn _mint_token_is_unconstructible_doctests() {}
}