#!/usr/bin/env bash
# Batch Agent diagnostics on sub-servers (SSH from central DB creds).
#
# Usage:
#   bash scripts/agent_remote_diagnose.sh --id 95
#   bash scripts/agent_remote_diagnose.sh --name 颜又文
#   bash scripts/agent_remote_diagnose.sh --offline-only --limit 20
#   bash scripts/agent_remote_diagnose.sh --offline-only -o /tmp/agent-offline.md
#
# Run on machine with .env (local dev or ssh nexus + cd /opt/nexus).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SECRETS="${ROOT}/deploy/nexus-1panel.secrets.sh"
if [[ -f "$SECRETS" ]]; then
  # shellcheck disable=SC1090
  source "$SECRETS"
fi
PYTHON="${ROOT}/.venv/bin/python"
if [[ ! -x "$PYTHON" ]]; then
  PYTHON=python3
fi
exec "$PYTHON" "${ROOT}/scripts/agent_remote_diagnose.py" "$@"
