The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(free-tier): send preview_full_connectors on account creation
alt-glitch65bc6727b43c
diff --git a/apps/desktop/BUILDING.md b/apps/desktop/BUILDING.mdindex ab7140a8586..f78f0c07cd9 100644--- a/apps/desktop/BUILDING.md+++ b/apps/desktop/BUILDING.md@@ -187,8 +187,8 @@ For local commit builds, `HERMES_BUNDLE_ENV_JSON` accepts a JSON object whosestring values are defaults and whose `null` values are explicit clears. For example,`{"HERMES_HOME":null,"HERMES_DATA_DIR_SUFFIX":"magic-test"}`. Only`HERMES_HOME`, `HERMES_DATA_DIR_SUFFIX`, `HERMES_DESKTOP_USER_DATA_DIR`,-`HERMES_SHARED_AUTH_DIR`, and `HERMES_GUEST_ONBOARDING`-are accepted. Process-control variables such as `NODE_OPTIONS` and `PATH`+`HERMES_SHARED_AUTH_DIR`, `HERMES_GUEST_ONBOARDING`, and+`HERMES_PREVIEW_FULL_CONNECTORS` are accepted. Process-control variables such as `NODE_OPTIONS` and `PATH`are rejected. These settings are not applied to the build runner itself.Commit archive keys still use the SHA, so use a fresh commit for differentdefaults: an existing artifact is never overwritten with different bytes.diff --git a/apps/desktop/electron/updater/channel-protocol.ts b/apps/desktop/electron/updater/channel-protocol.tsindex 9a789d6d2a4..01f61b978d2 100644--- a/apps/desktop/electron/updater/channel-protocol.ts+++ b/apps/desktop/electron/updater/channel-protocol.ts@@ -373,7 +373,8 @@ function request(fields: Fields): ChannelRequest {'HERMES_DATA_DIR_SUFFIX','HERMES_DESKTOP_USER_DATA_DIR','HERMES_SHARED_AUTH_DIR',- 'HERMES_GUEST_ONBOARDING'+ 'HERMES_GUEST_ONBOARDING',+ 'HERMES_PREVIEW_FULL_CONNECTORS'])for (const key of environment.keys()) {diff --git a/apps/desktop/scripts/bundle-env.mjs b/apps/desktop/scripts/bundle-env.mjsindex d2327b28a15..953819519be 100644--- a/apps/desktop/scripts/bundle-env.mjs+++ b/apps/desktop/scripts/bundle-env.mjs@@ -3,7 +3,7 @@// Match scripts/releases/bundle_env.py and the channel request decoder.const ALLOWED_KEYS = new Set(['HERMES_HOME', 'HERMES_DATA_DIR_SUFFIX', 'HERMES_DESKTOP_USER_DATA_DIR',- 'HERMES_SHARED_AUTH_DIR', 'HERMES_GUEST_ONBOARDING'+ 'HERMES_SHARED_AUTH_DIR', 'HERMES_GUEST_ONBOARDING', 'HERMES_PREVIEW_FULL_CONNECTORS'])/** Validate a bundle environment object: plain object of identifiers todiff --git a/hermes_cli/anon_auth.py b/hermes_cli/anon_auth.pyindex 33cf7b3c205..679819992f1 100644--- a/hermes_cli/anon_auth.py+++ b/hermes_cli/anon_auth.py@@ -50,6 +50,11 @@ ANON_SECRET_ENV = "HERMES_ANON_API_SECRET"# tier did not exist. ``guest_enabled`` is the only reader. Not a user preference: never written to# config.yaml or .env, never shown in setup. Deleted at GA together with this comment.GUEST_ONBOARDING_ENV = "HERMES_GUEST_ONBOARDING"+# Preview cohort for the free tier's connector set, sent once on account creation so the account+# service can record it on the account. Exactly "true" or "false" is sent as that boolean; anything+# else (unset included) omits the field and the service applies its default. Self-reported and+# baked into desktop bundles in plain text: the service must treat it as a preference, never proof.+PREVIEW_FULL_CONNECTORS_ENV = "HERMES_PREVIEW_FULL_CONNECTORS"GUEST_MINT_TIMEOUT_SECONDS = 5.0# Copy shared by every surface that names the free tier (R-USR-1): never guest / anonymous / account.FREE_TIER_LABEL = "Nous · free tier"@@ -326,9 +331,17 @@ def _raise_for_anon_status(retryable=code not in ANON_TERMINAL_CODES)+def mint_request_body() -> Dict[str, Any]:+ """The ``/api/anonymous/create`` body: ``{"preview_full_connectors": bool}`` when the env var is+ exactly ``true`` / ``false``, else ``{}``."""+ raw = (os.environ.get(PREVIEW_FULL_CONNECTORS_ENV) or "").strip()+ return {"preview_full_connectors": raw == "true"} if raw in ("true", "false") else {}++def mint_guest(client: httpx.Client, portal_base_url: str) -> Dict[str, Any]:"""``POST /api/anonymous/create`` -> ``{user_id, org_id, token, idle_ttl_days}``. Token shown once."""- response = client.post(f"{portal_base_url.rstrip('/')}/api/anonymous/create", headers=_anon_headers(), json={})+ response = client.post(+ f"{portal_base_url.rstrip('/')}/api/anonymous/create", headers=_anon_headers(), json=mint_request_body())payload = _raise_for_anon_status(response, action="sign-up")token = payload.get("token")if not isinstance(token, str) or not token.startswith("anon_"):diff --git a/scripts/releases/bundle_env.py b/scripts/releases/bundle_env.pyindex c7c3aa21ec1..fbd96edb451 100644--- a/scripts/releases/bundle_env.py+++ b/scripts/releases/bundle_env.py@@ -7,7 +7,7 @@ import json# Keep this list aligned with the Desktop bundle banner and channel decoder._ALLOWED = frozenset({"HERMES_HOME", "HERMES_DATA_DIR_SUFFIX", "HERMES_DESKTOP_USER_DATA_DIR",- "HERMES_SHARED_AUTH_DIR", "HERMES_GUEST_ONBOARDING",+ "HERMES_SHARED_AUTH_DIR", "HERMES_GUEST_ONBOARDING", "HERMES_PREVIEW_FULL_CONNECTORS",})diff --git a/tests/hermes_cli/anon_portal.py b/tests/hermes_cli/anon_portal.pyindex e6696c87622..93b550c7e68 100644--- a/tests/hermes_cli/anon_portal.py+++ b/tests/hermes_cli/anon_portal.py@@ -52,6 +52,7 @@ class FakePortal:self.challenge_url = f"{PORTAL}/challenge?code=ticket"self.optional_challenge = Falseself.token_requests: list[dict] = []+ self.create_requests: list[dict] = []def creates(self) -> int:return [p for _, p in self.calls].count("/api/anonymous/create")@@ -66,6 +67,7 @@ class FakePortal:if self.gate_closed:return httpx.Response(401, json={"error": "invalid_shared_secret"})if path == "/api/anonymous/create":+ self.create_requests.append(json.loads(request.content or b"{}"))if self.create_response is not None:return self.create_responseself.minted += 1diff --git a/tests/hermes_cli/test_anon_auth_core.py b/tests/hermes_cli/test_anon_auth_core.pyindex 0f2690bc5a6..5b76e84d9d5 100644--- a/tests/hermes_cli/test_anon_auth_core.py+++ b/tests/hermes_cli/test_anon_auth_core.py@@ -137,6 +137,22 @@ class TestExplicitProvision:assert anon_auth.ensure_portal_identity(explicit=True) is Noneassert portal.minted == 0+ @pytest.mark.parametrize("raw, body", [+ ("true", {"preview_full_connectors": True}),+ ("false", {"preview_full_connectors": False}),+ (None, {}),+ ("1", {}),+ ])+ def test_preview_full_connectors_rides_the_create_call(self, portal, monkeypatch, raw, body):+ """The cohort reaches the account service on the one call that creates the account, as a+ real boolean; anything but exactly true/false leaves the body empty (the service default)."""+ if raw is None:+ monkeypatch.delenv(anon_auth.PREVIEW_FULL_CONNECTORS_ENV, raising=False)+ else:+ monkeypatch.setenv(anon_auth.PREVIEW_FULL_CONNECTORS_ENV, raw)+ anon_auth.ensure_portal_identity(explicit=True)+ assert portal.create_requests == [body]+class TestResolverIsUnchanged:def test_guest_is_last_resort_and_explicit_key_wins(self, portal, monkeypatch):