Skip to content

The agent that grows with you

revert: no setup profile release migration

alt-glitch0c4af9e3a8ea
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index 5565104cd78..b22d728438e 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -446,10 +446,10 @@ def _nous_shared_shape(src: dict[str, Any]) -> dict[str, Any]:
if src.get(k) not in (None, "")}}
-def _write_shared_nous_state(state: dict[str, Any]) -> bool:
- """Persist a minimal copy of the Nous OAuth state to the shared store; False when the save failed.
+def _write_shared_nous_state(state: dict[str, Any]) -> None:
+ """Persist a minimal copy of the Nous OAuth state to the shared store.
- Best-effort: failures are logged, not raised; per-profile auth.json stays the source of truth.
+ Best-effort: failures are logged and swallowed; per-profile auth.json stays the source of truth.
"""
from hermes_cli.auth import _nonempty_str, _save_private_json
refresh_token = state.get("refresh_token")
@@ -457,7 +457,7 @@ def _write_shared_nous_state(state: dict[str, Any]) -> bool:
# or a guest's anon_ credential, which is the whole identity and may not have been exchanged yet.
is_guest = _nonempty_str(state.get("anon_token"))
if not is_guest and not (_nonempty_str(refresh_token) and _nonempty_str(state.get("access_token"))):
- return True
+ return
shared = {
"_schema": 1, **_nous_shared_shape(state),
"updated_at": datetime.now(UTC).isoformat()}
@@ -470,8 +470,6 @@ def _write_shared_nous_state(state: dict[str, Any]) -> bool:
refresh_token_fp=_token_fingerprint(refresh_token))
except Exception as exc:
logger.debug("Failed to write shared Nous auth store: %s", exc)
- return False
- return True
def _read_shared_nous_state() -> Optional[dict[str, Any]]:
diff --git a/hermes_cli/onboarding_migrations.py b/hermes_cli/onboarding_migrations.py
deleted file mode 100644
index 07cbc4190b1..00000000000
--- a/hermes_cli/onboarding_migrations.py
+++ /dev/null
@@ -1,186 +0,0 @@
-"""One-shot release of the agentic desktop onboarding's setup profiles.
-
-Canary/RC desktop builds made a ``hermes-setup[-noun]`` profile, marked by ``.setup-profile.json``,
-and limited its tools. This turns each one into a plain profile: the marker and the setup tool
-limits go; its sessions, credentials and memories stay. It runs at serve boot before any RPC is
-served, under a file lock, once per install (latched in the root config).
-"""
-
-from __future__ import annotations
-
-import logging
-import threading
-from pathlib import Path
-
-from hermes_cli.profiles import _iter_named_profile_dirs
-from hermes_constants import get_default_hermes_root, get_hermes_home
-
-logger = logging.getLogger(__name__)
-
-SETUP_MARKER = ".setup-profile.json"
-_RELEASED_FLAG = "setup_profile_released" # root config onboarding.seen.<flag>
-_OLD_GUIDE_SKIPPED_FLAG = "setup_intro" # written by the agentic build for a returning user
-_ADDED_DISABLED_KEY = "setup_disabled_toolsets" # marker key: toolsets setup itself disabled
-# The exact cli toolset and deferred-tool lists setup wrote; a list the user changed since is theirs and stays.
-_SETUP_CLI_TOOLSETS = ["setup", "start_chat", "connections", "no_mcp"]
-_SETUP_DEFERRED_TOOLS = [
- "computer_use", "session_search", "image_generate", "todo_list", "process_manage", "cronjob_manage",
- "drive_preview", "desktop_preview", "annotate_preview", "show_tip", "desktop_project",
- "close_terminal", "read_terminal", "read_window_below", "focus_pane", "react_to_message",
-]
-# Name -> the hub identifier its optional-skills copy installed under; a same-named skill from elsewhere stays.
-_RETIRED_SKILLS = {name: f"official/productivity/{name}" for name in ("initiate-setup", "first-task")}
-_lock_holder = threading.local()
-
-
-def release_setup_profiles() -> None:
- """Release every setup profile under the root, map the old guide's outcome onto ``onboarding.run``,
- and uninstall the two retired skills. A no-op once latched, and when this backend runs inside a
- setup profile (it never rewrites its own live home; a launch from another profile does it)."""
- from agent.onboarding import is_seen, mark_seen
- from hermes_cli.auth import _file_lock
- from hermes_cli.config import read_user_config_raw
-
- if (get_hermes_home() / SETUP_MARKER).is_file():
- return
- root = get_default_hermes_root()
- config_path = root / "config.yaml"
- with _file_lock(root / ".setup-profile-release.lock", _lock_holder, 5.0,
- "another backend is releasing the setup profile"):
- if is_seen(read_user_config_raw(config_path), _RELEASED_FLAG):
- return
- marked = {path: _read_marker(path) for path in _iter_named_profile_dirs() if (path / SETUP_MARKER).is_file()}
- done = _old_guide_done(marked.values(), config_path)
- if done or marked:
- # Settled before any marker goes: once released, the setup profile counts as install
- # history, so an unset run would keep onboarding shut for a user who never finished it.
- _settle_run(config_path, not done)
- # A profile whose identity did not reach the shared store keeps its marker and the latch stays
- # open, so the next boot retries instead of leaving the install without that identity.
- unshared = {path for path in marked if not _share_identity(path)}
- for path, marker in marked.items():
- if path not in unshared:
- _release(path, marker)
- for home in (root, *_iter_named_profile_dirs()):
- _uninstall_retired_skills(home)
- if unshared:
- logger.warning("setup profile release deferred: could not share the identity of %s",
- ", ".join(sorted(path.name for path in unshared)))
- return
- mark_seen(config_path, _RELEASED_FLAG)
-
-
-def release_setup_copy(copy_dir: Path, source_dir: Path) -> None:
- """A clone, import or distribution install of a setup profile is released as it is made, since the
- boot release may already have latched (an archive from a canary build imported later). The copy
- also loses the retired onboarding skills, which the latched boot cleanup would never reach."""
- if (source_dir / SETUP_MARKER).is_file():
- _release(copy_dir, _read_marker(source_dir))
- _uninstall_retired_skills(copy_dir)
-
-
-def _read_marker(path: Path) -> dict:
- from utils import read_json_or_empty
- return read_json_or_empty(path / SETUP_MARKER)
-
-
-def _old_guide_done(markers, config_path: Path) -> bool:
- """The user finished or skipped the agentic guide, so onboarding must not open for them again."""
- from agent.onboarding import is_seen
- from hermes_cli.config import read_user_config_raw
-
- if any(marker.get("intro") == "seen" or marker.get("completed_at") for marker in markers):
- return True
- return any(is_seen(read_user_config_raw(path), _OLD_GUIDE_SKIPPED_FLAG)
- for path in {config_path, get_hermes_home() / "config.yaml"})
-
-
-def _settle_run(config_path: Path, run: bool) -> None:
- """``onboarding.run = run`` unless the root config already says what it wants."""
- from hermes_cli.config import read_user_config_raw
-
- section = read_user_config_raw(config_path).get("onboarding")
- if not isinstance(section, dict) or not isinstance(section.get("run"), bool):
- _write_run(config_path, run)
-
-
-def _write_run(config_path: Path, value: bool) -> None:
- """Persist the root ``onboarding.run`` as one write, keeping every other key and comment."""
- from hermes_cli import config as config_mod
-
- with config_mod._CONFIG_LOCK:
- config = config_mod.read_user_config_raw(config_path)
- config_mod._ensure_dict(config, "onboarding")["run"] = value
- config_mod.atomic_config_write(config_path, config)
-
-
-def _share_identity(profile: Path) -> bool:
- """A guest or sign-in made inside the setup profile becomes the install's shared Nous identity
- when the shared store has none (the shared store stays the identity of record otherwise).
- False only when that write failed."""
- from hermes_cli.auth import _load_auth_store, _provider_state_in
- from hermes_cli.auth_nous import _nous_shared_store_lock, _read_shared_nous_state, _write_shared_nous_state
-
- state = _provider_state_in(_load_auth_store(profile / "auth.json"), "nous")
- if not state:
- return True
- with _nous_shared_store_lock():
- return _read_shared_nous_state() is not None or _write_shared_nous_state(state)
-
-
-def _release(profile: Path, marker: dict) -> None:
- """Drop the marker and the tool limits setup gave the profile: its cli toolset list, the toolsets
- setup itself disabled (the user's own disabled toolsets stay) and its deferred-tool list."""
- from agent.skill_utils import parse_config_string_list
- from hermes_cli.config import atomic_config_replace, read_user_config_raw
-
- config_path = profile / "config.yaml"
- if config_path.is_file():
- config = read_user_config_raw(config_path)
- if (config.get("platform_toolsets") or {}).get("cli") == _SETUP_CLI_TOOLSETS:
- _set_key(config, "platform_toolsets", "cli", None)
- added = set(marker.get(_ADDED_DISABLED_KEY) or [])
- disabled = [name for name in parse_config_string_list((config.get("agent") or {}).get("disabled_toolsets"))
- if name not in added]
- _set_key(config, "agent", "disabled_toolsets", disabled or None)
- search = dict((config.get("tools") or {}).get("tool_search") or {})
- if search.get("defer") == _SETUP_DEFERRED_TOOLS:
- search.pop("defer") # only the list setup wrote; the user's other tool_search keys stay
- _set_key(config, "tools", "tool_search", search or None)
- atomic_config_replace(config_path, config)
- (profile / SETUP_MARKER).unlink(missing_ok=True)
- logger.info("released the setup profile %s; its chats, credentials and memories stay", profile.name)
-
-
-def _set_key(config: dict, section: str, key: str, value) -> None:
- """``config[section][key] = value``; ``None`` removes the key, and the section with its last key."""
- entries = dict(config.get(section) or {})
- if value is None:
- entries.pop(key, None)
- else:
- entries[key] = value
- if entries:
- config[section] = entries
- else:
- config.pop(section, None)
-
-
-def _uninstall_retired_skills(home: Path) -> None:
- """Hand-installed copies of the two retired onboarding skills would become live broken commands."""
- from utils import read_json_or_empty
-
- installed = read_json_or_empty(home / "skills" / ".hub" / "lock.json").get("installed") or {}
- retired = [name for name, identifier in _RETIRED_SKILLS.items()
- if (installed.get(name) or {}).get("source") == "official"
- and installed[name].get("identifier") == identifier]
- if not retired:
- return
- from hermes_constants import reset_hermes_home_override, set_hermes_home_override
- from tools.skills_hub_install import uninstall_skill
-
- token = set_hermes_home_override(home)
- try:
- for name in retired:
- logger.info("%s", uninstall_skill(name)[1])
- finally:
- reset_hermes_home_override(token)
diff --git a/hermes_cli/profile_distribution.py b/hermes_cli/profile_distribution.py
index 91b9c688f31..e2b63be0258 100644
--- a/hermes_cli/profile_distribution.py
+++ b/hermes_cli/profile_distribution.py
@@ -572,9 +572,6 @@ def _copy_dist_payload(staged: Path, target: Path, manifest: DistributionManifes
# Make sure the manifest on disk reflects resolved name + source
write_manifest(target, manifest)
- from hermes_cli.onboarding_migrations import SETUP_MARKER, release_setup_copy
- if any(rel_parts == (SETUP_MARKER,) for _, rel_parts in entries):
- release_setup_copy(target, target)
def _bootstrap_user_dirs(target: Path) -> None:
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 6be1ec854f0..58c123f8c03 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -1436,9 +1436,6 @@ def create_profile(
_clone_all_into(source_dir, staging, canon)
else:
_bootstrap_profile_dir(staging, source_dir, sync_imports=sync_imports)
- if source_dir is not None:
- from hermes_cli.onboarding_migrations import release_setup_copy
- release_setup_copy(staging, source_dir)
if source_dir is not None and not clone_channels:
from hermes_cli.profile_channels import strip_channel_settings
stripped = strip_channel_settings(staging, include_state=clone_all, source_dir=source_dir)
@@ -2361,8 +2358,6 @@ def import_profile(archive_path: str, name: Optional[str] = None) -> Path:
shutil.rmtree(child)
else:
child.unlink()
- from hermes_cli.onboarding_migrations import release_setup_copy
- release_setup_copy(final_source, final_source)
shutil.move(str(final_source), str(profile_dir))
return profile_dir
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py
index 3c08191d3b6..3c682251209 100644
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@ -295,15 +295,6 @@ async def _lifespan(app: FastAPI):
threading.Thread(target=_boot_local_runtime, daemon=True, name="local-runtime-boot").start()
- # Canary/RC desktop builds left a setup profile behind: release it before any RPC is served and
- # before the free-tier bootstrap reconciles the shared Nous identity. A failure must not stop serve.
- try:
- from hermes_cli.onboarding_migrations import release_setup_profiles
-
- release_setup_profiles()
- except Exception: # health: allow BLE001 -- a boot migration must not stop serve; logged with traceback
- _log.exception("setup profile release failed; it is retried on the next boot")
-
# Nous free tier: the one boot-time creator of its identity. Inventories credentials, mints only
# when HERMES_GUEST_ONBOARDING=1, records the answer for setup.status / free_tier.status and
# broadcasts `setup.ready`. Off-thread so a slow portal never delays the socket; the desktop's
diff --git a/tests/hermes_cli/test_onboarding_migrations.py b/tests/hermes_cli/test_onboarding_migrations.py
deleted file mode 100644
index af1538b4713..00000000000
--- a/tests/hermes_cli/test_onboarding_migrations.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""The one-shot release of the agentic onboarding's setup profiles: a marked profile becomes a plain one
-(marker and setup tool limits gone; chats, credentials and memories kept), the old guide's outcome maps
-onto ``onboarding.run``, and the retired onboarding skills are uninstalled."""
-
-from __future__ import annotations
-
-import json
-from pathlib import Path
-
-import pytest
-
-from hermes_cli import onboarding_migrations, profiles
-from hermes_cli.config import atomic_config_write, read_user_config_raw
-from hermes_state import SessionDB
-
-MARKER = ".setup-profile.json"
-SETUP_DEFER = list(onboarding_migrations._SETUP_DEFERRED_TOOLS)
-
-
-def root(tmp_path, monkeypatch) -> Path:
- home = tmp_path / ".hermes"
- home.mkdir()
- monkeypatch.setattr(Path, "home", lambda: tmp_path)
- monkeypatch.setenv("HERMES_HOME", str(home))
- monkeypatch.setenv("HERMES_SHARED_AUTH_DIR", str(tmp_path / "shared-auth"))
- return home
-
-
-def _setup_profile(name: str, marker: dict) -> Path:
- """A profile the agentic build made: its marker, its tool limits on top of a user-disabled toolset,
- a task chat, a memory and a guest identity."""
- path = profiles.create_profile(name, no_alias=True)
- atomic_config_write(path / "config.yaml", {
- "agent": {"disabled_toolsets": ["browser", "project", "catalog"], "reasoning_effort": "low"},
- "platform_toolsets": {"cli": ["setup", "start_chat", "connections", "no_mcp"]},
- "tools": {"tool_search": {"defer": SETUP_DEFER}},
- })
- (path / MARKER).write_text(json.dumps({"setup_disabled_toolsets": ["project", "catalog"], **marker}))
- db = SessionDB(path / "state.db")
- try:
- db.create_session("task-chat", "desktop")
- finally:
- db.close()
- (path / "memories").mkdir(exist_ok=True)
- (path / "memories" / "USER.md").write_text("Likes short answers.\n")
- (path / "auth.json").write_text(json.dumps({"version": 1, "providers": {"nous": {"anon_token": "anon_guest"}}}))
- return path
-
-
-def _sessions(path: Path) -> int:
- db = SessionDB(path / "state.db")
- try:
- return len(db._read_all("SELECT id FROM sessions"))
- finally:
- db.close()
-
-
-def test_a_finished_guide_releases_its_profile_once_and_keeps_its_chats(root):
- setup = _setup_profile("hermes-setup", {"intro": "seen", "completed_at": "2026-10-07T10:00:00+00:00"})
- work = profiles.create_profile("work", no_alias=True)
- atomic_config_write(work / "config.yaml", {"platform_toolsets": {"cli": ["terminal"]}})
-
- onboarding_migrations.release_setup_profiles()
-
- assert not (setup / MARKER).exists()
- config = read_user_config_raw(setup / "config.yaml")
- assert config["agent"] == {"disabled_toolsets": ["browser"], "reasoning_effort": "low"}
- assert "platform_toolsets" not in config and "tools" not in config
- assert _sessions(setup) == 1
- assert (setup / "memories" / "USER.md").read_text() == "Likes short answers.\n"
- assert json.loads((setup / "auth.json").read_text())["providers"]["nous"]["anon_token"] == "anon_guest"
- assert read_user_config_raw(work / "config.yaml") == {"platform_toolsets": {"cli": ["terminal"]}}
-
- root_config = read_user_config_raw(root / "config.yaml")
- assert root_config["onboarding"]["run"] is False
- assert root_config["onboarding"]["seen"]["setup_profile_released"] is True
-
- from hermes_cli.auth_nous import _read_shared_nous_state
- assert (_read_shared_nous_state() or {}).get("anon_token") == "anon_guest"
-
- # Latched: a marker that reappears (an old build ran again) is left for that build.
- (setup / MARKER).write_text("{}")
- onboarding_migrations.release_setup_profiles()
- assert (setup / MARKER).exists()
-
-
[email protected]("cli", [["safe"], []])
-def test_a_cli_toolset_list_the_user_changed_outlives_the_release(root, cli):
- setup = _setup_profile("hermes-setup", {"intro": "seen"})
- config = read_user_config_raw(setup / "config.yaml")
- config["platform_toolsets"] = {"cli": cli}
- atomic_config_write(setup / "config.yaml", config)
-
- onboarding_migrations.release_setup_profiles()
-
- assert read_user_config_raw(setup / "config.yaml")["platform_toolsets"] == {"cli": cli}