| import os |
| import subprocess |
| import shutil |
| import sys |
|
|
| |
| os.environ["TELEGRAM_API_URL"] = "https://api.telegram.org/" |
| os.environ["LOCAL_BOT_API_URL"] = "https://api.telegram.org/" |
|
|
| home = os.path.expanduser("~") |
| hermes_dir = os.path.join(home, ".hermes") |
| os.makedirs(hermes_dir, exist_ok=True) |
|
|
| print("[1] Setting up configs and skills...") |
|
|
| |
| OR_KEY = os.getenv('OPENROUTER_API_KEY') |
| NV_KEY = os.getenv('NVIDIA_API_KEY') |
| TG_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN') |
| TG_USER = os.getenv('TELEGRAM_ALLOWED_USERS') or os.getenv('TELEGRAM_USER_ID') |
|
|
| if not TG_TOKEN or not TG_USER: |
| print("❌ ERROR: Main Telegram credentials missing!") |
| sys.exit(1) |
|
|
| TG_USER_STR = str(TG_USER).strip() |
|
|
| |
| with open(os.path.join(hermes_dir, ".env"), "w") as f: |
| f.write(f"OPENROUTER_API_KEY={OR_KEY}\n") |
| f.write(f"NVIDIA_API_KEY={NV_KEY}\n") |
| f.write(f"TELEGRAM_BOT_TOKEN={TG_TOKEN}\n") |
| f.write(f"TELEGRAM_ALLOWED_USERS={TG_USER_STR}\n") |
|
|
| |
| with open(os.path.join(hermes_dir, "config.yaml"), "w") as f: |
| f.write("""model: |
| provider: nvidia |
| model: meta/llama-3.1-405b-instruct |
| |
| providers: |
| nvidia: |
| base_url: "https://integrate.api.nvidia.com/v1" |
| api_key: "${NVIDIA_API_KEY}" |
| openrouter: |
| api_key: "${OPENROUTER_API_KEY}" |
| |
| terminal: |
| backend: local |
| |
| memory: |
| enabled: true |
| |
| display: |
| tool_progress: "off" |
| |
| compression: |
| enabled: true |
| threshold: 0.60 |
| """) |
|
|
| |
| skills_path = os.path.join(hermes_dir, "skills.md") |
| with open(skills_path, "w") as f: |
| f.write("""# Hermes Agent Skills |
| ## Core Instructions |
| - You are a helpful AI assistant with access to local terminal tools. |
| - ALWAYS use available tools if the user task requires it. |
| - Be concise and efficient. |
| |
| ## Core Behavior |
| - NEVER say "I cannot do this" or "I am just an AI". |
| - You have access to this Docker environment. |
| - You can create, edit, delete, and execute files via commands. |
| """) |
|
|
| print("✅ Config and Skills created successfully.") |
|
|
| |
| print("[2] Launching Hermes Telegram Gateway in Foreground...") |
| hermes_bin = shutil.which("hermes") or "/usr/local/bin/hermes" |
|
|
| sys.stdout.flush() |
| subprocess.run( |
| [hermes_bin, "gateway", "run"], |
| env=os.environ, |
| stdout=sys.stdout, |
| stderr=sys.stderr |
| ) |