Skip to content

The agent that grows with you

feat(onboarding): onboarding.state answers {run, eligible}; onboarding.set_run

alt-glitchc5b80f3f2332
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index bf0d4024de4..7ad8a98f2bc 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -2202,6 +2202,16 @@ export interface OnboardingStateResult {
profile?: string | null
}
export type OnboardingIntro = 'unseen' | 'seen'
+/** ``run``: the questionnaire opens on this launch (root config ``onboarding.run``, else a fresh install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``). */
+export interface OnboardingRunStateResult {
+ run: boolean
+ eligible: boolean
+}
+/** ``mark_profile_offered`` also latches ``onboarding.seen.profile_build_offered`` in the root config, so the first chat after the questionnaire gets the plain intro instead of the profile offer. */
+export interface OnboardingSetRunParams {
+ run: boolean
+ mark_profile_offered?: boolean
+}
export interface OnboardingResetSetupProfileResult {
name: string
path: string
@@ -5284,7 +5294,10 @@ export interface RpcMethods {
'onboarding.record_failed_start': { params: Params; result: OnboardingStateResult }
/** Restore the setup profile to its created state in place (soul, memories, skills, sessions). */
'onboarding.reset_setup_profile': { params: Params; result: OnboardingResetSetupProfileResult }
- 'onboarding.state': { params: Params; result: OnboardingStateResult }
+ /** Write onboarding.run in the root profile's config.yaml; answers the new state. */
+ 'onboarding.set_run': { params: OnboardingSetRunParams; result: OnboardingRunStateResult }
+ /** Whether the desktop first-run questionnaire is due; reads the root profile's config. */
+ 'onboarding.state': { params: Params; result: OnboardingRunStateResult }
/** Spill a large paste to a file and hand back the inline placeholder. */
'paste.collapse': { params: PasteCollapseParams; result: PasteCollapseResult }
/** Render a PDF's pages to PNG and queue them as images for the next turn. */
@@ -5689,6 +5702,7 @@ export const RPC_METHODS = [
'onboarding.mark_seen',
'onboarding.record_failed_start',
'onboarding.reset_setup_profile',
+ 'onboarding.set_run',
'onboarding.state',
'paste.collapse',
'pdf.attach',
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 8ff52bc944e..7fb16d03604 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -2112,9 +2112,27 @@
}
}
},
+ {
+ "name": "onboarding.set_run",
+ "summary": "Write onboarding.run in the root profile's config.yaml; answers the new state.",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/OnboardingSetRunParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/OnboardingRunStateResult"
+ }
+ }
+ },
{
"name": "onboarding.state",
- "summary": "",
+ "summary": "Whether the desktop first-run questionnaire is due; reads the root profile's config.",
"params": [
{
"name": "params",
@@ -2126,7 +2144,7 @@
"result": {
"name": "result",
"schema": {
- "$ref": "#/components/schemas/OnboardingStateResult"
+ "$ref": "#/components/schemas/OnboardingRunStateResult"
}
}
},
@@ -20416,6 +20434,46 @@
"title": "OnboardingResetSetupProfileResult",
"type": "object"
},
+ "OnboardingRunStateResult": {
+ "additionalProperties": false,
+ "description": "``run``: the questionnaire opens on this launch (root config ``onboarding.run``, else a fresh\ninstall). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).",
+ "properties": {
+ "run": {
+ "title": "Run",
+ "type": "boolean"
+ },
+ "eligible": {
+ "title": "Eligible",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "run",
+ "eligible"
+ ],
+ "title": "OnboardingRunStateResult",
+ "type": "object"
+ },
+ "OnboardingSetRunParams": {
+ "additionalProperties": false,
+ "description": "``mark_profile_offered`` also latches ``onboarding.seen.profile_build_offered`` in the root config,\nso the first chat after the questionnaire gets the plain intro instead of the profile offer.",
+ "properties": {
+ "run": {
+ "title": "Run",
+ "type": "boolean"
+ },
+ "mark_profile_offered": {
+ "default": false,
+ "title": "Mark Profile Offered",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "run"
+ ],
+ "title": "OnboardingSetRunParams",
+ "type": "object"
+ },
"OnboardingStateResult": {
"additionalProperties": false,
"properties": {
diff --git a/hermes_cli/setup_profile.py b/hermes_cli/setup_profile.py
index ea4fb99981d..835e9466c63 100644
--- a/hermes_cli/setup_profile.py
+++ b/hermes_cli/setup_profile.py
@@ -2,7 +2,6 @@ from __future__ import annotations
import json
import logging
-import os
import random
import shutil
from datetime import datetime, timezone, UTC
@@ -140,8 +139,8 @@ def _live_owner(owner: str) -> str:
def onboarding_eligible() -> bool:
- from hermes_cli.anon_auth import GUEST_ONBOARDING_ENV
- return os.environ.get(GUEST_ONBOARDING_ENV, "").strip() == "1"
+ from hermes_cli.anon_auth import guest_enabled
+ return guest_enabled()
def read_state() -> dict:
diff --git a/tests/tui_gateway/test_onboarding_run_rpc.py b/tests/tui_gateway/test_onboarding_run_rpc.py
new file mode 100644
index 00000000000..ac36a7fafc0
--- /dev/null
+++ b/tests/tui_gateway/test_onboarding_run_rpc.py
@@ -0,0 +1,74 @@
+"""``onboarding.state`` / ``onboarding.set_run`` read and write the ROOT profile's config.yaml, even
+from a pooled backend launched under a named profile, and answer ``{run, eligible}``."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from tui_gateway import server
+from agent.onboarding import PROFILE_BUILD_FLAG
+from hermes_cli import profiles
+from hermes_cli.config import read_user_config_raw
+
+
+def launched_under_work(tmp_path, monkeypatch) -> tuple[Path, Path]:
+ root = tmp_path / ".hermes"
+ root.mkdir()
+ monkeypatch.setattr(Path, "home", lambda: tmp_path)
+ monkeypatch.setenv("HERMES_HOME", str(root))
+ work = profiles.create_profile("work", no_alias=True)
+ monkeypatch.setenv("HERMES_HOME", str(work))
+ monkeypatch.setenv("HERMES_GUEST_ONBOARDING", "1")
+ return root, work
+
+
+def _call(method: str, params: dict | None = None) -> dict:
+ return server.handle_request({"jsonrpc": "2.0", "id": 5, "method": method, "params": params or {}})
+
+
+def _onboarding(home: Path) -> dict:
+ return read_user_config_raw(home / "config.yaml").get("onboarding") or {}
+
+
+def test_state_answers_run_and_eligible(launched_under_work, monkeypatch):
+ # The user's own "work" profile is install history, so an unset flag is not due.
+ assert _call("onboarding.state")["result"] == {"run": False, "eligible": True}
+
+ monkeypatch.delenv("HERMES_GUEST_ONBOARDING")
+ assert _call("onboarding.state")["result"]["eligible"] is False
+
+
+def test_set_run_writes_the_root_config(launched_under_work):
+ root, work = launched_under_work
+
+ assert _call("onboarding.set_run", {"run": True})["result"] == {"run": True, "eligible": True}
+ assert _onboarding(root)["run"] is True
+ assert "run" not in _onboarding(work)
+ assert _call("onboarding.state")["result"]["run"] is True
+
+
+def test_start_marks_the_first_chat_offer_in_the_root_config(launched_under_work):
+ root, work = launched_under_work
+
+ _call("onboarding.set_run", {"run": False, "mark_profile_offered": True})
+
+ assert _onboarding(root)["run"] is False
+ assert _onboarding(root)["seen"][PROFILE_BUILD_FLAG] is True
+ assert PROFILE_BUILD_FLAG not in (_onboarding(work).get("seen") or {})
+
+
+def test_skip_leaves_the_first_chat_offer_alone(launched_under_work):
+ root, _work = launched_under_work
+
+ _call("onboarding.set_run", {"run": False})
+
+ assert _onboarding(root)["run"] is False
+ assert PROFILE_BUILD_FLAG not in (_onboarding(root).get("seen") or {})
+
+
+def test_set_run_requires_a_bool(launched_under_work):
+ assert "error" in _call("onboarding.set_run", {})
+ assert "error" in _call("onboarding.set_run", {"run": "yes"})
diff --git a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
index 6f285ef624b..049fe4e26cf 100644
--- a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
+++ b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
@@ -394,11 +394,34 @@ class OnboardingStateResult(Result):
profile: str | None = None
-method("onboarding.state", params=Params, result=OnboardingStateResult)
method("onboarding.record_failed_start", params=Params, result=OnboardingStateResult)
method("onboarding.mark_seen", params=Params, result=OnboardingStateResult)
+class OnboardingRunStateResult(Result):
+ """``run``: the questionnaire opens on this launch (root config ``onboarding.run``, else a fresh
+ install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``)."""
+
+ run: bool
+ eligible: bool
+
+
+method("onboarding.state", params=Params, result=OnboardingRunStateResult,
+ doc="Whether the desktop first-run questionnaire is due; reads the root profile's config.")
+
+
+class OnboardingSetRunParams(Params):
+ """``mark_profile_offered`` also latches ``onboarding.seen.profile_build_offered`` in the root config,
+ so the first chat after the questionnaire gets the plain intro instead of the profile offer."""
+
+ run: bool
+ mark_profile_offered: bool = False
+
+
+method("onboarding.set_run", params=OnboardingSetRunParams, result=OnboardingRunStateResult,
+ doc="Write onboarding.run in the root profile's config.yaml; answers the new state.")
+
+
class OnboardingResetSetupProfileResult(Result):
name: str
path: str
diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.py
index 22ec1dbdfd0..f3ebf2d6af7 100644
--- a/tui_gateway/methods_onboarding.py
+++ b/tui_gateway/methods_onboarding.py
@@ -48,14 +48,30 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"profile": setup.name, "session_id": row["id"], "empty": not row["message_count"]})
+# onboarding.state and onboarding.set_run are unscoped on purpose: onboarding.run and the first-chat
+# flag live in the root profile's config.yaml whichever profile this backend was launched under.
@method("onboarding.state")
def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import read_state, settle_returning_user
+ return _ok(rid, _run_state())
- def settle_then_read() -> dict:
- settle_returning_user()
- return read_state()
- return _onboarding_state_result(rid, settle_then_read)
+
+@method("onboarding.set_run")
+def _(rid, params: dict) -> dict:
+ from agent.onboarding import PROFILE_BUILD_FLAG, mark_seen
+ from hermes_cli.onboarding_run import set_run
+ from hermes_constants import get_default_hermes_root
+ if not isinstance(params.get("run"), bool):
+ return _err(rid, 4002, "onboarding.set_run requires a boolean 'run'")
+ set_run(params["run"])
+ if params.get("mark_profile_offered"):
+ mark_seen(get_default_hermes_root() / "config.yaml", PROFILE_BUILD_FLAG)
+ return _ok(rid, _run_state())
+
+
+def _run_state() -> dict:
+ from hermes_cli.anon_auth import guest_enabled
+ from hermes_cli.onboarding_run import should_run
+ return {"run": should_run(), "eligible": guest_enabled()}
@method("onboarding.record_failed_start")