The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor: delete the initiate-setup turn core, keep the scripted prelude
alt-glitch3a867a9e65f7
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex d929838b720..938ca517a58 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -2346,7 +2346,7 @@ def init_agent(read_preview_callback: Callable[..., Any] | None = None, drive_preview_callback: Callable[..., Any] | None = None,read_window_below_callback: Callable[..., Any] | None = None, connection_callback: Callable[..., Any] | None = None,tour_callback: Callable[..., Any] | None = None, theme_callback: Callable[..., Any] | None = None,- setup_choose_callback: Callable[..., Any] | None = None, setup_beat_callback: Callable[..., Any] | None = None,+ setup_beat_callback: Callable[..., Any] | None = None,step_callback: Callable[..., Any] | None = None,stream_delta_callback: Callable[..., Any] | None = None, interim_assistant_callback: Callable[..., Any] | None = None,tool_gen_callback: Callable[..., Any] | None = None, status_callback: Callable[..., Any] | None = None,diff --git a/agent/agent_init_params.py b/agent/agent_init_params.pyindex 3345f37921a..16f3d548e82 100644--- a/agent/agent_init_params.py+++ b/agent/agent_init_params.py@@ -26,7 +26,7 @@ _CALLBACK_PARAMS = ("thinking_callback", "reasoning_callback", "clarify_callback","read_terminal_callback", "read_preview_callback", "drive_preview_callback","read_window_below_callback", "connection_callback", "tour_callback", "theme_callback",- "setup_choose_callback", "setup_beat_callback", "step_callback", "stream_delta_callback",+ "setup_beat_callback", "step_callback", "stream_delta_callback","interim_assistant_callback","status_callback", "notice_callback", "notice_clear_callback","event_callback", "reaction_callback", "tool_gen_callback",diff --git a/agent/first_task_prompt.py b/agent/first_task_prompt.pydeleted file mode 100644index d0086d52cd4..00000000000--- a/agent/first_task_prompt.py+++ /dev/null@@ -1,29 +0,0 @@-"""The ``first-task`` skill for the task chat a setup handoff opens.--``start_chat`` sends it in that chat's first user message, the way ``/initiate-setup`` carries its skill, so-no system prompt changes. It rides at the tail, after the visible ask and the "What setup learned" block:-session previews read the ask, and the history projection cuts the message at ``MARKER`` so no surface-shows the skill.-"""--from __future__ import annotations--import json-from pathlib import Path--from hermes_constants import get_optional_skills_dir--MARKER = "\n\n[/first-task]\n\n"---def first_task_tail(connect: list, install: list) -> str:- """``connect``: connector ids to show on one connect card; ``install``: catalog plugin ids to install."""- skill_dir = get_optional_skills_dir(Path(__file__).resolve().parent.parent / "optional-skills")- skill = (skill_dir / "productivity" / "first-task" / "SKILL.md").read_text(encoding="utf-8-sig").strip()- facts = json.dumps({"connect": connect, "install": install}, ensure_ascii=False)- return f"{MARKER}{skill}\n\n```json\n{facts}\n```"---def visible_text(text: str) -> str:- """The part of a user message a surface shows: everything before the first-task skill."""- return text.partition(MARKER)[0]diff --git a/agent/initiate_setup_facts.py b/agent/initiate_setup_facts.pydeleted file mode 100644index 2dd95e1ee6c..00000000000--- a/agent/initiate_setup_facts.py+++ /dev/null@@ -1,312 +0,0 @@-"""Machine and account facts for the ``/initiate-setup`` first turn and the setup cards.--Hardware facts come from ``hermes_platform.host``. Account facts (full name, locale) come from OS-user records, never from environment variables such as HOME or LANG. They describe the machine-that runs the Hermes backend; when the desktop app drives a remote backend, that is not the-user's laptop.-"""--from __future__ import annotations--import os-import platform-import re-import sys-import time-from pathlib import Path--from hermes_constants import get_optional_skills_dir-from hermes_platform.host import facts as host-from hermes_platform.host import products, runtime--# Generic account names that are not a person's name.-_NON_NAMES = frozenset({- "admin", "administrator", "default", "guest", "me", "owner", "root", "test", "user",-})-_HANDLE_CHARS = re.compile(r"[\d_@/\\]")--FORK_QUESTION = "Know what you'd like it to make?"-# Reading the Blender plugin's app declaration takes the network.-_APP_STATE_DEADLINE_S = 5--_BLENDER_TASK = {"id": "plugin:blender", "label": "Help me make something in Blender", "plugins": ["blender"]}-_NVIDIA_TASK = {- "id": "plugin:nvidia",- "label": "Set up my games and streaming",- "plugins": ["nvidia-app", "nvidia-broadcast"],-}---def skill_dir() -> Path:- return get_optional_skills_dir(Path(__file__).resolve().parent.parent / "optional-skills") / "productivity" / "initiate-setup"---# --- account facts --------------------------------------------------------------------def _posix_account() -> tuple[str, str]:- """Return (login, full name) from the user database."""- import pwd-- entry = pwd.getpwuid(os.getuid()) # windows-footgun: ok — only called off Windows (_account)- return entry.pw_name, entry.pw_gecos.split(",", 1)[0].strip()---def _windows_account() -> tuple[str, str]:- """Return (login, display name) from Win32 account APIs."""- import ctypes- from ctypes import wintypes-- login_buf = ctypes.create_unicode_buffer(257)- login_len = wintypes.DWORD(len(login_buf))- login = login_buf.value if ctypes.windll.advapi32.GetUserNameW(login_buf, ctypes.byref(login_len)) else ""-- # EXTENDED_NAME_FORMAT NameDisplay = 3. Local accounts without a display name fail here.- name_buf = ctypes.create_unicode_buffer(257)- name_len = wintypes.ULONG(len(name_buf))- full = name_buf.value if ctypes.windll.secur32.GetUserNameExW(3, name_buf, ctypes.byref(name_len)) else ""- return login, full---def _account() -> tuple[str, str]:- try:- return _windows_account() if sys.platform == "win32" else _posix_account()- except (AttributeError, ImportError, KeyError, OSError):- return "", ""---def _suggested_name(login: str, full: str) -> str | None:- """A real full name only; a login handle is never offered as the user's name."""- name = " ".join(full.split())- if not (2 <= len(name) <= 40) or name.lower() in _NON_NAMES or name.lower() == login.lower():- return None- # Digits or underscores ("p14", "CD_01.05") or an all-lowercase cased name mark a handle.- if _HANDLE_CHARS.search(name) or name == name.lower() != name.upper():- return None- return name---def suggested_name() -> str | None:- """The row ``setup_choose`` adds to the name card. It stays on this computer unless the user picks it."""- return _suggested_name(*_account())---def _darwin_locale() -> str:- """First preferred UI language, e.g. ``de-DE``, via CoreFoundation."""- import ctypes- import ctypes.util-- cf = ctypes.CDLL(ctypes.util.find_library("CoreFoundation"))- cf.CFLocaleCopyPreferredLanguages.restype = ctypes.c_void_p- cf.CFArrayGetCount.argtypes = [ctypes.c_void_p]- cf.CFArrayGetCount.restype = ctypes.c_long- cf.CFArrayGetValueAtIndex.argtypes = [ctypes.c_void_p, ctypes.c_long]- cf.CFArrayGetValueAtIndex.restype = ctypes.c_void_p- cf.CFStringGetCString.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_long, ctypes.c_uint32]- cf.CFStringGetCString.restype = ctypes.c_bool- cf.CFRelease.argtypes = [ctypes.c_void_p]-- languages = cf.CFLocaleCopyPreferredLanguages()- if not languages:- return ""- try:- if cf.CFArrayGetCount(languages) < 1:- return ""- buffer = ctypes.create_string_buffer(64)- # kCFStringEncodingUTF8- if not cf.CFStringGetCString(cf.CFArrayGetValueAtIndex(languages, 0), buffer, 64, 0x08000100):- return ""- return buffer.value.decode()- finally:- cf.CFRelease(languages)---def _windows_locale() -> str:- import ctypes-- buffer = ctypes.create_unicode_buffer(85)- return buffer.value if ctypes.windll.kernel32.GetUserDefaultLocaleName(buffer, 85) else ""---def _linux_locale() -> str:- """System locale from its config file; the shell's LANG is deliberately not read."""- for path in ("/etc/locale.conf", "/etc/default/locale"):- try:- with open(path, encoding="utf-8-sig") as handle:- for line in handle:- key, _, value = line.strip().partition("=")- if key == "LANG" and value:- return value.strip("\"'").split(".", 1)[0].replace("_", "-")- except OSError:- continue- return ""---def _locale() -> str:- try:- if sys.platform == "darwin":- return _darwin_locale()- if sys.platform == "win32":- return _windows_locale()- return _linux_locale()- except (AttributeError, OSError, TypeError, ValueError):- return ""---# --- the facts block ---------------------------------------------------------------------def _machine_kind(os_family: str, spark: bool) -> str:- if spark:- return "Spark"- return {"darwin": "Mac", "win32": "PC"}.get(os_family, "computer")---def facts() -> dict:- """The facts the ``/initiate-setup`` turn sends, read as they are. A key that was not measured is left out.- The account's full name is not one of them: ``setup_choose`` adds it to the name card itself, so it reaches the- model only when the user picks it."""- os_family, arch, gpu, cpu = host.os_family(), host.native_arch(), host.gpu_class(), host.cpu_model()- ram = host.ram_total_bytes()- spark = products.nvidia_platform() in ("rtx_spark", "dgx_spark")- machine = {- "os_family": os_family,- "os_release": platform.release(),- "native_arch": arch,- "cpu_model": cpu,- "ram_gb": round(ram / 2**30) if ram else None,- "gpu_class": None if gpu == "unknown" else gpu,- "vendor": host.cpu_vendor(),- "wsl": runtime.is_wsl(),- "container": runtime.is_container(),- }- block = {- "machine": {key: value for key, value in machine.items() if value not in (None, "")},- "machine_kind": _machine_kind(os_family, spark),- "has_nvidia_gpu": gpu == "nvidia",- "is_spark": spark,- "locale": _locale(),- }- return {key: value for key, value in block.items() if value not in (None, "")}---# --- setup cards -------------------------------------------------------------------------def _fork(kind: str) -> dict:- """The fork card's fixed rows; ``fork_card`` puts first tasks from the setup picks in front. Ids are stable;- labels may be translated."""- return {"question": FORK_QUESTION, "options": [- {"id": "mind", "label": "I have something in mind"},- {"id": "machine", "label": f"Help me set up this {kind}"},- {"id": "figure", "label": "Let's figure it out together"},- ]}---# Connector picks a daily brief has nothing to read from.-_NOT_BRIEF = frozenset({"discord", "spotify", "steam", "telegram", "whatsapp", "youtube", "twitch", "reddit"})---def _from_picks(cards: dict) -> list[dict]:- picks, ids = cards.get("picks") or {}, cards.get("pick_ids") or {}- apps = [str(label) for label in picks.get("connectors") or () if str(label).lower() not in _NOT_BRIEF]- plugins = set(ids.get("plugins") or ())- rows = [{"id": "brief", "label": f"A daily brief from {' and '.join(apps[:2])}"}] if apps else []- rows += [{"id": task_id, "label": task["label"]} for task_id, task in (cards.get("plugin_tasks") or {}).items()- if plugins & set(task["plugins"])]- return rows + ([{"id": "week", "label": "A summary of my week"}] if apps else [])---def _from_machine(suggest: dict) -> list[dict]:- # No local-model row: the app's own offer sets that up on the managed runtime; a task chat would improvise one.- kind = suggest.get("kind") or "computer"- return [{"id": "apps", "label": f"Install a few apps for this {kind}"}] if suggest.get("spark") else []---def _from_nothing(suggest: dict) -> list[dict]:- page = f"A one-page guide to this {suggest.get('kind') or 'computer'}"- return [{"id": "page", "label": page}, {"id": "script", "label": "A quick script that tidies my Downloads"}]---def fork_card(cards: dict) -> dict:- """The fork card when it is shown: two first tasks, each finishable in minutes, from the apps and plugins- picked earlier in this setup and the machine, in front of the fixed rows."""- suggest = cards.get("suggest") or {}- picks, machine = _from_picks(cards), _from_machine(suggest)- ordered = picks[:1] + machine[:1] + picks[1:] + machine[1:] + _from_nothing(suggest)- fork = cards.get("fork") or _fork(suggest.get("kind") or "computer")- return {**fork, "options": ordered[:2] + fork["options"]}---def _app_states(names: list[str]) -> dict[str, str]:- """Each catalog plugin's app state as the plugins card and the installer judge it: the resolver over the- plugin's pinned ``app:`` declaration. Read in parallel; ``unknown`` for any that takes longer than the deadline."""- from agent.memory_provider import spawn_context_thread- from hermes_cli.plugin_catalog import get_live_catalog_entry- from hermes_cli.plugin_catalog_presence import presence-- states: dict[str, str] = {}-- def read(name: str) -> None:- entry = get_live_catalog_entry(name)- states[name] = presence(entry).state if entry else "unknown"-- workers = [spawn_context_thread(lambda n=name: read(n), name=f"initiate-setup-{name}") for name in names]- for worker in workers:- worker.start()- deadline = time.monotonic() + _APP_STATE_DEADLINE_S- for worker in workers:- worker.join(max(0.0, deadline - time.monotonic()))- return {name: states.get(name, "unknown") for name in names}---def _plugin_tasks(states: dict[str, str]) -> list[dict]:- """The fork's plugin rows, each offered only when the app its plugins need is there (*states* from- ``_app_states``): the installer refuses a plugin whose app is missing, so the card never offers one."""- tasks = []- nvidia_plugins = [name for name in _NVIDIA_TASK["plugins"] if states.get(name, "missing_app") != "missing_app"]- if nvidia_plugins:- tasks.append({**_NVIDIA_TASK, "plugins": nvidia_plugins})- if states["blender"] != "missing_app":- tasks.append(_BLENDER_TASK)- return tasks---def _description(block: dict) -> str:- machine = block.get("machine") or {}- parts = [- "an NVIDIA Spark" if block.get("is_spark") else "has an NVIDIA GPU" if block.get("has_nvidia_gpu") else "",- machine.get("cpu_model", ""),- f"{machine.get('os_family', '')} {machine.get('os_release', '')}".strip(),- machine.get("native_arch", ""),- ]- return ", ".join(part for part in parts if part)---def _handoff(kind: str, description: str) -> dict:- """The handoff message's parts and its two plans from ``templates/handoff.md``, the machine plan naming this- computer, so the model reads them only when it reaches the handoff."""- text = (skill_dir() / "templates" / "handoff.md").read_text(encoding="utf-8-sig")- sections = dict(re.findall(r"^## (\S+)\n\n(.*?)\n*(?=^## |\Z)", text, re.MULTILINE | re.DOTALL))- machine = sections["machine"].replace("<machine_kind>", kind).replace("<description>", description)- return {"message": sections["message"], "build": sections["build"], "machine": machine}---def setup_cards(block: dict) -> dict:- """What the setup cards take from the facts: the fork rows and what its first tasks are built from, the- Blender preselect, the handoff text the fork result carries, and the machine line ``start_chat`` appends- to the task chat's first message."""- kind, description = block["machine_kind"], _description(block)- nvidia = block.get("has_nvidia_gpu") and block["machine"].get("os_family") == "win32"- states = _app_states(["blender", *(_NVIDIA_TASK["plugins"] if nvidia else [])])- plugin_tasks, blender = _plugin_tasks(states), states["blender"]- ram = f", {block['machine']['ram_gb']} GB RAM" if block["machine"].get("ram_gb") else ""- return {- "learned": [f"This {kind}: {description}{ram}."],- "fork": _fork(kind),- # What ``fork_card`` builds first tasks from, beside the picks the cards record.- "suggest": {"kind": kind, "spark": bool(block.get("is_spark"))},- "plugin_tasks": {task["id"]: {"label": task["label"], "plugins": task["plugins"]} for task in plugin_tasks},- "preselected": {"connectors": [], "plugins": ["blender"] if blender in ("present", "app_not_running") else []},- "handoff": _handoff(kind, description),- }diff --git a/agent/initiate_setup_prompt.py b/agent/initiate_setup_prompt.pydeleted file mode 100644index 999c8cc98ac..00000000000--- a/agent/initiate_setup_prompt.py+++ /dev/null@@ -1,121 +0,0 @@-from __future__ import annotations--import json--from agent import initiate_setup_facts--HEADER = "[/initiate-setup]"-# The desktop opening the backend plays before the first model call (English only, app-owned copy).-INTRO = "Hi, I'm Hermes.\n\nLet's set things up for you. Then we'll get something cool done."---def build_initiate_setup_prompt(surface: str, tools, primary_profile: str, session_id: str | None = None) -> str:- """The skill, then one JSON block of facts the model reads as they are. ``session_id``: the desktop session- the turn runs in; its ``setup_choose`` cards read the same facts."""- from hermes_cli.anon_auth import free_tier_route- from hermes_cli.setup_profile import read_cards, read_state, record_cards-- host = initiate_setup_facts.facts()- if session_id:- # Kickoff re-sends the command into a stalled chat: keep the picks already recorded there.- record_cards(session_id, {**read_cards(session_id), **initiate_setup_facts.setup_cards(host)})- block = {- "surface": surface,- "tools_present": sorted(set(tools)),- "primary_profile": primary_profile,- "guest_free_tier": free_tier_route(),- "setup_completed_at": read_state().get("completed_at"),- **host,- }- block = {key: value for key, value in block.items() if value is not None}- skill = (initiate_setup_facts.skill_dir() / "SKILL.md").read_text(encoding="utf-8-sig").strip()- return f"{HEADER}\n\n{skill}\n\n```json\n{json.dumps(block, indent=2, ensure_ascii=False)}\n```"---NAME_QUESTION = "What should I call you?"-# A closed card counts as answered: the skill takes the default and never re-asks it.-_ANSWERED = ("submitted", "cancelled")---def _json_object(text) -> dict:- try:- value = json.loads(text) if isinstance(text, str) else text- except ValueError:- return {}- return value if isinstance(value, dict) else {}---def _opening_step(call) -> str | None:- """``name`` or ``accent`` for the opening's cards, ``""`` for any other setup card, None otherwise."""- function = (call.get("function") or {}) if isinstance(call, dict) else {}- if function.get("name") != "setup_choose":- return None- args = _json_object(function.get("arguments"))- if args.get("kind") == "accent":- return "accent"- return "name" if args.get("kind") == "question" and args.get("question") == NAME_QUESTION else ""---def _opening_so_far(history):- """``(lines said, {card: reply})`` for the opening in ``history``; None once any other setup card was asked.-- Lines are matched by text: a resumed history keeps an unanswered card's row but drops its call."""- said, replies, card_by_call = set(), {}, {}- for message in history:- if message.get("role") == "assistant" and isinstance(message.get("content"), str):- said.add(message["content"])- for call in message.get("tool_calls") or ():- step = _opening_step(call)- if step == "":- return None- if step:- card_by_call[call.get("id")] = step- step = card_by_call.get(message.get("tool_call_id")) if message.get("role") == "tool" else None- reply = _json_object(message.get("content")) if step else {}- if reply.get("outcome") in _ANSWERED:- replies[step] = reply- return said, replies---def initiate_setup_prelude(message, surface: str, tools, history):- """The desktop opening as a scripted prelude (``agent/turn_scripted_prelude.py``), or None.-- Only a desktop ``/initiate-setup`` turn gets it, and only for the opening cards the history has no- answer for: the app sends the command again after a relaunch cut the opening off, and a line- already in the chat is not said twice. Other surfaces keep the model-only opening. The- skill starts after the accent answer.- """- if (surface != "desktop" or "setup_choose" not in tools or not isinstance(message, str)- or not message.startswith(HEADER)):- return None- so_far = _opening_so_far(history)- if so_far is None or {"name", "accent"} <= so_far[1].keys():- return None- return _opening(*so_far)---def intro_resends(prompt: str, surface: str) -> bool:- """True while the desktop intro owns recovery of this ``/initiate-setup`` turn: after a relaunch the- app sends the command again (the prelude replays only the unanswered opening cards), so a generic- auto-continue of the cut-off turn would race it. A TUI chat has no intro to resend it."""- from hermes_cli.setup_profile import onboarding_eligible, read_state-- return (surface == "desktop" and prompt.startswith(HEADER) and onboarding_eligible()- and read_state().get("intro") == "unseen")---def _opening(said: set, replies: dict):- reply = replies.get("name")- if reply is None:- # ``options`` is required by the tool schema. setup_choose adds the account's name as a row itself, so the- # saved call never carries it.- card = {"kind": "question", "question": NAME_QUESTION, "options": [], "multi_select": False}- reply = _json_object((yield "" if INTRO in said else INTRO, "setup_choose", card))- if "accent" in replies:- return- picked = reply.get("picked")- label = reply.get("label") if isinstance(reply.get("label"), str) else ""- name = label if picked == "suggested" else picked.strip() if isinstance(picked, str) else ""- line = f"Good to meet you, {name}." if name else "Good to meet you."- accent = {"kind": "accent", "question": "Which colour?", "options": [], "multi_select": False}- yield "" if line in said else line, "setup_choose", accentdiff --git a/agent/turn_scripted_prelude.py b/agent/turn_scripted_prelude.pyindex 1eeb6580f32..b7945cc5ce6 100644--- a/agent/turn_scripted_prelude.py+++ b/agent/turn_scripted_prelude.py@@ -1,7 +1,7 @@"""Scripted prelude: tool calls a prompt built-in plays before the turn's first model call.-A prelude is a generator owned by the built-in (``agent.initiate_setup_prompt.initiate_setup_prelude``-is the one today). Each step it yields ``(content, tool_name, args)``: the assistant text and the one+A prelude is a generator owned by the caller that starts the turn (the desktop onboarding opening is the+intended one). Each step it yields ``(content, tool_name, args)``: the assistant text and the onetool call that row carries. The loop runs it through the unchanged ``run_tool_round`` (row persistedbefore the tool runs, interim text and tool events emitted, tool hooks fired) and sends the tool'sresult string back into the generator, so a later step can use an earlier answer.diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 28eec914283..2bb436a20c8 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -4488,25 +4488,6 @@ export interface ClarifyQuestion {export interface ClarifyResult {answers?: Record<string, string | null> | null}-export interface SetupChooseRequestParams {- session_id: string- kind: SetupChooseKind- question: string- options?: SetupChooseOption[] | null- multi_select?: boolean- preselected?: string[] | null-}-export type SetupChooseKind = 'question' | 'accent' | 'theme' | 'layout' | 'connectors' | 'plugins' | 'tour' | 'fork' | 'machine_use'-export interface SetupChooseOption {- id: string- label: string- detail?: string | null-}-export interface SetupChooseResult {- picked?: string | string[] | null- label?: string | string[] | null- said?: string | null-}/** ``card`` is the beat's data (``agent/onboarding_flow.py::BEATS``): name, theme, connectors and plugins have their own shape; layout, tour and build carry ``options``. ``tool_call_id`` is the setup_beat call the card belongs to: only that transcript row draws it. */export interface SetupBeatRequestParams {session_id: string@@ -5925,7 +5906,6 @@ export interface ServerRequestMap {secret: { params: SecretRequestParams; result: ValueResult }/** The onboarding chat's card for one beat; blocks setup_beat until answered (300 s). */setup_beat: { params: SetupBeatRequestParams; result: SetupBeatResult }- setup_choose: { params: SetupChooseRequestParams; result: SetupChooseResult }/** Masked sudo password for the terminal tool. */sudo: { params: SudoRequestParams; result: ValueResult }/** Read the visible in-app terminal buffer (JSON text answer). */@@ -5954,7 +5934,6 @@ export const SERVER_REQUEST_METHODS = ['preview.read','secret','setup_beat',- 'setup_choose','sudo','terminal.read','theme.apply',diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 801cc6072bd..71509cd0657 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -33322,165 +33322,6 @@"title": "SetupBuildAnswer","type": "object"},- "SetupChooseKind": {- "enum": [- "question",- "accent",- "theme",- "layout",- "connectors",- "plugins",- "tour",- "fork",- "machine_use"- ],- "title": "SetupChooseKind",- "type": "string"- },- "SetupChooseOption": {- "additionalProperties": false,- "properties": {- "id": {- "title": "Id",- "type": "string"- },- "label": {- "title": "Label",- "type": "string"- },- "detail": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "default": null,- "title": "Detail"- }- },- "required": [- "id",- "label"- ],- "title": "SetupChooseOption",- "type": "object"- },- "SetupChooseRequestParams": {- "additionalProperties": false,- "properties": {- "session_id": {- "title": "Session Id",- "type": "string"- },- "kind": {- "$ref": "#/components/schemas/SetupChooseKind"- },- "question": {- "title": "Question",- "type": "string"- },- "options": {- "anyOf": [- {- "items": {- "$ref": "#/components/schemas/SetupChooseOption"- },- "type": "array"- },- {- "type": "null"- }- ],- "default": null,- "title": "Options"- },- "multi_select": {- "default": false,- "title": "Multi Select",- "type": "boolean"- },- "preselected": {- "anyOf": [- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "default": null,- "title": "Preselected"- }- },- "required": [- "session_id",- "kind",- "question"- ],- "title": "SetupChooseRequestParams",- "type": "object"- },- "SetupChooseResult": {- "additionalProperties": false,- "properties": {- "picked": {- "anyOf": [- {- "type": "string"- },- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "default": null,- "title": "Picked"- },- "label": {- "anyOf": [- {- "type": "string"- },- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "default": null,- "title": "Label"- },- "said": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "default": null,- "title": "Said"- }- },- "title": "SetupChooseResult",- "type": "object"- },"SetupConnectorsAnswer": {"additionalProperties": false,"properties": {@@ -41063,24 +40904,6 @@}}},- {- "name": "setup_choose",- "summary": "",- "params": [- {- "name": "params",- "schema": {- "$ref": "#/components/schemas/SetupChooseRequestParams"- }- }- ],- "result": {- "name": "result",- "schema": {- "$ref": "#/components/schemas/SetupChooseResult"- }- }- },{"name": "sudo","summary": "Masked sudo password for the terminal tool.",diff --git a/run_agent.py b/run_agent.pyindex f3352c10ab7..42583ab9e83 100644--- a/run_agent.py+++ b/run_agent.py@@ -255,7 +255,7 @@ class AIAgent(drive_preview_callback: Callable[..., Any] | None = None, read_window_below_callback: Callable[..., Any] | None = None,connection_callback: Callable[..., Any] | None = None, tour_callback: Callable[..., Any] | None = None,theme_callback: Callable[..., Any] | None = None,- setup_choose_callback: Callable[..., Any] | None = None, setup_beat_callback: Callable[..., Any] | None = None,+ setup_beat_callback: Callable[..., Any] | None = None,step_callback: Callable[..., Any] | None = None,stream_delta_callback: Callable[..., Any] | None = None, interim_assistant_callback: Callable[..., Any] | None = None,tool_gen_callback: Callable[..., Any] | None = None, status_callback: Callable[..., Any] | None = None,diff --git a/tests/hermes_cli/test_setup_profile_answers.py b/tests/hermes_cli/test_setup_profile_answers.pydeleted file mode 100644index bb639a4a10c..00000000000--- a/tests/hermes_cli/test_setup_profile_answers.py+++ /dev/null@@ -1,33 +0,0 @@-"""Setup keeps what is already there: a re-sent /initiate-setup keeps the picks, and a Reset run from the setup-chat itself still gets the launch profile's skills."""--from agent import initiate_setup_prompt-from hermes_cli import profiles, setup_profile---def test_resent_setup_prompt_keeps_the_recorded_picks(tmp_path, monkeypatch):- monkeypatch.setenv("HERMES_HOME", str(tmp_path))- monkeypatch.setattr(setup_profile, "read_state", dict)- monkeypatch.setattr("hermes_cli.anon_auth.free_tier_route", lambda: None)- setup_profile.record_cards("s1", {"pick_ids": ["github"], "picks": {"plugins": ["blender"]}})-- initiate_setup_prompt.build_initiate_setup_prompt("desktop", [], "default", session_id="s1")-- cards = setup_profile.read_cards("s1")- assert cards["pick_ids"] == ["github"]- assert cards["picks"] == {"plugins": ["blender"]}- assert "fork" in cards---def test_reset_run_from_the_setup_profile_copies_the_launch_profiles_skills(tmp_path, monkeypatch):- launch, setup = tmp_path / "launch", tmp_path / "hermes-setup"- for home in (launch, setup):- (home / "skills" / "notes").mkdir(parents=True)- (home / "skills" / "notes" / "SKILL.md").write_text("notes", encoding="utf-8")- (setup / profiles.SETUP_PROFILE_MARKER).write_text("{}", encoding="utf-8")- monkeypatch.setenv("HERMES_HOME", str(setup))- monkeypatch.setattr(setup_profile, "find_setup_profile", lambda: ("hermes-setup", setup))-- setup_profile.reset_setup_profile(launch)-- assert (setup / "skills" / "notes" / "SKILL.md").read_text(encoding="utf-8") == "notes"diff --git a/tests/tui_gateway/test_auto_continue.py b/tests/tui_gateway/test_auto_continue.pyindex 9888fbed9b7..cf4e291a6c3 100644--- a/tests/tui_gateway/test_auto_continue.py+++ b/tests/tui_gateway/test_auto_continue.py@@ -409,34 +409,6 @@ def test_hosted_room_marker_is_left_to_the_driver(schedule_env, marker_home):assert read_turn_marker(marker_home, "session-key") is not None-def unseen_intro(monkeypatch):- """An onboarding-enabled install whose desktop intro has not been seen yet."""- from hermes_cli import setup_profile- monkeypatch.setattr(setup_profile, "onboarding_eligible", lambda: True)- monkeypatch.setattr(setup_profile, "read_state", lambda: {"intro": "unseen"})---def test_desktop_setup_turn_is_left_to_the_intro(schedule_env, marker_home, unseen_intro):- record_turn_start(marker_home, "session-key", "[/initiate-setup]\nset me up")-- result = server._maybe_schedule_auto_continue("sid", _session(source="desktop"), "session-key")-- assert result is None- assert not schedule_env- assert read_turn_marker(marker_home, "session-key") is None---def test_tui_setup_turn_still_auto_continues(emits, schedule_env, marker_home, unseen_intro):- record_turn_start(marker_home, "session-key", "[/initiate-setup]\nset me up")-- result = server._maybe_schedule_auto_continue("sid", _session(source="tui"), "session-key")-- assert result is not None- (text, _kwargs), = schedule_env- assert "[/initiate-setup]" in text--def test_stale_marker_is_cleared_not_continued(schedule_env, marker_home, monkeypatch):record_turn_start(marker_home, "session-key", "old prompt")monkeypatch.setattr(diff --git a/tui_gateway/agent_callbacks.py b/tui_gateway/agent_callbacks.pyindex 18b7d30ad8b..26249132cb7 100644--- a/tui_gateway/agent_callbacks.py+++ b/tui_gateway/agent_callbacks.py@@ -138,11 +138,6 @@ def _emit_reasoning_delta(sid: str, text: str) -> None:_emit("reasoning.delta", sid, {"text": text, **({"verbose": True} if _session_verbose(sid) else {})})-def _setup_choose_request(sid: str, payload: dict) -> dict | None:- from tui_gateway import server_requests- return server_requests.send("setup_choose", sid, dict(payload), timeout=_clarify_timeout_seconds())--def _agent_cbs(sid: str) -> dict:# Late import: bind_module rebinds this function to server.py's globals and skips plain imports.from tui_gateway.theme_bridge import theme_request@@ -186,7 +181,6 @@ def _agent_cbs(sid: str) -> dict:"tour_callback": lambda payload: _tour_request(sid, payload),# set_theme (desktop GUI): theme.apply with the tour probe ladder, or a theme.pick card."theme_callback": lambda payload: theme_request(sid, payload),- "setup_choose_callback": lambda payload: _setup_choose_request(sid, payload),"setup_beat_callback": lambda payload: _setup_beat_request(sid, payload)}# Interim assistant commentary (text alongside tool calls), gated on display.interim_assistant_diff --git a/tui_gateway/contracts/server_requests.py b/tui_gateway/contracts/server_requests.pyindex 5511b718ab7..d75545b7cc0 100644--- a/tui_gateway/contracts/server_requests.py+++ b/tui_gateway/contracts/server_requests.py@@ -56,43 +56,6 @@ server_request("clarify", params=ClarifyRequestParams, result=ClarifyResult,doc="The clarify tool: ask the user 1-5 questions.")-class SetupChooseKind(WireEnum):- question = "question"- accent = "accent"- theme = "theme"- layout = "layout"- connectors = "connectors"- plugins = "plugins"- tour = "tour"- fork = "fork"- machine_use = "machine_use"---class SetupChooseOption(Params):- id: str- label: str- detail: str | None = None---class SetupChooseRequestParams(ServerRequestParams):- kind: SetupChooseKind- question: str- options: list[SetupChooseOption] | None = None- multi_select: bool = False- # Row ids the card starts with picked: the plugins the setup facts found (Blender).- preselected: list[str] | None = None---class SetupChooseResult(Result):- picked: str | list[str] | None = None- # The name the card showed for each picked row (one per id in ``picked``); the model says it, not the id.- label: str | list[str] | None = None- # Composer text that named no row of the card: the user's words, never a pick.- said: str | None = None---server_request("setup_choose", params=SetupChooseRequestParams, result=SetupChooseResult)-# ── setup_beat (first-run onboarding) ─────────────────────────────────────────────────────────diff --git a/tui_gateway/prompt_turn.py b/tui_gateway/prompt_turn.pyindex 15b72adf2e1..827d4f398e2 100644--- a/tui_gateway/prompt_turn.py+++ b/tui_gateway/prompt_turn.py@@ -794,10 +794,7 @@ def _invoke_agent(if turn_author and "turn_author" in run_params:run_kwargs["turn_author"] = turn_authorif "prelude" in run_params:- from agent.initiate_setup_prompt import initiate_setup_prelude- prelude = initiate_setup_prelude(- text, _resolve_agent_platform(_session_source(session)), agent.valid_tool_names, st.history,- ) or _onboarding_prelude(agent, st.history)+ prelude = _onboarding_prelude(agent, st.history)if prelude is not None:run_kwargs["prelude"] = prelude_adopt_submit_user_row(session, agent, run_kwargs["persist_user_message"], text)diff --git a/tui_gateway/session_auto_continue.py b/tui_gateway/session_auto_continue.pyindex 9615b5a927b..ba20b94d41b 100644--- a/tui_gateway/session_auto_continue.py+++ b/tui_gateway/session_auto_continue.py@@ -68,10 +68,6 @@ def _maybe_schedule_auto_continue(sid: str, session: dict, session_key: str) ->return Noneif not marker.get("auto_continue", True):return None # The mailbox owns recovery and receipt identity for imported turns.- from agent.initiate_setup_prompt import intro_resends- if intro_resends(marker["prompt"], _session_source(session)):- clear_turn_marker(home, session_key) # the desktop intro sends /initiate-setup again itself- return None# Ownership, not forensics: a sibling backend sharing this HERMES_HOME can be mid-turn on this very session, so# its live marker says "someone is working on it", never "someone crashed". Leave the marker for its writer —# clearing it would cancel the live turn's own account of itself. See #94778.diff --git a/tui_gateway/session_history.py b/tui_gateway/session_history.pyindex 38d8fccea6e..ef6dc0e38ec 100644--- a/tui_gateway/session_history.py+++ b/tui_gateway/session_history.py@@ -305,9 +305,7 @@ def _history_to_messages(history: list[dict], *, profile_home=None, image_urls:if _is_display_hidden_marker(role, content_text):continueif role == "user":- # A setup handoff's first message carries the first-task skill after what the user sees.- from agent.first_task_prompt import visible_text- content_text = visible_text(_DISCORD_TRIGGERING_NOTE_RE.sub(r"\1", content_text))+ content_text = _DISCORD_TRIGGERING_NOTE_RE.sub(r"\1", content_text)if role == "assistant" and m.get("tool_calls"):for tc in m["tool_calls"]:fn, tc_id = tc.get("function", {}), tc.get("id", "")