Spaces:
Paused
Paused
fix: update sync interval to 600 seconds and enhance environment variable handling in startup scripts
Browse filesFiles changed (3)
- README.md+114-52
- hermes-sync.py+1-1
- start.sh+24-3
8 unmodified lines9101112121314141516171 unmodified line19202122222324254 unmodified lines30313233333435364 unmodified lines414243444445464747484950515253545556575859535455565758596061623 unmodified lines6667686969707172737172737475767778757980778182838481858683848788899091889293909192939495969495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621639816416516616716810310416917017117217310810911011111211317417511517617711717817911918018112118218312318418518618718812812913018919019119219319410 unmodified lines2052062071472082092102112121521531541552132142152162172182192208 unmodified lineslicense: mitsecrets: - name: LLM_API_KEY description: "Your LLM provider API key (e.g. Anthropic, OpenAI, Google, OpenRouter)." description: "Your LLM provider API key for direct providers such as OpenRouter, Anthropic, OpenAI, Google, DeepSeek, xAI, and others." - name: LLM_MODEL description: "Model ID to use, e.g. google/gemini-2.0-flash or openai/gpt-4o." description: "Model or provider model ID, such as openrouter/anthropic/claude-sonnet-4 or openai/gpt-4o." - name: GATEWAY_TOKEN description: "Strong token to secure your dashboard and API (generate: openssl rand -hex 32)." - name: TELEGRAM_BOT_TOKEN1 unmodified line - name: TELEGRAM_ALLOWED_USERS description: "Comma-separated list of numeric user IDs allowed to use the bot." - name: HF_TOKEN description: "Hugging Face token with write access. Used for automatic workspace backup." description: "Hugging Face token with write access. Used for automatic workspace backup and HF providers." - name: CLOUDFLARE_WORKERS_TOKEN description: "Cloudflare API token for automatic Worker proxy and KeepAlive setup."---4 unmodified lines[](https://huggingface.co/spaces)[](https://github.com/NousResearch/hermes-agent)
**Self-hosted Hermes AI agent gateway — free, no server needed.** HuggingMes runs [Nous Research Hermes Agent](https://github.com/NousResearch/hermes-agent) on HuggingFace Spaces, providing a 24/7 personal AI assistant. It includes a premium management dashboard, automatic persistent backup to HF Datasets, and built-in connectivity fixes to bypass platform restrictions. Deploy in minutes on the free HF Spaces tier with full data persistence.**Self-hosted Hermes AI agent gateway for Hugging Face Spaces.** HuggingMes runs [Nous Research Hermes Agent](https://github.com/NousResearch/hermes-agent) on HuggingFace Spaces, giving you a 24/7 personal AI assistant with a management dashboard, persistent HF Dataset backup, and automatic connectivity fixes for blocked outbound traffic. HuggingMes directly wires the startup providers listed below, and it can also use Hermes providers configured through `hermes model` or `config.yaml`.
## Table of Contents
4 unmodified lines- [📱 Telegram Setup](#-telegram-setup)- [🌐 Cloudflare Proxy](#-cloudflare-proxy)- [💾 Backup & Persistence](#-backup--persistence)- [💓 Staying Alive](#-staying-alive)- [💓 Staying Alive](#-staying-alive-recommended-on-free-hf-spaces)- [🔐 Security & Advanced](#-security--advanced)- [💻 Local Development](#-local-development)- [🏗️ Architecture](#️-architecture)- [🏗️ Architecture](#-architecture)- [🐛 Troubleshooting](#-troubleshooting)- [🌟 More Projects](#-more-projects)
## ✨ Features
- 🧠 **Hermes Core:** Runs the powerful Hermes agent framework for multi-modal chat and tool use.- 🔐 **Secure by Default:** Adds a custom auth layer to protect the Hermes dashboard and API routes.- 🌐 **Built-in Connectivity:** Includes transparent outbound proxying via Cloudflare Workers for Telegram, Google APIs, and more.- 📊 **Premium Dashboard:** Beautiful Web UI at `/` for real-time monitoring of uptime, sync health, and agent status.- 💾 **Persistent Backup:** Automatically syncs agent state, chats, and config to a private HF Dataset.- ⏰ **Easy Keep-Alive:** Uses `CLOUDFLARE_WORKERS_TOKEN` to automatically set up a cron-triggered keep-awake worker at boot.- 🐳 **Optimized Infrastructure:** Minimal resource usage with clean startup logs and production-ready proxying.- 🧠 **Hermes Core:** Runs Hermes Agent for multi-turn chat, tools, memory, and agent workflows.- 🔐 **Secure by Default:** Protects the dashboard and API with a single gateway token.- 🌐 **Built-in Connectivity:** Adds Cloudflare Worker proxy support for Telegram and other blocked outbound traffic.- 📊 **Dashboard:** Real-time view of uptime, sync health, and agent status at `/`.- 💾 **Persistent Backup:** Syncs chats, config, and session data to a private HF Dataset.- ⏰ **Keep-Alive:** Can provision a cron-triggered Cloudflare Worker to keep the Space awake.- 🤖 **Broad Provider Support:** Supports Hermes' native providers, direct API-key providers, OAuth providers, and custom OpenAI-compatible endpoints.
## 🚀 Quick Start
3 unmodified lines
### Step 2: Add Your Secrets
Navigate to your new Space's **Settings → Variables and secrets**, and add the following three under **Secrets**:In your Space's **Settings → Variables and secrets**, add these under **Secrets**:
- `LLM_API_KEY` – Your provider API key (e.g., Anthropic, OpenAI, OpenRouter).- `LLM_MODEL` – The model ID string (e.g., `google/gemini-2.0-flash` or `openai/gpt-4o`).- `GATEWAY_TOKEN` – A custom password to secure your dashboard.- `LLM_API_KEY` - Your provider API key for direct providers.- `LLM_MODEL` - The model ID to use, such as `openrouter/anthropic/claude-sonnet-4`, `openai/gpt-4o`, or `google/gemini-2.5-flash`.- `GATEWAY_TOKEN` - A strong token to secure the dashboard.- `TELEGRAM_BOT_TOKEN` - Telegram bot token from BotFather.- `TELEGRAM_ALLOWED_USERS` - Comma-separated numeric Telegram user IDs.- `HF_TOKEN` - Hugging Face token with write access for backups and HF providers.- `CLOUDFLARE_WORKERS_TOKEN` - Cloudflare token for outbound proxying and keep-alive automation.
### Step 3: Access Your Dashboard### Step 3: Deploy & Run
Once the build is complete, visit your Space's public URL. You will see the HuggingMes management dashboard. Click **Open Hermes UI** and enter your `GATEWAY_TOKEN` to access the agent interface.After the Space builds, open it and click **Open Hermes UI** to access the agent interface.
## 🔐 Access Control
Hermes' built-in dashboard is local-first. HuggingMes adds a secure wrapper:Hermes' built-in dashboard is wrapped by HuggingMes:
- **Dashboard:** Opening `/app/` requires your `GATEWAY_TOKEN`.- **API:** Routes under `/v1/*` (OpenAI-compatible) require `Authorization: Bearer <GATEWAY_TOKEN>`.- **Dashboard:** Opening `/app/` requires `GATEWAY_TOKEN`.- **API:** Routes under `/v1/*` require `Authorization: Bearer <GATEWAY_TOKEN>`.
## 🤖 LLM Providers
HuggingMes automatically maps your `LLM_MODEL` and `LLM_API_KEY` to the correct Hermes configuration.HuggingMes supports Hermes providers in two different ways:
| Provider | Prefix | Example `LLM_MODEL` || :--- | :--- | :--- || **Google** | `google/` | `google/gemini-2.0-flash` || **OpenRouter** | `openrouter/` | `openrouter/anthropic/claude-3.5-sonnet` || **Anthropic** | `anthropic/` | `anthropic/claude-3-opus-latest` || **OpenAI** | `openai/` | `openai/gpt-4o` || **HuggingFace** | `huggingface/` | `huggingface/meta-llama/Llama-3.3-70B-Instruct` |- **Direct startup providers:** Set `LLM_API_KEY` and `LLM_MODEL`, and HuggingMes maps them during boot.- **Hermes-native providers:** Use `hermes model` after the Space starts, or edit `config.yaml` through the Hermes UI.- **Custom OpenAI-compatible endpoints:** Point Hermes at your own `/v1` endpoint.
### Direct startup providers
These are the providers that HuggingMes maps directly from `LLM_MODEL` and `LLM_API_KEY` at startup.
| Provider | Prefix | Example `LLM_MODEL` | Key env || :--- | :--- | :--- | :--- || OpenRouter | `openrouter/` | `openrouter/anthropic/claude-sonnet-4` | `LLM_API_KEY` -> `OPENROUTER_API_KEY` || Hugging Face Inference Providers | `huggingface/` or `hf/` | `huggingface/Qwen/Qwen3-235B-A22B-Thinking-2507` | `LLM_API_KEY` -> `HF_TOKEN` || AI Gateway / Vercel AI Gateway | `ai-gateway/` or `vercel-ai-gateway/` | `ai-gateway/openai/gpt-4o` | `LLM_API_KEY` -> `AI_GATEWAY_API_KEY` || Anthropic | `anthropic/` | `anthropic/claude-sonnet-4-6` | `LLM_API_KEY` -> `ANTHROPIC_API_KEY` || OpenAI / OpenAI Codex | `openai/` or `openai-codex/` | `openai/gpt-4o` | `LLM_API_KEY` -> `OPENAI_API_KEY` || Google Gemini | `google/` or `gemini/` | `google/gemini-2.5-flash` | `LLM_API_KEY` -> `GOOGLE_API_KEY` and `GEMINI_API_KEY` || DeepSeek | `deepseek/` | `deepseek/deepseek-chat` | `LLM_API_KEY` -> `DEEPSEEK_API_KEY` || Kimi / Moonshot | `kimi-coding/` or `moonshot/` | `kimi-coding/kimi-for-coding` | `LLM_API_KEY` -> `KIMI_API_KEY` || Kimi / Moonshot (China) | `kimi-coding-cn/` | `kimi-coding-cn/kimi-k2.5` | `LLM_API_KEY` -> `KIMI_CN_API_KEY` || Arcee AI | `arcee/` | `arcee/trinity-large-thinking` | `LLM_API_KEY` -> `ARCEEAI_API_KEY` || GMI Cloud | `gmi/` | `gmi/zai-org/GLM-5.1-FP8` | `LLM_API_KEY` -> `GMI_API_KEY` || MiniMax | `minimax/` | `minimax/MiniMax-M2.7` | `LLM_API_KEY` -> `MINIMAX_API_KEY` || MiniMax (China) | `minimax-cn/` | `minimax-cn/MiniMax-M2.7` | `LLM_API_KEY` -> `MINIMAX_CN_API_KEY` || Alibaba Cloud | `alibaba/` | `alibaba/qwen3.5-plus` | `LLM_API_KEY` -> `DASHSCOPE_API_KEY` || Alibaba Coding Plan | `alibaba-coding-plan/` | `alibaba-coding-plan/qwen3-coder-plus` | `LLM_API_KEY` -> `DASHSCOPE_API_KEY` || Xiaomi MiMo | `xiaomi/` | `xiaomi/mimo-v2-pro` | `LLM_API_KEY` -> `XIAOMI_API_KEY` || Tencent TokenHub | `tencent-tokenhub/` | `tencent-tokenhub/hy3-preview` | `LLM_API_KEY` -> `TOKENHUB_API_KEY` || Z.ai / GLM | `zai/`, `z-ai/`, `z.ai/`, or `glm/` | `zai/glm-5` | `LLM_API_KEY` -> `GLM_API_KEY` || NVIDIA NIM | `nvidia/` | `nvidia/nemotron-3-super-120b-a12b` | `LLM_API_KEY` -> `NVIDIA_API_KEY` || xAI / Grok | `xai/` or `grok/` | `xai/grok-4-1-fast-reasoning` | `LLM_API_KEY` -> `XAI_API_KEY` || Kilo Code | `kilocode/` | `kilocode/<model-id>` | `LLM_API_KEY` -> `KILOCODE_API_KEY` || OpenCode Zen | `opencode-zen/` | `opencode-zen/<model-id>` | `LLM_API_KEY` -> `OPENCODE_ZEN_API_KEY` || OpenCode Go | `opencode-go/` | `opencode-go/<model-id>` | `LLM_API_KEY` -> `OPENCODE_GO_API_KEY` |
### Hermes-native providers and OAuth flows
These providers are supported by Hermes and can be used in HuggingMes once the agent config is set through `hermes model` or `config.yaml`. HuggingMes does not auto-map them from `LLM_MODEL` at boot unless Hermes itself handles that provider.
| Provider | How to use | Notes || :--- | :--- | :--- || Nous Portal | `hermes model` | Subscription-based OAuth provider in Hermes || OpenAI Codex | `hermes model` | ChatGPT OAuth / Codex models || GitHub Copilot | `hermes model` | Uses `COPILOT_GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth token` || GitHub Copilot ACP | `hermes model` | Spawns the Copilot CLI backend || Anthropic (OAuth / Claude Code) | `hermes model` | Also supports `ANTHROPIC_API_KEY` || Google Gemini (OAuth) | `hermes model` | Browser OAuth flow, including free-tier Gemini OAuth || Qwen Portal (OAuth) | `hermes model` | Alibaba Qwen portal OAuth login || MiniMax (OAuth) | `hermes model` | Portal login for MiniMax models || Hugging Face Inference Providers | `hermes model` | Unified HF provider routing with model suffixes like `:fastest` and `:cheapest` || AWS Bedrock | `hermes model` or `config.yaml` | Uses AWS credentials chain, not an API key || Ollama Cloud | `hermes model` | Managed Ollama catalog with `OLLAMA_API_KEY` || Arcee AI | `hermes model` | First-class Hermes provider || GMI Cloud | `hermes model` | First-class Hermes provider || Alibaba Cloud / DashScope | `hermes model` | First-class Hermes provider for Qwen models || Tencent TokenHub | `hermes model` | First-class Hermes provider || Custom endpoint | `hermes model` or `config.yaml` | Any OpenAI-compatible endpoint |
### Custom and self-hosted endpoints
HuggingMes also works with any OpenAI-compatible server. Common examples include local Ollama, LM Studio, llama.cpp / llama-server, vLLM, SGLang, LocalAI, Jan, LiteLLM, ClawRouter, Together AI, Groq, Fireworks AI, Azure OpenAI, and similar services.
Use either the Hermes model wizard or a direct `config.yaml` entry with a `base_url`, `model`, and optional API key. For local servers that do not require auth, leave the key empty.
### Recommended provider choices
- **Just want it to work:** OpenRouter or Hermes' Nous Portal.- **Want local models:** Ollama, LM Studio, llama.cpp, vLLM, or SGLang through a custom endpoint.- **Need cloud APIs:** OpenAI, Anthropic, Google Gemini, DeepSeek, xAI, Hugging Face, or any other direct provider above.- **Need routing or fallback:** Use a custom endpoint such as LiteLLM or ClawRouter.
## 📱 Telegram Setup *(Optional)*## 📱 Telegram Setup
To use Hermes via Telegram:
1. Add `TELEGRAM_BOT_TOKEN` from [@BotFather](https://t.me/BotFather).2. Add `TELEGRAM_ALLOWED_USERS` (comma-separated numeric IDs) to restrict access.3. Add `CLOUDFLARE_WORKERS_TOKEN` to bypass HF network restrictions automatically.2. Add `TELEGRAM_ALLOWED_USERS` if you want to restrict access.3. Add `CLOUDFLARE_WORKERS_TOKEN` if you need automatic outbound proxying for Telegram API traffic.
## 🌐 Cloudflare Proxy
HuggingFace Spaces often block outbound connections to external APIs. HuggingMes handles this automatically:
1. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.2. Restart the Space.
HuggingMes will auto-provision a Worker proxy for Telegram and other restricted traffic, and set up a keep-awake cron.Hugging Face Spaces often block outbound calls to APIs used by Telegram and some provider backends. HuggingMes can provision a Cloudflare Worker proxy automatically when you add `CLOUDFLARE_WORKERS_TOKEN`.
## 💾 Backup & Persistence## 💾 Backup & Persistence *(Optional)*
Set `HF_TOKEN` with **Write** access to enable backup. HuggingMes syncs all agent data to a private Dataset named `huggingmes-backup` every 180 seconds.Set `HF_TOKEN` with write access to enable backup. HuggingMes syncs workspace data to a private HF Dataset named `huggingmes-backup` every 600 seconds by default.
## 💓 Staying Alive *(Recommended on Free HF Spaces)*## 💓 Staying Alive
Your Space will automatically be kept awake by a background Cloudflare Worker when you configure the `CLOUDFLARE_WORKERS_TOKEN` secret. The worker uses a cron trigger to regularly ping your Space's `/health` endpoint. The dashboard displays the current keep-alive worker status.With `CLOUDFLARE_WORKERS_TOKEN` set, HuggingMes can create a keep-alive worker that pings the Space's `/health` endpoint on a schedule so the free tier stays awake longer.
## 🔐 Security & Advanced## 🔐 Security & Advanced *(Optional)*
| Variable | Default | Description || :--- | :--- | :--- || `GATEWAY_TOKEN` | — | Token for dashboard and API auth || `HF_TOKEN` | — | HF token with write access for backups || `CLOUDFLARE_WORKERS_TOKEN` | — | Cloudflare API token for proxy & keep-awake || `SYNC_INTERVAL` | `180` | Backup frequency in seconds || `HF_TOKEN` | — | HF token with write access for backups and HF providers || `CLOUDFLARE_WORKERS_TOKEN` | — | Cloudflare API token for proxying and keep-awake || `SYNC_INTERVAL` | `600` | Backup frequency in seconds || `CLOUDFLARE_KEEPALIVE_ENABLED` | `true` | Set `false` to disable keep-awake worker || `TELEGRAM_MODE` | `webhook` | `webhook` or `polling` |
10 unmodified lines- **Dashboard (`/`)**: Real-time management and monitoring.- **Hermes App (`/app/`)**: Secure proxied access to the Hermes UI.- **API (`/v1/*`)**: Proxied OpenAI-compatible agent API.- **Health Check (`/health`)**: Readiness probe for HF and Keep-Alive.- **Health Check (`/health`)**: Readiness probe for HF and keep-alive.- **Sync Engine**: Python background task for HF Dataset persistence.
## 🐛 Troubleshooting
- **Telegram bot not responding:** Ensure `CLOUDFLARE_WORKERS_TOKEN` is set. Check logs for "Setting up Cloudflare proxy".- **Authentication failed:** Clear your browser cookies or use an incognito window if your `GATEWAY_TOKEN` has changed.- **Data not persisting:** Ensure `HF_TOKEN` has **Write** permissions.- **Space keeps sleeping:** Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret to enable automatic keep-awake monitoring via Cloudflare Workers.- **Telegram bot not responding:** Ensure `CLOUDFLARE_WORKERS_TOKEN` is set and check logs for the proxy setup step.- **Authentication failed:** Clear browser cookies or use an incognito window if `GATEWAY_TOKEN` changed.- **Data not persisting:** Ensure `HF_TOKEN` has write access.- **Provider not showing up:** If it is a Hermes-native provider, run `hermes model` and complete the provider-specific setup there. If it is a custom endpoint, verify the `base_url` exposes `/v1/models` or `/v1/chat/completions`.- **Space keeps sleeping:** Add `CLOUDFLARE_WORKERS_TOKEN` to enable automatic keep-awake monitoring.
## 🌟 More Projects
22 unmodified lines232425262627282922 unmodified lines
HERMES_HOME = Path(os.environ.get("HERMES_HOME", "/opt/data"))STATUS_FILE = Path("/tmp/huggingmes-sync-status.json")INTERVAL = int(os.environ.get("SYNC_INTERVAL", "180"))INTERVAL = int(os.environ.get("SYNC_INTERVAL", "600"))INITIAL_DELAY = int(os.environ.get("SYNC_START_DELAY", "10"))HF_TOKEN = os.environ.get("HF_TOKEN", "").strip()HF_USERNAME = os.environ.get("HF_USERNAME", "").strip()13 unmodified lines141516171718192097 unmodified lines11811912012112112212312420 unmodified lines145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180101 unmodified lines28228328426428528628728813 unmodified linesGATEWAY_API_PORT="${API_SERVER_PORT:-8642}"DASHBOARD_PORT="${DASHBOARD_PORT:-9119}"TELEGRAM_WEBHOOK_PORT="${TELEGRAM_WEBHOOK_PORT:-8765}"SYNC_INTERVAL="${SYNC_INTERVAL:-180}"SYNC_INTERVAL="${SYNC_INTERVAL:-600}"BACKUP_DATASET="${BACKUP_DATASET_NAME:-huggingmes-backup}"CF_PROXY_ENV_FILE="/tmp/huggingmes-cloudflare-proxy.env"
97 unmodified lines [ "$PROVIDER_FOR_CONFIG" = "auto" ] && PROVIDER_FOR_CONFIG="openrouter" MODEL_FOR_CONFIG="${MODEL_INPUT#openrouter/}" ;; huggingface) huggingface|hf) [ -n "$LLM_API_KEY" ] && export HF_TOKEN="${HF_TOKEN:-$LLM_API_KEY}" [ "$PROVIDER_FOR_CONFIG" = "auto" ] && PROVIDER_FOR_CONFIG="huggingface" MODEL_FOR_CONFIG="${MODEL_INPUT#huggingface/}"20 unmodified lines kimi-coding|moonshot) [ -n "$LLM_API_KEY" ] && export KIMI_API_KEY="${KIMI_API_KEY:-$LLM_API_KEY}" ;; kimi-coding-cn|moonshot-cn|kimi-cn) [ -n "$LLM_API_KEY" ] && export KIMI_CN_API_KEY="${KIMI_CN_API_KEY:-$LLM_API_KEY}" ;; minimax) [ -n "$LLM_API_KEY" ] && export MINIMAX_API_KEY="${MINIMAX_API_KEY:-$LLM_API_KEY}" ;; minimax-cn) [ -n "$LLM_API_KEY" ] && export MINIMAX_CN_API_KEY="${MINIMAX_CN_API_KEY:-$LLM_API_KEY}" ;; xiaomi) [ -n "$LLM_API_KEY" ] && export XIAOMI_API_KEY="${XIAOMI_API_KEY:-$LLM_API_KEY}" ;; zai|z-ai|z.ai|glm) [ -n "$LLM_API_KEY" ] && export GLM_API_KEY="${GLM_API_KEY:-$LLM_API_KEY}" ;; arcee|arcee-ai|arceeai) [ -n "$LLM_API_KEY" ] && export ARCEEAI_API_KEY="${ARCEEAI_API_KEY:-$LLM_API_KEY}" ;; gmi|gmi-cloud|gmicloud) [ -n "$LLM_API_KEY" ] && export GMI_API_KEY="${GMI_API_KEY:-$LLM_API_KEY}" ;; alibaba) [ -n "$LLM_API_KEY" ] && export DASHSCOPE_API_KEY="${DASHSCOPE_API_KEY:-$LLM_API_KEY}" ;; alibaba-coding-plan|alibaba_coding) [ -n "$LLM_API_KEY" ] && export DASHSCOPE_API_KEY="${DASHSCOPE_API_KEY:-$LLM_API_KEY}" ;; tencent-tokenhub|tencent|tokenhub|tencentmaas) [ -n "$LLM_API_KEY" ] && export TOKENHUB_API_KEY="${TOKENHUB_API_KEY:-$LLM_API_KEY}" ;; nvidia) [ -n "$LLM_API_KEY" ] && export NVIDIA_API_KEY="${NVIDIA_API_KEY:-$LLM_API_KEY}" ;;101 unmodified lines echo "Telegram : not configured"fiif [ -n "${HF_TOKEN:-}" ]; then echo "Backup : ${BACKUP_DATASET} (every ${SYNC_INTERVAL:-180}s)" echo "Backup : ${BACKUP_DATASET} (every ${SYNC_INTERVAL:-600}s)"else echo "Backup : disabled"fiREADME.md+114-52
hermes-sync.py+1-1
start.sh+24-3