#!/usr/bin/env bash
# Install the Koretex provider skill into a local Hermes Agent (or any agentskills.io runtime).
#   Run:  curl -fsSL https://koretex.ai/skills/koretex-node-provider/install.sh -o koretex-skill.sh && bash koretex-skill.sh
# Then, in your agent, ask: "join Koretex / earn while my machine is idle".
set -euo pipefail

BASE="${KORETEX_SKILL_BASE:-https://koretex.ai/skills/koretex-node-provider}"
DEST="${HERMES_SKILLS_DIR:-$HOME/.hermes/skills}/koretex-node-provider"

echo "› Installing the koretex-node-provider skill → $DEST"
mkdir -p "$DEST/scripts"
curl -fsSL "$BASE/SKILL.md"                 -o "$DEST/SKILL.md"
curl -fsSL "$BASE/scripts/koretex-up.sh"    -o "$DEST/scripts/koretex-up.sh"
curl -fsSL "$BASE/scripts/koretex-status.sh" -o "$DEST/scripts/koretex-status.sh"
chmod +x "$DEST/scripts/"*.sh

echo "✓ Installed. Your agent can now read SKILL.md and configure itself."
echo "  In Hermes: \"join Koretex and earn while idle\" — it will install the node, enroll a"
echo "  self-custody wallet, serve the best-fit model, and route its own inference through Koretex."
