#![allow(dead_code)]
use super::sandbox::{SandboxLevel, SandboxPermissions};
#[derive(Debug, Clone, Default)]
pub struct ToolContext {
pub allowed_paths: Vec<String>,
pub timeout_ms: u64,
pub working_dir: String,
pub sandbox: SandboxPermissions,
}
impl ToolContext {
#[must_use]
pub fn new(working_dir: String) -> Self {
Self {
working_dir: working_dir.clone(),
sandbox: SandboxPermissions::default().with_workspace(working_dir),
..Default::default()
}
}
#[must_use]
pub fn with_sandbox_level(mut self, level: SandboxLevel) -> Self {
self.sandbox.level = level;
self
}
#[must_use]
pub const fn with_timeout(mut self, timeout_ms: u64) -> Self {
self.timeout_ms = timeout_ms;
self
}
#[must_use]
pub fn with_allowed_paths(mut self, paths: Vec<String>) -> Self {
self.allowed_paths = paths;
self
}
#[must_use]
pub fn is_write_allowed(&self, path: &str) -> bool {
self.sandbox.is_write_allowed(path)
}
}