agenticverse/AgentNexa
0
1#!/bin/bash2set -e3 4BOOT_START=$(date +%s)5 6echo "[entrypoint] HermesFace — Hermes Agent on HuggingFace Spaces"7echo "[entrypoint] ===================================================="8 9HERMES_HOME="/opt/data"10INSTALL_DIR="/opt/hermes"11 12# ── DNS pre-resolution (background — non-blocking) ────────────────────────13# Resolves Telegram / WhatsApp / Discord domains via DoH when HF Spaces14# system DNS refuses them. Writes /tmp/dns-resolved.json for dns-fix.cjs15# and appends /etc/hosts for Python processes.16echo "[entrypoint] Starting DNS resolution in background..."17python3 /opt/data/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1 &18DNS_PID=$!19echo "[entrypoint] DNS resolver PID: $DNS_PID"20 21# Enable Node.js DNS fix preload for playwright / whatsapp-bridge / web build.22export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /opt/data/scripts/dns-fix.cjs"23 24# ── Activate virtual environment ─────────────────────────────────────────25if [ -f "${INSTALL_DIR}/.venv/bin/activate" ]; then26 source "${INSTALL_DIR}/.venv/bin/activate"27 echo "[entrypoint] Activated venv: $(which python3)"28fi29 30# ── Ensure data directories ─────────────────────────────────────────────31mkdir -p "$HERMES_HOME"/{cron,sessions,logs,hooks,memories,skills,skins,plans,workspace,home}32 33# ── Bootstrap config files ───────────────────────────────────────────────34if [ ! -f "$HERMES_HOME/.env" ] && [ -f "$INSTALL_DIR/.env.example" ]; then35 cp "$INSTALL_DIR/.env.example" "$HERMES_HOME/.env"36 echo "[entrypoint] Created .env from example"37fi38 39if [ ! -f "$HERMES_HOME/config.yaml" ] && [ -f "$INSTALL_DIR/cli-config.yaml.example" ]; then40 cp "$INSTALL_DIR/cli-config.yaml.example" "$HERMES_HOME/config.yaml"41 echo "[entrypoint] Created config.yaml from example"42fi43 44if [ ! -f "$HERMES_HOME/SOUL.md" ] && [ -f "$INSTALL_DIR/docker/SOUL.md" ]; then45 cp "$INSTALL_DIR/docker/SOUL.md" "$HERMES_HOME/SOUL.md"46 echo "[entrypoint] Created SOUL.md from template"47fi48 49# ── Sync bundled skills ──────────────────────────────────────────────────50if [ -d "$INSTALL_DIR/skills" ] && [ -f "$INSTALL_DIR/tools/skills_sync.py" ]; then51 python3 "$INSTALL_DIR/tools/skills_sync.py" 2>&1 || echo "[entrypoint] Skills sync skipped"52fi53 54# ── Build artifacts check ───────────────────────────────────────────────55echo "[entrypoint] Build artifacts check:"56test -f "$INSTALL_DIR/run_agent.py" && echo " OK run_agent.py" || echo " INFO: run_agent.py not found"57test -f "$INSTALL_DIR/gateway/run.py" && echo " OK gateway/run.py" || echo " INFO: gateway/run.py not found"58test -d "$INSTALL_DIR/web" && echo " OK web/ dashboard" || echo " INFO: web/ not found"59command -v hermes >/dev/null 2>&1 && echo " OK hermes CLI: $(which hermes)" || echo " INFO: hermes CLI not in PATH"60 61# Create logs62mkdir -p /opt/data/logs63touch /opt/data/logs/app.log64 65ENTRYPOINT_END=$(date +%s)66echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"67 68# ── Start Hermes via sync_hf.py (handles persistence + process management)69echo "[entrypoint] Starting Hermes Agent via sync_hf.py..."70exec python3 -u /opt/data/scripts/sync_hf.py71 