2026-02-02 19:01:51 -08:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
"""
|
|
|
|
|
|
Hermes CLI - Main entry point.
|
|
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
hermes # Interactive chat (default)
|
|
|
|
|
|
hermes chat # Interactive chat
|
|
|
|
|
|
hermes gateway # Run gateway in foreground
|
|
|
|
|
|
hermes gateway start # Start gateway as service
|
|
|
|
|
|
hermes gateway stop # Stop gateway service
|
|
|
|
|
|
hermes gateway status # Show gateway status
|
|
|
|
|
|
hermes gateway install # Install gateway service
|
|
|
|
|
|
hermes gateway uninstall # Uninstall gateway service
|
|
|
|
|
|
hermes setup # Interactive setup wizard
|
2026-02-20 17:24:00 -08:00
|
|
|
|
hermes logout # Clear stored authentication
|
2026-02-02 19:01:51 -08:00
|
|
|
|
hermes status # Show status of all components
|
|
|
|
|
|
hermes cron # Manage cron jobs
|
|
|
|
|
|
hermes cron list # List cron jobs
|
2026-02-21 16:21:19 -08:00
|
|
|
|
hermes cron status # Check if cron scheduler is running
|
2026-02-02 19:01:51 -08:00
|
|
|
|
hermes doctor # Check configuration and dependencies
|
|
|
|
|
|
hermes version # Show version
|
2026-02-02 22:18:18 -08:00
|
|
|
|
hermes update # Update to latest version
|
|
|
|
|
|
hermes uninstall # Uninstall Hermes Agent
|
2026-02-02 19:01:51 -08:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
import os
|
|
|
|
|
|
import sys
|
|
|
|
|
|
from pathlib import Path
|
2026-02-25 23:00:10 -08:00
|
|
|
|
from typing import Optional
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
# Add project root to path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
|
|
|
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
|
|
|
2026-02-26 16:49:14 +11:00
|
|
|
|
# Load .env from ~/.hermes/.env first, then project root as dev fallback
|
2026-02-02 19:01:51 -08:00
|
|
|
|
from dotenv import load_dotenv
|
2026-02-26 16:49:14 +11:00
|
|
|
|
from hermes_cli.config import get_env_path, get_hermes_home
|
|
|
|
|
|
_user_env = get_env_path()
|
|
|
|
|
|
if _user_env.exists():
|
2026-02-25 15:20:42 -08:00
|
|
|
|
try:
|
2026-02-26 16:49:14 +11:00
|
|
|
|
load_dotenv(dotenv_path=_user_env, encoding="utf-8")
|
2026-02-25 15:20:42 -08:00
|
|
|
|
except UnicodeDecodeError:
|
2026-02-26 16:49:14 +11:00
|
|
|
|
load_dotenv(dotenv_path=_user_env, encoding="latin-1")
|
|
|
|
|
|
load_dotenv(dotenv_path=PROJECT_ROOT / '.env', override=False)
|
|
|
|
|
|
|
|
|
|
|
|
# Point mini-swe-agent at ~/.hermes/ so it shares our config
|
|
|
|
|
|
os.environ.setdefault("MSWEA_GLOBAL_CONFIG_DIR", str(get_hermes_home()))
|
|
|
|
|
|
os.environ.setdefault("MSWEA_SILENT_STARTUP", "1")
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-21 03:32:11 -08:00
|
|
|
|
import logging
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
from hermes_cli import __version__
|
2026-02-20 23:23:32 -08:00
|
|
|
|
from hermes_constants import OPENROUTER_BASE_URL
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-21 03:32:11 -08:00
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-22 02:16:11 -08:00
|
|
|
|
def _has_any_provider_configured() -> bool:
|
|
|
|
|
|
"""Check if at least one inference provider is usable."""
|
|
|
|
|
|
from hermes_cli.config import get_env_path, get_hermes_home
|
2026-02-25 18:20:38 -08:00
|
|
|
|
from hermes_cli.auth import get_auth_status
|
2026-02-22 02:16:11 -08:00
|
|
|
|
|
2026-02-26 19:56:24 -08:00
|
|
|
|
# Check env vars (may be set by .env or shell).
|
|
|
|
|
|
# OPENAI_BASE_URL alone counts — local models (vLLM, llama.cpp, etc.)
|
|
|
|
|
|
# often don't require an API key.
|
|
|
|
|
|
provider_env_vars = ("OPENROUTER_API_KEY", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_BASE_URL")
|
|
|
|
|
|
if any(os.getenv(v) for v in provider_env_vars):
|
2026-02-22 02:16:11 -08:00
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
# Check .env file for keys
|
|
|
|
|
|
env_file = get_env_path()
|
|
|
|
|
|
if env_file.exists():
|
|
|
|
|
|
try:
|
|
|
|
|
|
for line in env_file.read_text().splitlines():
|
|
|
|
|
|
line = line.strip()
|
|
|
|
|
|
if line.startswith("#") or "=" not in line:
|
|
|
|
|
|
continue
|
|
|
|
|
|
key, _, val = line.partition("=")
|
|
|
|
|
|
val = val.strip().strip("'\"")
|
2026-02-26 19:56:24 -08:00
|
|
|
|
if key.strip() in provider_env_vars and val:
|
2026-02-22 02:16:11 -08:00
|
|
|
|
return True
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Check for Nous Portal OAuth credentials
|
|
|
|
|
|
auth_file = get_hermes_home() / "auth.json"
|
|
|
|
|
|
if auth_file.exists():
|
|
|
|
|
|
try:
|
|
|
|
|
|
import json
|
|
|
|
|
|
auth = json.loads(auth_file.read_text())
|
|
|
|
|
|
active = auth.get("active_provider")
|
|
|
|
|
|
if active:
|
2026-02-25 18:20:38 -08:00
|
|
|
|
status = get_auth_status(active)
|
|
|
|
|
|
if status.get("logged_in"):
|
2026-02-22 02:16:11 -08:00
|
|
|
|
return True
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-25 23:00:10 -08:00
|
|
|
|
def _resolve_last_cli_session() -> Optional[str]:
|
|
|
|
|
|
"""Look up the most recent CLI session ID from SQLite. Returns None if unavailable."""
|
|
|
|
|
|
try:
|
|
|
|
|
|
from hermes_state import SessionDB
|
|
|
|
|
|
db = SessionDB()
|
|
|
|
|
|
sessions = db.search_sessions(source="cli", limit=1)
|
|
|
|
|
|
db.close()
|
|
|
|
|
|
if sessions:
|
|
|
|
|
|
return sessions[0]["id"]
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
def cmd_chat(args):
|
|
|
|
|
|
"""Run interactive chat CLI."""
|
2026-02-25 23:00:10 -08:00
|
|
|
|
# Resolve --continue into --resume with the latest CLI session
|
|
|
|
|
|
if getattr(args, "continue_last", False) and not getattr(args, "resume", None):
|
|
|
|
|
|
last_id = _resolve_last_cli_session()
|
|
|
|
|
|
if last_id:
|
|
|
|
|
|
args.resume = last_id
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("No previous CLI session found to continue.")
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
2026-02-22 02:16:11 -08:00
|
|
|
|
# First-run guard: check if any provider is configured before launching
|
|
|
|
|
|
if not _has_any_provider_configured():
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("It looks like Hermes isn't configured yet -- no API keys or providers found.")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" Run: hermes setup")
|
|
|
|
|
|
print()
|
|
|
|
|
|
try:
|
|
|
|
|
|
reply = input("Run setup now? [Y/n] ").strip().lower()
|
|
|
|
|
|
except (EOFError, KeyboardInterrupt):
|
|
|
|
|
|
reply = "n"
|
|
|
|
|
|
if reply in ("", "y", "yes"):
|
|
|
|
|
|
cmd_setup(args)
|
|
|
|
|
|
return
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("You can run 'hermes setup' at any time to configure.")
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
# Sync bundled skills on every CLI launch (fast -- skips unchanged skills)
|
|
|
|
|
|
try:
|
|
|
|
|
|
from tools.skills_sync import sync_skills
|
|
|
|
|
|
sync_skills(quiet=True)
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# Import and run the CLI
|
|
|
|
|
|
from cli import main as cli_main
|
|
|
|
|
|
|
|
|
|
|
|
# Build kwargs from args
|
|
|
|
|
|
kwargs = {
|
|
|
|
|
|
"model": args.model,
|
2026-02-20 17:24:00 -08:00
|
|
|
|
"provider": getattr(args, "provider", None),
|
2026-02-02 19:01:51 -08:00
|
|
|
|
"toolsets": args.toolsets,
|
|
|
|
|
|
"verbose": args.verbose,
|
|
|
|
|
|
"query": args.query,
|
2026-02-25 22:56:12 -08:00
|
|
|
|
"resume": getattr(args, "resume", None),
|
2026-02-02 19:01:51 -08:00
|
|
|
|
}
|
|
|
|
|
|
# Filter out None values
|
|
|
|
|
|
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
|
|
|
|
|
|
|
|
|
|
|
cli_main(**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_gateway(args):
|
|
|
|
|
|
"""Gateway management commands."""
|
|
|
|
|
|
from hermes_cli.gateway import gateway_command
|
|
|
|
|
|
gateway_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-25 21:04:36 -08:00
|
|
|
|
def cmd_whatsapp(args):
|
2026-03-02 17:51:33 -08:00
|
|
|
|
"""Set up WhatsApp: choose mode, configure, install bridge, pair via QR."""
|
2026-02-25 21:04:36 -08:00
|
|
|
|
import os
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
from hermes_cli.config import get_env_value, save_env_value
|
|
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("⚕ WhatsApp Setup")
|
|
|
|
|
|
print("=" * 50)
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 1: Choose mode ──────────────────────────────────────────────
|
|
|
|
|
|
current_mode = get_env_value("WHATSAPP_MODE") or ""
|
|
|
|
|
|
if not current_mode:
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("How will you use WhatsApp with Hermes?")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" 1. Separate bot number (recommended)")
|
|
|
|
|
|
print(" People message the bot's number directly — cleanest experience.")
|
|
|
|
|
|
print(" Requires a second phone number with WhatsApp installed on a device.")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" 2. Personal number (self-chat)")
|
|
|
|
|
|
print(" You message yourself to talk to the agent.")
|
|
|
|
|
|
print(" Quick to set up, but the UX is less intuitive.")
|
|
|
|
|
|
print()
|
|
|
|
|
|
try:
|
|
|
|
|
|
choice = input(" Choose [1/2]: ").strip()
|
|
|
|
|
|
except (EOFError, KeyboardInterrupt):
|
|
|
|
|
|
print("\nSetup cancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if choice == "1":
|
|
|
|
|
|
save_env_value("WHATSAPP_MODE", "bot")
|
|
|
|
|
|
wa_mode = "bot"
|
|
|
|
|
|
print(" ✓ Mode: separate bot number")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" ┌─────────────────────────────────────────────────┐")
|
|
|
|
|
|
print(" │ Getting a second number for the bot: │")
|
|
|
|
|
|
print(" │ │")
|
|
|
|
|
|
print(" │ Easiest: Install WhatsApp Business (free app) │")
|
|
|
|
|
|
print(" │ on your phone with a second number: │")
|
|
|
|
|
|
print(" │ • Dual-SIM: use your 2nd SIM slot │")
|
|
|
|
|
|
print(" │ • Google Voice: free US number (voice.google) │")
|
|
|
|
|
|
print(" │ • Prepaid SIM: $3-10, verify once │")
|
|
|
|
|
|
print(" │ │")
|
|
|
|
|
|
print(" │ WhatsApp Business runs alongside your personal │")
|
|
|
|
|
|
print(" │ WhatsApp — no second phone needed. │")
|
|
|
|
|
|
print(" └─────────────────────────────────────────────────┘")
|
|
|
|
|
|
else:
|
|
|
|
|
|
save_env_value("WHATSAPP_MODE", "self-chat")
|
|
|
|
|
|
wa_mode = "self-chat"
|
|
|
|
|
|
print(" ✓ Mode: personal number (self-chat)")
|
|
|
|
|
|
else:
|
|
|
|
|
|
wa_mode = current_mode
|
|
|
|
|
|
mode_label = "separate bot number" if wa_mode == "bot" else "personal number (self-chat)"
|
|
|
|
|
|
print(f"\n✓ Mode: {mode_label}")
|
|
|
|
|
|
|
|
|
|
|
|
# ── Step 2: Enable WhatsApp ──────────────────────────────────────────
|
|
|
|
|
|
print()
|
2026-02-25 21:04:36 -08:00
|
|
|
|
current = get_env_value("WHATSAPP_ENABLED")
|
|
|
|
|
|
if current and current.lower() == "true":
|
|
|
|
|
|
print("✓ WhatsApp is already enabled")
|
|
|
|
|
|
else:
|
|
|
|
|
|
save_env_value("WHATSAPP_ENABLED", "true")
|
|
|
|
|
|
print("✓ WhatsApp enabled")
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 3: Allowed users ────────────────────────────────────────────
|
2026-02-25 21:04:36 -08:00
|
|
|
|
current_users = get_env_value("WHATSAPP_ALLOWED_USERS") or ""
|
|
|
|
|
|
if current_users:
|
|
|
|
|
|
print(f"✓ Allowed users: {current_users}")
|
2026-03-02 17:51:33 -08:00
|
|
|
|
try:
|
|
|
|
|
|
response = input("\n Update allowed users? [y/N] ").strip()
|
|
|
|
|
|
except (EOFError, KeyboardInterrupt):
|
|
|
|
|
|
response = "n"
|
2026-02-25 21:04:36 -08:00
|
|
|
|
if response.lower() in ("y", "yes"):
|
2026-03-02 17:51:33 -08:00
|
|
|
|
if wa_mode == "bot":
|
|
|
|
|
|
phone = input(" Phone numbers that can message the bot (comma-separated): ").strip()
|
|
|
|
|
|
else:
|
|
|
|
|
|
phone = input(" Your phone number (e.g. 15551234567): ").strip()
|
2026-02-25 21:04:36 -08:00
|
|
|
|
if phone:
|
|
|
|
|
|
save_env_value("WHATSAPP_ALLOWED_USERS", phone.replace(" ", ""))
|
|
|
|
|
|
print(f" ✓ Updated to: {phone}")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print()
|
2026-03-02 17:51:33 -08:00
|
|
|
|
if wa_mode == "bot":
|
|
|
|
|
|
print(" Who should be allowed to message the bot?")
|
|
|
|
|
|
phone = input(" Phone numbers (comma-separated, or * for anyone): ").strip()
|
|
|
|
|
|
else:
|
|
|
|
|
|
phone = input(" Your phone number (e.g. 15551234567): ").strip()
|
2026-02-25 21:04:36 -08:00
|
|
|
|
if phone:
|
|
|
|
|
|
save_env_value("WHATSAPP_ALLOWED_USERS", phone.replace(" ", ""))
|
|
|
|
|
|
print(f" ✓ Allowed users set: {phone}")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(" ⚠ No allowlist — the agent will respond to ALL incoming messages")
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 4: Install bridge dependencies ──────────────────────────────
|
2026-02-25 21:04:36 -08:00
|
|
|
|
project_root = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
bridge_dir = project_root / "scripts" / "whatsapp-bridge"
|
|
|
|
|
|
bridge_script = bridge_dir / "bridge.js"
|
|
|
|
|
|
|
|
|
|
|
|
if not bridge_script.exists():
|
|
|
|
|
|
print(f"\n✗ Bridge script not found at {bridge_script}")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if not (bridge_dir / "node_modules").exists():
|
|
|
|
|
|
print("\n→ Installing WhatsApp bridge dependencies...")
|
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
|
["npm", "install"],
|
|
|
|
|
|
cwd=str(bridge_dir),
|
|
|
|
|
|
capture_output=True,
|
|
|
|
|
|
text=True,
|
|
|
|
|
|
timeout=120,
|
|
|
|
|
|
)
|
|
|
|
|
|
if result.returncode != 0:
|
|
|
|
|
|
print(f" ✗ npm install failed: {result.stderr}")
|
|
|
|
|
|
return
|
|
|
|
|
|
print(" ✓ Dependencies installed")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("✓ Bridge dependencies already installed")
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 5: Check for existing session ───────────────────────────────
|
2026-02-25 21:04:36 -08:00
|
|
|
|
session_dir = Path.home() / ".hermes" / "whatsapp" / "session"
|
|
|
|
|
|
session_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
if (session_dir / "creds.json").exists():
|
|
|
|
|
|
print("✓ Existing WhatsApp session found")
|
2026-03-02 17:51:33 -08:00
|
|
|
|
try:
|
|
|
|
|
|
response = input("\n Re-pair? This will clear the existing session. [y/N] ").strip()
|
|
|
|
|
|
except (EOFError, KeyboardInterrupt):
|
|
|
|
|
|
response = "n"
|
2026-02-25 21:04:36 -08:00
|
|
|
|
if response.lower() in ("y", "yes"):
|
|
|
|
|
|
import shutil
|
|
|
|
|
|
shutil.rmtree(session_dir, ignore_errors=True)
|
|
|
|
|
|
session_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
print(" ✓ Session cleared")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("\n✓ WhatsApp is configured and paired!")
|
|
|
|
|
|
print(" Start the gateway with: hermes gateway")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 6: QR code pairing ──────────────────────────────────────────
|
2026-02-25 21:04:36 -08:00
|
|
|
|
print()
|
|
|
|
|
|
print("─" * 50)
|
2026-03-02 17:51:33 -08:00
|
|
|
|
if wa_mode == "bot":
|
|
|
|
|
|
print("📱 Open WhatsApp (or WhatsApp Business) on the")
|
|
|
|
|
|
print(" phone with the BOT's number, then scan:")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("📱 Open WhatsApp on your phone, then scan:")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" Settings → Linked Devices → Link a Device")
|
2026-02-25 21:04:36 -08:00
|
|
|
|
print("─" * 50)
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
subprocess.run(
|
|
|
|
|
|
["node", str(bridge_script), "--pair-only", "--session", str(session_dir)],
|
|
|
|
|
|
cwd=str(bridge_dir),
|
|
|
|
|
|
)
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
2026-03-02 17:51:33 -08:00
|
|
|
|
# ── Step 7: Post-pairing ─────────────────────────────────────────────
|
2026-02-25 21:04:36 -08:00
|
|
|
|
print()
|
|
|
|
|
|
if (session_dir / "creds.json").exists():
|
|
|
|
|
|
print("✓ WhatsApp paired successfully!")
|
|
|
|
|
|
print()
|
2026-03-02 17:51:33 -08:00
|
|
|
|
if wa_mode == "bot":
|
|
|
|
|
|
print(" Next steps:")
|
|
|
|
|
|
print(" 1. Start the gateway: hermes gateway")
|
|
|
|
|
|
print(" 2. Send a message to the bot's WhatsApp number")
|
|
|
|
|
|
print(" 3. The agent will reply automatically")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" Tip: Agent responses are prefixed with '⚕ Hermes Agent'")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(" Next steps:")
|
|
|
|
|
|
print(" 1. Start the gateway: hermes gateway")
|
|
|
|
|
|
print(" 2. Open WhatsApp → Message Yourself")
|
|
|
|
|
|
print(" 3. Type a message — the agent will reply")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" Tip: Agent responses are prefixed with '⚕ Hermes Agent'")
|
|
|
|
|
|
print(" so you can tell them apart from your own messages.")
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(" Or install as a service: hermes gateway install")
|
2026-02-25 21:04:36 -08:00
|
|
|
|
else:
|
|
|
|
|
|
print("⚠ Pairing may not have completed. Run 'hermes whatsapp' to try again.")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
def cmd_setup(args):
|
|
|
|
|
|
"""Interactive setup wizard."""
|
|
|
|
|
|
from hermes_cli.setup import run_setup_wizard
|
|
|
|
|
|
run_setup_wizard(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-20 17:52:46 -08:00
|
|
|
|
def cmd_model(args):
|
|
|
|
|
|
"""Select default model — starts with provider selection, then model picker."""
|
|
|
|
|
|
from hermes_cli.auth import (
|
|
|
|
|
|
resolve_provider, get_provider_auth_state, PROVIDER_REGISTRY,
|
|
|
|
|
|
_prompt_model_selection, _save_model_choice, _update_config_for_provider,
|
|
|
|
|
|
resolve_nous_runtime_credentials, fetch_nous_models, AuthError, format_auth_error,
|
2026-02-25 18:20:38 -08:00
|
|
|
|
_login_nous,
|
2026-02-20 17:52:46 -08:00
|
|
|
|
)
|
|
|
|
|
|
from hermes_cli.config import load_config, save_config, get_env_value, save_env_value
|
|
|
|
|
|
|
|
|
|
|
|
config = load_config()
|
|
|
|
|
|
current_model = config.get("model")
|
|
|
|
|
|
if isinstance(current_model, dict):
|
|
|
|
|
|
current_model = current_model.get("default", "")
|
|
|
|
|
|
current_model = current_model or "(not set)"
|
|
|
|
|
|
|
2026-02-20 18:17:55 -08:00
|
|
|
|
# Read effective provider the same way the CLI does at startup:
|
|
|
|
|
|
# config.yaml model.provider > env var > auto-detect
|
|
|
|
|
|
import os
|
|
|
|
|
|
config_provider = None
|
|
|
|
|
|
model_cfg = config.get("model")
|
|
|
|
|
|
if isinstance(model_cfg, dict):
|
|
|
|
|
|
config_provider = model_cfg.get("provider")
|
|
|
|
|
|
|
|
|
|
|
|
effective_provider = (
|
|
|
|
|
|
os.getenv("HERMES_INFERENCE_PROVIDER")
|
|
|
|
|
|
or config_provider
|
|
|
|
|
|
or "auto"
|
|
|
|
|
|
)
|
2026-02-25 18:20:38 -08:00
|
|
|
|
try:
|
|
|
|
|
|
active = resolve_provider(effective_provider)
|
|
|
|
|
|
except AuthError as exc:
|
|
|
|
|
|
warning = format_auth_error(exc)
|
|
|
|
|
|
print(f"Warning: {warning} Falling back to auto provider detection.")
|
|
|
|
|
|
active = resolve_provider("auto")
|
2026-02-20 18:17:55 -08:00
|
|
|
|
|
|
|
|
|
|
# Detect custom endpoint
|
|
|
|
|
|
if active == "openrouter" and get_env_value("OPENAI_BASE_URL"):
|
|
|
|
|
|
active = "custom"
|
2026-02-20 17:52:46 -08:00
|
|
|
|
|
|
|
|
|
|
provider_labels = {
|
|
|
|
|
|
"openrouter": "OpenRouter",
|
|
|
|
|
|
"nous": "Nous Portal",
|
2026-02-25 18:20:38 -08:00
|
|
|
|
"openai-codex": "OpenAI Codex",
|
2026-02-20 18:17:55 -08:00
|
|
|
|
"custom": "Custom endpoint",
|
2026-02-20 17:52:46 -08:00
|
|
|
|
}
|
2026-02-20 18:17:55 -08:00
|
|
|
|
active_label = provider_labels.get(active, active)
|
2026-02-20 17:52:46 -08:00
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
print(f" Current model: {current_model}")
|
|
|
|
|
|
print(f" Active provider: {active_label}")
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
# Step 1: Provider selection — put active provider first with marker
|
|
|
|
|
|
providers = [
|
|
|
|
|
|
("openrouter", "OpenRouter (100+ models, pay-per-use)"),
|
|
|
|
|
|
("nous", "Nous Portal (Nous Research subscription)"),
|
2026-02-25 18:25:15 -08:00
|
|
|
|
("openai-codex", "OpenAI Codex"),
|
2026-02-20 17:52:46 -08:00
|
|
|
|
("custom", "Custom endpoint (self-hosted / VLLM / etc.)"),
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# Reorder so the active provider is at the top
|
2026-02-25 18:20:38 -08:00
|
|
|
|
active_key = active if active in ("openrouter", "nous", "openai-codex") else "custom"
|
2026-02-20 17:52:46 -08:00
|
|
|
|
ordered = []
|
|
|
|
|
|
for key, label in providers:
|
|
|
|
|
|
if key == active_key:
|
|
|
|
|
|
ordered.insert(0, (key, f"{label} ← currently active"))
|
|
|
|
|
|
else:
|
|
|
|
|
|
ordered.append((key, label))
|
|
|
|
|
|
ordered.append(("cancel", "Cancel"))
|
|
|
|
|
|
|
|
|
|
|
|
provider_idx = _prompt_provider_choice([label for _, label in ordered])
|
|
|
|
|
|
if provider_idx is None or ordered[provider_idx][0] == "cancel":
|
|
|
|
|
|
print("No change.")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
selected_provider = ordered[provider_idx][0]
|
|
|
|
|
|
|
|
|
|
|
|
# Step 2: Provider-specific setup + model selection
|
|
|
|
|
|
if selected_provider == "openrouter":
|
|
|
|
|
|
_model_flow_openrouter(config, current_model)
|
|
|
|
|
|
elif selected_provider == "nous":
|
|
|
|
|
|
_model_flow_nous(config, current_model)
|
2026-02-25 18:20:38 -08:00
|
|
|
|
elif selected_provider == "openai-codex":
|
|
|
|
|
|
_model_flow_openai_codex(config, current_model)
|
2026-02-20 17:52:46 -08:00
|
|
|
|
elif selected_provider == "custom":
|
|
|
|
|
|
_model_flow_custom(config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _prompt_provider_choice(choices):
|
|
|
|
|
|
"""Show provider selection menu. Returns index or None."""
|
|
|
|
|
|
try:
|
|
|
|
|
|
from simple_term_menu import TerminalMenu
|
|
|
|
|
|
menu_items = [f" {c}" for c in choices]
|
|
|
|
|
|
menu = TerminalMenu(
|
|
|
|
|
|
menu_items, cursor_index=0,
|
|
|
|
|
|
menu_cursor="-> ", menu_cursor_style=("fg_green", "bold"),
|
|
|
|
|
|
menu_highlight_style=("fg_green",),
|
|
|
|
|
|
cycle_cursor=True, clear_screen=False,
|
|
|
|
|
|
title="Select provider:",
|
|
|
|
|
|
)
|
|
|
|
|
|
idx = menu.show()
|
|
|
|
|
|
print()
|
|
|
|
|
|
return idx
|
2026-02-25 14:10:54 -08:00
|
|
|
|
except (ImportError, NotImplementedError):
|
2026-02-20 17:52:46 -08:00
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Fallback: numbered list
|
|
|
|
|
|
print("Select provider:")
|
|
|
|
|
|
for i, c in enumerate(choices, 1):
|
|
|
|
|
|
print(f" {i}. {c}")
|
|
|
|
|
|
print()
|
|
|
|
|
|
while True:
|
|
|
|
|
|
try:
|
|
|
|
|
|
val = input(f"Choice [1-{len(choices)}]: ").strip()
|
|
|
|
|
|
if not val:
|
|
|
|
|
|
return None
|
|
|
|
|
|
idx = int(val) - 1
|
|
|
|
|
|
if 0 <= idx < len(choices):
|
|
|
|
|
|
return idx
|
|
|
|
|
|
print(f"Please enter 1-{len(choices)}")
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
print("Please enter a number")
|
|
|
|
|
|
except (KeyboardInterrupt, EOFError):
|
|
|
|
|
|
print()
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _model_flow_openrouter(config, current_model=""):
|
|
|
|
|
|
"""OpenRouter provider: ensure API key, then pick model."""
|
2026-02-20 18:17:55 -08:00
|
|
|
|
from hermes_cli.auth import _prompt_model_selection, _save_model_choice, deactivate_provider
|
2026-02-20 17:52:46 -08:00
|
|
|
|
from hermes_cli.config import get_env_value, save_env_value
|
|
|
|
|
|
|
|
|
|
|
|
api_key = get_env_value("OPENROUTER_API_KEY")
|
|
|
|
|
|
if not api_key:
|
|
|
|
|
|
print("No OpenRouter API key configured.")
|
|
|
|
|
|
print("Get one at: https://openrouter.ai/keys")
|
|
|
|
|
|
print()
|
|
|
|
|
|
try:
|
|
|
|
|
|
key = input("OpenRouter API key (or Enter to cancel): ").strip()
|
|
|
|
|
|
except (KeyboardInterrupt, EOFError):
|
|
|
|
|
|
print()
|
|
|
|
|
|
return
|
|
|
|
|
|
if not key:
|
|
|
|
|
|
print("Cancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
save_env_value("OPENROUTER_API_KEY", key)
|
|
|
|
|
|
print("API key saved.")
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
2026-02-22 02:16:11 -08:00
|
|
|
|
from hermes_cli.models import model_ids
|
|
|
|
|
|
openrouter_models = model_ids()
|
2026-02-20 17:52:46 -08:00
|
|
|
|
|
2026-02-22 02:16:11 -08:00
|
|
|
|
selected = _prompt_model_selection(openrouter_models, current_model=current_model)
|
2026-02-20 17:52:46 -08:00
|
|
|
|
if selected:
|
|
|
|
|
|
# Clear any custom endpoint and set provider to openrouter
|
|
|
|
|
|
if get_env_value("OPENAI_BASE_URL"):
|
|
|
|
|
|
save_env_value("OPENAI_BASE_URL", "")
|
|
|
|
|
|
save_env_value("OPENAI_API_KEY", "")
|
|
|
|
|
|
_save_model_choice(selected)
|
2026-02-20 18:17:55 -08:00
|
|
|
|
|
|
|
|
|
|
# Update config provider and deactivate any OAuth provider
|
2026-02-20 17:52:46 -08:00
|
|
|
|
from hermes_cli.config import load_config, save_config
|
|
|
|
|
|
cfg = load_config()
|
|
|
|
|
|
model = cfg.get("model")
|
|
|
|
|
|
if isinstance(model, dict):
|
|
|
|
|
|
model["provider"] = "openrouter"
|
2026-02-20 23:23:32 -08:00
|
|
|
|
model["base_url"] = OPENROUTER_BASE_URL
|
2026-02-20 17:52:46 -08:00
|
|
|
|
save_config(cfg)
|
2026-02-20 18:17:55 -08:00
|
|
|
|
deactivate_provider()
|
2026-02-20 17:52:46 -08:00
|
|
|
|
print(f"Default model set to: {selected} (via OpenRouter)")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("No change.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _model_flow_nous(config, current_model=""):
|
|
|
|
|
|
"""Nous Portal provider: ensure logged in, then pick model."""
|
|
|
|
|
|
from hermes_cli.auth import (
|
|
|
|
|
|
get_provider_auth_state, _prompt_model_selection, _save_model_choice,
|
2026-02-20 18:17:55 -08:00
|
|
|
|
_update_config_for_provider, resolve_nous_runtime_credentials,
|
|
|
|
|
|
fetch_nous_models, AuthError, format_auth_error,
|
|
|
|
|
|
_login_nous, PROVIDER_REGISTRY,
|
2026-02-20 17:52:46 -08:00
|
|
|
|
)
|
2026-02-20 18:17:55 -08:00
|
|
|
|
from hermes_cli.config import get_env_value, save_env_value
|
2026-02-20 17:52:46 -08:00
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
state = get_provider_auth_state("nous")
|
|
|
|
|
|
if not state or not state.get("access_token"):
|
|
|
|
|
|
print("Not logged into Nous Portal. Starting login...")
|
|
|
|
|
|
print()
|
|
|
|
|
|
try:
|
|
|
|
|
|
mock_args = argparse.Namespace(
|
|
|
|
|
|
portal_url=None, inference_url=None, client_id=None,
|
|
|
|
|
|
scope=None, no_browser=False, timeout=15.0,
|
|
|
|
|
|
ca_bundle=None, insecure=False,
|
|
|
|
|
|
)
|
|
|
|
|
|
_login_nous(mock_args, PROVIDER_REGISTRY["nous"])
|
|
|
|
|
|
except SystemExit:
|
|
|
|
|
|
print("Login cancelled or failed.")
|
|
|
|
|
|
return
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
print(f"Login failed: {exc}")
|
|
|
|
|
|
return
|
2026-02-20 18:17:55 -08:00
|
|
|
|
# login_nous already handles model selection + config update
|
2026-02-20 17:52:46 -08:00
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Already logged in — fetch models and select
|
|
|
|
|
|
print("Fetching models from Nous Portal...")
|
|
|
|
|
|
try:
|
|
|
|
|
|
creds = resolve_nous_runtime_credentials(min_key_ttl_seconds=5 * 60)
|
|
|
|
|
|
model_ids = fetch_nous_models(
|
|
|
|
|
|
inference_base_url=creds.get("base_url", ""),
|
|
|
|
|
|
api_key=creds.get("api_key", ""),
|
|
|
|
|
|
)
|
|
|
|
|
|
except Exception as exc:
|
2026-03-01 20:20:30 -08:00
|
|
|
|
relogin = isinstance(exc, AuthError) and exc.relogin_required
|
2026-02-20 17:52:46 -08:00
|
|
|
|
msg = format_auth_error(exc) if isinstance(exc, AuthError) else str(exc)
|
2026-03-01 20:20:30 -08:00
|
|
|
|
if relogin:
|
|
|
|
|
|
print(f"Session expired: {msg}")
|
|
|
|
|
|
print("Re-authenticating with Nous Portal...\n")
|
|
|
|
|
|
try:
|
|
|
|
|
|
mock_args = argparse.Namespace(
|
|
|
|
|
|
portal_url=None, inference_url=None, client_id=None,
|
|
|
|
|
|
scope=None, no_browser=False, timeout=15.0,
|
|
|
|
|
|
ca_bundle=None, insecure=False,
|
|
|
|
|
|
)
|
|
|
|
|
|
_login_nous(mock_args, PROVIDER_REGISTRY["nous"])
|
|
|
|
|
|
except Exception as login_exc:
|
|
|
|
|
|
print(f"Re-login failed: {login_exc}")
|
|
|
|
|
|
return
|
2026-02-20 17:52:46 -08:00
|
|
|
|
print(f"Could not fetch models: {msg}")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if not model_ids:
|
|
|
|
|
|
print("No models returned by the inference API.")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
selected = _prompt_model_selection(model_ids, current_model=current_model)
|
|
|
|
|
|
if selected:
|
|
|
|
|
|
_save_model_choice(selected)
|
2026-02-20 18:17:55 -08:00
|
|
|
|
# Reactivate Nous as the provider and update config
|
|
|
|
|
|
inference_url = creds.get("base_url", "")
|
|
|
|
|
|
_update_config_for_provider("nous", inference_url)
|
|
|
|
|
|
# Clear any custom endpoint that might conflict
|
|
|
|
|
|
if get_env_value("OPENAI_BASE_URL"):
|
|
|
|
|
|
save_env_value("OPENAI_BASE_URL", "")
|
|
|
|
|
|
save_env_value("OPENAI_API_KEY", "")
|
2026-02-20 17:52:46 -08:00
|
|
|
|
print(f"Default model set to: {selected} (via Nous Portal)")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("No change.")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-25 18:20:38 -08:00
|
|
|
|
def _model_flow_openai_codex(config, current_model=""):
|
|
|
|
|
|
"""OpenAI Codex provider: ensure logged in, then pick model."""
|
|
|
|
|
|
from hermes_cli.auth import (
|
|
|
|
|
|
get_codex_auth_status, _prompt_model_selection, _save_model_choice,
|
|
|
|
|
|
_update_config_for_provider, _login_openai_codex,
|
|
|
|
|
|
PROVIDER_REGISTRY, DEFAULT_CODEX_BASE_URL,
|
|
|
|
|
|
)
|
2026-02-25 19:27:54 -08:00
|
|
|
|
from hermes_cli.codex_models import get_codex_model_ids
|
2026-02-25 18:20:38 -08:00
|
|
|
|
from hermes_cli.config import get_env_value, save_env_value
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
status = get_codex_auth_status()
|
|
|
|
|
|
if not status.get("logged_in"):
|
|
|
|
|
|
print("Not logged into OpenAI Codex. Starting login...")
|
|
|
|
|
|
print()
|
|
|
|
|
|
try:
|
|
|
|
|
|
mock_args = argparse.Namespace()
|
|
|
|
|
|
_login_openai_codex(mock_args, PROVIDER_REGISTRY["openai-codex"])
|
|
|
|
|
|
except SystemExit:
|
|
|
|
|
|
print("Login cancelled or failed.")
|
|
|
|
|
|
return
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
print(f"Login failed: {exc}")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-02-28 21:47:51 -08:00
|
|
|
|
_codex_token = None
|
|
|
|
|
|
try:
|
|
|
|
|
|
from hermes_cli.auth import resolve_codex_runtime_credentials
|
|
|
|
|
|
_codex_creds = resolve_codex_runtime_credentials()
|
|
|
|
|
|
_codex_token = _codex_creds.get("api_key")
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
codex_models = get_codex_model_ids(access_token=_codex_token)
|
2026-02-25 18:20:38 -08:00
|
|
|
|
|
|
|
|
|
|
selected = _prompt_model_selection(codex_models, current_model=current_model)
|
|
|
|
|
|
if selected:
|
|
|
|
|
|
_save_model_choice(selected)
|
|
|
|
|
|
_update_config_for_provider("openai-codex", DEFAULT_CODEX_BASE_URL)
|
|
|
|
|
|
# Clear custom endpoint env vars that would otherwise override Codex.
|
|
|
|
|
|
if get_env_value("OPENAI_BASE_URL"):
|
|
|
|
|
|
save_env_value("OPENAI_BASE_URL", "")
|
|
|
|
|
|
save_env_value("OPENAI_API_KEY", "")
|
|
|
|
|
|
print(f"Default model set to: {selected} (via OpenAI Codex)")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("No change.")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-20 17:52:46 -08:00
|
|
|
|
def _model_flow_custom(config):
|
|
|
|
|
|
"""Custom endpoint: collect URL, API key, and model name."""
|
2026-02-20 18:17:55 -08:00
|
|
|
|
from hermes_cli.auth import _save_model_choice, deactivate_provider
|
2026-02-20 17:52:46 -08:00
|
|
|
|
from hermes_cli.config import get_env_value, save_env_value, load_config, save_config
|
|
|
|
|
|
|
|
|
|
|
|
current_url = get_env_value("OPENAI_BASE_URL") or ""
|
|
|
|
|
|
current_key = get_env_value("OPENAI_API_KEY") or ""
|
|
|
|
|
|
|
|
|
|
|
|
print("Custom OpenAI-compatible endpoint configuration:")
|
|
|
|
|
|
if current_url:
|
|
|
|
|
|
print(f" Current URL: {current_url}")
|
|
|
|
|
|
if current_key:
|
|
|
|
|
|
print(f" Current key: {current_key[:8]}...")
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
base_url = input(f"API base URL [{current_url or 'e.g. https://api.example.com/v1'}]: ").strip()
|
|
|
|
|
|
api_key = input(f"API key [{current_key[:8] + '...' if current_key else 'optional'}]: ").strip()
|
|
|
|
|
|
model_name = input("Model name (e.g. gpt-4, llama-3-70b): ").strip()
|
|
|
|
|
|
except (KeyboardInterrupt, EOFError):
|
|
|
|
|
|
print("\nCancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if not base_url and not current_url:
|
|
|
|
|
|
print("No URL provided. Cancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Validate URL format
|
|
|
|
|
|
effective_url = base_url or current_url
|
|
|
|
|
|
if not effective_url.startswith(("http://", "https://")):
|
|
|
|
|
|
print(f"Invalid URL: {effective_url} (must start with http:// or https://)")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if base_url:
|
|
|
|
|
|
save_env_value("OPENAI_BASE_URL", base_url)
|
|
|
|
|
|
if api_key:
|
|
|
|
|
|
save_env_value("OPENAI_API_KEY", api_key)
|
|
|
|
|
|
|
|
|
|
|
|
if model_name:
|
|
|
|
|
|
_save_model_choice(model_name)
|
|
|
|
|
|
|
2026-02-20 18:17:55 -08:00
|
|
|
|
# Update config and deactivate any OAuth provider
|
2026-02-20 17:52:46 -08:00
|
|
|
|
cfg = load_config()
|
|
|
|
|
|
model = cfg.get("model")
|
|
|
|
|
|
if isinstance(model, dict):
|
|
|
|
|
|
model["provider"] = "auto"
|
|
|
|
|
|
model["base_url"] = effective_url
|
|
|
|
|
|
save_config(cfg)
|
2026-02-20 18:17:55 -08:00
|
|
|
|
deactivate_provider()
|
2026-02-20 17:52:46 -08:00
|
|
|
|
|
|
|
|
|
|
print(f"Default model set to: {model_name} (via {effective_url})")
|
|
|
|
|
|
else:
|
2026-02-20 18:17:55 -08:00
|
|
|
|
if base_url or api_key:
|
|
|
|
|
|
deactivate_provider()
|
2026-02-20 17:52:46 -08:00
|
|
|
|
print("Endpoint saved. Use `/model` in chat or `hermes model` to set a model.")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-20 17:24:00 -08:00
|
|
|
|
def cmd_login(args):
|
|
|
|
|
|
"""Authenticate Hermes CLI with a provider."""
|
|
|
|
|
|
from hermes_cli.auth import login_command
|
|
|
|
|
|
login_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_logout(args):
|
|
|
|
|
|
"""Clear provider authentication."""
|
|
|
|
|
|
from hermes_cli.auth import logout_command
|
|
|
|
|
|
logout_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
def cmd_status(args):
|
|
|
|
|
|
"""Show status of all components."""
|
|
|
|
|
|
from hermes_cli.status import show_status
|
|
|
|
|
|
show_status(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_cron(args):
|
|
|
|
|
|
"""Cron job management."""
|
|
|
|
|
|
from hermes_cli.cron import cron_command
|
|
|
|
|
|
cron_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_doctor(args):
|
|
|
|
|
|
"""Check configuration and dependencies."""
|
|
|
|
|
|
from hermes_cli.doctor import run_doctor
|
|
|
|
|
|
run_doctor(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_config(args):
|
|
|
|
|
|
"""Configuration management."""
|
|
|
|
|
|
from hermes_cli.config import config_command
|
|
|
|
|
|
config_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_version(args):
|
|
|
|
|
|
"""Show version."""
|
|
|
|
|
|
print(f"Hermes Agent v{__version__}")
|
|
|
|
|
|
print(f"Project: {PROJECT_ROOT}")
|
|
|
|
|
|
|
|
|
|
|
|
# Show Python version
|
|
|
|
|
|
print(f"Python: {sys.version.split()[0]}")
|
|
|
|
|
|
|
|
|
|
|
|
# Check for key dependencies
|
|
|
|
|
|
try:
|
|
|
|
|
|
import openai
|
|
|
|
|
|
print(f"OpenAI SDK: {openai.__version__}")
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
print("OpenAI SDK: Not installed")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-02 22:18:18 -08:00
|
|
|
|
def cmd_uninstall(args):
|
|
|
|
|
|
"""Uninstall Hermes Agent."""
|
|
|
|
|
|
from hermes_cli.uninstall import run_uninstall
|
|
|
|
|
|
run_uninstall(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-02 23:00:22 -08:00
|
|
|
|
def _update_via_zip(args):
|
|
|
|
|
|
"""Update Hermes Agent by downloading a ZIP archive.
|
|
|
|
|
|
|
|
|
|
|
|
Used on Windows when git file I/O is broken (antivirus, NTFS filter
|
|
|
|
|
|
drivers causing 'Invalid argument' errors on file creation).
|
|
|
|
|
|
"""
|
|
|
|
|
|
import shutil
|
|
|
|
|
|
import tempfile
|
|
|
|
|
|
import zipfile
|
|
|
|
|
|
from urllib.request import urlretrieve
|
|
|
|
|
|
|
|
|
|
|
|
branch = "main"
|
|
|
|
|
|
zip_url = f"https://github.com/NousResearch/hermes-agent/archive/refs/heads/{branch}.zip"
|
|
|
|
|
|
|
|
|
|
|
|
print("→ Downloading latest version...")
|
|
|
|
|
|
try:
|
|
|
|
|
|
tmp_dir = tempfile.mkdtemp(prefix="hermes-update-")
|
|
|
|
|
|
zip_path = os.path.join(tmp_dir, f"hermes-agent-{branch}.zip")
|
|
|
|
|
|
urlretrieve(zip_url, zip_path)
|
|
|
|
|
|
|
|
|
|
|
|
print("→ Extracting...")
|
|
|
|
|
|
with zipfile.ZipFile(zip_path, 'r') as zf:
|
|
|
|
|
|
zf.extractall(tmp_dir)
|
|
|
|
|
|
|
|
|
|
|
|
# GitHub ZIPs extract to hermes-agent-<branch>/
|
|
|
|
|
|
extracted = os.path.join(tmp_dir, f"hermes-agent-{branch}")
|
|
|
|
|
|
if not os.path.isdir(extracted):
|
|
|
|
|
|
# Try to find it
|
|
|
|
|
|
for d in os.listdir(tmp_dir):
|
|
|
|
|
|
candidate = os.path.join(tmp_dir, d)
|
|
|
|
|
|
if os.path.isdir(candidate) and d != "__MACOSX":
|
|
|
|
|
|
extracted = candidate
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
# Copy updated files over existing installation, preserving venv/node_modules/.git
|
|
|
|
|
|
preserve = {'venv', 'node_modules', '.git', '__pycache__', '.env'}
|
|
|
|
|
|
update_count = 0
|
|
|
|
|
|
for item in os.listdir(extracted):
|
|
|
|
|
|
if item in preserve:
|
|
|
|
|
|
continue
|
|
|
|
|
|
src = os.path.join(extracted, item)
|
|
|
|
|
|
dst = os.path.join(str(PROJECT_ROOT), item)
|
|
|
|
|
|
if os.path.isdir(src):
|
|
|
|
|
|
if os.path.exists(dst):
|
|
|
|
|
|
shutil.rmtree(dst)
|
|
|
|
|
|
shutil.copytree(src, dst)
|
|
|
|
|
|
else:
|
|
|
|
|
|
shutil.copy2(src, dst)
|
|
|
|
|
|
update_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
print(f"✓ Updated {update_count} items from ZIP")
|
|
|
|
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
|
|
shutil.rmtree(tmp_dir, ignore_errors=True)
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"✗ ZIP update failed: {e}")
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
# Reinstall Python dependencies
|
|
|
|
|
|
print("→ Updating Python dependencies...")
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
uv_bin = shutil.which("uv")
|
|
|
|
|
|
if uv_bin:
|
|
|
|
|
|
subprocess.run(
|
|
|
|
|
|
[uv_bin, "pip", "install", "-e", ".", "--quiet"],
|
|
|
|
|
|
cwd=PROJECT_ROOT, check=True,
|
|
|
|
|
|
env={**os.environ, "VIRTUAL_ENV": str(PROJECT_ROOT / "venv")}
|
|
|
|
|
|
)
|
|
|
|
|
|
else:
|
|
|
|
|
|
venv_pip = PROJECT_ROOT / "venv" / ("Scripts" if sys.platform == "win32" else "bin") / "pip"
|
|
|
|
|
|
if venv_pip.exists():
|
|
|
|
|
|
subprocess.run([str(venv_pip), "install", "-e", ".", "--quiet"], cwd=PROJECT_ROOT, check=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Sync skills
|
|
|
|
|
|
try:
|
|
|
|
|
|
from tools.skills_sync import sync_skills
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
print("→ Syncing bundled skills...")
|
2026-03-02 23:00:22 -08:00
|
|
|
|
result = sync_skills(quiet=True)
|
|
|
|
|
|
if result["copied"]:
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
print(f" + {len(result['copied'])} new: {', '.join(result['copied'])}")
|
|
|
|
|
|
if result.get("updated"):
|
|
|
|
|
|
print(f" ↑ {len(result['updated'])} updated: {', '.join(result['updated'])}")
|
|
|
|
|
|
if result.get("cleaned"):
|
|
|
|
|
|
print(f" − {len(result['cleaned'])} removed from manifest")
|
|
|
|
|
|
if not result["copied"] and not result.get("updated"):
|
2026-03-02 23:00:22 -08:00
|
|
|
|
print(" ✓ Skills are up to date")
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("✓ Update complete!")
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
def cmd_update(args):
|
|
|
|
|
|
"""Update Hermes Agent to the latest version."""
|
|
|
|
|
|
import subprocess
|
2026-02-07 23:54:53 +00:00
|
|
|
|
import shutil
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-20 21:25:04 -08:00
|
|
|
|
print("⚕ Updating Hermes Agent...")
|
2026-02-02 19:01:51 -08:00
|
|
|
|
print()
|
|
|
|
|
|
|
2026-03-02 23:00:22 -08:00
|
|
|
|
# Try git-based update first, fall back to ZIP download on Windows
|
|
|
|
|
|
# when git file I/O is broken (antivirus, NTFS filter drivers, etc.)
|
|
|
|
|
|
use_zip_update = False
|
2026-02-02 19:01:51 -08:00
|
|
|
|
git_dir = PROJECT_ROOT / '.git'
|
2026-03-02 23:00:22 -08:00
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
if not git_dir.exists():
|
2026-03-02 23:00:22 -08:00
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
|
use_zip_update = True
|
|
|
|
|
|
else:
|
|
|
|
|
|
print("✗ Not a git repository. Please reinstall:")
|
|
|
|
|
|
print(" curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash")
|
|
|
|
|
|
sys.exit(1)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-03-02 22:31:42 -08:00
|
|
|
|
# On Windows, git can fail with "unable to write loose object file: Invalid argument"
|
|
|
|
|
|
# due to filesystem atomicity issues. Set the recommended workaround.
|
2026-03-02 23:00:22 -08:00
|
|
|
|
if sys.platform == "win32" and git_dir.exists():
|
2026-03-02 22:31:42 -08:00
|
|
|
|
subprocess.run(
|
2026-03-02 23:00:22 -08:00
|
|
|
|
["git", "-c", "windows.appendAtomically=false", "config", "windows.appendAtomically", "false"],
|
2026-03-02 22:31:42 -08:00
|
|
|
|
cwd=PROJECT_ROOT, check=False, capture_output=True
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-03-02 23:00:22 -08:00
|
|
|
|
if use_zip_update:
|
|
|
|
|
|
# ZIP-based update for Windows when git is broken
|
|
|
|
|
|
_update_via_zip(args)
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# Fetch and pull
|
|
|
|
|
|
try:
|
|
|
|
|
|
print("→ Fetching updates...")
|
2026-03-02 23:00:22 -08:00
|
|
|
|
git_cmd = ["git"]
|
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
|
git_cmd = ["git", "-c", "windows.appendAtomically=false"]
|
|
|
|
|
|
|
|
|
|
|
|
subprocess.run(git_cmd + ["fetch", "origin"], cwd=PROJECT_ROOT, check=True)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
# Get current branch
|
|
|
|
|
|
result = subprocess.run(
|
2026-03-02 23:00:22 -08:00
|
|
|
|
git_cmd + ["rev-parse", "--abbrev-ref", "HEAD"],
|
2026-02-02 19:01:51 -08:00
|
|
|
|
cwd=PROJECT_ROOT,
|
|
|
|
|
|
capture_output=True,
|
|
|
|
|
|
text=True,
|
|
|
|
|
|
check=True
|
|
|
|
|
|
)
|
|
|
|
|
|
branch = result.stdout.strip()
|
|
|
|
|
|
|
|
|
|
|
|
# Check if there are updates
|
|
|
|
|
|
result = subprocess.run(
|
2026-03-02 23:00:22 -08:00
|
|
|
|
git_cmd + ["rev-list", f"HEAD..origin/{branch}", "--count"],
|
2026-02-02 19:01:51 -08:00
|
|
|
|
cwd=PROJECT_ROOT,
|
|
|
|
|
|
capture_output=True,
|
|
|
|
|
|
text=True,
|
|
|
|
|
|
check=True
|
|
|
|
|
|
)
|
|
|
|
|
|
commit_count = int(result.stdout.strip())
|
|
|
|
|
|
|
|
|
|
|
|
if commit_count == 0:
|
|
|
|
|
|
print("✓ Already up to date!")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
print(f"→ Found {commit_count} new commit(s)")
|
|
|
|
|
|
print("→ Pulling updates...")
|
2026-03-02 23:00:22 -08:00
|
|
|
|
subprocess.run(git_cmd + ["pull", "origin", branch], cwd=PROJECT_ROOT, check=True)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-07 23:54:53 +00:00
|
|
|
|
# Reinstall Python dependencies (prefer uv for speed, fall back to pip)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
print("→ Updating Python dependencies...")
|
2026-02-07 23:54:53 +00:00
|
|
|
|
uv_bin = shutil.which("uv")
|
|
|
|
|
|
if uv_bin:
|
|
|
|
|
|
subprocess.run(
|
|
|
|
|
|
[uv_bin, "pip", "install", "-e", ".", "--quiet"],
|
|
|
|
|
|
cwd=PROJECT_ROOT, check=True,
|
|
|
|
|
|
env={**os.environ, "VIRTUAL_ENV": str(PROJECT_ROOT / "venv")}
|
|
|
|
|
|
)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
else:
|
2026-03-02 22:31:42 -08:00
|
|
|
|
venv_pip = PROJECT_ROOT / "venv" / ("Scripts" if sys.platform == "win32" else "bin") / "pip"
|
2026-02-07 23:54:53 +00:00
|
|
|
|
if venv_pip.exists():
|
|
|
|
|
|
subprocess.run([str(venv_pip), "install", "-e", ".", "--quiet"], cwd=PROJECT_ROOT, check=True)
|
|
|
|
|
|
else:
|
|
|
|
|
|
subprocess.run(["pip", "install", "-e", ".", "--quiet"], cwd=PROJECT_ROOT, check=True)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
# Check for Node.js deps
|
|
|
|
|
|
if (PROJECT_ROOT / "package.json").exists():
|
|
|
|
|
|
import shutil
|
|
|
|
|
|
if shutil.which("npm"):
|
|
|
|
|
|
print("→ Updating Node.js dependencies...")
|
|
|
|
|
|
subprocess.run(["npm", "install", "--silent"], cwd=PROJECT_ROOT, check=False)
|
|
|
|
|
|
|
2026-02-02 19:39:23 -08:00
|
|
|
|
print()
|
|
|
|
|
|
print("✓ Code updated!")
|
|
|
|
|
|
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
# Sync bundled skills (copies new, updates changed, respects user deletions)
|
2026-02-19 18:25:53 -08:00
|
|
|
|
try:
|
|
|
|
|
|
from tools.skills_sync import sync_skills
|
|
|
|
|
|
print()
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
print("→ Syncing bundled skills...")
|
2026-02-19 18:25:53 -08:00
|
|
|
|
result = sync_skills(quiet=True)
|
|
|
|
|
|
if result["copied"]:
|
fix: restore all removed bundled skills + fix skills sync system
- Restored 21 skills removed in commits 757d012 and 740dd92:
accelerate, audiocraft, code-review, faiss, flash-attention, gguf,
grpo-rl-training, guidance, llava, nemo-curator, obliteratus, peft,
pytorch-fsdp, pytorch-lightning, simpo, slime, stable-diffusion,
tensorrt-llm, torchtitan, trl-fine-tuning, whisper
- Rewrote sync_skills() with proper update semantics:
* New skills (not in manifest): copied to user dir
* Existing skills (in manifest + on disk): updated via hash comparison
* User-deleted skills (in manifest, not on disk): respected, not re-added
* Stale manifest entries (removed from bundled): cleaned from manifest
- Added sync_skills() to CLI startup (cmd_chat) and gateway startup
(start_gateway) — previously only ran during 'hermes update'
- Updated cmd_update output to show new/updated/cleaned counts
- Rewrote tests: 20 tests covering manifest CRUD, dir hashing, fresh
install, user deletion respect, update detection, stale cleanup, and
name collision handling
75 bundled skills total. 2002 tests pass.
2026-03-06 15:57:12 -08:00
|
|
|
|
print(f" + {len(result['copied'])} new: {', '.join(result['copied'])}")
|
|
|
|
|
|
if result.get("updated"):
|
|
|
|
|
|
print(f" ↑ {len(result['updated'])} updated: {', '.join(result['updated'])}")
|
|
|
|
|
|
if result.get("cleaned"):
|
|
|
|
|
|
print(f" − {len(result['cleaned'])} removed from manifest")
|
|
|
|
|
|
if not result["copied"] and not result.get("updated"):
|
2026-02-19 18:25:53 -08:00
|
|
|
|
print(" ✓ Skills are up to date")
|
2026-02-21 03:32:11 -08:00
|
|
|
|
except Exception as e:
|
|
|
|
|
|
logger.debug("Skills sync during update failed: %s", e)
|
2026-02-19 18:25:53 -08:00
|
|
|
|
|
2026-02-02 19:39:23 -08:00
|
|
|
|
# Check for config migrations
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("→ Checking configuration for new options...")
|
|
|
|
|
|
|
|
|
|
|
|
from hermes_cli.config import (
|
|
|
|
|
|
get_missing_env_vars, get_missing_config_fields,
|
|
|
|
|
|
check_config_version, migrate_config
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
missing_env = get_missing_env_vars(required_only=True)
|
|
|
|
|
|
missing_config = get_missing_config_fields()
|
|
|
|
|
|
current_ver, latest_ver = check_config_version()
|
|
|
|
|
|
|
|
|
|
|
|
needs_migration = missing_env or missing_config or current_ver < latest_ver
|
|
|
|
|
|
|
|
|
|
|
|
if needs_migration:
|
|
|
|
|
|
print()
|
|
|
|
|
|
if missing_env:
|
|
|
|
|
|
print(f" ⚠️ {len(missing_env)} new required setting(s) need configuration")
|
|
|
|
|
|
if missing_config:
|
|
|
|
|
|
print(f" ℹ️ {len(missing_config)} new config option(s) available")
|
|
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
response = input("Would you like to configure them now? [Y/n]: ").strip().lower()
|
|
|
|
|
|
|
|
|
|
|
|
if response in ('', 'y', 'yes'):
|
|
|
|
|
|
print()
|
|
|
|
|
|
results = migrate_config(interactive=True, quiet=False)
|
|
|
|
|
|
|
|
|
|
|
|
if results["env_added"] or results["config_added"]:
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("✓ Configuration updated!")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("Skipped. Run 'hermes config migrate' later to configure.")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(" ✓ Configuration is up to date")
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
print()
|
|
|
|
|
|
print("✓ Update complete!")
|
2026-02-26 20:26:05 -08:00
|
|
|
|
|
|
|
|
|
|
# Auto-restart gateway if it's running as a systemd service
|
|
|
|
|
|
try:
|
|
|
|
|
|
check = subprocess.run(
|
|
|
|
|
|
["systemctl", "--user", "is-active", "hermes-gateway"],
|
|
|
|
|
|
capture_output=True, text=True, timeout=5,
|
|
|
|
|
|
)
|
|
|
|
|
|
if check.stdout.strip() == "active":
|
|
|
|
|
|
print()
|
|
|
|
|
|
print("→ Gateway service is running — restarting to pick up changes...")
|
|
|
|
|
|
restart = subprocess.run(
|
|
|
|
|
|
["systemctl", "--user", "restart", "hermes-gateway"],
|
|
|
|
|
|
capture_output=True, text=True, timeout=15,
|
|
|
|
|
|
)
|
|
|
|
|
|
if restart.returncode == 0:
|
|
|
|
|
|
print("✓ Gateway restarted.")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(f"⚠ Gateway restart failed: {restart.stderr.strip()}")
|
|
|
|
|
|
print(" Try manually: hermes gateway restart")
|
|
|
|
|
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
|
|
|
|
|
pass # No systemd (macOS, WSL1, etc.) — skip silently
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
print()
|
2026-02-28 21:47:51 -08:00
|
|
|
|
print("Tip: You can now select a provider and model:")
|
|
|
|
|
|
print(" hermes model # Select provider and model")
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
2026-03-02 23:00:22 -08:00
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
|
print(f"⚠ Git update failed: {e}")
|
|
|
|
|
|
print("→ Falling back to ZIP download...")
|
|
|
|
|
|
print()
|
|
|
|
|
|
_update_via_zip(args)
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(f"✗ Update failed: {e}")
|
|
|
|
|
|
sys.exit(1)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
"""Main entry point for hermes CLI."""
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
|
prog="hermes",
|
|
|
|
|
|
description="Hermes Agent - AI assistant with tool-calling capabilities",
|
|
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
|
|
|
|
epilog="""
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
hermes Start interactive chat
|
|
|
|
|
|
hermes chat -q "Hello" Single query mode
|
2026-02-25 23:04:08 -08:00
|
|
|
|
hermes --continue Resume the most recent session
|
|
|
|
|
|
hermes --resume <session_id> Resume a specific session
|
2026-02-02 19:01:51 -08:00
|
|
|
|
hermes setup Run setup wizard
|
2026-02-20 17:24:00 -08:00
|
|
|
|
hermes logout Clear stored authentication
|
2026-02-20 17:52:46 -08:00
|
|
|
|
hermes model Select default model
|
2026-02-02 19:01:51 -08:00
|
|
|
|
hermes config View configuration
|
|
|
|
|
|
hermes config edit Edit config in $EDITOR
|
|
|
|
|
|
hermes config set model gpt-4 Set a config value
|
|
|
|
|
|
hermes gateway Run messaging gateway
|
|
|
|
|
|
hermes gateway install Install as system service
|
2026-02-25 23:04:08 -08:00
|
|
|
|
hermes sessions list List past sessions
|
2026-02-02 19:01:51 -08:00
|
|
|
|
hermes update Update to latest version
|
|
|
|
|
|
|
|
|
|
|
|
For more help on a command:
|
|
|
|
|
|
hermes <command> --help
|
|
|
|
|
|
"""
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
|
"--version", "-V",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Show version and exit"
|
|
|
|
|
|
)
|
2026-02-25 22:56:12 -08:00
|
|
|
|
parser.add_argument(
|
|
|
|
|
|
"--resume", "-r",
|
|
|
|
|
|
metavar="SESSION_ID",
|
|
|
|
|
|
default=None,
|
|
|
|
|
|
help="Resume a previous session by ID (shortcut for: hermes chat --resume ID)"
|
|
|
|
|
|
)
|
2026-02-25 23:00:10 -08:00
|
|
|
|
parser.add_argument(
|
|
|
|
|
|
"--continue", "-c",
|
|
|
|
|
|
dest="continue_last",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
default=False,
|
|
|
|
|
|
help="Resume the most recent CLI session"
|
|
|
|
|
|
)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
subparsers = parser.add_subparsers(dest="command", help="Command to run")
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# chat command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
chat_parser = subparsers.add_parser(
|
|
|
|
|
|
"chat",
|
|
|
|
|
|
help="Interactive chat with the agent",
|
|
|
|
|
|
description="Start an interactive chat session with Hermes Agent"
|
|
|
|
|
|
)
|
|
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"-q", "--query",
|
|
|
|
|
|
help="Single query (non-interactive mode)"
|
|
|
|
|
|
)
|
|
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"-m", "--model",
|
|
|
|
|
|
help="Model to use (e.g., anthropic/claude-sonnet-4)"
|
|
|
|
|
|
)
|
|
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"-t", "--toolsets",
|
|
|
|
|
|
help="Comma-separated toolsets to enable"
|
|
|
|
|
|
)
|
2026-02-20 17:24:00 -08:00
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"--provider",
|
2026-02-25 18:20:38 -08:00
|
|
|
|
choices=["auto", "openrouter", "nous", "openai-codex"],
|
2026-02-20 17:24:00 -08:00
|
|
|
|
default=None,
|
|
|
|
|
|
help="Inference provider (default: auto)"
|
|
|
|
|
|
)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"-v", "--verbose",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Verbose output"
|
|
|
|
|
|
)
|
2026-02-25 22:56:12 -08:00
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"--resume", "-r",
|
|
|
|
|
|
metavar="SESSION_ID",
|
|
|
|
|
|
help="Resume a previous session by ID (shown on exit)"
|
|
|
|
|
|
)
|
2026-02-25 23:00:10 -08:00
|
|
|
|
chat_parser.add_argument(
|
|
|
|
|
|
"--continue", "-c",
|
|
|
|
|
|
dest="continue_last",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
default=False,
|
|
|
|
|
|
help="Resume the most recent CLI session"
|
|
|
|
|
|
)
|
2026-02-02 19:01:51 -08:00
|
|
|
|
chat_parser.set_defaults(func=cmd_chat)
|
2026-02-20 17:52:46 -08:00
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# model command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
model_parser = subparsers.add_parser(
|
|
|
|
|
|
"model",
|
|
|
|
|
|
help="Select default model and provider",
|
|
|
|
|
|
description="Interactively select your inference provider and default model"
|
|
|
|
|
|
)
|
|
|
|
|
|
model_parser.set_defaults(func=cmd_model)
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# gateway command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
gateway_parser = subparsers.add_parser(
|
|
|
|
|
|
"gateway",
|
|
|
|
|
|
help="Messaging gateway management",
|
|
|
|
|
|
description="Manage the messaging gateway (Telegram, Discord, WhatsApp)"
|
|
|
|
|
|
)
|
|
|
|
|
|
gateway_subparsers = gateway_parser.add_subparsers(dest="gateway_command")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway run (default)
|
|
|
|
|
|
gateway_run = gateway_subparsers.add_parser("run", help="Run gateway in foreground")
|
|
|
|
|
|
gateway_run.add_argument("-v", "--verbose", action="store_true")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway start
|
|
|
|
|
|
gateway_start = gateway_subparsers.add_parser("start", help="Start gateway service")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway stop
|
|
|
|
|
|
gateway_stop = gateway_subparsers.add_parser("stop", help="Stop gateway service")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway restart
|
|
|
|
|
|
gateway_restart = gateway_subparsers.add_parser("restart", help="Restart gateway service")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway status
|
|
|
|
|
|
gateway_status = gateway_subparsers.add_parser("status", help="Show gateway status")
|
|
|
|
|
|
gateway_status.add_argument("--deep", action="store_true", help="Deep status check")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway install
|
|
|
|
|
|
gateway_install = gateway_subparsers.add_parser("install", help="Install gateway as service")
|
|
|
|
|
|
gateway_install.add_argument("--force", action="store_true", help="Force reinstall")
|
|
|
|
|
|
|
|
|
|
|
|
# gateway uninstall
|
|
|
|
|
|
gateway_uninstall = gateway_subparsers.add_parser("uninstall", help="Uninstall gateway service")
|
2026-03-03 18:57:33 -08:00
|
|
|
|
|
|
|
|
|
|
# gateway setup
|
|
|
|
|
|
gateway_setup = gateway_subparsers.add_parser("setup", help="Configure messaging platforms")
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
gateway_parser.set_defaults(func=cmd_gateway)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# setup command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
setup_parser = subparsers.add_parser(
|
|
|
|
|
|
"setup",
|
|
|
|
|
|
help="Interactive setup wizard",
|
|
|
|
|
|
description="Configure Hermes Agent with an interactive wizard"
|
|
|
|
|
|
)
|
|
|
|
|
|
setup_parser.add_argument(
|
|
|
|
|
|
"--non-interactive",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Non-interactive mode (use defaults/env vars)"
|
|
|
|
|
|
)
|
|
|
|
|
|
setup_parser.add_argument(
|
|
|
|
|
|
"--reset",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Reset configuration to defaults"
|
|
|
|
|
|
)
|
|
|
|
|
|
setup_parser.set_defaults(func=cmd_setup)
|
2026-02-20 17:24:00 -08:00
|
|
|
|
|
2026-02-25 21:04:36 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# whatsapp command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
whatsapp_parser = subparsers.add_parser(
|
|
|
|
|
|
"whatsapp",
|
|
|
|
|
|
help="Set up WhatsApp integration",
|
|
|
|
|
|
description="Configure WhatsApp and pair via QR code"
|
|
|
|
|
|
)
|
|
|
|
|
|
whatsapp_parser.set_defaults(func=cmd_whatsapp)
|
|
|
|
|
|
|
2026-02-20 17:24:00 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# login command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
login_parser = subparsers.add_parser(
|
|
|
|
|
|
"login",
|
|
|
|
|
|
help="Authenticate with an inference provider",
|
|
|
|
|
|
description="Run OAuth device authorization flow for Hermes CLI"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--provider",
|
2026-02-25 18:20:38 -08:00
|
|
|
|
choices=["nous", "openai-codex"],
|
2026-02-20 17:24:00 -08:00
|
|
|
|
default=None,
|
2026-02-25 18:20:38 -08:00
|
|
|
|
help="Provider to authenticate with (default: nous)"
|
2026-02-20 17:24:00 -08:00
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--portal-url",
|
|
|
|
|
|
help="Portal base URL (default: production portal)"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--inference-url",
|
|
|
|
|
|
help="Inference API base URL (default: production inference API)"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--client-id",
|
|
|
|
|
|
default=None,
|
|
|
|
|
|
help="OAuth client id to use (default: hermes-cli)"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--scope",
|
|
|
|
|
|
default=None,
|
|
|
|
|
|
help="OAuth scope to request"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--no-browser",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Do not attempt to open the browser automatically"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--timeout",
|
|
|
|
|
|
type=float,
|
|
|
|
|
|
default=15.0,
|
|
|
|
|
|
help="HTTP request timeout in seconds (default: 15)"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--ca-bundle",
|
|
|
|
|
|
help="Path to CA bundle PEM file for TLS verification"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.add_argument(
|
|
|
|
|
|
"--insecure",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Disable TLS verification (testing only)"
|
|
|
|
|
|
)
|
|
|
|
|
|
login_parser.set_defaults(func=cmd_login)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# logout command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
logout_parser = subparsers.add_parser(
|
|
|
|
|
|
"logout",
|
|
|
|
|
|
help="Clear authentication for an inference provider",
|
|
|
|
|
|
description="Remove stored credentials and reset provider config"
|
|
|
|
|
|
)
|
|
|
|
|
|
logout_parser.add_argument(
|
|
|
|
|
|
"--provider",
|
2026-02-25 18:20:38 -08:00
|
|
|
|
choices=["nous", "openai-codex"],
|
2026-02-20 17:24:00 -08:00
|
|
|
|
default=None,
|
|
|
|
|
|
help="Provider to log out from (default: active provider)"
|
|
|
|
|
|
)
|
|
|
|
|
|
logout_parser.set_defaults(func=cmd_logout)
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# status command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
status_parser = subparsers.add_parser(
|
|
|
|
|
|
"status",
|
|
|
|
|
|
help="Show status of all components",
|
|
|
|
|
|
description="Display status of Hermes Agent components"
|
|
|
|
|
|
)
|
|
|
|
|
|
status_parser.add_argument(
|
|
|
|
|
|
"--all",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Show all details (redacted for sharing)"
|
|
|
|
|
|
)
|
|
|
|
|
|
status_parser.add_argument(
|
|
|
|
|
|
"--deep",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Run deep checks (may take longer)"
|
|
|
|
|
|
)
|
|
|
|
|
|
status_parser.set_defaults(func=cmd_status)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# cron command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
cron_parser = subparsers.add_parser(
|
|
|
|
|
|
"cron",
|
|
|
|
|
|
help="Cron job management",
|
|
|
|
|
|
description="Manage scheduled tasks"
|
|
|
|
|
|
)
|
|
|
|
|
|
cron_subparsers = cron_parser.add_subparsers(dest="cron_command")
|
|
|
|
|
|
|
|
|
|
|
|
# cron list
|
|
|
|
|
|
cron_list = cron_subparsers.add_parser("list", help="List scheduled jobs")
|
|
|
|
|
|
cron_list.add_argument("--all", action="store_true", help="Include disabled jobs")
|
|
|
|
|
|
|
2026-02-21 16:21:19 -08:00
|
|
|
|
# cron status
|
|
|
|
|
|
cron_subparsers.add_parser("status", help="Check if cron scheduler is running")
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
2026-02-21 16:21:19 -08:00
|
|
|
|
# cron tick (mostly for debugging)
|
|
|
|
|
|
cron_subparsers.add_parser("tick", help="Run due jobs once and exit")
|
2026-02-02 19:01:51 -08:00
|
|
|
|
|
|
|
|
|
|
cron_parser.set_defaults(func=cmd_cron)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# doctor command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
doctor_parser = subparsers.add_parser(
|
|
|
|
|
|
"doctor",
|
|
|
|
|
|
help="Check configuration and dependencies",
|
|
|
|
|
|
description="Diagnose issues with Hermes Agent setup"
|
|
|
|
|
|
)
|
|
|
|
|
|
doctor_parser.add_argument(
|
|
|
|
|
|
"--fix",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Attempt to fix issues automatically"
|
|
|
|
|
|
)
|
|
|
|
|
|
doctor_parser.set_defaults(func=cmd_doctor)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# config command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
config_parser = subparsers.add_parser(
|
|
|
|
|
|
"config",
|
|
|
|
|
|
help="View and edit configuration",
|
|
|
|
|
|
description="Manage Hermes Agent configuration"
|
|
|
|
|
|
)
|
|
|
|
|
|
config_subparsers = config_parser.add_subparsers(dest="config_command")
|
|
|
|
|
|
|
|
|
|
|
|
# config show (default)
|
|
|
|
|
|
config_show = config_subparsers.add_parser("show", help="Show current configuration")
|
|
|
|
|
|
|
|
|
|
|
|
# config edit
|
|
|
|
|
|
config_edit = config_subparsers.add_parser("edit", help="Open config file in editor")
|
|
|
|
|
|
|
|
|
|
|
|
# config set
|
|
|
|
|
|
config_set = config_subparsers.add_parser("set", help="Set a configuration value")
|
|
|
|
|
|
config_set.add_argument("key", nargs="?", help="Configuration key (e.g., model, terminal.backend)")
|
|
|
|
|
|
config_set.add_argument("value", nargs="?", help="Value to set")
|
|
|
|
|
|
|
|
|
|
|
|
# config path
|
|
|
|
|
|
config_path = config_subparsers.add_parser("path", help="Print config file path")
|
|
|
|
|
|
|
|
|
|
|
|
# config env-path
|
|
|
|
|
|
config_env = config_subparsers.add_parser("env-path", help="Print .env file path")
|
|
|
|
|
|
|
2026-02-02 19:39:23 -08:00
|
|
|
|
# config check
|
|
|
|
|
|
config_check = config_subparsers.add_parser("check", help="Check for missing/outdated config")
|
|
|
|
|
|
|
|
|
|
|
|
# config migrate
|
|
|
|
|
|
config_migrate = config_subparsers.add_parser("migrate", help="Update config with new options")
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
config_parser.set_defaults(func=cmd_config)
|
|
|
|
|
|
|
Add messaging platform enhancements: STT, stickers, Discord UX, Slack, pairing, hooks
Major feature additions inspired by OpenClaw/ClawdBot integration analysis:
Voice Message Transcription (STT):
- Auto-transcribe voice/audio messages via OpenAI Whisper API
- Download voice to ~/.hermes/audio_cache/ on Telegram/Discord/WhatsApp
- Inject transcript as text so all models can understand voice input
- Configurable model (whisper-1, gpt-4o-mini-transcribe, gpt-4o-transcribe)
Telegram Sticker Understanding:
- Describe static stickers via vision tool with JSON-backed cache
- Cache keyed by file_unique_id avoids redundant API calls
- Animated/video stickers get emoji-based fallback description
Discord Rich UX:
- Native slash commands (/ask, /reset, /status, /stop) via app_commands
- Button-based exec approvals (Allow Once / Always Allow / Deny)
- ExecApprovalView with user authorization and timeout handling
Slack Integration:
- Full SlackAdapter using slack-bolt with Socket Mode
- DMs, channel messages (mention-gated), /hermes slash command
- File attachment handling with bot-token-authenticated downloads
DM Pairing System:
- Code-based user authorization as alternative to static allowlists
- 8-char codes from unambiguous alphabet, 1-hour expiry
- Rate limiting, lockout after failed attempts, chmod 0600 on data
- CLI: hermes pairing list/approve/revoke/clear-pending
Event Hook System:
- File-based hook discovery from ~/.hermes/hooks/
- HOOK.yaml + handler.py per hook, sync/async handler support
- Events: gateway:startup, session:start/reset, agent:start/step/end
- Wildcard matching (command:* catches all command events)
Cross-Channel Messaging:
- send_message agent tool for delivering to any connected platform
- Enables cron job delivery and cross-platform notifications
Human-Like Response Pacing:
- Configurable delays between message chunks (off/natural/custom)
- HERMES_HUMAN_DELAY_MODE env var with min/max ms settings
Warm Injection Message Style:
- Retrofitted image vision messages with friendly kawaii-consistent tone
- All new injection messages (STT, stickers, errors) use warm style
Also: updated config migration to prompt for optional keys interactively,
bumped config version, updated README, AGENTS.md, .env.example,
cli-config.yaml.example, install scripts, pyproject.toml, and toolsets.
2026-02-15 21:38:59 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# pairing command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
pairing_parser = subparsers.add_parser(
|
|
|
|
|
|
"pairing",
|
|
|
|
|
|
help="Manage DM pairing codes for user authorization",
|
|
|
|
|
|
description="Approve or revoke user access via pairing codes"
|
|
|
|
|
|
)
|
|
|
|
|
|
pairing_sub = pairing_parser.add_subparsers(dest="pairing_action")
|
|
|
|
|
|
|
|
|
|
|
|
pairing_list_parser = pairing_sub.add_parser("list", help="Show pending + approved users")
|
|
|
|
|
|
|
|
|
|
|
|
pairing_approve_parser = pairing_sub.add_parser("approve", help="Approve a pairing code")
|
|
|
|
|
|
pairing_approve_parser.add_argument("platform", help="Platform name (telegram, discord, slack, whatsapp)")
|
|
|
|
|
|
pairing_approve_parser.add_argument("code", help="Pairing code to approve")
|
|
|
|
|
|
|
|
|
|
|
|
pairing_revoke_parser = pairing_sub.add_parser("revoke", help="Revoke user access")
|
|
|
|
|
|
pairing_revoke_parser.add_argument("platform", help="Platform name")
|
|
|
|
|
|
pairing_revoke_parser.add_argument("user_id", help="User ID to revoke")
|
|
|
|
|
|
|
|
|
|
|
|
pairing_clear_parser = pairing_sub.add_parser("clear-pending", help="Clear all pending codes")
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_pairing(args):
|
|
|
|
|
|
from hermes_cli.pairing import pairing_command
|
|
|
|
|
|
pairing_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
pairing_parser.set_defaults(func=cmd_pairing)
|
|
|
|
|
|
|
Add Skills Hub — universal skill search, install, and management from online registries
Implements the Hermes Skills Hub with agentskills.io spec compliance,
multi-registry skill discovery, security scanning, and user-driven
management via CLI and /skills slash command.
Core features:
- Security scanner (tools/skills_guard.py): 120 threat patterns across
12 categories, trust-aware install policy (builtin/trusted/community),
structural checks, unicode injection detection, LLM audit pass
- Hub client (tools/skills_hub.py): GitHub, ClawHub, Claude Code
marketplace, and LobeHub source adapters with shared GitHubAuth
(PAT + gh CLI + GitHub App), lock file provenance tracking, quarantine
flow, and unified search across all sources
- CLI interface (hermes_cli/skills_hub.py): search, install, inspect,
list, audit, uninstall, publish (GitHub PR), snapshot export/import,
and tap management — powers both `hermes skills` and `/skills`
Spec conformance (Phase 0):
- Upgraded frontmatter parser to yaml.safe_load with fallback
- Migrated 39 SKILL.md files: tags/related_skills to metadata.hermes.*
- Added assets/ directory support and compatibility/metadata fields
- Excluded .hub/ from skill discovery in skills_tool.py
Updated 13 config/doc files including README, AGENTS.md, .env.example,
setup wizard, doctor, status, pyproject.toml, and docs.
2026-02-18 16:09:05 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# skills command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
skills_parser = subparsers.add_parser(
|
|
|
|
|
|
"skills",
|
|
|
|
|
|
help="Skills Hub — search, install, and manage skills from online registries",
|
|
|
|
|
|
description="Search, install, inspect, audit, and manage skills from GitHub, ClawHub, and other registries."
|
|
|
|
|
|
)
|
|
|
|
|
|
skills_subparsers = skills_parser.add_subparsers(dest="skills_action")
|
|
|
|
|
|
|
2026-03-06 01:29:45 -08:00
|
|
|
|
skills_browse = skills_subparsers.add_parser("browse", help="Browse all available skills (paginated)")
|
|
|
|
|
|
skills_browse.add_argument("--page", type=int, default=1, help="Page number (default: 1)")
|
|
|
|
|
|
skills_browse.add_argument("--size", type=int, default=20, help="Results per page (default: 20)")
|
|
|
|
|
|
skills_browse.add_argument("--source", default="all",
|
|
|
|
|
|
choices=["all", "official", "github", "clawhub", "lobehub"],
|
|
|
|
|
|
help="Filter by source (default: all)")
|
|
|
|
|
|
|
Add Skills Hub — universal skill search, install, and management from online registries
Implements the Hermes Skills Hub with agentskills.io spec compliance,
multi-registry skill discovery, security scanning, and user-driven
management via CLI and /skills slash command.
Core features:
- Security scanner (tools/skills_guard.py): 120 threat patterns across
12 categories, trust-aware install policy (builtin/trusted/community),
structural checks, unicode injection detection, LLM audit pass
- Hub client (tools/skills_hub.py): GitHub, ClawHub, Claude Code
marketplace, and LobeHub source adapters with shared GitHubAuth
(PAT + gh CLI + GitHub App), lock file provenance tracking, quarantine
flow, and unified search across all sources
- CLI interface (hermes_cli/skills_hub.py): search, install, inspect,
list, audit, uninstall, publish (GitHub PR), snapshot export/import,
and tap management — powers both `hermes skills` and `/skills`
Spec conformance (Phase 0):
- Upgraded frontmatter parser to yaml.safe_load with fallback
- Migrated 39 SKILL.md files: tags/related_skills to metadata.hermes.*
- Added assets/ directory support and compatibility/metadata fields
- Excluded .hub/ from skill discovery in skills_tool.py
Updated 13 config/doc files including README, AGENTS.md, .env.example,
setup wizard, doctor, status, pyproject.toml, and docs.
2026-02-18 16:09:05 -08:00
|
|
|
|
skills_search = skills_subparsers.add_parser("search", help="Search skill registries")
|
|
|
|
|
|
skills_search.add_argument("query", help="Search query")
|
2026-03-06 01:29:45 -08:00
|
|
|
|
skills_search.add_argument("--source", default="all", choices=["all", "official", "github", "clawhub", "lobehub"])
|
Add Skills Hub — universal skill search, install, and management from online registries
Implements the Hermes Skills Hub with agentskills.io spec compliance,
multi-registry skill discovery, security scanning, and user-driven
management via CLI and /skills slash command.
Core features:
- Security scanner (tools/skills_guard.py): 120 threat patterns across
12 categories, trust-aware install policy (builtin/trusted/community),
structural checks, unicode injection detection, LLM audit pass
- Hub client (tools/skills_hub.py): GitHub, ClawHub, Claude Code
marketplace, and LobeHub source adapters with shared GitHubAuth
(PAT + gh CLI + GitHub App), lock file provenance tracking, quarantine
flow, and unified search across all sources
- CLI interface (hermes_cli/skills_hub.py): search, install, inspect,
list, audit, uninstall, publish (GitHub PR), snapshot export/import,
and tap management — powers both `hermes skills` and `/skills`
Spec conformance (Phase 0):
- Upgraded frontmatter parser to yaml.safe_load with fallback
- Migrated 39 SKILL.md files: tags/related_skills to metadata.hermes.*
- Added assets/ directory support and compatibility/metadata fields
- Excluded .hub/ from skill discovery in skills_tool.py
Updated 13 config/doc files including README, AGENTS.md, .env.example,
setup wizard, doctor, status, pyproject.toml, and docs.
2026-02-18 16:09:05 -08:00
|
|
|
|
skills_search.add_argument("--limit", type=int, default=10, help="Max results")
|
|
|
|
|
|
|
|
|
|
|
|
skills_install = skills_subparsers.add_parser("install", help="Install a skill")
|
|
|
|
|
|
skills_install.add_argument("identifier", help="Skill identifier (e.g. openai/skills/skill-creator)")
|
|
|
|
|
|
skills_install.add_argument("--category", default="", help="Category folder to install into")
|
|
|
|
|
|
skills_install.add_argument("--force", action="store_true", help="Install despite caution verdict")
|
|
|
|
|
|
|
|
|
|
|
|
skills_inspect = skills_subparsers.add_parser("inspect", help="Preview a skill without installing")
|
|
|
|
|
|
skills_inspect.add_argument("identifier", help="Skill identifier")
|
|
|
|
|
|
|
|
|
|
|
|
skills_list = skills_subparsers.add_parser("list", help="List installed skills")
|
|
|
|
|
|
skills_list.add_argument("--source", default="all", choices=["all", "hub", "builtin"])
|
|
|
|
|
|
|
|
|
|
|
|
skills_audit = skills_subparsers.add_parser("audit", help="Re-scan installed hub skills")
|
|
|
|
|
|
skills_audit.add_argument("name", nargs="?", help="Specific skill to audit (default: all)")
|
|
|
|
|
|
|
|
|
|
|
|
skills_uninstall = skills_subparsers.add_parser("uninstall", help="Remove a hub-installed skill")
|
|
|
|
|
|
skills_uninstall.add_argument("name", help="Skill name to remove")
|
|
|
|
|
|
|
|
|
|
|
|
skills_publish = skills_subparsers.add_parser("publish", help="Publish a skill to a registry")
|
|
|
|
|
|
skills_publish.add_argument("skill_path", help="Path to skill directory")
|
|
|
|
|
|
skills_publish.add_argument("--to", default="github", choices=["github", "clawhub"], help="Target registry")
|
|
|
|
|
|
skills_publish.add_argument("--repo", default="", help="Target GitHub repo (e.g. openai/skills)")
|
|
|
|
|
|
|
|
|
|
|
|
skills_snapshot = skills_subparsers.add_parser("snapshot", help="Export/import skill configurations")
|
|
|
|
|
|
snapshot_subparsers = skills_snapshot.add_subparsers(dest="snapshot_action")
|
|
|
|
|
|
snap_export = snapshot_subparsers.add_parser("export", help="Export installed skills to a file")
|
|
|
|
|
|
snap_export.add_argument("output", help="Output JSON file path")
|
|
|
|
|
|
snap_import = snapshot_subparsers.add_parser("import", help="Import and install skills from a file")
|
|
|
|
|
|
snap_import.add_argument("input", help="Input JSON file path")
|
|
|
|
|
|
snap_import.add_argument("--force", action="store_true", help="Force install despite caution verdict")
|
|
|
|
|
|
|
|
|
|
|
|
skills_tap = skills_subparsers.add_parser("tap", help="Manage skill sources")
|
|
|
|
|
|
tap_subparsers = skills_tap.add_subparsers(dest="tap_action")
|
|
|
|
|
|
tap_subparsers.add_parser("list", help="List configured taps")
|
|
|
|
|
|
tap_add = tap_subparsers.add_parser("add", help="Add a GitHub repo as skill source")
|
|
|
|
|
|
tap_add.add_argument("repo", help="GitHub repo (e.g. owner/repo)")
|
|
|
|
|
|
tap_rm = tap_subparsers.add_parser("remove", help="Remove a tap")
|
|
|
|
|
|
tap_rm.add_argument("name", help="Tap name to remove")
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_skills(args):
|
|
|
|
|
|
from hermes_cli.skills_hub import skills_command
|
|
|
|
|
|
skills_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
skills_parser.set_defaults(func=cmd_skills)
|
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# tools command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
tools_parser = subparsers.add_parser(
|
|
|
|
|
|
"tools",
|
|
|
|
|
|
help="Configure which tools are enabled per platform",
|
|
|
|
|
|
description="Interactive tool configuration — enable/disable tools for CLI, Telegram, Discord, etc."
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_tools(args):
|
|
|
|
|
|
from hermes_cli.tools_config import tools_command
|
|
|
|
|
|
tools_command(args)
|
|
|
|
|
|
|
|
|
|
|
|
tools_parser.set_defaults(func=cmd_tools)
|
|
|
|
|
|
|
2026-02-19 00:57:31 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# sessions command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
sessions_parser = subparsers.add_parser(
|
|
|
|
|
|
"sessions",
|
|
|
|
|
|
help="Manage session history (list, export, prune, delete)",
|
|
|
|
|
|
description="View and manage the SQLite session store"
|
|
|
|
|
|
)
|
|
|
|
|
|
sessions_subparsers = sessions_parser.add_subparsers(dest="sessions_action")
|
|
|
|
|
|
|
|
|
|
|
|
sessions_list = sessions_subparsers.add_parser("list", help="List recent sessions")
|
|
|
|
|
|
sessions_list.add_argument("--source", help="Filter by source (cli, telegram, discord, etc.)")
|
|
|
|
|
|
sessions_list.add_argument("--limit", type=int, default=20, help="Max sessions to show")
|
|
|
|
|
|
|
|
|
|
|
|
sessions_export = sessions_subparsers.add_parser("export", help="Export sessions to a JSONL file")
|
|
|
|
|
|
sessions_export.add_argument("output", help="Output JSONL file path")
|
|
|
|
|
|
sessions_export.add_argument("--source", help="Filter by source")
|
|
|
|
|
|
sessions_export.add_argument("--session-id", help="Export a specific session")
|
|
|
|
|
|
|
|
|
|
|
|
sessions_delete = sessions_subparsers.add_parser("delete", help="Delete a specific session")
|
|
|
|
|
|
sessions_delete.add_argument("session_id", help="Session ID to delete")
|
|
|
|
|
|
sessions_delete.add_argument("--yes", "-y", action="store_true", help="Skip confirmation")
|
|
|
|
|
|
|
|
|
|
|
|
sessions_prune = sessions_subparsers.add_parser("prune", help="Delete old sessions")
|
|
|
|
|
|
sessions_prune.add_argument("--older-than", type=int, default=90, help="Delete sessions older than N days (default: 90)")
|
|
|
|
|
|
sessions_prune.add_argument("--source", help="Only prune sessions from this source")
|
|
|
|
|
|
sessions_prune.add_argument("--yes", "-y", action="store_true", help="Skip confirmation")
|
|
|
|
|
|
|
|
|
|
|
|
sessions_stats = sessions_subparsers.add_parser("stats", help="Show session store statistics")
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_sessions(args):
|
|
|
|
|
|
import json as _json
|
|
|
|
|
|
try:
|
|
|
|
|
|
from hermes_state import SessionDB
|
|
|
|
|
|
db = SessionDB()
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"Error: Could not open session database: {e}")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
action = args.sessions_action
|
|
|
|
|
|
|
|
|
|
|
|
if action == "list":
|
|
|
|
|
|
sessions = db.search_sessions(source=args.source, limit=args.limit)
|
|
|
|
|
|
if not sessions:
|
|
|
|
|
|
print("No sessions found.")
|
|
|
|
|
|
return
|
|
|
|
|
|
print(f"{'ID':<30} {'Source':<12} {'Model':<30} {'Messages':>8} {'Started'}")
|
|
|
|
|
|
print("─" * 100)
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
for s in sessions:
|
|
|
|
|
|
started = datetime.fromtimestamp(s["started_at"]).strftime("%Y-%m-%d %H:%M") if s["started_at"] else "?"
|
|
|
|
|
|
model = (s.get("model") or "?")[:28]
|
|
|
|
|
|
ended = " (ended)" if s.get("ended_at") else ""
|
|
|
|
|
|
print(f"{s['id']:<30} {s['source']:<12} {model:<30} {s['message_count']:>8} {started}{ended}")
|
|
|
|
|
|
|
|
|
|
|
|
elif action == "export":
|
|
|
|
|
|
if args.session_id:
|
|
|
|
|
|
data = db.export_session(args.session_id)
|
|
|
|
|
|
if not data:
|
|
|
|
|
|
print(f"Session '{args.session_id}' not found.")
|
|
|
|
|
|
return
|
|
|
|
|
|
with open(args.output, "w") as f:
|
|
|
|
|
|
f.write(_json.dumps(data, ensure_ascii=False) + "\n")
|
|
|
|
|
|
print(f"Exported 1 session to {args.output}")
|
|
|
|
|
|
else:
|
|
|
|
|
|
sessions = db.export_all(source=args.source)
|
|
|
|
|
|
with open(args.output, "w") as f:
|
|
|
|
|
|
for s in sessions:
|
|
|
|
|
|
f.write(_json.dumps(s, ensure_ascii=False) + "\n")
|
|
|
|
|
|
print(f"Exported {len(sessions)} sessions to {args.output}")
|
|
|
|
|
|
|
|
|
|
|
|
elif action == "delete":
|
|
|
|
|
|
if not args.yes:
|
|
|
|
|
|
confirm = input(f"Delete session '{args.session_id}' and all its messages? [y/N] ")
|
|
|
|
|
|
if confirm.lower() not in ("y", "yes"):
|
|
|
|
|
|
print("Cancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
if db.delete_session(args.session_id):
|
|
|
|
|
|
print(f"Deleted session '{args.session_id}'.")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(f"Session '{args.session_id}' not found.")
|
|
|
|
|
|
|
|
|
|
|
|
elif action == "prune":
|
|
|
|
|
|
days = args.older_than
|
|
|
|
|
|
source_msg = f" from '{args.source}'" if args.source else ""
|
|
|
|
|
|
if not args.yes:
|
|
|
|
|
|
confirm = input(f"Delete all ended sessions older than {days} days{source_msg}? [y/N] ")
|
|
|
|
|
|
if confirm.lower() not in ("y", "yes"):
|
|
|
|
|
|
print("Cancelled.")
|
|
|
|
|
|
return
|
|
|
|
|
|
count = db.prune_sessions(older_than_days=days, source=args.source)
|
|
|
|
|
|
print(f"Pruned {count} session(s).")
|
|
|
|
|
|
|
|
|
|
|
|
elif action == "stats":
|
|
|
|
|
|
total = db.session_count()
|
|
|
|
|
|
msgs = db.message_count()
|
|
|
|
|
|
print(f"Total sessions: {total}")
|
|
|
|
|
|
print(f"Total messages: {msgs}")
|
|
|
|
|
|
for src in ["cli", "telegram", "discord", "whatsapp", "slack"]:
|
|
|
|
|
|
c = db.session_count(source=src)
|
|
|
|
|
|
if c > 0:
|
|
|
|
|
|
print(f" {src}: {c} sessions")
|
|
|
|
|
|
import os
|
|
|
|
|
|
db_path = db.db_path
|
|
|
|
|
|
if db_path.exists():
|
|
|
|
|
|
size_mb = os.path.getsize(db_path) / (1024 * 1024)
|
|
|
|
|
|
print(f"Database size: {size_mb:.1f} MB")
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
sessions_parser.print_help()
|
|
|
|
|
|
|
|
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
sessions_parser.set_defaults(func=cmd_sessions)
|
|
|
|
|
|
|
feat: add /insights command with usage analytics and cost estimation
Inspired by Claude Code's /insights, adapted for Hermes Agent's multi-platform
architecture. Analyzes session history from state.db to produce comprehensive
usage insights.
Features:
- Overview stats: sessions, messages, tokens, estimated cost, active time
- Model breakdown: per-model sessions, tokens, and cost estimation
- Platform breakdown: CLI vs Telegram vs Discord etc. (unique to Hermes)
- Tool usage ranking: most-used tools with percentages
- Activity patterns: day-of-week chart, peak hours, streaks
- Notable sessions: longest, most messages, most tokens, most tool calls
- Cost estimation: real pricing data for 25+ models (OpenAI, Anthropic,
DeepSeek, Google, Meta) with fuzzy model name matching
- Configurable time window: --days flag (default 30)
- Source filtering: --source flag to filter by platform
Three entry points:
- /insights slash command in CLI (supports --days and --source flags)
- /insights slash command in gateway (compact markdown format)
- hermes insights CLI subcommand (standalone)
Includes 56 tests covering pricing helpers, format helpers, empty DB,
populated DB with multi-platform data, filtering, formatting, and edge cases.
2026-03-06 14:04:59 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# insights command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
insights_parser = subparsers.add_parser(
|
|
|
|
|
|
"insights",
|
|
|
|
|
|
help="Show usage insights and analytics",
|
|
|
|
|
|
description="Analyze session history to show token usage, costs, tool patterns, and activity trends"
|
|
|
|
|
|
)
|
|
|
|
|
|
insights_parser.add_argument("--days", type=int, default=30, help="Number of days to analyze (default: 30)")
|
|
|
|
|
|
insights_parser.add_argument("--source", help="Filter by platform (cli, telegram, discord, etc.)")
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_insights(args):
|
|
|
|
|
|
try:
|
|
|
|
|
|
from hermes_state import SessionDB
|
|
|
|
|
|
from agent.insights import InsightsEngine
|
|
|
|
|
|
|
|
|
|
|
|
db = SessionDB()
|
|
|
|
|
|
engine = InsightsEngine(db)
|
|
|
|
|
|
report = engine.generate(days=args.days, source=args.source)
|
|
|
|
|
|
print(engine.format_terminal(report))
|
|
|
|
|
|
db.close()
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"Error generating insights: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
insights_parser.set_defaults(func=cmd_insights)
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# version command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
version_parser = subparsers.add_parser(
|
|
|
|
|
|
"version",
|
|
|
|
|
|
help="Show version information"
|
|
|
|
|
|
)
|
|
|
|
|
|
version_parser.set_defaults(func=cmd_version)
|
|
|
|
|
|
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# update command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
update_parser = subparsers.add_parser(
|
|
|
|
|
|
"update",
|
|
|
|
|
|
help="Update Hermes Agent to the latest version",
|
|
|
|
|
|
description="Pull the latest changes from git and reinstall dependencies"
|
|
|
|
|
|
)
|
|
|
|
|
|
update_parser.set_defaults(func=cmd_update)
|
|
|
|
|
|
|
2026-02-02 22:18:18 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# uninstall command
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
uninstall_parser = subparsers.add_parser(
|
|
|
|
|
|
"uninstall",
|
|
|
|
|
|
help="Uninstall Hermes Agent",
|
|
|
|
|
|
description="Remove Hermes Agent from your system. Can keep configs/data for reinstall."
|
|
|
|
|
|
)
|
|
|
|
|
|
uninstall_parser.add_argument(
|
|
|
|
|
|
"--full",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Full uninstall - remove everything including configs and data"
|
|
|
|
|
|
)
|
|
|
|
|
|
uninstall_parser.add_argument(
|
|
|
|
|
|
"--yes", "-y",
|
|
|
|
|
|
action="store_true",
|
|
|
|
|
|
help="Skip confirmation prompts"
|
|
|
|
|
|
)
|
|
|
|
|
|
uninstall_parser.set_defaults(func=cmd_uninstall)
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# =========================================================================
|
|
|
|
|
|
# Parse and execute
|
|
|
|
|
|
# =========================================================================
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
# Handle --version flag
|
|
|
|
|
|
if args.version:
|
|
|
|
|
|
cmd_version(args)
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-02-25 23:00:10 -08:00
|
|
|
|
# Handle top-level --resume / --continue as shortcut to chat
|
|
|
|
|
|
if (args.resume or args.continue_last) and args.command is None:
|
2026-02-25 22:56:12 -08:00
|
|
|
|
args.command = "chat"
|
|
|
|
|
|
args.query = None
|
|
|
|
|
|
args.model = None
|
|
|
|
|
|
args.provider = None
|
|
|
|
|
|
args.toolsets = None
|
|
|
|
|
|
args.verbose = False
|
|
|
|
|
|
cmd_chat(args)
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-02-02 19:01:51 -08:00
|
|
|
|
# Default to chat if no command specified
|
|
|
|
|
|
if args.command is None:
|
|
|
|
|
|
args.query = None
|
|
|
|
|
|
args.model = None
|
2026-02-20 17:24:00 -08:00
|
|
|
|
args.provider = None
|
2026-02-02 19:01:51 -08:00
|
|
|
|
args.toolsets = None
|
|
|
|
|
|
args.verbose = False
|
2026-02-25 22:56:12 -08:00
|
|
|
|
args.resume = None
|
2026-02-25 23:00:10 -08:00
|
|
|
|
args.continue_last = False
|
2026-02-02 19:01:51 -08:00
|
|
|
|
cmd_chat(args)
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Execute the command
|
|
|
|
|
|
if hasattr(args, 'func'):
|
|
|
|
|
|
args.func(args)
|
|
|
|
|
|
else:
|
|
|
|
|
|
parser.print_help()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
main()
|