import json
import os
import requests
import sys


def sync_reports(url):
    response = requests.get(url, timeout=5)
    return response.json()


def load_runtime_config():
    api_url = os.getenv("API_URL")
    if not api_url:
        raise ValueError("API_URL is required")
    return {"api_url": api_url}


def run_cli():
    if len(sys.argv) < 2:
        raise ValueError("missing payload")
    payload = json.loads(sys.argv[1])
    return payload["user"]


def render_frontend_inputs(item):
    return item.get("description", "")
