Skip to content

The agent that grows with you

fix: restore first-run guidance before gateway admission

Teknium351b8eb462f5
diff --git a/hermes_cli/gateway_chat_startup.py b/hermes_cli/gateway_chat_startup.py
index 885eace3310..a53560131f0 100644
--- a/hermes_cli/gateway_chat_startup.py
+++ b/hermes_cli/gateway_chat_startup.py
@@ -4,11 +4,27 @@ from __future__ import annotations
def launch_gateway_chat(args) -> int:
try:
- from hermes_cli.main import _confirm_startup_expensive_model_override
+ from hermes_cli.main import (
+ _confirm_startup_expensive_model_override,
+ _first_run_setup_guard,
+ _has_any_provider_configured,
+ )
from hermes_cli.gateway_chat import launch_from_args
+ import os
# Consent belongs before discovery/admission, even with --yolo.
_confirm_startup_expensive_model_override(args)
+ # A resumed/remote session owns its provider policy. Explicit endpoint/key
+ # launches can also be usable without a configured local profile.
+ if not (
+ getattr(args, "resume", None)
+ or os.environ.get("HERMES_TUI_GATEWAY_URL", "").strip()
+ or getattr(args, "base_url", None)
+ or getattr(args, "api_key", None)
+ or _has_any_provider_configured()
+ ):
+ _first_run_setup_guard(args)
+ return 0
return launch_from_args(args)
except ImportError as exc:
from hermes_constants import emit_partial_update_hint
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index 9d6d825f685..9a8f30fa99d 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -1005,7 +1005,8 @@ def _has_any_provider_configured(*, strict_profile_scope: bool = False) -> bool:
if not strict_profile_scope:
try:
if any(
- get_auth_status(pid).get("logged_in")
+ (status := get_auth_status(pid)).get("logged_in")
+ and status.get("key_source") != "keyless"
for pid, pconfig in PROVIDER_REGISTRY.items()
if pconfig.auth_type == "api_key"
):
diff --git a/tests/hermes_cli/test_gateway_first_run_live.py b/tests/hermes_cli/test_gateway_first_run_live.py
new file mode 100644
index 00000000000..57ed7ae4aa2
--- /dev/null
+++ b/tests/hermes_cli/test_gateway_first_run_live.py
@@ -0,0 +1,29 @@
+"""First-run guidance on the real CLI without a configured executor."""
+import os
+from pathlib import Path
+import subprocess
+import sys
+
+import pytest
+
+
[email protected]("argv", [[], ["chat"], ["-z", "hello"]])
+def test_headless_first_run_exits_with_setup_guidance_before_gateway(tmp_path, argv):
+ home = tmp_path / "state"
+ home.mkdir(mode=0o700)
+ user = tmp_path / "user"
+ user.mkdir()
+ root = Path(__file__).resolve().parents[2]
+ env = {k: os.environ[k] for k in ("PATH", "LANG", "TZ") if k in os.environ}
+ env.update(HOME=str(user), USERPROFILE=str(user), HERMES_HOME=str(home),
+ PYTHONPATH=str(root), PYTHONUNBUFFERED="1")
+ result = subprocess.run(
+ [sys.executable, "-m", "hermes_cli.main", *argv], cwd=tmp_path, env=env,
+ stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=40,
+ )
+ assert result.returncode == 1, (result.stdout, result.stderr)
+ assert "hermes config set model.provider custom" in result.stdout
+ assert "Run setup now?" not in result.stdout
+ assert "Session:" not in result.stderr
+ assert not (home / "gateway.pid").exists()
+ assert not (home / "state.db").exists()