#!/usr/bin/env bash
# Sovereign Foveal Vision & Episodic Memory MCP / HTTP Server
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export PYTHONPATH="${REPO_ROOT}/src:${PYTHONPATH:-}"

if [ -x "${REPO_ROOT}/.venv/bin/python3" ]; then
  PY_BIN="${REPO_ROOT}/.venv/bin/python3"
else
  PY_BIN="python3"
fi

for arg in "$@"; do
  case "$arg" in
    --serve-http|--import-screenpipe)
      exec "$PY_BIN" -m whole_body_compute.integrations.foveal_memory "$@"
      ;;
  esac
done

exec "$PY_BIN" -m whole_body_compute.integrations.foveal_memory --mcp-stdio "$@"
