The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore: trim comments the code already says across the onboarding stack
alt-glitchfe46dc282cb4
diff --git a/agent/onboarding_session.py b/agent/onboarding_session.pyindex fb8642038aa..15251b2dba0 100644--- a/agent/onboarding_session.py+++ b/agent/onboarding_session.py@@ -76,7 +76,7 @@ def onboarding_prelude(agent, history: Iterable[dict]) -> Iterator[tuple[str, stdef onboarding_turn_note(agent, *, history_empty: bool, card_waiting: bool) -> str:"""Before a user turn in the onboarding chat, while no card waits: which card is closed and how to- bring it back. Rides the turn's API-only notes, like the first-contact note."""+ bring it back."""from agent.onboarding_flow import is_activefrom agent.onboarding_record import loadfrom agent.onboarding_text import turn_notediff --git a/apps/desktop/electron/backend-claim.ts b/apps/desktop/electron/backend-claim.tsindex bf60765992f..1f43e79e583 100644--- a/apps/desktop/electron/backend-claim.ts+++ b/apps/desktop/electron/backend-claim.ts@@ -2,9 +2,7 @@* backend-claim.ts** Process start-marker probes used to match backend ownership records against- * live processes, extracted from main.ts so they are testable without booting- * Electron — including on a Windows CI lane that drives the probe with REAL- * PowerShell (`processStartMarker` shells out to powershell.exe).+ * live processes.*/import { execFile } from 'node:child_process'diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 5f59e065d3c..f56ce759b60 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -4092,10 +4092,6 @@ function writeBackendOwnership(contents) {}}-// execText and processStartMarker moved to backend-claim.ts (#93608) so the-// start-marker probe is testable — including on Windows CI with real-// PowerShell — without booting Electron. main.ts calls through the module.-async function backendCommandForPid(pid) {try {const command = IS_WINDOWS ? 'powershell.exe' : 'ps'diff --git a/apps/desktop/electron/source-backend.test.ts b/apps/desktop/electron/source-backend.test.tsindex 95e92724cd3..b352279fe15 100644--- a/apps/desktop/electron/source-backend.test.ts+++ b/apps/desktop/electron/source-backend.test.ts@@ -10,7 +10,6 @@ import WebSocket from 'ws'import { waitForDashboardPort } from './backend-ready'import { createSourcePythonBackend, resolveSourceInstallationBackend, type SourceBackend } from './source-backend'-// The argv the Desktop passes for a source-tree `hermes serve` backend.const SERVE_ARGS = ['serve', '--host', '127.0.0.1', '--port', '0']interface Fixture {diff --git a/apps/desktop/src/api/canonical-clarify-prompt.test.ts b/apps/desktop/src/api/canonical-clarify-prompt.test.tsindex b7fa358f2b4..5361d657a47 100644--- a/apps/desktop/src/api/canonical-clarify-prompt.test.ts+++ b/apps/desktop/src/api/canonical-clarify-prompt.test.ts@@ -17,7 +17,6 @@ test('a reopened sibling chat delivers retained questions before returning and rserver.on('connection', (socket: any) => socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())- // The connection's own handshake (the local-Desktop declaration), not a frame under test.if (frame.method === 'client.capabilities') { socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { server_requests: [] } })); return }sent.push(frame)socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id,@@ -59,7 +58,6 @@ test('a canonical clarify prompt drives the question card and its lock answers oserver.on('connection', (socket: any) => {socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())- // The connection's own handshake (the local-Desktop declaration), not a frame under test.if (frame.method === 'client.capabilities') { socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { server_requests: [] } })); return }sent.push(frame)socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { status: 'resolved' } }))diff --git a/apps/desktop/src/api/canonical-create-options.test.ts b/apps/desktop/src/api/canonical-create-options.test.tsindex 9f946dc8263..7135835b743 100644--- a/apps/desktop/src/api/canonical-create-options.test.ts+++ b/apps/desktop/src/api/canonical-create-options.test.ts@@ -39,7 +39,6 @@ test.each(CASES)('%s: the Desktop create frame is admitted by the owner contractserver.on('connection', (socket: any) => {socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())- // The connection's own handshake (the local-Desktop declaration), not a frame under test.if (frame.method === 'client.capabilities') { socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { server_requests: [] } })); return }sent.push(frame)const fields = Object.keys(frame.params).filter(key => !CREATE_KEYS.has(key))diff --git a/apps/desktop/src/api/canonical-producer-contract.test.ts b/apps/desktop/src/api/canonical-producer-contract.test.tsindex b6b8864f84b..abf4d0071f9 100644--- a/apps/desktop/src/api/canonical-producer-contract.test.ts+++ b/apps/desktop/src/api/canonical-producer-contract.test.ts@@ -233,7 +233,6 @@ test.each(SITES)('%s: the canonical frame fits the generated contract', async (_server.on('connection', (socket: any) => {socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())- // The connection's own handshake (the local-Desktop declaration), not a frame under test.if (frame.method === 'client.capabilities') { socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { server_requests: [] } })); return }sent.push(frame)const fields = problems(frame.method, frame.params)diff --git a/apps/desktop/src/api/canonical-profile-route.test.ts b/apps/desktop/src/api/canonical-profile-route.test.tsindex 2651779b4db..474130004cd 100644--- a/apps/desktop/src/api/canonical-profile-route.test.ts+++ b/apps/desktop/src/api/canonical-profile-route.test.ts@@ -15,7 +15,6 @@ test('a sibling profile route survives canonical request translation', async ()server.on('connection', (socket: any) => {socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())- // The connection's own handshake (the local-Desktop declaration), not a frame under test.if (frame.method === 'client.capabilities') { socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { server_requests: [] } })); return }sent.push(frame)diff --git a/apps/desktop/src/api/client.ts b/apps/desktop/src/api/client.tsindex 53d07b5e668..68c5a3e1b74 100644--- a/apps/desktop/src/api/client.ts+++ b/apps/desktop/src/api/client.ts@@ -327,8 +327,6 @@ export class HermesGateway extends JsonRpcGatewayClient {})}- // Only a local connection dials natively (electron/local-gateway.ts): this machine's gateway, with- // a ticket from its private control socket, which is what the backend checks the claim against.protected override isDesktopLocal(): boolean {return this.canonical}diff --git a/apps/shared/src/json-rpc-channel.test.ts b/apps/shared/src/json-rpc-channel.test.tsindex 00867b01fe3..2fd66ea1f40 100644--- a/apps/shared/src/json-rpc-channel.test.ts+++ b/apps/shared/src/json-rpc-channel.test.ts@@ -194,9 +194,6 @@ describe('JsonRpcRequestChannel', () => {})it('says it is the local Desktop first on the socket, in a call of its own', () => {- // The boot's first onboarding.state goes out as soon as the socket opens; the backend reads frames- // in order, so the declaration must already be ahead of it. Its own call: a backend older than the- // field refuses only it and keeps server_requests.let local = trueconst channel = new JsonRpcRequestChannel({ desktopLocal: () => local, requestIdPrefix: 'c' })const { sent, transport } = spyTransport()@@ -207,7 +204,6 @@ describe('JsonRpcRequestChannel', () => {channel.handleFrame(JSON.stringify({ jsonrpc: '2.0', method: 'event', params: { type: 'gateway.ready', payload: {} } }))expect(params()).toEqual([{ desktop_local: true }, { assume_fresh: true }, { server_requests: true }])- // A remote connection says nothing.local = falsechannel.attach(spyTransport().transport)expect(params()).toHaveLength(3)diff --git a/gateway/session_local.py b/gateway/session_local.pyindex eb910662d1e..ca1aae6b02f 100644--- a/gateway/session_local.py+++ b/gateway/session_local.py@@ -238,7 +238,7 @@ def staged_creation_follows(authority, actor, request_id):def _welcome_trial_model():"""The free model for a chat that has no configured one, while the welcome trial carries thisactivity (the local Desktop, a claimed guest): what the agent pins on the welcome host anyway- (``anon_auth.pin_model_for_route``). Else None, and the create refuses as before."""+ (``anon_auth.pin_model_for_route``). Else None, and the create refuses."""from hermes_cli import anon_authreturn anon_auth.GUEST_MODEL if anon_auth.free_inference_active() else None@@ -283,7 +283,7 @@ def stage_local_session(authority, actor, params, *, trusted_policy=None, truste{**json.loads(policy.request_json), 'model_requested': raw_model, 'route_derived': derived},sort_keys=True))if desktop_local and policy.source == 'gui':- import json # owner-stamped like ``model_requested``: the client cannot send it as a create field+ import jsonpolicy = replace(policy, request_json=json.dumps({**json.loads(policy.request_json), 'desktop_local': True}, sort_keys=True))if policy.model is None:diff --git a/gateway/session_onboarding.py b/gateway/session_onboarding.pyindex 1fc7ee1c341..0555df633f7 100644--- a/gateway/session_onboarding.py+++ b/gateway/session_onboarding.py@@ -5,13 +5,8 @@ start creates it here, writes the run record (``agent.onboarding_record``) beforattaches the asking connection and admits the hidden opening turn through the same durable FIFO as atyped message. The record is what makes it an onboarding chat for every later turn: the ``onboarding``toolset fold-in (``run_turn``), the scripted greeting and name card and the per-turn note-(``run_turn_runner``), all from ``agent.onboarding_session``.--Before this module the methods fell through to the old sidecar handler (``tui_gateway/-methods_onboarding.py``), which built its own live runtime for the chat, and the window's-``session.resume`` on that chat was refused with ``runtime_coordination_required`` because another-writer held it. ``onboarding.state`` and ``onboarding.set_run`` read and write only config and stay on-the sidecar handler.+(``run_turn_runner``), all from ``agent.onboarding_session``. ``onboarding.state`` and+``onboarding.set_run`` read and write only config and stay on the sidecar handler."""from __future__ import annotations@@ -25,7 +20,7 @@ from hermes_state_runtime import RuntimeStoreErrorlogger = logging.getLogger(__name__)-ONBOARDING_PROFILE = 'default' # tui_gateway/methods_onboarding.py::_ONBOARDING_PROFILE+ONBOARDING_PROFILE = 'default'class OnboardingRefusal(RuntimeStoreError):@@ -45,7 +40,6 @@ def handlers(connection):def _onboarding_connection(connection):- """The connection to the profile onboarding runs in: this one, or its sibling on a host-scoped socket."""return connection._sibling_for(ONBOARDING_PROFILE) or connection@@ -90,7 +84,6 @@ async def start(connection, ref, params):await connection.resume(chat, {})opening = plan['opening'] if plan['stored'] else await asyncio.to_thread(_opening_for, authority, stored)if opening is not None:- # The opening rules ride a hidden user turn; its prelude plays the greeting and the name card.run_id = await asyncio.to_thread(_run_id, authority, stored)await connection.submit(chat, {'session_id': stored, 'text': opening, 'display_kind': 'hidden','submission_id': f'onboarding-opening:{run_id or stored}'})@@ -99,9 +92,8 @@ async def start(connection, ref, params):def _choose_run(authority, request):- """Which chat the run lives in (the open one, or None for a new chat), the facts and the trial- claim a new chat needs. A refused claim (5079) or a blocked one with nothing else to run on (5080)- leaves no chat, so the install stays due."""+ """A refused claim (5079) or a blocked one with nothing else to run on (5080) leaves no chat, so+ the install stays due."""from agent.onboarding_facts import read_factsfrom agent.onboarding_flow import Factsfrom agent.onboarding_record import load, open_session_ids@@ -114,18 +106,15 @@ def _choose_run(authority, request):'replaced': [sid for sid in open_ids if sid != stored]}if stored is not None:facts = Facts.from_stored(load(db, stored)['facts'])- # A chat with no messages never got its opening (a restart between start and the first turn).if not (db.get_session(stored) or {}).get('message_count'):plan['opening'] = opening_prompt(facts)plan['facts'] = factsreturn planplan['facts'] = read_facts(facts_source=request.facts_source.value, locale=request.locale)- if not request.rerun: # a rerun never claims: it runs on the configured model+ if not request.rerun:try:plan['claimed'] = _claim_before_run(assume_fresh=request.assume_fresh)except AuthError as exc:- # The trial claim failed (portal down, rate limited): no guest and no chat, so the next- # launch is still a first install and tries again.logger.info('onboarding.start: welcome trial not claimed: %s', exc)raise OnboardingRefusal(5079, str(exc)) from excexcept _NoModelForTheRun as exc:@@ -136,7 +125,7 @@ def _choose_run(authority, request):def _claim_before_run(*, assume_fresh):"""``onboarding.run: true`` on disk before the welcome-trial claim, so a crash after the claim still- opens onboarding next launch (tui_gateway/methods_onboarding.py::_claim_before_run)."""+ opens onboarding next launch."""from hermes_cli import anon_authfrom hermes_cli.onboarding_run import set_runfrom hermes_cli.welcome_trial import claim_desktop_free_tier, provider_configured@@ -148,7 +137,6 @@ def _claim_before_run(*, assume_fresh):async def _create_chat(connection):- """A new local Desktop session owned by the authority from its first row."""from gateway.session_local import stage_local_sessionfrom gateway.session_local_recovery import restore_local_sessionfrom gateway.session_runtime_workers import tracked_write@@ -158,8 +146,6 @@ async def _create_chat(connection):client_local=connection.native_owner,desktop_local=getattr(connection.transport, 'desktop_local', False))if not (staged['policy'] or {}).get('model'):- # Nothing to run the chat on (a rerun before any provider is set up): no chat, the way a blocked- # claim opens none, instead of a row whose launch policy can never be restored.raise OnboardingRefusal(5080, 'No model is set up to run onboarding on.')await tracked_write(authority, partial(commit_local_session, authority.db, epoch=authority.epoch, receipt=staged))return restore_local_session(authority, staged['session_id']).session_iddiff --git a/gateway/session_server_requests.py b/gateway/session_server_requests.pyindex 6ccd4931067..56ad7791159 100644--- a/gateway/session_server_requests.py+++ b/gateway/session_server_requests.py@@ -119,7 +119,7 @@ def waiting(events, session_id, method) -> bool:def withdraw(events, session_id, method) -> int:"""Settle every open *method* request on this live session's stream with no answer, the way aviewer that answered would: the asker reads None and every renderer gets ``request.cancel- reason: resolved``. Main's ``_cancel_session_requests(sid, "resolved", method=...)``."""+ reason: resolved``."""with _lock:settled = [_open.pop(rid) for rid, p in list(_open.items())if p.session_id == session_id and p.events is events and p.method == method]diff --git a/hermes_cli/anon_auth.py b/hermes_cli/anon_auth.pyindex 0ed8845bb1c..1138212ebe9 100644--- a/hermes_cli/anon_auth.py+++ b/hermes_cli/anon_auth.py@@ -501,7 +501,6 @@ def _mint_locked(client: httpx.Client, portal: str, auth_store: dict[str, Any],"portal_base_url": portal.rstrip("/"),"user_id": minted.get("user_id"), "org_id": minted.get("org_id"),"idle_ttl_days": minted.get("idle_ttl_days"),- # Always present: True only for the welcome trial's own mint.WELCOME_CLAIM_FLAG: welcome_claim,}_store_provider_state(auth_store, "nous", state, set_active=False)diff --git a/hermes_cli/anon_challenge.py b/hermes_cli/anon_challenge.pyindex fb383af7131..0d4292197c8 100644--- a/hermes_cli/anon_challenge.py+++ b/hermes_cli/anon_challenge.py@@ -122,7 +122,7 @@ def client_surface() -> str:desktop app spawned, else ``cli``. ``HERMES_DESKTOP``alone is inherited by every terminal-pane shell, so desktop ownership needs the spawn credential."""from hermes_cli.process_identity import is_desktop_owned_backend, serves_local_desktop_now- if serves_local_desktop_now(): # the gateway, working for the Desktop app on this machine+ if serves_local_desktop_now():return "desktop"status = sys.modules.get("gateway.status")if status is not None and status.owns_gateway_runtime_lock():diff --git a/hermes_cli/free_tier_bootstrap.py b/hermes_cli/free_tier_bootstrap.pyindex aa58f7012db..64c9f989382 100644--- a/hermes_cli/free_tier_bootstrap.py+++ b/hermes_cli/free_tier_bootstrap.py@@ -186,7 +186,7 @@ def _build_record(*, other: bool) -> SetupRecord:def run_bootstrap(*, announce: bool = True) -> SetupRecord:- """Grandfather an existing free-model guest -> inventory -> resolve inference -> record ->+ """Settle an interrupted claim -> inventory -> resolve inference -> record ->broadcast. Idempotent per process: a second call returns the existing record. Never raises.``announce=False`` skips the ``setup.ready`` event."""global _record, _starteddiff --git a/tests/gateway/test_local_desktop_identity.py b/tests/gateway/test_local_desktop_identity.pyindex 57572de03aa..322642c65c2 100644--- a/tests/gateway/test_local_desktop_identity.py+++ b/tests/gateway/test_local_desktop_identity.py@@ -1,12 +1,7 @@"""Who counts as the Desktop app on this machine, on the unified gateway.-The welcome trial and first-run onboarding are offered only to the local Desktop. Before the gateway-the Desktop spawned its own ``hermes serve`` and that process carried the proof in its env-(``HERMES_DESKTOP`` + the spawn token). The gateway serves the Desktop, the CLI, the TUI and bots from-one process and has neither variable, so ``onboarding.state`` answered ``eligible: false`` for every-fresh install: the app showed the provider picker and never started onboarding or the trial.--The proof is now per connection: the Desktop says it is local (``client.capabilities+The welcome trial and first-run onboarding are offered only to the local Desktop. The proof is per+connection: the Desktop says it is local (``client.capabilities{desktop_local}``), and that counts only on a connection that redeemed a native ticket."""from __future__ import annotations@@ -48,8 +43,8 @@ async def _connect(tmp_path, monkeypatch, *, native=True, config=None):monkeypatch.setenv("HERMES_HOME", str(home))monkeypatch.setattr(server, "_hermes_home", str(home))monkeypatch.setattr(server, "_db", None)- monkeypatch.setattr("gateway.run._hermes_home", home) # frozen at import: the first test's home otherwise- for name in ("HERMES_DESKTOP", "HERMES_DASHBOARD_SESSION_TOKEN"): # the gateway's own env has neither+ monkeypatch.setattr("gateway.run._hermes_home", home)+ for name in ("HERMES_DESKTOP", "HERMES_DASHBOARD_SESSION_TOKEN"):monkeypatch.delenv(name, raising=False)store = SessionStore(home / "sessions", GatewayConfig())runner = SimpleNamespace(_session_db=store._db, session_store=store, _draining=False, adapters={},@@ -59,7 +54,7 @@ async def _connect(tmp_path, monkeypatch, *, native=True, config=None):authority = await initialize_session_authority(runner, profile_id=str(home), instance_id="owner")identity: dict = {"user_id": "uid:1", "provider": "local", "profile_id": str(home), "instance_id": "owner"}if native:- identity["native_bootstrap"] = True # redeemed a ticket from this machine's control socket+ identity["native_bootstrap"] = Truetransport = _Transport(identity)connection = AuthorityConnection(authority, transport, identity)from gateway.session_local_migration import bind_native_transport@@ -81,14 +76,11 @@ async def _request(conn, rid, method, params):@pytest.mark.asyncioasync def test_a_fresh_install_is_offered_onboarding_once_the_desktop_says_it_is_local(tmp_path, monkeypatch):- # A brand-new user on their own computer: no provider, no Nous identity, --fresh-install.conn = await _connect(tmp_path, monkeypatch)try:before = await _request(conn, 1, "onboarding.state", {"assume_fresh": True})- assert before["result"]["eligible"] is False # nothing has said this is the local Desktop yet+ assert before["result"]["eligible"] is False- # As the Desktop sends it: on its own after server_requests, so a backend older than the field- # refuses only this call. The earlier answer stands.from tui_gateway import server_requestsawait _request(conn, 2, "client.capabilities", {"server_requests": True})declared = await _request(conn, 3, "client.capabilities", {"desktop_local": True})@@ -128,7 +120,7 @@ async def test_a_desktop_chat_runs_its_turns_as_work_for_the_local_desktop(tmp_ptry:await _request(conn, 1, "client.capabilities", {"server_requests": True, "desktop_local": True})desktop = (await _request(conn, 2, "session.create", {"source": "gui", "request_id": "a"}))["result"]- conn.transport.desktop_local = False # e.g. the same gateway's TUI connection+ conn.transport.desktop_local = Falsetui = (await _request(conn, 3, "session.create", {"source": "tui", "request_id": "b"}))["result"]def inside_turn(stored):@@ -138,7 +130,7 @@ async def test_a_desktop_chat_runs_its_turns_as_work_for_the_local_desktop(tmp_passert inside_turn(desktop["stored_session_id"]) is Trueassert inside_turn(tui["stored_session_id"]) is False- assert on_local_desktop_backend() is False # nothing leaks out of the turn+ assert on_local_desktop_backend() is Falsefinally:await conn.connection.close()@@ -160,7 +152,7 @@ async def test_a_trial_users_desktop_chat_runs_on_the_free_model(tmp_path, monkereceipt = local_receipt(conn.authority.db, created["result"]["stored_session_id"])assert receipt["policy"]["model"] == anon_auth.GUEST_MODEL- conn.transport.desktop_local = False # only the claim is the Desktop's; every chat runs on it+ conn.transport.desktop_local = Falseother = await _request(conn, 3, "session.create", {"source": "gui", "request_id": "b"})assert "result" in other, otherassert local_receipt(conn.authority.db, other["result"]["stored_session_id"])["policy"]["model"] == anon_auth.GUEST_MODEL@@ -175,7 +167,7 @@ async def test_a_fresh_launch_claims_the_trial_and_opens_onboarding_on_it(tmp_pastate = {}guest = {"auth_method": anon_auth.ANON_AUTH_METHOD, anon_auth.WELCOME_CLAIM_FLAG: True}- def claim(**kwargs): # the portal mint: the guest exists from here on+ def claim(**kwargs):if welcome_trial.claim_blocker(assume_fresh=kwargs.get("assume_fresh", False)):return Nonestate.update(guest)@@ -198,9 +190,6 @@ async def test_a_fresh_launch_claims_the_trial_and_opens_onboarding_on_it(tmp_pa@pytest.mark.asyncioasync def test_the_first_local_desktop_connection_runs_the_desktop_boot_work(tmp_path, monkeypatch):- """`hermes serve` recorded a fresh install at boot (onboarding stays due when the first launch misses- the run). The gateway never boots that way, so the local Desktop's first accepted connection does it,- as work for that Desktop, and only once."""from hermes_cli import anon_auth, free_tier_bootstrap, onboarding_runfrom tui_gateway import serverseen = []diff --git a/tests/gateway/test_onboarding_on_the_authority.py b/tests/gateway/test_onboarding_on_the_authority.pyindex 8d1bb0019ba..d2b6707be6e 100644--- a/tests/gateway/test_onboarding_on_the_authority.py+++ b/tests/gateway/test_onboarding_on_the_authority.py@@ -1,11 +1,5 @@"""The desktop's onboarding chat on the unified gateway: the window resumes the chat that``onboarding.start`` opened.--Desktop sends ``onboarding.start`` on the authority-backed socket, then ``session.resume`` on the-``stored_session_id`` it returned. When the start built its own live runtime for that chat (the old-sidecar's ``session.resume`` + ``prompt.submit``), the authority found the chat leased by another-writer and refused every resume with ``runtime_coordination_required``: the greeting painted, the-name card closed unanswered, and "Resume failed" toasted on every retry."""from __future__ import annotations@@ -49,7 +43,7 @@ async def _desktop(tmp_path, monkeypatch, turns):monkeypatch.setattr("agent.onboarding_facts.read_facts", lambda **kw: FACTS)(home / ".env").write_text("OPENROUTER_API_KEY=sk-or-test\n", encoding="utf-8")(home / "config.yaml").write_text("model:\n provider: openrouter\n default: anthropic/claude-sonnet-4\n",- encoding="utf-8") # a model to run on+ encoding="utf-8")async def answer(event):turns.append(event)@@ -65,7 +59,7 @@ async def _desktop(tmp_path, monkeypatch, turns):identity = {"user_id": "uid:1", "provider": "local", "profile_id": str(home), "instance_id": "owner"}connection = AuthorityConnection(authority, transport, identity)from gateway.session_local_migration import bind_native_transport- bind_native_transport(authority, connection.actor, identity) # the redeemed native ticket+ bind_native_transport(authority, connection.actor, identity)return SimpleNamespace(authority=authority, connection=connection, transport=transport, db=store._db)@@ -73,7 +67,7 @@ async def _request(desktop, rid, method, params):from tui_gateway.ws import _dispatch_requestreply = await _dispatch_request(desktop.connection, {"jsonrpc": "2.0", "id": rid, "method": method,"params": params}, method, desktop.transport)- if reply is None: # a long handler answers on the socket from the pool+ if reply is None:def written():return next((f for f in desktop.transport.frames if isinstance(f, dict) and f.get("id") == rid), None)await async_wait_until(written, timeout=20)@@ -95,7 +89,6 @@ async def test_the_window_resumes_the_chat_onboarding_start_opened(tmp_path, monassert "error" not in resumed, resumedassert resumed["result"]["session_id"] == stored- # The authority owns the chat from its first row and runs its hidden opening turn itself.assert stored.startswith("local-") and stored in desktop.authority.sessionsawait async_wait_until(lambda: turns, timeout=10)assert "first-run onboarding" in turns[0].text and "setup_beat" in turns[0].text@@ -113,13 +106,11 @@ async def test_a_rerun_replaces_the_open_run_and_skip_ends_the_new_one(tmp_path,first = (await _request(desktop, 1, "onboarding.start", {"rerun": True}))["result"]["stored_session_id"]second = (await _request(desktop, 2, "onboarding.start", {"rerun": True}))["result"]["stored_session_id"]assert second != first- assert onboarding_record.load(desktop.db, first)["phase"] != "onboarding" # ended as replaced+ assert onboarding_record.load(desktop.db, first)["phase"] != "onboarding"assert onboarding_record.load(desktop.db, second)["phase"] == "onboarding"- # A start without rerun (a second window, a reconnect) gets the open run back, no second chat.again = (await _request(desktop, 3, "onboarding.start", {}))["result"]assert again["stored_session_id"] == second and again["resumed"] is True- # The name card waits on the live chat; Skip setup ends the run and closes the card unanswered.live = desktop.authority.sessions[second]answer = asyncio.get_running_loop().run_in_executor(None, lambda: ask_viewer_result(live.event_stream, second, "setup_beat", {"beat": "name"}, timeout=10))@@ -139,7 +130,7 @@ async def test_a_rerun_with_no_model_opens_no_chat(tmp_path, monkeypatch):desktop = await _desktop(tmp_path, monkeypatch, [])(tmp_path / ".hermes" / "config.yaml").write_text("{}\n", encoding="utf-8")(tmp_path / ".hermes" / ".env").write_text("", encoding="utf-8")- monkeypatch.setattr("gateway.run._resolve_gateway_model", lambda config=None: None) # no provider anywhere+ monkeypatch.setattr("gateway.run._resolve_gateway_model", lambda config=None: None)try:before = {row["id"] for row in desktop.db.search_sessions(limit=100)}refused = await _request(desktop, 1, "onboarding.start", {"rerun": True})@@ -163,7 +154,7 @@ def test_an_onboarding_chat_folds_in_setup_beat_for_its_whole_life(tmp_path):onboarding_record.start(db, "onb", FACTS)assert onboarding_chat_toolsets(["web"], db, "onb") == ["web", "onboarding"]assert onboarding_chat_toolsets(["web"], db, "plain") == ["web"]- assert onboarding_chat_toolsets([], db, "onb") == [] # a zero-tool chat stays zero-tool+ assert onboarding_chat_toolsets([], db, "onb") == []onboarding_record.advance(db, "onb", End("skipped"))assert onboarding_chat_toolsets(["web"], db, "onb") == ["web", "onboarding"]finally:@@ -186,7 +177,7 @@ def test_the_authority_turn_plays_the_opening_and_skips_the_note_while_a_card_wa_gateway_turn_context_notes="")assert list(arm_onboarding_turn(agent, owner, [])) == [(GREETING, "setup_beat", {"beat": "name"})]assert arm_onboarding_turn(SimpleNamespace(valid_tool_names={"terminal"}), owner, []) is None- assert arm_onboarding_turn(agent, None, []) is None # not an authority-owned local turn+ assert arm_onboarding_turn(agent, None, []) is Nonewith _lock:_open["srq-test"] = _Pending("onb", events=stream, method="setup_beat")try:diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.pyindex 4ff53f659dc..b9771d65cdc 100644--- a/tui_gateway/methods_onboarding.py+++ b/tui_gateway/methods_onboarding.py@@ -106,9 +106,8 @@ _local_desktop_boot_started = Falsedef begin_local_desktop_boot() -> None:- """The local Desktop's first accepted connection to this process. It no longer spawns its own- ``hermes serve``, so the boot work that ran there (record a fresh install, settle an interrupted- claim, the setup record and the due answer) runs here, once, as work for that Desktop."""+ """The local Desktop's first accepted connection to this process: record a fresh install, settle an+ interrupted claim, the setup record and the due answer, once, as work for that Desktop."""global _local_desktop_boot_startedfrom hermes_cli import free_tier_bootstrapfrom hermes_cli.process_identity import serving_local_desktopdiff --git a/tui_gateway/methods_voice.py b/tui_gateway/methods_voice.pyindex 176efc93490..08520f95076 100644--- a/tui_gateway/methods_voice.py+++ b/tui_gateway/methods_voice.py@@ -531,7 +531,7 @@ def _(rid, params: dict) -> dict:# than the field refuses only that call and keeps the ``server_requests`` it already accepted.if "server_requests" in params:server_requests.advertise(transport, bool(params.get("server_requests")))- if "desktop_local" in params and hasattr(transport, "auth_identity"): # a WebSocket client+ if "desktop_local" in params and hasattr(transport, "auth_identity"):transport.desktop_local = local_desktop_client(transport.auth_identity, params.get("desktop_local"))if transport.desktop_local:from tui_gateway import serverdiff --git a/tui_gateway/ws.py b/tui_gateway/ws.pyindex 03afca0ace6..310be695976 100644--- a/tui_gateway/ws.py+++ b/tui_gateway/ws.py@@ -134,7 +134,6 @@ class WSTransport:#: for legacy-token/stdio. RPC params can never populate it: sole identity authority for browser controllers#: and for the ``user_id`` the agent is built with (``server._session_auth_user_id``).self.auth_identity = auth_identity- # Accepted ``client.capabilities {desktop_local}`` (process_identity.local_desktop_client).self.desktop_local = False#: The served profile home whose skin this peer follows (None = the launch home); see change_watcher.self.skin_home: str | None = None