#!/usr/bin/env python3 import subprocess import sys import json args = json.loads(sys.stdin.read()) command = args.get("command", "") try: result = subprocess.run( ["bash", "-c", command], capture_output=True, text=True, timeout=120, ) output = result.stdout if result.stderr: output += f"\n[stderr] {result.stderr}" if result.returncode != 0: output += f"\n[exit code: {result.returncode}]" print(output.strip() or "[no output]") except subprocess.TimeoutExpired: print("[command timed out after 120s]") except Exception as e: print(f"[error: {e}]")