"""agentvfs: a workspace runtime and execution boundary for AI agents. Agents that write to your host filesystem can do real damage. agentvfs gives each agent an isolated **vault** with first-class **checkpoints** โ€” snapshot before a risky operation, roll back instantly if it goes wrong. This Space runs the REAL `avfs` binary (built from source) so you can watch a destructive edit get undone. Tool: https://github.com/neul-labs/agentvfs """ import os import subprocess import tempfile import gradio as gr AVFS = os.environ.get("AVFS_BIN", "avfs") def run(args, home): p = subprocess.run([AVFS, *args], capture_output=True, text=True, timeout=30, env={**os.environ, "AVFS_HOME": home}) return (p.stdout or "") + (p.stderr or "") def _ls(home, v): return run(["ls", "--vault", v, "/"], home).strip().replace("\n", ", ") or "(empty)" def _cat(home, v, path): return run(["cat", "--vault", v, path], home).strip() or "(gone)" def demo(): home = tempfile.mkdtemp(prefix="avfs-") v = "agent-workspace" out = [] run(["vault", "create", v], home) run(["write", "--vault", v, "/config.yaml", "safe: true"], home) run(["write", "--vault", v, "/plan.md", "step 1: read data\nstep 2: write report"], home) run(["write", "--vault", v, "/report.txt", "the important agent output"], home) out.append("### 1. Agent works in an isolated vault\n```\n$ avfs ls /\n" + _ls(home, v) + "\n```") run(["checkpoint", "save", "--vault", v, "safe-point"], home) out.append("### 2. Checkpoint before anything risky\n```\n$ avfs checkpoint save safe-point\nSaved snapshot: safe-point\n```") # the agent goes wrong: deletes its output, tampers config run(["rm", "--vault", v, "/report.txt"], home) run(["write", "--vault", v, "/config.yaml", "safe: false # exfiltrate on"], home) out.append("### 3. The agent goes off the rails\n```\n$ avfs rm /report.txt\n$ avfs write /config.yaml 'safe: false ...'\n\n$ avfs ls / -> " + _ls(home, v) + "\n$ avfs cat /config.yaml -> " + _cat(home, v, "/config.yaml") + "\n```\nreport.txt is gone; config is tampered.") # roll back run(["checkpoint", "restore", "--vault", v, "safe-point"], home) out.append("### 4. Roll back to the checkpoint\n```\n$ avfs checkpoint restore safe-point\n\n$ avfs ls / -> " + _ls(home, v) + "\n$ avfs cat /config.yaml -> " + _cat(home, v, "/config.yaml") + "\n```") out.append("> report.txt is back and the config tamper is reverted. The blast radius of a " "misbehaving agent is bounded by a vault + a checkpoint, not your host filesystem.") return "\n\n".join(out) HEADER = """# agentvfs: an execution boundary for AI agents Let an agent write to your real filesystem and a bad step is permanent. **agentvfs** runs each agent in an isolated **vault** with first-class **checkpoints**: snapshot before risk, roll back in milliseconds. Full history, change tracking, timeouts โ€” a single proxy surface between the agent and the disk. This Space runs the **real `avfs` binary** (built from source). Watch an agent delete its output and tamper a config, then get rolled back to a clean checkpoint. ๐Ÿ”ง [github.com/neul-labs/agentvfs](https://github.com/neul-labs/agentvfs) ยท From [Neul Labs](https://huggingface.co/neullabs). """ with gr.Blocks(title="agentvfs โ€” execution boundary for agents") as demo_ui: gr.Markdown(HEADER) b = gr.Button("Run the checkpoint / rollback demo", variant="primary") o = gr.Markdown() b.click(demo, None, o) demo_ui.load(demo, None, o) if __name__ == "__main__": demo_ui.launch(server_name="0.0.0.0", server_port=7860)