| 129 | return path |
| 130 | |
| 131 | def run_bash(command: str) -> str: |
| 132 | dangerous = ["rm -rf /", "sudo", "shutdown", "reboot", "> /dev/"] |
| 133 | if any(d in command for d in dangerous): |
| 134 | return "Error: Dangerous command blocked" |
| 135 | try: |
| 136 | r = subprocess.run(command, shell=True, cwd=WORKDIR, |
| 137 | capture_output=True, text=True, timeout=120) |
| 138 | out = (r.stdout + r.stderr).strip() |
| 139 | return out[:50000] if out else "(no output)" |
| 140 | except subprocess.TimeoutExpired: |
| 141 | return "Error: Timeout (120s)" |
| 142 | |
| 143 | def run_read(path: str, limit: int = None) -> str: |
| 144 | try: |