def parse_timeout_duration(timeout: str | None, default_seconds: int = 10) -> int:
    """
    Parses a string like '90s', '2m', '1m30s' into total seconds (int).
    Supports 's', 'm' (lower or upper case). Returns default if invalid.
    '1m30s' -> 90
    """
    if not timeout or not isinstance(timeout, str):
        return default_seconds

    timeout = timeout.strip().lower()

    pattern = r"^(?:(\d+)m)?(?:(\d+)s)?$"
    match = re.fullmatch(pattern, timeout)
    if not match:
        return default_seconds

    minutes = int(match.group(1)) if match.group(1) else 0
    seconds = int(match.group(2)) if match.group(2) else 0
    total = minutes * 60 + seconds

    return total if total > 0 else default_seconds

    Parses a string like '90s', '2m', '1m30s' into total seconds (int).
    Supports 's', 'm' (lower or upper case). Returns default if invalid.
    '1m30s' -> 90
    
sandbox/executor_manager/util.py