The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): hermes webapp refuses a HERMES_HOME that names a deleted profile
emozilla1236645fa7a5
diff --git a/hermes_cli/webapp_launcher.py b/hermes_cli/webapp_launcher.pyindex a00565bde13..8d8e264cdf5 100644--- a/hermes_cli/webapp_launcher.py+++ b/hermes_cli/webapp_launcher.py@@ -10,6 +10,7 @@ one-use link cannot be redeemed, it prints the gateway's private link for the usfrom __future__ import annotationsimport json+import sysimport timefrom pathlib import Path@@ -32,6 +33,18 @@ def _gateway_home(home: Path) -> Path:return implied_host_root(home) or home+def _deleted_profile_refusal(home: Path) -> str | None:+ """What ``-p <name>`` says when *home* is a named profile that was deleted or never created, else+ None. ``HERMES_HOME`` set to such a home skips that check, and its gateway would be the default+ one, so the command refuses it the same way rather than act on the default profile."""+ from hermes_cli.profiles import _missing_profile_error+ from hermes_constants import named_profile_home, named_profile_is_live+ profile = named_profile_home(home)+ if profile is None or named_profile_is_live(profile):+ return None+ return str(_missing_profile_error(profile.name))++def _build(args):from hermes_cli.config import get_project_rootfrom hermes_cli.webapp import prepare_webapp_renderer@@ -198,6 +211,9 @@ def cmd_webapp(args) -> int:from hermes_constants import get_hermes_homehome = get_hermes_home()+ if (refusal := _deleted_profile_refusal(home)) is not None:+ print(f"Error: {refusal}", file=sys.stderr)+ return 1target = _gateway_home(home)if args.status:return _status(target)diff --git a/tests/hermes_cli/test_webapp_launcher.py b/tests/hermes_cli/test_webapp_launcher.pyindex d5c31ea2031..cc1994657ec 100644--- a/tests/hermes_cli/test_webapp_launcher.py+++ b/tests/hermes_cli/test_webapp_launcher.py@@ -300,6 +300,28 @@ def test_a_home_whose_gateway_never_ran_reads_as_having_none(tmp_path):assert launcher._gateway_state(_home(tmp_path / "idle")) == "absent"[email protected]("deleted", ["removed", "tombstoned"])[email protected]("action", [{"sign_out": True}, {"status": True}, {}])+def test_a_hermes_home_at_a_deleted_profile_is_refused_like_its_profile_flag(world, capsys, deleted, action):+ """``HERMES_HOME`` naming a deleted profile is refused exactly as ``-p <name>`` is, so signing+ out never replaces the default gateway's credential instead."""+ from gateway.webapp_listener import TOKEN_PATH, browser_session_token+ from hermes_constants import mark_named_profile_deleted++ gone = world["root"] / "profiles" / "gone"+ if deleted == "tombstoned":+ _home(gone)+ mark_named_profile_deleted(gone)+ before = browser_session_token(world["root"])+ _use_home(world, gone)+ assert launcher.cmd_webapp(_args(**action)) == 1+ refused = capsys.readouterr()+ assert "Error: Profile 'gone' does not exist. Create it with: hermes profile create gone" in refused.err+ assert "Signed out" not in refused.out+ assert (world["calls"]["control"], world["calls"]["ensure"], world["calls"]["build"]) == ([], [], 0)+ assert (world["root"] / TOKEN_PATH).read_text().strip() == before++def test_the_webapp_command_takes_one_action_at_a_time():import argparsefrom hermes_cli.subcommands.webapp import build_webapp_parser