use supercode_harness::tools::{BashTool, SandboxPolicy, Tool, ToolContext};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let dir = std::env::temp_dir().join(format!("sc-cookbook-sandbox-{}", std::process::id()));
std::fs::create_dir_all(&dir)?;
let bash = BashTool::default();
for policy in [
SandboxPolicy::ReadOnly,
SandboxPolicy::WorkspaceWrite,
SandboxPolicy::DangerFullAccess,
] {
let mut ctx = ToolContext::new(dir.clone());
ctx.sandbox = policy;
let marker = dir.join("written.txt");
let _ = std::fs::remove_file(&marker);
bash.execute(
serde_json::json!({ "command": "echo hi > written.txt" }),
&ctx,
)
.await?;
let landed = marker.exists();
println!(
"{:<18} write inside cwd → {}",
format!("{policy:?}"),
if landed { "ALLOWED" } else { "blocked" }
);
}
std::fs::remove_dir_all(&dir).ok();
println!("\nOn macOS the block is enforced by the OS (seatbelt), not just the file tool.");
Ok(())
}