from __future__ import annotations import tempfile import time from pathlib import Path from pyro_mcp import Pyro def main() -> None: pyro = Pyro() with tempfile.TemporaryDirectory(prefix="pyro-workspace-seed-") as seed_dir: Path(seed_dir, "note.txt").write_text("hello from shell\n", encoding="utf-8") created = pyro.create_workspace(environment="debian:12", seed_path=seed_dir) workspace_id = str(created["workspace_id"]) try: opened = pyro.open_shell(workspace_id) shell_id = str(opened["shell_id"]) pyro.write_shell(workspace_id, shell_id, input="pwd") deadline = time.time() + 5 while True: read = pyro.read_shell( workspace_id, shell_id, cursor=0, plain=True, wait_for_idle_ms=300, ) output = str(read["output"]) if "/workspace" in output or time.time() >= deadline: print(output, end="") break time.sleep(0.1) pyro.close_shell(workspace_id, shell_id) finally: pyro.delete_workspace(workspace_id) if __name__ == "__main__": main()