#!/bin/bash
# Hermes Agent 安装 - 国内镜像加速版
# 镜像源: https://res.agthub.tech

set -euo pipefail

MIRROR_URL="https://res.agthub.tech"

echo "=== Hermes Agent 安装 (国内镜像) ==="
echo "镜像源: $MIRROR_URL"
echo ""

# 1. 用国内加速安装 uv（Hermes 依赖的 Python 包管理器）
if ! command -v uv &>/dev/null; then
  echo ">> 安装 uv (pip 镜像: https://pypi.tuna.tsinghua.edu.cn/simple)..."
  curl -LsSf https://astral.sh/uv/install.sh | \
    UV_PYTHON_INSTALL_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
    bash
  # 刷新 PATH
  export PATH="$HOME/.local/bin:$PATH"
fi

# 2. 安装 Hermes Agent
echo ">> 安装 Hermes Agent (清华 pip 镜像)..."
uv pip install --system hermes-agent \
  -i https://pypi.tuna.tsinghua.edu.cn/simple \
  --trusted-host pypi.tuna.tsinghua.edu.cn

echo ""
echo "=== 安装完成! ==="
echo "运行 'hermes setup' 配置模型后开始使用"
