Spaces:
Paused
Paused
fix: correct spelling of 'HuggingMes' across multiple files
Browse filesFiles changed (12)
- .env.example+3-3
- CHANGELOG.md+1-1
- CONTRIBUTING.md+1-1
- Dockerfile+12-12
- README.md+10-10
- SECURITY.md+1-1
- cloudflare-keepalive-setup.py+4-4
- cloudflare-proxy-setup.py+4-4
- docker-compose.yml+4-4
- health-server.js+27-14
- hermes-sync.py+5-5
- start.sh+8-8
1234530 unmodified lines3637383940414243# ============================================================================# HuggingMess - Hermes Agent on Hugging Face Spaces# Configuration Reference# ============================================================================30 unmodified lines# HF token with write access for private Dataset backupHF_TOKEN=hf_your_token_here# Dataset name (default: huggingmess-backup)# BACKUP_DATASET_NAME=huggingmess-backup# Backup interval in seconds (default: 180)SYNC_INTERVAL=1801234530 unmodified lines3637383940414243# ============================================================================# HuggingMes - Hermes Agent on Hugging Face Spaces# Configuration Reference# ============================================================================30 unmodified lines# HF token with write access for private Dataset backupHF_TOKEN=hf_your_token_here# Dataset name (default: huggingmes-backup)# BACKUP_DATASET_NAME=huggingmes-backup# Backup interval in seconds (default: 180)SYNC_INTERVAL=180
1 unmodified line23456781 unmodified line## 0.1.0 - 2026-05-03- Initial HuggingMess Docker Space wrapper for Nous Research Hermes Agent.- Added HF Space dashboard, `/health`, `/status`, `/v1/*` proxy, and Telegram webhook proxy.- Added Cloudflare Worker setup for Telegram Bot API base URL proxying.- Added private HF Dataset backup and restore for Hermes state.1 unmodified line23456781 unmodified line## 0.1.0 - 2026-05-03- Initial HuggingMes Docker Space wrapper for Nous Research Hermes Agent.- Added HF Space dashboard, `/health`, `/status`, `/v1/*` proxy, and Telegram webhook proxy.- Added Cloudflare Worker setup for Telegram Bot API base URL proxying.- Added private HF Dataset backup and restore for Hermes state.
123456# ContributingThanks for improving HuggingMess.## Local Checks123456# ContributingThanks for improving HuggingMes.## Local Checks
12348 unmodified lines13141516171819202122232425262728293031322 unmodified lines35363738# HuggingMess - Hermes Agent Gateway for Hugging Face SpacesARG HERMES_AGENT_VERSION=latestFROM nousresearch/hermes-agent:${HERMES_AGENT_VERSION}8 unmodified lines&& rm -rf /var/lib/apt/lists/* \&& uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir huggingface_hubCOPY --chown=hermes:hermes start.sh /opt/huggingmess/start.shCOPY --chown=hermes:hermes health-server.js /opt/huggingmess/health-server.jsCOPY --chown=hermes:hermes hermes-sync.py /opt/huggingmess/hermes-sync.pyCOPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmess/cloudflare-proxy-setup.pyCOPY --chown=hermes:hermes cloudflare-keepalive-setup.py /opt/huggingmess/cloudflare-keepalive-setup.pyRUN chmod +x \/opt/huggingmess/start.sh \/opt/huggingmess/hermes-sync.py \/opt/huggingmess/cloudflare-proxy-setup.py \/opt/huggingmess/cloudflare-keepalive-setup.pyENV HERMES_HOME=/opt/data \HUGGINGMESS_APP_DIR=/opt/huggingmess \HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \PYTHONUNBUFFERED=12 unmodified linesHEALTHCHECK --interval=30s --timeout=5s --start-period=90s \CMD curl -fsS http://localhost:7861/health || exit 1CMD ["/opt/huggingmess/start.sh"]12348 unmodified lines13141516171819202122232425262728293031322 unmodified lines35363738# HuggingMes - Hermes Agent Gateway for Hugging Face SpacesARG HERMES_AGENT_VERSION=latestFROM nousresearch/hermes-agent:${HERMES_AGENT_VERSION}8 unmodified lines&& rm -rf /var/lib/apt/lists/* \&& uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir huggingface_hubCOPY --chown=hermes:hermes start.sh /opt/huggingmes/start.shCOPY --chown=hermes:hermes health-server.js /opt/huggingmes/health-server.jsCOPY --chown=hermes:hermes hermes-sync.py /opt/huggingmes/hermes-sync.pyCOPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.pyCOPY --chown=hermes:hermes cloudflare-keepalive-setup.py /opt/huggingmes/cloudflare-keepalive-setup.pyRUN chmod +x \/opt/huggingmes/start.sh \/opt/huggingmes/hermes-sync.py \/opt/huggingmes/cloudflare-proxy-setup.py \/opt/huggingmes/cloudflare-keepalive-setup.pyENV HERMES_HOME=/opt/data \HUGGINGMES_APP_DIR=/opt/huggingmes \HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \PYTHONUNBUFFERED=12 unmodified linesHEALTHCHECK --interval=30s --timeout=5s --start-period=90s \CMD curl -fsS http://localhost:7861/health || exit 1CMD ["/opt/huggingmes/start.sh"]
12345623 unmodified lines3031323334353625 unmodified lines626364656667685 unmodified lines74757677787980818283848586878889909113 unmodified lines105106107108109110111112113114115116117118119120---title: HuggingMessemoji: 📚colorFrom: bluecolorTo: indigosdk: docker23 unmodified lines[](https://huggingface.co/spaces)[](https://github.com/NousResearch/hermes-agent)**Self-hosted Hermes AI agent gateway — free, no server needed.** HuggingMess 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.## Table of Contents25 unmodified lines### Step 1: Duplicate this Space[](https://huggingface.co/spaces/somratpro/HuggingMess?duplicate=true)### Step 2: Add Your Secrets5 unmodified lines### Step 3: Access Your DashboardOnce the build is complete, visit your Space's public URL. You will see the HuggingMess management dashboard. Click **Open Hermes UI** and enter your `GATEWAY_TOKEN` to access the agent interface.## 🔐 Access ControlHermes' built-in dashboard is local-first. HuggingMess adds a secure wrapper:- **Dashboard:** Opening `/app/` requires your `GATEWAY_TOKEN`.- **API:** Routes under `/v1/*` (OpenAI-compatible) require `Authorization: Bearer <GATEWAY_TOKEN>`.## 🤖 LLM ProvidersHuggingMess automatically maps your `LLM_MODEL` and `LLM_API_KEY` to the correct Hermes configuration.| Provider | Prefix | Example `LLM_MODEL` || :--- | :--- | :--- |13 unmodified lines## 🌐 Cloudflare ProxyHuggingFace Spaces often block outbound connections to external APIs. HuggingMess handles this automatically:1. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.2. Restart the Space.HuggingMess will auto-provision a Worker proxy for Telegram and other restricted traffic, and set up a keep-awake cron.## 💾 Backup & PersistenceSet `HF_TOKEN` with **Write** access to enable backup. HuggingMess syncs all agent data to a private Dataset named `huggingmess-backup` every 180 seconds.## 💓 Staying Alive *(Recommended on Free HF Spaces)*12345623 unmodified lines3031323334353625 unmodified lines626364656667685 unmodified lines74757677787980818283848586878889909113 unmodified lines105106107108109110111112113114115116117118119120---title: HuggingMesemoji: ⚚colorFrom: bluecolorTo: indigosdk: docker23 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.## Table of Contents25 unmodified lines### Step 1: Duplicate this Space[](https://huggingface.co/spaces/somratpro/HuggingMes?duplicate=true)### Step 2: Add Your Secrets5 unmodified lines### Step 3: Access Your DashboardOnce 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.## 🔐 Access ControlHermes' built-in dashboard is local-first. HuggingMes adds a secure wrapper:- **Dashboard:** Opening `/app/` requires your `GATEWAY_TOKEN`.- **API:** Routes under `/v1/*` (OpenAI-compatible) require `Authorization: Bearer <GATEWAY_TOKEN>`.## 🤖 LLM ProvidersHuggingMes automatically maps your `LLM_MODEL` and `LLM_API_KEY` to the correct Hermes configuration.| Provider | Prefix | Example `LLM_MODEL` || :--- | :--- | :--- |13 unmodified lines## 🌐 Cloudflare ProxyHuggingFace 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.## 💾 Backup & PersistenceSet `HF_TOKEN` with **Write** access to enable backup. HuggingMes syncs all agent data to a private Dataset named `huggingmes-backup` every 180 seconds.## 💓 Staying Alive *(Recommended on Free HF Spaces)*
123456# SecurityHuggingMess runs a full agent gateway with tool access. Treat the Space and its secrets like a server.## Required Hardening123456# SecurityHuggingMes runs a full agent gateway with tool access. Treat the Space and its secrets like a server.## Required Hardening
11 unmodified lines1213141516171814 unmodified lines3334353637383916 unmodified lines5657585960616213 unmodified lines7677787980818211 unmodified linesfrom pathlib import PathAPI_BASE = "https://api.cloudflare.com/client/v4"KEEPALIVE_STATUS_FILE = Path("/tmp/huggingmess-cloudflare-keepalive-status.json")def cf_request(method: str, path: str, token: str, body: bytes | None = None, content_type: str = "application/json"):14 unmodified linesdef slugify(value: str) -> str:cleaned = re.sub(r"[^a-z0-9-]+", "-", value.lower()).strip("-")cleaned = re.sub(r"-{2,}", "-", cleaned)return (cleaned or "huggingmess-proxy")[:63].rstrip("-")def get_space_host() -> str:16 unmodified linesspace_host = get_space_host()if space_host:return slugify(f"{space_host.replace('.hf.space', '')}-keepalive")return "huggingmess-keepalive"def render_keepalive_worker(target_url: str) -> str:13 unmodified linesconst response = await fetch(TARGET_URL, {{method: "GET",headers: {{"user-agent": "HuggingMess Cloudflare KeepAlive","cache-control": "no-cache"}},cf: {{ cacheTtl: 0, cacheEverything: false }}11 unmodified lines1213141516171814 unmodified lines3334353637383916 unmodified lines5657585960616213 unmodified lines7677787980818211 unmodified linesfrom pathlib import PathAPI_BASE = "https://api.cloudflare.com/client/v4"KEEPALIVE_STATUS_FILE = Path("/tmp/huggingmes-cloudflare-keepalive-status.json")def cf_request(method: str, path: str, token: str, body: bytes | None = None, content_type: str = "application/json"):14 unmodified linesdef slugify(value: str) -> str:cleaned = re.sub(r"[^a-z0-9-]+", "-", value.lower()).strip("-")cleaned = re.sub(r"-{2,}", "-", cleaned)return (cleaned or "huggingmes-proxy")[:63].rstrip("-")def get_space_host() -> str:16 unmodified linesspace_host = get_space_host()if space_host:return slugify(f"{space_host.replace('.hf.space', '')}-keepalive")return "huggingmes-keepalive"def render_keepalive_worker(target_url: str) -> str:13 unmodified linesconst response = await fetch(TARGET_URL, {{method: "GET",headers: {{"user-agent": "HuggingMes Cloudflare KeepAlive","cache-control": "no-cache"}},cf: {{ cacheTtl: 0, cacheEverything: false }}
12 unmodified lines131415161718192031 unmodified lines525354555657583 unmodified lines6263646566676812 unmodified linesfrom pathlib import PathAPI_BASE = "https://api.cloudflare.com/client/v4"ENV_FILE = Path("/tmp/huggingmess-cloudflare-proxy.env")ENV_FILE = Path("/tmp/huggingmess-cloudflare-proxy.env")DEFAULT_ALLOWED = ["api.telegram.org","discord.com",31 unmodified linesdef slugify(value: str) -> str:cleaned = re.sub(r"[^a-z0-9-]+", "-", value.lower()).strip("-")cleaned = re.sub(r"-{2,}", "-", cleaned)return (cleaned or "huggingmess-proxy")[:63].rstrip("-")def derive_worker_name() -> str:3 unmodified linesspace_host = os.environ.get("SPACE_HOST", "").strip()if space_host:return slugify(f"{space_host.replace('.hf.space', '')}-proxy")return "huggingmess-proxy"def render_worker(secret_value: str, allowed_targets: list[str], allow_proxy_all: bool) -> str:12 unmodified lines131415161718192031 unmodified lines525354555657583 unmodified lines6263646566676812 unmodified linesfrom pathlib import PathAPI_BASE = "https://api.cloudflare.com/client/v4"ENV_FILE = Path("/tmp/huggingmes-cloudflare-proxy.env")ENV_FILE = Path("/tmp/huggingmes-cloudflare-proxy.env")DEFAULT_ALLOWED = ["api.telegram.org","discord.com",31 unmodified linesdef slugify(value: str) -> str:cleaned = re.sub(r"[^a-z0-9-]+", "-", value.lower()).strip("-")cleaned = re.sub(r"-{2,}", "-", cleaned)return (cleaned or "huggingmes-proxy")[:63].rstrip("-")def derive_worker_name() -> str:3 unmodified linesspace_host = os.environ.get("SPACE_HOST", "").strip()if space_host:return slugify(f"{space_host.replace('.hf.space', '')}-proxy")return "huggingmes-proxy"def render_worker(secret_value: str, allowed_targets: list[str], allow_proxy_all: bool) -> str:
123456789105 unmodified lines16171819202122services:huggingmess:build:context: .args:HERMES_AGENT_VERSION: ${HERMES_AGENT_VERSION:-latest}image: huggingmess:localports:- "7861:7861"environment:5 unmodified linesHF_TOKEN: ${HF_TOKEN:-}SPACE_HOST: ${SPACE_HOST:-localhost:7861}volumes:- huggingmess-data:/opt/datavolumes:huggingmess-data:123456789105 unmodified lines16171819202122services:huggingmes:build:context: .args:HERMES_AGENT_VERSION: ${HERMES_AGENT_VERSION:-latest}image: huggingmes:localports:- "7861:7861"environment:5 unmodified linesHF_TOKEN: ${HF_TOKEN:-}SPACE_HOST: ${SPACE_HOST:-localhost:7861}volumes:- huggingmes-data:/opt/datavolumes:huggingmes-data:
13 unmodified lines141516171819202122232429 unmodified lines5455565758596061 unmodified lines1221231241251261271289 unmodified lines138139140141142143144265 unmodified lines4104114124134144154164 unmodified lines42142242342442542642742811 unmodified lines4404414424434444454465 unmodified lines4524534544554564574584 unmodified lines46346446546646746846938 unmodified lines508509510511512513514126 unmodified lines64164264364464513 unmodified linesconst API_SERVER_KEY = process.env.API_SERVER_KEY || "";const APP_BASE = "/app";const LOGIN_PATH = "/login";const SESSION_COOKIE = "huggingmess_session";const SYNC_STATUS_FILE = "/tmp/huggingmess-sync-status.json";const CLOUDFLARE_KEEPALIVE_STATUS_FILE ="/tmp/huggingmess-cloudflare-keepalive-status.json";function canConnect(port, host = GATEWAY_HOST, timeoutMs = 600) {return new Promise((resolve) => {29 unmodified linesif (!API_SERVER_KEY) return "";return crypto.createHmac("sha256", API_SERVER_KEY).update("huggingmess-session-v1").digest("hex");}61 unmodified lines<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>HuggingMess Login</title><style>:root { color-scheme: dark; --bg:#10141f; --panel:#171d2b; --line:#293246; --text:#f4f7fb; --muted:#9aa7bd; --bad:#ef4444; --accent:#38bdf8; }* { box-sizing:border-box; }9 unmodified lines</head><body><main><h1>Open HuggingMess</h1><p>Enter the <code>GATEWAY_TOKEN</code> from your Space secrets.</p>${errorHtml}<form method="post" action="${LOGIN_PATH}">265 unmodified linesconst telegramDetail = data.telegram.configured? `${data.telegram.webhook ? "Webhook" : "Polling"}${data.telegram.proxy ? " via CF proxy" : ""}`: "Not configured";const backupDetail = data.backup?.message ? escapeHtml(data.backup.message) : "No status yet";const keepAliveDetail = keepaliveConfigured? `Pinging <code>${escapeHtml(data.keepalive.targetUrl || "/health")}</code>`: process.env.CLOUDFLARE_WORKERS_TOKEN4 unmodified linesconst tiles = [renderTile({title: "Gateway",value: toneBadge(data.gateway ? "Online" : "Offline", data.gateway ? "ok" : "off"),detail: data.gateway ? `API on port ${data.ports.gateway}` : `Unreachable`,tone: data.gateway ? "ok" : "off",meta: data.authConfigured ? "Protected" : "Unprotected",}),11 unmodified lines}),renderTile({title: "Telegram",value: toneBadge(data.telegram.configured ? "Configured" : "Disabled", telegramTone),detail: telegramDetail,tone: telegramTone,}),5 unmodified lines}),renderTile({title: "Keep Awake",value: toneBadge(keepaliveConfigured ? "CF Cron" : keepaliveStatus.toUpperCase(), keepAliveTone),detail: keepAliveDetail,tone: keepAliveTone,}),4 unmodified lines<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>HuggingMess</title><style>:root { color-scheme: dark; --bg:#08080f; --panel:#12111b; --panel2:#151421; --line:#26243a; --text:#f6f4ff; --muted:#7f7a9e; --soft:#b8b3d7; --good:#22c55e; --warn:#f5c542; --bad:#fb7185; --accent:#6557df; --accent2:#7c6cf2; }* { box-sizing:border-box; }38 unmodified lines<body><main><header><h1>HuggingMess</h1><div class="subtitle">Self-hosted - Hermes Agent</div></header><a class="hero-action" href="${APP_BASE}/" target="_blank" rel="noopener noreferrer">Open Hermes Agent -></a>126 unmodified lines});server.listen(PORT, "0.0.0.0", () => {console.log(`HuggingMess dashboard listening on 0.0.0.0:${PORT}`);});13 unmodified lines141516171819202122232429 unmodified lines5455565758596061 unmodified lines1221231241251261271289 unmodified lines138139140141142143144265 unmodified lines4104114124134144154164174184 unmodified lines42342442542642742842943043143243343443511 unmodified lines4474484494504514524534544554565 unmodified lines4624634644654664674684694704714 unmodified lines47647747847948048148238 unmodified lines521522523524525526527126 unmodified lines65465565665765813 unmodified linesconst API_SERVER_KEY = process.env.API_SERVER_KEY || "";const APP_BASE = "/app";const LOGIN_PATH = "/login";const SESSION_COOKIE = "huggingmes_session";const SYNC_STATUS_FILE = "/tmp/huggingmes-sync-status.json";const CLOUDFLARE_KEEPALIVE_STATUS_FILE ="/tmp/huggingmes-cloudflare-keepalive-status.json";function canConnect(port, host = GATEWAY_HOST, timeoutMs = 600) {return new Promise((resolve) => {29 unmodified linesif (!API_SERVER_KEY) return "";return crypto.createHmac("sha256", API_SERVER_KEY).update("huggingmes-session-v1").digest("hex");}61 unmodified lines<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>HuggingMes Login</title><style>:root { color-scheme: dark; --bg:#10141f; --panel:#171d2b; --line:#293246; --text:#f4f7fb; --muted:#9aa7bd; --bad:#ef4444; --accent:#38bdf8; }* { box-sizing:border-box; }9 unmodified lines</head><body><main><h1>Open HuggingMes</h1><p>Enter the <code>GATEWAY_TOKEN</code> from your Space secrets.</p>${errorHtml}<form method="post" action="${LOGIN_PATH}">265 unmodified linesconst telegramDetail = data.telegram.configured? `${data.telegram.webhook ? "Webhook" : "Polling"}${data.telegram.proxy ? " via CF proxy" : ""}`: "Not configured";const backupDetail = data.backup?.message? escapeHtml(data.backup.message): "No status yet";const keepAliveDetail = keepaliveConfigured? `Pinging <code>${escapeHtml(data.keepalive.targetUrl || "/health")}</code>`: process.env.CLOUDFLARE_WORKERS_TOKEN4 unmodified linesconst tiles = [renderTile({title: "Gateway",value: toneBadge(data.gateway ? "Online" : "Offline",data.gateway ? "ok" : "off",),detail: data.gateway? `API on port ${data.ports.gateway}`: `Unreachable`,tone: data.gateway ? "ok" : "off",meta: data.authConfigured ? "Protected" : "Unprotected",}),11 unmodified lines}),renderTile({title: "Telegram",value: toneBadge(data.telegram.configured ? "Configured" : "Disabled",telegramTone,),detail: telegramDetail,tone: telegramTone,}),5 unmodified lines}),renderTile({title: "Keep Awake",value: toneBadge(keepaliveConfigured ? "CF Cron" : keepaliveStatus.toUpperCase(),keepAliveTone,),detail: keepAliveDetail,tone: keepAliveTone,}),4 unmodified lines<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>HuggingMes</title><style>:root { color-scheme: dark; --bg:#08080f; --panel:#12111b; --panel2:#151421; --line:#26243a; --text:#f6f4ff; --muted:#7f7a9e; --soft:#b8b3d7; --good:#22c55e; --warn:#f5c542; --bad:#fb7185; --accent:#6557df; --accent2:#7c6cf2; }* { box-sizing:border-box; }38 unmodified lines<body><main><header><h1>HuggingMes</h1><div class="subtitle">Self-hosted - Hermes Agent</div></header><a class="hero-action" href="${APP_BASE}/" target="_blank" rel="noopener noreferrer">Open Hermes Agent -></a>126 unmodified lines});server.listen(PORT, "0.0.0.0", () => {console.log(`HuggingMes dashboard listening on 0.0.0.0:${PORT}`);});
1234516 unmodified lines22232425262728293031323334107 unmodified lines14214314414514614714888 unmodified lines237238239240241242243#!/usr/bin/env python3"""HuggingMess Hermes state backup via Hugging Face Datasets."""import hashlibimport json16 unmodified lineslogging.getLogger("huggingface_hub").setLevel(logging.ERROR)HERMES_HOME = Path(os.environ.get("HERMES_HOME", "/opt/data"))STATUS_FILE = Path("/tmp/huggingmess-sync-status.json")INTERVAL = int(os.environ.get("SYNC_INTERVAL", "180"))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()SPACE_AUTHOR_NAME = os.environ.get("SPACE_AUTHOR_NAME", "").strip()BACKUP_DATASET_NAME = os.environ.get("BACKUP_DATASET_NAME", "huggingmess-backup").strip()INCLUDE_ENV = os.environ.get("SYNC_INCLUDE_ENV", "").strip().lower() in {"1", "true", "yes"}MAX_FILE_SIZE_BYTES = int(os.environ.get("SYNC_MAX_FILE_BYTES", str(50 * 1024 * 1024)))107 unmodified linesdef create_snapshot_dir(source_root: Path) -> Path:staging_root = Path(tempfile.mkdtemp(prefix="huggingmess-sync-"))for path in sorted(source_root.rglob("*")):rel = path.relative_to(source_root)rel_posix = rel.as_posix()88 unmodified linesrepo_id=repo_id,repo_type="dataset",token=HF_TOKEN,commit_message=f"HuggingMess sync {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}",ignore_patterns=[".git/*", ".git"],)finally:1234516 unmodified lines22232425262728293031323334107 unmodified lines14214314414514614714888 unmodified lines237238239240241242243#!/usr/bin/env python3"""HuggingMes Hermes state backup via Hugging Face Datasets."""import hashlibimport json16 unmodified lineslogging.getLogger("huggingface_hub").setLevel(logging.ERROR)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"))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()SPACE_AUTHOR_NAME = os.environ.get("SPACE_AUTHOR_NAME", "").strip()BACKUP_DATASET_NAME = os.environ.get("BACKUP_DATASET_NAME", "huggingmes-backup").strip()INCLUDE_ENV = os.environ.get("SYNC_INCLUDE_ENV", "").strip().lower() in {"1", "true", "yes"}MAX_FILE_SIZE_BYTES = int(os.environ.get("SYNC_MAX_FILE_BYTES", str(50 * 1024 * 1024)))107 unmodified linesdef create_snapshot_dir(source_root: Path) -> Path:staging_root = Path(tempfile.mkdtemp(prefix="huggingmes-sync-"))for path in sorted(source_root.rglob("*")):rel = path.relative_to(source_root)rel_posix = rel.as_posix()88 unmodified linesrepo_id=repo_id,repo_type="dataset",token=HF_TOKEN,commit_message=f"HuggingMes sync {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}",ignore_patterns=[".git/*", ".git"],)finally:
3 unmodified lines456789101112131415161718192021224 unmodified lines2728293031323351 unmodified lines85868788899091182 unmodified lines27427527627727827928012 unmodified lines2932942952962972982993 unmodified linesumask 0077# ════════════════════════════════════════════════════════════════# HuggingMess — Hermes Gateway for HF Spaces# ════════════════════════════════════════════════════════════════# ── Startup Banner ──APP_DIR="${HUGGINGMESS_APP_DIR:-/opt/huggingmess}"HERMES_HOME="${HERMES_HOME:-/opt/data}"PUBLIC_PORT="${PORT:-7861}"GATEWAY_API_PORT="${API_SERVER_PORT:-8642}"DASHBOARD_PORT="${DASHBOARD_PORT:-9119}"TELEGRAM_WEBHOOK_PORT="${TELEGRAM_WEBHOOK_PORT:-8765}"SYNC_INTERVAL="${SYNC_INTERVAL:-180}"BACKUP_DATASET="${BACKUP_DATASET_NAME:-huggingmess-backup}"CF_PROXY_ENV_FILE="/tmp/huggingmess-cloudflare-proxy.env"export HERMES_HOMEexport API_SERVER_ENABLED="${API_SERVER_ENABLED:-true}"4 unmodified linesecho ""echo " ╔══════════════════════════════════════════╗"echo " ║ 💬 HuggingMess Hermes Gateway ║"echo " ╚══════════════════════════════════════════╝"echo ""51 unmodified linesfiif [ -n "${TELEGRAM_WEBHOOK_URL:-}" ] && [ -z "${TELEGRAM_WEBHOOK_SECRET:-}" ]; thenSECRET_FILE="$HERMES_HOME/.huggingmess-telegram-webhook-secret"if [ -f "$SECRET_FILE" ]; thenexport TELEGRAM_WEBHOOK_SECRETTELEGRAM_WEBHOOK_SECRET="$(cat "$SECRET_FILE")"182 unmodified lines# ── Trap SIGTERM for graceful shutdown ──graceful_shutdown() {echo "Shutting down HuggingMess..."if [ -n "${HF_TOKEN:-}" ]; thenpython3 "$APP_DIR/hermes-sync.py" sync-once || echo "Warning: shutdown sync failed."fi12 unmodified linesbody = json.dumps({"event": "restart","status": "success","message": "HuggingMess Hermes gateway has started.","model": os.environ.get("MODEL_FOR_CONFIG", ""),}).encode()req = urllib.request.Request(os.environ["WEBHOOK_URL"], data=body, method="POST", headers={"Content-Type": "application/json"})3 unmodified lines456789101112131415161718192021224 unmodified lines2728293031323351 unmodified lines85868788899091182 unmodified lines27427527627727827928012 unmodified lines2932942952962972982993 unmodified linesumask 0077# ════════════════════════════════════════════════════════════════# HuggingMes — Hermes Gateway for HF Spaces# ════════════════════════════════════════════════════════════════# ── Startup Banner ──APP_DIR="${HUGGINGMES_APP_DIR:-/opt/huggingmes}"HERMES_HOME="${HERMES_HOME:-/opt/data}"PUBLIC_PORT="${PORT:-7861}"GATEWAY_API_PORT="${API_SERVER_PORT:-8642}"DASHBOARD_PORT="${DASHBOARD_PORT:-9119}"TELEGRAM_WEBHOOK_PORT="${TELEGRAM_WEBHOOK_PORT:-8765}"SYNC_INTERVAL="${SYNC_INTERVAL:-180}"BACKUP_DATASET="${BACKUP_DATASET_NAME:-huggingmes-backup}"CF_PROXY_ENV_FILE="/tmp/huggingmes-cloudflare-proxy.env"export HERMES_HOMEexport API_SERVER_ENABLED="${API_SERVER_ENABLED:-true}"4 unmodified linesecho ""echo " ╔══════════════════════════════════════════╗"echo " ║ 💬 HuggingMes Hermes Gateway ║"echo " ╚══════════════════════════════════════════╝"echo ""51 unmodified linesfiif [ -n "${TELEGRAM_WEBHOOK_URL:-}" ] && [ -z "${TELEGRAM_WEBHOOK_SECRET:-}" ]; thenSECRET_FILE="$HERMES_HOME/.huggingmes-telegram-webhook-secret"if [ -f "$SECRET_FILE" ]; thenexport TELEGRAM_WEBHOOK_SECRETTELEGRAM_WEBHOOK_SECRET="$(cat "$SECRET_FILE")"182 unmodified lines# ── Trap SIGTERM for graceful shutdown ──graceful_shutdown() {echo "Shutting down HuggingMes..."if [ -n "${HF_TOKEN:-}" ]; thenpython3 "$APP_DIR/hermes-sync.py" sync-once || echo "Warning: shutdown sync failed."fi12 unmodified linesbody = json.dumps({"event": "restart","status": "success","message": "HuggingMes Hermes gateway has started.","model": os.environ.get("MODEL_FOR_CONFIG", ""),}).encode()req = urllib.request.Request(os.environ["WEBHOOK_URL"], data=body, method="POST", headers={"Content-Type": "application/json"})
.env.example+3-3
CHANGELOG.md+1-1
CONTRIBUTING.md+1-1
Dockerfile+12-12
README.md+10-10
SECURITY.md+1-1
cloudflare-keepalive-setup.py+4-4
cloudflare-proxy-setup.py+4-4
docker-compose.yml+4-4
health-server.js+27-14
hermes-sync.py+5-5
start.sh+8-8