hermes-agent/tests/hermes_cli/test_cli_first_message.py
alt-glitch a8cf3a2cdc test: move the free-tier tests onto the welcome-trial rules
Tests that turned the free tier on with the env flag now build the real state
(a claimed trial on the desktop's local backend, via anon_portal.claimed_trial);
tests that turned it off now use what they were really about: a connector-only
guest, the CLI surface, or nous.guest: false.

Deleted with the behaviour they guarded: the gateway boot bootstrap, the
gateway startup and /status free-tier lines, the CLI notice and banner route
model, the env truth table, the boot-mint retry loop, and the re-mint of a dead
guest. Where the rule reversed, one test keeps the new rule: a dead credential
is retired and never replaced; a claimed guest never resolves to nous off the
desktop backend; a connector-only guest never asks for an inference token.
2026-10-14 00:32:21 +05:30

47 lines
2.0 KiB
Python

"""A fresh install's first CLI message reaches the model exactly as typed.
The first-contact note (the profile-build offer or the plain intro) is sent by the messaging gateway and
the TUI/desktop backend. The CLI never sent one. A one-shot ``hermes chat -q`` in a fresh home, which is
how kanban workers and scripted runs start, must not gain that note or record
``onboarding.seen.profile_build_offered`` in the profile's config.
"""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
from agent.onboarding import PROFILE_BUILD_FLAG, is_seen
from hermes_cli.config_effective import load_user_config_effective
from tests.fakes.fake_llm_provider import FakeLLMServer, Text, write_hermes_home
ROOT = Path(__file__).parents[2]
PROMPT = "work kanban task t_1"
def test_first_cli_message_in_a_fresh_home_reaches_the_model_unchanged(tmp_path):
home = tmp_path / "hermes"
with FakeLLMServer([Text("done")]) as srv:
write_hermes_home(
home, srv.base_url,
extra_config="updates:\n check: false\nmodels_dev:\n url: http://127.0.0.1:9/api.json\n",
)
env = {**os.environ, "HERMES_HOME": str(home), "PYTHONUTF8": "1"}
env["PYTHONPATH"] = str(ROOT) + os.pathsep + env.get("PYTHONPATH", "")
for name in ("HERMES_DESKTOP", "HERMES_DASHBOARD_SESSION_TOKEN"):
env.pop(name, None)
proc = subprocess.run(
[sys.executable, "-m", "hermes_cli.main", "chat", "-q", PROMPT],
cwd=ROOT, env=env, stdin=subprocess.DEVNULL, capture_output=True,
text=True, encoding="utf-8", timeout=240, check=False,
)
requests = srv.main_requests()
assert proc.returncode == 0, proc.stderr[-3000:]
assert requests, f"the model was never called; stderr tail: {proc.stderr[-2000:]}"
users = [m["content"] for m in requests[0]["messages"] if m.get("role") == "user"]
assert users == [PROMPT]
assert not is_seen(load_user_config_effective(home / "config.yaml"), PROFILE_BUILD_FLAG)