The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli): pairing/portal_cli — hoist catalog table, fold lockout/open branches (output byte-identical) (309->298 LOC)
Tekniumdc65025e14dc
diff --git a/hermes_cli/pairing.py b/hermes_cli/pairing.pyindex 5217819794e..5eef104cab0 100644--- a/hermes_cli/pairing.py+++ b/hermes_cli/pairing.py@@ -23,7 +23,6 @@ def _cmd_list(store):"""List all pending and approved users."""pending = store.list_pending()approved = store.list_approved()-if not pending and not approved:print("No pairing data found. No one has tried to pair yet~")return@@ -72,19 +71,11 @@ def _cmd_approve(store, platform: str, code: str):elif store._is_locked_out(platform):# approve_code returns None for both invalid codes and lockout — say which.import time as _time- limits = store._load_json(store._rate_limit_path())- lockout_until = limits.get(f"_lockout:{platform}", 0)- remaining = max(0, int(lockout_until - _time.time()))- mins = remaining // 60- print(- f"\n Platform '{platform}' is locked out after too many failed "- f"approval attempts."- )+ lockout_until = store._load_json(store._rate_limit_path()).get(f"_lockout:{platform}", 0)+ mins = max(0, int(lockout_until - _time.time())) // 60+ print(f"\n Platform '{platform}' is locked out after too many failed approval attempts.")print(f" Lockout clears in ~{mins} minute(s).")- print(- " To reset sooner, delete the '_lockout:{0}' entry from "- "~/.hermes/platforms/pairing/_rate_limits.json\n".format(platform)- )+ print(f" To reset sooner, delete the '_lockout:{platform}' entry from ~/.hermes/platforms/pairing/_rate_limits.json\n")else:print(f"\n Pairing request or code '{code}' not found or expired for platform '{platform}'.")print(" Run 'hermes pairing list' to see pending requests.\n")@@ -93,7 +84,6 @@ def _cmd_approve(store, platform: str, code: str):def _cmd_revoke(store, platform: str, user_id: str):"""Revoke a user's access."""platform = platform.lower().strip()-if store.revoke(platform, user_id):print(f"\n Revoked access for user {user_id} on {platform}.\n")else:diff --git a/hermes_cli/portal_cli.py b/hermes_cli/portal_cli.pyindex dddb442c109..f59f239627b 100644--- a/hermes_cli/portal_cli.py+++ b/hermes_cli/portal_cli.py@@ -10,6 +10,14 @@ from hermes_cli.config import load_configDEFAULT_PORTAL_URL = "https://portal.nousresearch.com"SUBSCRIPTION_URL = "https://portal.nousresearch.com/manage-subscription"DOCS_URL = "https://hermes-agent.nousresearch.com/docs/user-guide/features/tool-gateway"+# Static `portal tools` catalog — the partners Tool Gateway routes to today: (key, label, partner).+_CATALOG = [+ ("web", "Web search & extract", "Firecrawl"),+ ("image_gen", "Image generation", "FAL"),+ ("tts", "Text-to-speech", "OpenAI TTS"),+ ("browser", "Browser automation", "Browser Use"),+ ("modal", "Cloud terminal", "Modal"),+]def _feature_state(feat, *, via_nous: str) -> str:@@ -29,12 +37,10 @@ def _cmd_status(args) -> int:from hermes_cli.nous_subscription import get_nous_subscription_featuresconfig = load_config() or {}-try:auth = get_nous_auth_status_local() or {} # refresh-free snapshotexcept Exception:auth = {}-logged_in = bool(auth.get("logged_in"))print()@@ -67,19 +73,12 @@ def _cmd_status(args) -> int:try:features = get_nous_subscription_features(config)except Exception:- features = None-- if features is None:print(" (could not resolve subscription state)")return 0-- rows = [(feat.label, _feature_state(feat, via_nous="via Nous Portal"))- for feat in features.items()]-+ rows = [(feat.label, _feature_state(feat, via_nous="via Nous Portal")) for feat in features.items()]width = max((len(r[0]) for r in rows), default=0)for label, state in rows:print(f" {label:<{width}} {state}")-if not logged_in:print()print(color(f" Docs: {DOCS_URL}", Colors.DIM))@@ -88,17 +87,16 @@ def _cmd_status(args) -> int:def _cmd_open(args) -> int:"""Open the Portal subscription page in the default browser."""- target = SUBSCRIPTION_URL- print(f"Opening {target}")+ print(f"Opening {SUBSCRIPTION_URL}")try:- opened = webbrowser.open(target)+ opened = webbrowser.open(SUBSCRIPTION_URL)except Exception:opened = False- if not opened:- print()- print("Could not launch a browser. Visit the URL above manually.")- return 1- return 0+ if opened:+ return 0+ print()+ print("Could not launch a browser. Visit the URL above manually.")+ return 1def _cmd_tools(args) -> int:@@ -112,15 +110,6 @@ def _cmd_tools(args) -> int:print("Could not resolve Tool Gateway state.", file=sys.stderr)return 1- # Static catalog — the partners Tool Gateway routes to today.- catalog = [- ("web", "Web search & extract", "Firecrawl"),- ("image_gen", "Image generation", "FAL"),- ("tts", "Text-to-speech", "OpenAI TTS"),- ("browser", "Browser automation", "Browser Use"),- ("modal", "Cloud terminal", "Modal"),- ]-print()print(color(" Tool Gateway catalog", Colors.MAGENTA))print(color(" ────────────────────", Colors.MAGENTA))@@ -129,8 +118,8 @@ def _cmd_tools(args) -> int:print(color(" Not logged into Nous Portal — sign in with `hermes portal`.", Colors.YELLOW))print()- label_width = max(len(label) for _, label, _ in catalog)- for key, label, partner in catalog:+ label_width = max(len(label) for _, label, _ in _CATALOG)+ for key, label, partner in _CATALOG:feat = features.features.get(key)state = color("unknown", Colors.DIM) if feat is None else _feature_state(feat, via_nous="✓ via Nous Portal")print(f" {label:<{label_width}} partner: {partner:<14} {state}")