Skip to content

The agent that grows with you

fix(free-tier): the shared store keeps welcome_claim; a guest pool row is not a Portal login

alt-glitch9cb019dad9c4
diff --git a/hermes_cli/anon_auth.py b/hermes_cli/anon_auth.py
index b9529c4e0a7..405d26701c8 100644
--- a/hermes_cli/anon_auth.py
+++ b/hermes_cli/anon_auth.py
@@ -37,8 +37,8 @@ from typing import Any, Callable, Dict, Optional
from agent.retry_utils import parse_retry_after_seconds
from hermes_cli.auth_constants import (
- AuthError, DEFAULT_NOUS_PORTAL_URL, DEFAULT_NOUS_WELCOME_URL, NOUS_INFERENCE_INVOKE_SCOPE, _decode_jwt_claims,
- httpx)
+ AuthError, DEFAULT_NOUS_PORTAL_URL, DEFAULT_NOUS_WELCOME_URL, NOUS_INFERENCE_INVOKE_SCOPE, WELCOME_CLAIM_FLAG,
+ _decode_jwt_claims, httpx)
logger = logging.getLogger("hermes_cli.auth")
@@ -50,9 +50,6 @@ ANON_SECRET_HEADER = "x-anonymous-api-secret"
# The shared secret gates the anonymous surface during its integration phase. It is a deployment
# secret (Sid's), read from the environment only.
ANON_SECRET_ENV = "HERMES_ANON_API_SECRET"
-# Set on a guest's ``providers.nous`` state when the desktop's first install claims the welcome trial
-# (``hermes_cli.welcome_trial``). Only a stamped guest carries inference; connector mints never set it.
-WELCOME_CLAIM_FLAG = "welcome_claim"
# Preview cohort for the free tier's connector set, sent once on account creation so the account
# service can record it on the account. "1" / "true" send true and "0" / "false" send false; anything
# else (unset included) omits the field and the service applies its default. Self-reported and
diff --git a/hermes_cli/auth_constants.py b/hermes_cli/auth_constants.py
index 1ce3257d329..70e4eca66a2 100644
--- a/hermes_cli/auth_constants.py
+++ b/hermes_cli/auth_constants.py
@@ -59,6 +59,9 @@ DEFAULT_NOUS_INFERENCE_URL = "https://inference-api.nousresearch.com/v1"
# the host allowlist, because the paid host cross-refuses an anonymous JWT with a 400.
DEFAULT_NOUS_WELCOME_URL = "https://welcome-api.nousresearch.com/v1"
DEFAULT_NOUS_CLIENT_ID = "hermes-cli"
+# On every guest minted since the welcome trial: True when the desktop's first install claimed it
+# (``hermes_cli.welcome_trial``), False for a connector mint. Absent = minted before the trial existed.
+WELCOME_CLAIM_FLAG = "welcome_claim"
NOUS_INFERENCE_INVOKE_SCOPE = "inference:invoke"
NOUS_BILLING_MANAGE_SCOPE = "billing:manage"
DEFAULT_NOUS_SCOPE = NOUS_INFERENCE_INVOKE_SCOPE
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index 252c80edbe7..65831f92ce1 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -24,7 +24,7 @@ from hermes_cli.auth_constants import (
DEFAULT_NOUS_INFERENCE_URL, DEFAULT_NOUS_PORTAL_URL, DEFAULT_NOUS_SCOPE, DEFAULT_NOUS_WELCOME_URL,
DEVICE_AUTH_POLL_INTERVAL_CAP_SECONDS, NOUS_AUTH_PATH_INVOKE_JWT, NOUS_BILLING_MANAGE_SCOPE,
NOUS_DEVICE_CODE_SOURCE, NOUS_INFERENCE_INVOKE_SCOPE, NOUS_INVOKE_JWT_MIN_TTL_SECONDS,
- _nous_err, httpx)
+ WELCOME_CLAIM_FLAG, _nous_err, httpx)
if TYPE_CHECKING: # annotation-only; the runtime import would be a cycle
from hermes_cli.auth import ProviderConfig
@@ -442,7 +442,9 @@ def _nous_shared_shape(src: dict[str, Any]) -> dict[str, Any]:
"inference_base_url": src.get("inference_base_url") or (
DEFAULT_NOUS_WELCOME_URL if src.get("auth_method") == "anonymous" else DEFAULT_NOUS_INFERENCE_URL),
"obtained_at": src.get("obtained_at"), "expires_at": src.get("expires_at"),
- **{k: src[k] for k in ("auth_method", "account_tier", "anon_token", "user_id", "org_id", "connectors_token")
+ # WELCOME_CLAIM_FLAG travels too: an adopted connector guest that lost it would read as pre-trial.
+ **{k: src[k] for k in ("auth_method", "account_tier", "anon_token", "user_id", "org_id", "connectors_token",
+ WELCOME_CLAIM_FLAG)
if src.get(k) not in (None, "")}}
@@ -1163,7 +1165,9 @@ def _snapshot_nous_pool_status() -> dict[str, Any]:
try:
from agent.credential_pool import load_pool
pool = load_pool("nous")
- entries = list(pool.entries()) if pool and pool.has_credentials() else []
+ # A guest's row is not a Portal login: without its trial stamp in auth.json it runs nothing.
+ entries = [e for e in pool.entries() if getattr(e, "auth_method", None) != "anonymous"] if (
+ pool and pool.has_credentials()) else []
if not entries:
return _empty_nous_auth_status()
entry = max(entries, key=lambda e: (
diff --git a/tests/hermes_cli/test_welcome_trial.py b/tests/hermes_cli/test_welcome_trial.py
index 109b029ddcd..a2239a87365 100644
--- a/tests/hermes_cli/test_welcome_trial.py
+++ b/tests/hermes_cli/test_welcome_trial.py
@@ -131,6 +131,24 @@ def test_a_reaped_claimant_replaced_by_a_connector_guest_is_not_grandfathered(po
assert not anon_auth.free_inference_active()
+def test_a_connector_guest_adopted_from_the_shared_store_is_not_grandfathered(portal, monkeypatch):
+ from hermes_cli.auth import _load_auth_store, _save_auth_store
+ from hermes_constants import get_hermes_home
+
+ as_local_desktop_backend(monkeypatch)
+ anon_auth.ensure_portal_identity(explicit=True) # connector mint: welcome_claim False, mirrored
+ store = _load_auth_store()
+ store["providers"].pop("nous") # a profile whose own identity differs adopts the shared one
+ _save_auth_store(store)
+ _chat(get_hermes_home() / "state.db", anon_auth.GUEST_MODEL)
+
+ adopted = anon_auth.ensure_portal_identity(explicit=True)
+
+ assert adopted[anon_auth.WELCOME_CLAIM_FLAG] is False
+ assert welcome_trial.grandfather_existing_guest() is False
+ assert portal.creates() == 1
+
+
LOSSES = {
"reaped": (lambda: anon_auth.clear_dead_guest("anon_credential_dead"), 1),
"replaced_by_connector": (lambda: (anon_auth.clear_dead_guest("anon_credential_dead"),
@@ -161,3 +179,18 @@ def test_a_lost_trial_is_never_claimed_again_after_a_relaunch(portal, monkeypatc
resolve_provider("auto")
record = free_tier_bootstrap.current_record()
assert (record.provider_configured, record.free_tier_account) == (False, False)
+
+
+
+def test_a_leftover_guest_pool_row_is_not_reported_as_a_nous_login(portal, monkeypatch):
+ from hermes_cli.auth import _load_auth_store, _save_auth_store, resolve_nous_runtime_credentials
+ from hermes_cli.auth_nous import get_nous_auth_status_local
+
+ claimed_trial(monkeypatch)
+ resolve_nous_runtime_credentials() # the trial ran, so the pool holds the guest's exchanged token
+ store = _load_auth_store()
+ store["providers"].pop("nous") # the claim is lost; only the pool row is left
+ _save_auth_store(store)
+
+ # Provider setup would otherwise tag Nous Portal "Connected" for a credential that runs nothing.
+ assert get_nous_auth_status_local()["logged_in"] is False