import subprocess from pathlib import Path from typing import Any, Dict def run_update_script(script_path: Path, current: str, latest: str, timeout: float) -> Dict[str, Any]: try: proc = subprocess.run( [str(script_path), current, latest], capture_output=True, text=True, timeout=timeout, ) return { "success": proc.returncode == 0, "output": proc.stdout.strip(), "error": proc.stderr.strip(), } except subprocess.TimeoutExpired: return {"success": False, "output": "", "error": "Script timed out"} except Exception as exc: return {"success": False, "output": "", "error": str(exc)}