How Hermex reaches a Hermes host: the sign-in, the one shared connection and its gateway
socket, the reconnect contract, feature detection and the compatibility pin. Every Hermes
surface goes through this, a webui server's optional Bots connection included.
bots.md owns what the screens do on top of it (chats, the inbox, rooms, Tasks,
Workspace, push provisioning). AGENTS.md (Working with the server) owns the
contract-verification order and how to advance the pin.
A Hermes server's sign-in is its direct-Hermes connection (below); a webui server can
keep one too, optionally, for its Bots. The connection is a Hermes dashboard's
HTTP/WebSocket backend, not webui.
The connection record, credentials and stable UUID live in server-scoped Keychain
storage. The host's identity is the install_id public /api/status reports (one
per Hermes root, so every Profile and every address that reaches it agree); the
record stores it the first time the host reports one (trust on first use; the inbox
backfills older records). A sign-in whose live id differs from the stored one
fails with .differentHost before the login POST, in HermesConnection.signIn(),
which every Bot surface and push provisioning goes through, so they all refuse
without sending the password. A gateway's Webapp names its install only to a caller signed
in (hermes_cli/web_routers/status.py), so when the public read had no id, sign-in reads
/api/status again signed in and runs the same check there, before anything loads (#1606).
There the password has already gone to the address: the check stops a changed host from
loading anything, not from receiving the password.
That second read is also how Hermex knows it reached a Webapp (servesWebapp). A missing stored or live id skips the check, and an
omitted id never clears a stored one. In the connection form, a new address or
username keeps the UUID when the host reports the stored install_id; otherwise a
different endpoint or username gets a new UUID. Password/name edits retain the
identity. After .differentHost, "Connect to this host instead" saves a new UUID
and discards the old connection's local data. The id is public: it catches an
address that now reaches another host, not an impostor. Removing the connection
deletes its drafts; removing the configured server deletes both its connection and
all its drafts.
A configured server is a webui server or a Hermes server (ServerAccount.kind, #899).
A Hermes server's id is its dashboard address as BotConnection.address(_:) parses it,
and its sign-in record is the same BotConnection JSON under bot_connection::<its URL>, so every Bot store, draft, cache, section order and bot link keys by it as they
do by a webui server. AuthManager.addHermesServer saves a sign-in the form already
verified and activates the server, and refuses an address already in the registry.
Hermes is the default kind (#712), so nothing about a Hermes server needs Bot Mode:
adding one, moving a webui server to one, and opening one and its bot links all work
with it off. Its home (#709) has two sides on one stack
and one shared connection, the Bots inbox and the Sessions list, switched by a bottom bar
of (filter) [Bots | Sessions] (new chat) that each side fills: on Bots the filter holds
hidden bots and section order and new chat makes a bot or a group chat; on Sessions the
filter picks a Profile or All Profiles and new chat starts a session. Both sides lead with
webui's header (SessionsHeader): HERMEX, and one pill of search and the server's avatar
(Settings on tap, switching on hold), with no top bar. On Sessions the pill grows into the
search field; on Bots it opens the search sheet. The home keeps the inbox and the session
list's view model across the switch, so a switch shows the last roster or rows at once. It
reopens on the side last shown (@SceneStorage), Sessions at first, and a bot link turns it
to Bots. The two sides keep their own read marks, live states and identities. Without a
record (after Sign Out, which deletes the record and Bot data but keeps the server) or
after the host refuses its saved password at the login step, including the one silent
re-login a signed-in 401 starts (HermesConnections.onSignInRejected), the server is
.loggedOut and shows its connection form as the root: the address locked, the
password focused, no Remove, the avatar as the way out. No Bot screen exists in that
state, so nothing sends the refused password again; saving a sign-in signs the server
back in. A webui server's own connection keeps #884's per-screen flag instead. A
Hermes server sends no webui request: Settings skips its webui loads and hides their
rows, a webui 401 never signs it out, and webui's serverless session links (session?id=) and
bare-Profile New Chat in Profile links switch to the first webui server, or open nothing without
one. New chats (#1180) and shares (#1181) stay on it. Removing it or signing it out
drops its push pairing and asks the relay to delete this device's registration, unless
another configured server shares it; the relay call is best-effort (push.md). Its connection form is reached through Settings
→ Servers → the server → Hermes connection, and saving it signs the server back in. The
active Hermes server's page has both Sign Out of This Server, which keeps the server and
shows its sign-in form, and Remove Server. Moving a webui server's connection into a Hermes
server is #707's; a copy gets a fresh UUID.
First launch and Settings → Add Server open one sheet, AddServerView over
OnboardingViewModel (#900, #1540): onboarding is a welcome page whose "Add your server"
opens it (the setup prompt and private-network pages sit behind "I don't have one yet"),
and a webui server signing in again opens it with its address filled in. The address comes
first: its first tap, Continue, reads the public
/api/status there, parsed by BotConnection.address(_:) and sent with the form's
headers on a HermesConnection of its own. A JSON object carrying the auth_required flag is a
Hermes dashboard, and HermesSignInMethod.offered(by:) reads how it offers to sign in: a
password, the browser (below), both, or none (below). For a password, username and password appear, and the next Connect signs in once
(HermesConnection.signIn(), so the version gate, install check and #880's copy apply),
then calls addHermesServer; the status line under the address shows "Hermes ".
Hermes' own Host-header 400 and .blocked show their advice and stop. Anything else, including an
address or headers only the webui path accepts, goes on to the webui path unchanged:
onboarding's configure, Add Server's addServer, each showing the password field only
once the webui asks for one. Once a webui answered, the "Will
connect to" line shows AuthManager.normalizedServerURL's URL instead of the Hermes
parser's. Header rows without a value are never sent or saved. When a webui server's own
Hermes connection uses exactly the same parsed address, the form offers "Use the sign-in
saved on ": it fills username, password and headers, and the sign-in still
expects that record's install_id. The copies stay until the address parses to another
URL, even one differing only in scheme, or a webui answers there; then the unedited
username and password and every header row still carrying a copied value leave the form.
It is never matched by install_id, which any host can report. Connection Options holds
Cloudflare Access's Client ID and Secret (the CF-Access-Client-* rows, edited as two
fields), the other header rows, and the server's name, initials and color.
A host whose status offers browser sign-in (auth_flows ∋ native_pkce) and no basic
password provider asks for no username or password: the connect form and a Hermes
server's own sign-in form (BotConnectionSetup, which reads the server's status even
when signed out) show "Sign In with Browser" instead. A host that offers both shows a
Password | Browser picker (#1539), Password first, except that a saved browser sign-in's
form opens on Browser. Each method saves only its own credential: a password sign-in saves
no oauth, a browser sign-in no password. An Authorization connection header can't go
with a browser sign-in, so its refusal shows under the picker and Connect stays off. It binds a loopback listener on 127.0.0.1 at an ephemeral port, opens the
host's /auth/native/authorize (S256 PKCE, state, every query value percent-encoded,
no provider: the host picks its only interactive provider itself and renders its own
chooser for several) in an ephemeral ASWebAuthenticationSession, and keeps the first
GET /callback whose state matches. The listener answers every callback 302 hermexsignin://done, which closes the sheet. The code, single-use and valid for 120
seconds, goes straight to /auth/native/token (HermesConnection.signIn(browserCode:verifier:)),
which makes the form's connection a browser sign-in's (BotConnection.oauth, the host's
user id as username, no password) and signs in with the bearer, so the version gate,
install check and identity check apply. Closing the sheet shows nothing; a sheet closed
without a code or a refused code shows .browserSignInFailed. Signing the same account
in again from the server's form keeps the connection's UUID. A webui server's Bots
connection keeps to a password sign-in. Move to Hermes's host choice opens this same
form (#1266), which saves the destination as a Hermes server at once, without switching
to it, so a browser host can be a destination and its own connection rotates the token
the move then refreshes from (#1265). Not built: a
foreground rebind of the listener and a background task (on the 8.1 device the socket
survived 82 s of suspension; a reclaimed one shows "can't connect" in the sheet, and
signing in again recovers) and a revoke at sign-out (sign-out deletes the record and
its refresh token).
A dashboard bound to 127.0.0.1 without dashboard.public_url reports auth_required: false; upstream runs without a password on no other bind. A phone reaches it only through
something that forwards to loopback, such as tailscale serve, Caddy or cloudflared.
The connect form and a Hermes server's own sign-in form hide the username and password,
enable Connect, and warn that anyone who reaches the address can use the agent; the
server's Settings page keeps that warning while its record has no username and no
browser sign-in (BotConnection.hasNoCredentials). Its sign-in reads the dashboard's page
(GET /, public, with the connection's headers), takes the token its script sets as
window.__HERMES_SESSION_TOKEN__, and proves it with a gated read
(/api/profiles/active): at the 0.21.5 pin /api/auth/me refuses this mode, since only
the password gate sets a session. The token is held in memory only and sent as
X-Hermes-Session-Token, never Authorization: Bearer, which a proxy's basic auth may
hold, and a cross-origin redirect drops it. A gateway's open Webapp (hermes gateway run, 0.22.1+) serves the same page without the token, since it hands out credentials only
through one-use launch links (gateway/run_api.py), so Hermex doesn't support it; its
__HERMES_AUTH_REQUIRED__=false bootstrap tells it apart from a page that isn't a
dashboard's (.gatewayListener). POST /api/auth/ws-ticket is refused here, so both
socket upgrades present the token as ?token= with no subprotocol
(HermesREST.UpgradePass), which the host checks without one
(web_server_chat.py _ws_auth_reason), each after a gated read. A host restart replaces
the token: the 401 that follows reads the page again and resends once, as for any
signed-in 401, and the read before an upgrade does the same, since a refused upgrade
can't say why. A record saved without credentials meeting the host with its sign-in on,
or one saved with credentials meeting it without, fails with .signInChanged, which signs
the active Hermes server out to its sign-in form, as a refused password does. The form saves
what the host now asks for, so only a record without credentials shows the open warning.
The same connection form serves Bots, Settings and push setup. A schemeless
address defaults to HTTPS, except recognizable private/local IPs (including
Tailscale ranges), local names and single-label hosts use HTTP. Explicit schemes
and ports are preserved; TLS failures never trigger an HTTP downgrade. A pasted
link is reduced to its root: ws/wss become http/https, the query and
fragment are dropped, and a path starting with login, auth, api, chat or
sessions is removed; any other path (a proxy prefix) and credentials are refused.
While the text parses, the form shows the root it will connect to. Invalid
addresses display errors even before a transport exists. Cancellation invalidates
the attempt before late replies can save credentials or dismiss the screen.
The synchronous Keychain write is the commit point. Saved state changes with it;
old-connection cleanup then finishes independently of sheet cancellation and the
committed operation remains successful. Main-app ATS allows plain HTTP to .local and
single-label names through NSAllowsLocalNetworking, private/local and Tailscale IPs
through CIDR exceptions, and explicit http:// Tailscale names through the ts.net
subdomain exception. Public hosts still require HTTPS.
A failed sign-in names what to check (BotConnectionAdvice): the unreachable host,
a Host-header 400 (dashboard.public_url), a webui address, a proxy or Cloudflare
status, an access proxy's own sign-in (.blocked: a redirect to another host or a
non-JSON 401 on /api/status), a host with no sign-in Hermex can use (.browserSignIn),
a refused gateway upgrade (.upgradeRefused), and an open gateway Webapp
(.gatewayListener). The inbox and chat use the same copy for the messages they show, and
none of these retries on its own. Adding a server opens the gateway socket once after the
sign-in, so a refused upgrade or a handshake Hermex can't read stops the form and nothing is
saved. For an open Webapp the inbox and the Sessions list offer Add Server (a Bot
connection on a webui server, its connection form) in place of Reconnect or Retry, since
its address can't change.
A rejected password (.rejected(401)) offers "Update sign-in" in place of
Reconnect in the inbox, a chat and a room: it opens the connection form with the
password focused, from the inbox, because a chat's or room's client is bound to
the rejected record. The app never resends that password on its own; foregrounding,
pull to refresh and closing the form unsaved send nothing until the saved record
changes or the form saves a sign-in.
The saved connection's HTTP side is one HermesConnection (Networking/Hermes/):
an ephemeral cookie jar, a single-flight sign-in, and the only path Bot HTTP
requests and gateway upgrades are sent through. HermesConnections gives every
consumer of the active server's saved connection (inbox, chats, rooms, creator,
editor and push provisioning's BotDashboardClient) the same instance, so they sign
in once; a reconnect only mints a new ticket, or checks an open dashboard's page token. The registry holds its one entry weakly
and keys it by configured server and connection UUID. A request for another server
or UUID, or for the same UUID with a new address, account, password or headers,
retires the old connection first: its sign-in in flight stops and its late replies
throw .stale. Switching away from, signing out of or removing the configured server,
and saving other credentials or headers or removing them, retire it at once rather than
at the next lookup, so a sign-in finishing afterwards stores nothing and resends nothing; a
rename or an install id backfill keeps it. Nothing is pooled by hostname, so the same host and account under two
configured servers get two jars. The connection form and dev auto-login probe
unsaved credentials on their own HermesConnection, never the shared one.
Cancelling one waiting consumer never cancels the shared sign-in. A signed-in
request answered 401 signs in again once, sharing that sign-in with every other
consumer's 401, and is resent: the auth gate refuses /api/* before any handler
runs (hermes_cli/dashboard_auth/middleware.py), so the resend cannot repeat a
write. A Bot screen's delete, upload or download is sent, and resent, only while
that screen still owns it: one that closed during the sign-in sends nothing. A 401 from the login itself (bad credentials) ends the recovery and leaves
the connection signed out; the next request signs in again. A transport failure,
proxy status or 5xx fails only its request and leaves the sign-in as it was, and
is never resent. Provisioning keeps its 120/180-second deadlines, for its steps and
for a sign-in it starts, on a second session that shares the jar; everything else
keeps 15/30.
A connection signed in through the host's browser sign-in (#708) keeps
BotConnection.oauth (provider, user id and refresh token) in its record instead of a
password. Its sign-in posts the refresh token to /auth/native/refresh, saves the
rotated one (BotConnectionStore.saveRotatedRefreshToken, only while the record is still
that connection holding that token) before the access token is used, and sends the
access token, held in memory only, as Authorization: Bearer on every signed-in request;
the socket upgrades still present a ticket. Each launch refreshes once, and a signed-in
401 refreshes again and resends, as a password connection signs in again. A connection
reads the refresh token from the Keychain, never from a copy of the record, before its
first refresh and before any later one after another connection saved a newer token, and
adopt ignores it. Move to Hermes refreshes on a connection of its own beside the
server's (#1265), and the two share the saved token this way. Retiring a connection never
cancels its refresh in flight (the host may already have rotated the token), and every
other connection on that server, whenever it was made, waits for it to save before its next
refresh reads the token. A save that fails is retried at the next
rotation. A 401 from the refresh is .signInExpired, which signs the active
Hermes server out to its sign-in form. No extension or App Intent signs in to Hermes, so
the app is the token's only user.
Connection Headers, for a proxy such as Cloudflare Access, are saved in the
connection's own Keychain record (BotConnection.headers) and edited from the
connection form with the shared CustomHeadersEditor. HermesConnection sends them,
as HermesHeaders, on every request to its own origin: the public /api/status,
sign-in, identity, ticket, REST and plugin calls, uploads, downloads, and both socket
upgrades: the gateway's /api/ws and the Kanban event socket (#1045), each on its own
ticket. The status probe sends them too, and the form signs its unsaved candidate in
with the form's set. A cross-origin redirect drops them before the push relay or any
other host, and PushRelayClient never sees them. The policy refuses transport names
(Host, Cookie, Sec-WebSocket-* and similar), the names Hermes reads for its own
checks (Origin, X-Forwarded-Prefix, X-Hermes-Session-Token) and Bearer
authorization while allowing Cloudflare Access's JSON Authorization form; the form
says why under the row and keeps Connect off. Only one of CF-Access-Client-Id and
CF-Access-Client-Secret warns but still connects. A header change keeps the UUID,
and with it drafts, cache and push pairing; it only retires the live connection. A
saved list the policy later refuses sends none. The webui's custom headers are a source
only on a tap: opened from Move to Hermes, the form offers "Use 's
Headers", which fills that server's rows in visibly (#1266). The address is never
copied. Headers are never logged.
A browser sign-in's own bearer is its Authorization, so on that connection the policy
refuses any custom Authorization, Cloudflare Access's JSON form included; Access takes
its two-header CF-Access-Client-Id and CF-Access-Client-Secret form there. The browser
leg can't carry Connection Headers at all (ASWebAuthenticationSession's extra headers
reach only the first load, and only X- names), so a proxy that gates on headers needs
its own sign-in inside the browser sheet.
Each HermesConnection also owns the one gateway WebSocket its Bot screens share,
HermesGateway; on a gateway's Webapp each Profile's chats use a socket of their own
instead (HermesConnection.gateway(profile:), § The canonical session protocol). Every screen holds its own BotClient handle on it: the inbox, each
open chat (its controls and delegated work use the chat's), a room, the creator and
the editor. The socket opens when the first screen connects and closes when the last
one leaves, so it lives while any Bot screen is connected. Each screen leaves on
.background only, not on .inactive: Control Center or a notification banner keeps
the socket and its frames, which is cheaper than a reconnect and keeps a running turn's
tool rows in place. On .background, ContentView also has HermesConnections close
the socket once, silently (closeForBackground()), so the host sees a clean close
rather than a half-open socket the tunnel notices only at its idle cutoff. The chat,
inbox, rooms and editor reconnect on .active, onto one fresh socket with a new ticket
and one handshake; the creators reconnect on their next Create (#902).
Screens that connect while it opens wait for that one attempt, so screens
reconnecting after the same drop make one socket, one ticket and one handshake. A
reply settles only the call that sent it; every event and server request goes to
every attached screen, which admits only its own (a chat by its runtime ID, the inbox
sessions.changed), and the gateway never answers a server request itself. A screen's
close() fails only its own calls with .transport, cancels its uploads and
downloads and ends its callbacks; the last screen to leave closes the socket without
a disconnect. Cancelling a read discards its reply; cancelling a call that may have
reached the agent ends that screen's part as close() does and leaves the socket to
the others. A required call past its deadline ends only its screen, which hears
onDisconnect(.transport) once and reconnects onto the socket the others kept. A lost
socket (a read or send failure, 45 seconds of silence) is connection-wide: each
attached screen hears onDisconnect once and reconnects as before, and anything later
from that socket is dropped by its generation. Retiring the connection does the same with .stale and refuses
reconnects. A chat's session stays attached to the shared socket after the chat
leaves, until the socket closes; leaving a screen never closes a host session. The
connection form and dev auto-login probe on their own connection, so their own socket.
HermesConnection and HermesGateway log the connection's lifecycle to the device
log (HermesConnectionLog), under the bundle ID and the category HermesConnection:
each sign-in with its release, or the step that failed (status, login, identity,
ticket) and why; the socket opening or failing to open (a refused upgrade with its
status); a drop with its reason and any close code the other end sent; 45 seconds of
silence; the last screen leaving; the app going to the background; retirement; a reply that matched no open call; and a
call past its deadline, by method. Lines name connections c1, c2, … and each
connection's sockets s0, s1, …, never the server: interpolate only numbers, step,
case and method names, the release /api/status reports (upstream's package version) and
HermesConnectionLog.reason(_:), each .public, and never a host, address, URL,
session or runtime id, Profile name, title, message text, ticket, replay epoch or
install id. Events, deltas and keepalive pongs are never logged. HermesConversation logs
through the same logger, counts and codes only: each reattach (automatic retries before
it, and frames held, applied and dropped) and each session.resume refusal it retries.
Each HermesConnection keeps one in-memory HermesAttemptRecord, its lastAttempt:
Status (with the release and install checks), Sign-in (login, page token, browser token
exchange or refresh), Identity, Live authorization (a usable gateway ticket or page token)
and Live handshake (only once HermesGateway finished its handshake). A sign-in,
a browser token exchange or status() starts a new one; a stage that never ran stays Not
checked, so an open dashboard's Identity and a form's live stages stay unchecked. A ticket's
401 whose sign-in is refused is a Sign-in failure. Retiring the connection drops the record.
Saved setup (BotConnectionSetup, through BotTransport.lastAttempt), onboarding and Add
Server keep a failed attempt's record beside their error and show it as a collapsed Details
under the advice (ConnectionAttemptDetails); a new message, an edit to what Connect sends,
or a webui answering at the address drops it. Copy Details exports report(): app build,
iOS, server kind, reported and tested release, the attempt's UTC time and each stage, with a
failure's typed category (HTTP status, timed out, couldn't connect, certificate) and never
an error description, host, username, header, token or install id. Nothing is persisted
and no raw log lines are copied. About's support details (#1396) add the record of the
active server's current shared connection (HermesConnections.lastAttempt(server:)): its
time and each stage, never in Report a Problem's link. The lookup never makes a connection,
and setup's own connections never reach it.
Requests are typed in Networking/Hermes/: every HTTP request (method, path, query, JSON body) is a
HermesREST case, and every JSON-RPC request is a HermesCall case, one per
operation the app uses and none for any other upstream method. A case carries only
what callers vary; fixed contract values (the canonical title, queued, the avatar
asset) are encoded there. HermesCall.params() is the only way to the wire and
runs admission first, so the "typed exception" rules in bots.md hold for every caller;
HermesGateway still runs validateDispatch at the socket write and maps errors,
cancellation and timeouts. Password login requires the basic auth gate, verifies identity,
and each socket gets a fresh single-use ticket, or on a dashboard with no sign-in its page
token as ?token= (§ No sign-in). The upgrade is a URLRequest
(HermesREST.gatewayUpgrade) offering the hermes-gateway-v1 and ticket
subprotocols in its Sec-WebSocket-Protocol header, which is where
URLSessionWebSocketTask takes them from a request; the host splits that header
on commas (hermes_cli/web_server_chat.py). JSON-RPC uses text frames. There is no bootstrap-token,
OAuth, webui fallback, server provisioning or competing-backend path.
The host tells each agent what screen it writes to through a per-surface note in its system
prompt, picked by the session's source. A session with none runs as tui, whose note says
MEDIA: tags print as text and files must be delivered as paths. So every session.create and
session.resume Hermex sends carries source: "gui" (HermesCall.source), and a branch
inherits its parent's. The host has no built-in note for that name, so Hermex keeps its own in
each Profile's config as platform_hints.gui.append (HermesREST.platformNote), which the
host appends for that source (#1278). The name must also be one a gateway beside the dashboard
treats as local: it refuses an edit to a session it hasn't loaded otherwise, so sessions made by
2.0 builds that sent hermex answer 404 not_found to pin, archive, unread and rename on that
topology (#1335). Duplicate makes an editable copy of one. gui is the only local name with no
built-in note, and it has costs. Desktop chats run in-process as desktop and never read the
note, but a Desktop chat the gateway runs in a managed worker (safe mode, or the custom-provider
opt-in) runs as gui and gets Hermex's note (hermes-agent v0.22.5 agent/managed_worker.py).
The gateway's session picker and --source desktop filters list Hermex's sessions, and one a
TUI or Desktop resume hands to the gateway runs with Desktop's toolsets and approvals
(gateway/session_policy.py SURFACES). On the canonical protocol gui means Desktop; revisit
the name if Hermex moves to it. HermesConnection.keepPlatformNote reads the config once
per Profile per sign-in, before the first attach and before a new bot's chat is made, and writes
the note only when it is missing or different. PUT /api/config deep-merges, so nothing else in
the file changes. The note is read when the host builds an agent, so a runtime the host built
earlier keeps the old note until the host reaps it. Hermex owns append: a user's own text for
Hermex sessions goes in platform_hints.gui.replace, which the host puts before it. Text a user
put in platform_hints.hermex.replace for a 2.0 build no longer applies; move it to gui.
On a gateway Webapp, gui also gives the agent the desktop_ui toolset
(gateway/session_policy.py, toolsets.py): set_theme, show_tip and gui_tour, which the
pin defers behind tool_search. hermes serve adds it only for desktop
(tui_gateway/agent_factory.py _gui_surface_toolsets), so there a Hermex agent's set_theme
is refused before any request (captured at the pin, #1727). The note says Hermex has no tours, tips, panes or layouts
and that set_theme changes only light, dark and the accent (#1727); the chat answers
set_theme's requests itself (bots.md § blocking requests). Changing the note's text rewrites
every Profile's copy on its next sign-in check.
Every socket, reconnects included, runs the same handshake before any other RPC:
wait for gateway.ready (recording replay_epoch), then send
client.capabilities {server_requests: true}. From 0.21.4 the host refuses
every server request (approval withdrawn, clarify answered empty, sudo and
secret skipped) for a session whose only attached WebSocket clients never sent
it (tui_gateway/server_requests.py, session_transports.py). A host older
than the capability answers -32601; connect() ignores any JSON-RPC rejection
here, as the shared web client does, and connects as before. The host sends no
JSON heartbeat of its own (heartbeat: true in gateway.ready only means the
socket answers pings), so HermesGateway sends gateway.ping every 15 seconds
with string ids that never settle an RPC. Any inbound frame resets the 45-second
silence deadline; a socket quiet for longer is dropped and reconnects.
A Wi-Fi to cellular handover can leave the socket open but dead, so a network path
change (NetworkPathMonitor.changeCount, satisfied, app not in the background) probes
the current connection's open socket once (HermesGateway.probe(), #1372): one more
gateway.ping, and any frame within 8 seconds proves it alive. Silence, even with the
ping stuck in its send, drops the socket for every screen, which reconnect onto one
replacement. One deadline for every route; record slow-tunnel false positives before
adding per-route policy. The probe never opens a socket.
A gateway's own listener, such as the Webapp 0.23.0 serves behind its sign-in (port 9120),
says session_authority in gateway.ready (#1341). Its sockets speak the canonical session
protocol, which upstream Desktop adapts in apps/desktop/src/api/canonical-protocol.ts;
Hermex's adapter is HermesCanonicalProtocol.swift, where HermesGateway.send turns a
HermesCall into a frame. The parent issue's decisions are the rules:
- A session is attached with
session.resumeand replays under its own snapshot'sreplay_epoch. Screens on one socket share its subscription; the last to leave detaches it. - Sends carry a
submission_id; controls and approval and clarify answers carry the session'sexecution_generation. A stale fence isHermesFenceRefusaland nothing is resent. A sudo or secret answer is a bare JSON-RPC response frame (idandresult) with no generation. - Session edits are one fenced
session.mutate, the model included (#1603, #1604). - A send's photos go as its own
attachments: [{path, mime}](#1644), so the host stores them with the prompt and every client shows them.pendingrows list text only, and the resume snapshot has noinflight, so a queued photo's chip lives in the chat's memory until its turn starts (HermesChatTurnCoordinator.queuedImages). - Rooms fence Retry and Discard by member and generation, and seat only
seatable_profiles(#1605). - Each Profile's chats get a socket of their own on a Webapp (
HermesConnection.gateway(profile:)): session ids repeat across Profiles and a canonical session's events don't name theirs. Screens that aren't one session's (the inbox, rooms, Settings reads) keep the shared socket. - A Profile whose socket the Webapp refuses, while the shared one opens, is
.profileNotServed: the gateway serves only one Profile because its multiplex preflight found a blocker. The signed-in/api/statusgives the host's reason as prose inmultiplex_standalone_reason(the signed-out one leaves it out).HermesStandaloneReasonsummarizes it when every blocker is a duplicate bot token and otherwise shows the host's words alone. The chat error and the server's Settings page show both, and open Serve Every Profile (#1611): it readsGET /api/gateway/migrate/plan, removes a duplicate bot's.envkeys from the Profile the user says shouldn't keep it (DELETE /api/env), then after one confirmation startsPOST /api/gateway/migrate, whoseokmeans only that it started. The gateway restarts, so the screen waits onHermesRestartWaituntil the plan saysalready_multiplexedand itslive_servednames more than one Profile (the flag alone turns true before the restart), then opens the Profile's socket. Never gate on the plan'seligible(thehermes updatebar), and never writegateway.multiplex_profiles: truedirectly: an explicittrueskips the preflight. A blocker it doesn't recognize, or a duplicate whose removal didn't clear it (a token set inconfig.yaml, not the.env), offers a recovery chat opened explicitly ondefault, the Profile a standalone gateway serves (New Session's may be unserved). Its text names the unserved Profile and the host's words, asks the agent to walk throughhermes gateway migrate --multiplex --dry-run, and keeps the triage playbook's guardrails: propose commands, never read.env, never restart the gateway. - A password sign-in's cookies work there. A bearer token works only if this listener issued
it to a native sign-in (
hermes_cli/webapp_sign_in.py); a browser sign-in made elsewhere is refused at refresh as.signInExpired, which asks for one sign-in and never retries. - hermex-push's restart re-execs the gateway without its drain there (uzairansaruzi/hermex-push#33), so it isn't offered on a Webapp.
HERMES_AGENT_TESTED_SHA at the repo root pins the tested hermes-agent commit
(line 1) and the release /api/status reports as version (line 2), the Bot
counterpart of UPSTREAM_TESTED_SHA. The pin is 0.23.1 (3b421578); sections
of these docs that name an older commit record what was verified at the time. BotClient.connect() captures version
and the connection screen stores it on the BotConnection record.
HermesCompatibility holds the tested release and the minimum, 0.21.3: 0.21.2
publishes no gateway contract. HermesConnection compares the leading
MAJOR.MINOR.PATCH (a canary reads as its base release) right after the
/api/status read and refuses an older host with BotFailure.outdated before the
install check and the password, so the form, inbox, chats, rooms and push setup all
show the "update Hermes" copy. A missing or unreadable version proceeds: the pin
always reports one, so its absence means a proxy or a fork. At or above the
minimum, sign-in saves and dismisses whatever the release; no version warning is
shown (#626).
Each RPC validates the contract just in time. Advancing the pin is described in AGENTS.md
(Working with the server); update the file and the constant together, then run
scripts/capture-hermes-fixtures. It records what the host really sends for
/api/status, profiles.list, session.resume and one plain turn's event
frames into HermesMobileTests/Fixtures/HermesAgent/, and
HermesAgentFixtureTests feeds them through the real parsers, so a renamed or
dropped field fails a test instead of blanking a screen. The capture keeps only
the hermex-fixtures Profile, replaces every string outside an allow-list of ids,
event and status vocabulary, the release and the canned turn's text, and writes
nothing if the output still holds the host, the account, the socket ticket, a
home path, the install id or another Profile's name. --keep-raw and
--from-raw re-sanitize one capture without another live session. --local --gateway records
the canonical session protocol (#1341) from scripts/local-hermes --gateway into
canonical-*.json: gateway.ready, a create, idle, repeated and running resumes, a
replay under the session's own epoch, its epoch mismatch and gap, a detach and its stale
repeat, a session on a second Profile, and a turn's admission receipts, two queued
sends, a withdrawn one's message.complete, a stale_generation stop, the next
turn's start under the next generation, a clarify prompt's lifecycle, and the
session.mutate edits (rename, a revision conflict, a stale-generation rewind, a
branch, a rewind, a compaction, a busy and a settled delete, a titled create), and the
session settings (a model edit, Fast, reasoning, personality and approval mode, and the
config.set model and scoped Fast refusals).
HermesConversation (bots.md) runs one path for every attach and reattach, so a first
open, a foreground and a dropped socket recover the same way. The session keeps two ids:
the stored key, which Hermex caches, links and drafts by, and the runtime id, which keys
session-scoped calls and seq, changes after a reap, and is never kept.
An attach reads, in order: session.list for a bot's chat (session.create once for a new
session), an identity session.resume with omit_messages, session.events.since from the
last seq, then one more session.resume for live state, also without the transcript: the
chat reads its settled rows from REST pages (#1047). While attaching, this runtime's live
frames are held (#901), up to the 512 events the host's replay ring keeps, and handed over
once the snapshot is in: a frame at or below the replay's latest_seq is dropped, and a
later one takes the live path, where a gap is the owner's rebuild signal. Past 512 the held
frames are dropped and the owner rebuilds, as after a truncated replay. Host requests
(string ids) are never held. A held request.cancel or connection.* frame keeps the
snapshot from replacing the cards, as a live one does, so a card withdrawn mid-recovery
keeps its note. Replay detects discontinuity but never appends text to an overlapping
snapshot. Live recovery never reads the local search cache and has no speculative REST
adapter.
Transient socket loss reconnects silently while the chat is active, with delays
of 1, 2, 4, 8, 16 and then at most 30 seconds. session.resume answering 4007
(swapping in a replacement runtime) or 4009 (a client-gone interrupt settling)
is retried the same way for 60 seconds from the first refusal in a row, then
shows the usual advice. It is matched by code alone: a real "session not found"
is also 4007, and costs at most that minute. The same codes from other calls
are not retried. Leaving the screen or backgrounding
cancels recovery. Foreground/recovery reloads canonical identity, history and
current state before enabling commands. Authentication, identity and unsupported
host errors still surface actionable messages; commands are never retried.
One composer Send may wait for the reconnect (#1407), because prompt.submit has no
idempotency key: only plain text (no quotes, files, / command, Steer, Queue or Stop & send),
sent while the chat shows its offline cache or failing with NotSent for lack of a connection
(.transport, a URLError) before it reached the socket. It shows as a dimmed bubble with
"Waiting for connection" and Cancel, outside messages, and is kept in the draft
(ChatDraft.waitingSend), one at a time, and no other Send goes during that write; it waits only once that write succeeds and the chat
it was typed in is still on screen, and otherwise goes back ahead of anything typed since. The first attach after it, once the host's rows replace the cache,
sends it once, with no files, under the draft key it was held in; the #508 mark is on disk
before it goes, and the socket write checks the chat, the foreground and the deadline again.
The host's answer removes it; a lost answer puts the text back with the #508
hold; another missing connection waits for a distinct attach; anything else puts it back.
Cancel, ten minutes (checked again on reconnect and at the write), leaving the chat and a
replaced Bot Chat put the text back ahead of anything typed since. A relaunch puts it back too
and never sends it. Backgrounding only pauses it, even mid-delivery: iOS gives no delivery
while suspended, and the foreground's reattach sends it.
The inbox, the Hermes session list and a room on screen reconnect after a lost socket
through BotReconnectSchedule: the same delays on backoff while online, no attempts
while the network path is unsatisfied, and one immediate attempt from the first step
when it returns (#1372). A room tries the delays once and then waits for Reconnect or
the network's return; only a transport loss (.transport, a URLError) or a refusal
BotConnectionAdvice.isRetryable passes (408, 429, 5xx) heals there on its own. Closing,
backgrounding or covering the screen cancels a waiting reconnect.
While the inbox or the session list reconnects with rows on screen, it keeps two facts
apart (#1374). isReconnecting (isHermesReconnecting) starts at a retryable drop and
ends only when a roster or list read on the new socket succeeds, or at a refusal, a close
or another connection or Profile; a failed connect or read on the new socket counts as
another drop, keeps the live rows rather than swapping in the offline cache, and the backoff restarts from its first step only once that read succeeds.
The rows' live states stay as the last known ones (liveStatusesAreStale,
attentionStatesAreStale) through the drop, an offline device path and a failed
session.active_list, until a current status reply replaces them; rows can land first.
A -32601 status reply, a refusal or a close clears them instead. The home's header, and
the pushed list's title, say "Reconnecting…" after 800 ms (a tap runs the waiting
reconnect now) or, at once whenever the device is offline, "Offline · showing last known
status". The line stays away when the offline cache's banner or a refusal shown over the
rows already explains them.
Each list read also reads subagent.roster once per listed Profile (#1730), never on the
busy re-read or a timer: a row idle in session.active_list whose stored id or lineage root
the roster lists with live children or background processes shows Working, while a failed
read, a -32601 (never asked again on that socket), a close, a Profile switch or the offline
cache drops those marks.
The session list lifts loaded rows whose state is Input into a "Needs you" group above
Scheduled (#1393), by the same states the labels show, last known ones included; a search
or the offline cache keeps list order. session.active_list items carry no Profile or
source, so the group never adds a row the loaded pages lack.
With a saved connection, the screen's Status section reads the public /api/status
once when the form opens or on "Check again" (no credentials or cookies, only the
saved Connection Headers; no retries) and shows the live
version (or the stored one), gateway state and platform counts; scheduled Tasks need
the gateway, Bot chat notifications do not.
A host that answers a call with -32601 (method not found) lacks that method:
HermesGateway records it on the connection (unavailableMethods, never for the
handshake's own client.capabilities), and BotChatControls and a Hermes chat's
automations (session.control) read it, so a chat control the host lacks stays off in every chat on that connection until a new
connection starts empty.
An ordinary 4000 (invalid params) is not that signal. To learn whether a method
exists before calling it, the first consumer that needs to (#701 onward) sends a
deliberately invalid-parameter probe, {"__hermex_probe": true}: 4000 means
present, -32601 absent. Nothing sends one yet.
Every other check is a probe whose answer the app already understands. gateway.ready
lists no methods. A dashboard has no describe RPC: runtime.describe answers -32601 there,
and gateway.capabilities returns only per_session_exclusive_submit. A gateway's Webapp
answers runtime.describe with a capabilities list (plugin-rpc-v1 among them), which
nothing reads yet.
| Probe | Answer | Meaning |
|---|---|---|
GET /api/status (public) |
JSON object carrying the auth_required flag |
A Hermes dashboard; its version meets the minimum or the sign-in stops (connect form, HermesConnection.signIn()). false signs in with the page's token (§ No sign-in). |
GET /api/status |
Hermes' Host-header 400, or .blocked (an access proxy's own sign-in) |
The connect form shows its advice and stops; it does not try webui. |
GET /api/status |
anything else | Not Hermes: the connect form goes on to the webui path. |
client.capabilities in the handshake |
-32601 | A host before 0.21.4; connect anyway. |
| Any RPC | -32601 | The method is absent: unavailableMethods, and its control stays off. |
Any RPC with {"__hermex_probe": true} |
4000 / -32601 | The method exists / is absent, without running it. Unused so far. |
| A session-scoped RPC | 4001 | The runtime was reaped: reattach to the stored key. |
session.resume |
4001 with data.reason (or, on a dashboard, only message) |
The host won't open this session: BotFailure.resumeRefused carries the reason to the screen, and nothing retries it unasked. |
groups.capabilities |
a capability missing | Rooms hide, or their writes turn off (bots.md § Group rooms). |
GET /api/plugins/<name>/… |
404 {"detail": "Plugin not found"} |
The plugin is off or not installed (HermexPushPlugin.missingRoute, Kanban). |
GET /api/plugins/<name>/… |
404 {"detail": "No such API endpoint: …"} |
The dashboard never mounted the plugin's routes: it is new on disk and the host needs a restart, or the host lacks it (kanban.md, Absent plugin). |
GET /api/plugins/hermex-screen/capabilities |
200 / 404 Plugin not found / a catch-all 404 / 404 Not Found |
Whether a host with no stock Bot Screen can show its real desktop, and what to offer if not (HermexScreenPlugin.State, docs/agents/screen.md). |
GET /api/plugins/hermex-push/capabilities |
{plugin_version, routes} / any 404 |
The companion routes the loaded plugin mounts / none, so the feature doesn't show (bots.md § Push provisioning). |
GET /api/sessions/{id}/mutation-snapshot |
200 / a catch-all 404 (No such API endpoint, or serve's Headless backend) |
The host fences session writes / it is older and takes them bare (§ Session write fence). |
hermes-agent fences REST session writes (#1300): PATCH /api/sessions/{id} and
POST /api/sessions/import must carry request_id and expected_revision, or the host answers
409 client_upgrade_required (neither) or mutation_identity_required (one). BotClient sends a
fresh UUID as request_id on every write. A PATCH's expected_revision is the session's
runtime_revision, read from mutation-snapshot right before the write, because any activity on
the session moves it and a cached list row's value goes stale. An import always sends 0, the
revision of an anchor id the host doesn't have. Hermex never sends expected_generation. When the
snapshot route answers a catch-all 404 (hermes dashboard's "No such API endpoint" or hermes serve's
"Headless backend…"), the host predates the fence and the PATCH goes out bare;
older hosts ignore the extra fields on an import. A 409 (revision_conflict, stale_generation,
admission_conflict, session_busy, or an upgrade reason) is a HermesSessionFenceRefusal and is
never resent: the row action rolls back and reloads, and Move to Hermes leaves the batch uncertain
for its next run.
The Plugins screen (Settings → Server → Plugins, #1582) manages one Profile's plugins over
plugins.manage, because the dashboard's REST mutations can't name a Profile and act on the one
the dashboard runs as. A row's identity is its key: names collide across category folders
(image_gen/fal, video_gen/fal).
- A toggle can sync the Profile's Python packages first in either direction, which took 30 s on a
fresh host, so it waits three minutes. A refusal is 5026 with the host's message, which can be a
long
uverror. Losing the connection or the deadline leaves the outcome unknown: the screen says so, reads the list again and never resends. restart_requiredis true on any disable, and on an enable when no gateway answered. An enable'sactivation.deferredis what waits for the next session; a disable'sactivationcan be an earlier load's summary, so it is ignored.POST /api/gateway/restart?profile=answers once the restart has started, not once it has finished. On a multiplexed host it restarts the one gateway every Profile shares. Only a confirmed action sends it.- An install takes minutes: it clones, scans, syncs packages and loads the plugin, and a small one
took 55 s. A catalog install sends only
catalog_name, so the host resolves the repo and pin and enforces its removal list; a name it doesn't list is never retried as a repository. Every refusal is a bare 5026, so the sentence… already exists …is the only sign that Replace applies. - The install's
forcemeans two things: replace the existing copy, and accept a caution scan on a repo source. A dangerous scan stays blocked, and a catalog install at its pin is trusted. Replace's confirmation says so, because at this pin the findings can't be shown. A forced replacement of an enabled plugin with dependencies can still be refused for lack of a terminal; the host's message shows as is. - A catalog entry's Disclosure is the text after
Disclosure:orDisclosure —in itsdescription, the marker upstream reads. A required key saved from the install'smissing_envis written to the Profile's.env, butGET /api/envdoesn't list a key its catalog doesn't know. - Discover reads
GET /api/dashboard/plugins/catalog, about 2.9 MB and 1.8 s through a tunnel, once per screen and only in memory. The screen's Installed badges come fromplugins.manage liston the selected Profile, because this route's owninstalledfield reads only the dashboard's Profile.removedin the same reply is the only source of why Nous took a plugin out, so the catalog is also read when a Profile has a user install. - Catalog images load directly from GitHub, on a session that refuses Low Data Mode: HTTPS on
github.com,githubusercontent.comor a subdomain, as upstream's Desktop allows. SVGs are skipped and a GIF shows its first frame. updatere-pins a catalog install or pulls a git one, one plugin at a time. A re-pin that widens the plugin answersconsent_requiredwithdelta_lines, and a blocked scan answersscan_blockedwith its findings; neither changes anything. Only a caution verdict can be overridden. A git update doesn't hit the dependency consent that a forced reinstall does, even when its dependencies change. A catalog copy installed at arefother than the catalog's pin counts as pinned off-catalog, and the host refuses to update it.- A settings form's types on the wire are
string,number,boolean,enum,jsonandsecret.settingsrefuses secrets: they go toPUT /api/envunder the field'senv, then an emptysettingscall tells the host to reconnect the plugin's MCP servers on the new value. Only changed fields are sent. - Which toggles ask first comes from
GET /api/memory?profile=(active) andGET /api/messaging/platforms?profile=(enabledandconfigured). Until those answer, or if they fail, a toggle they might cover asks. The host doesn't list bundled memory providers, so only a user install can be the active one.
The Connected Apps screen (Settings → Server → Connected Apps, #1629) manages the apps one
Profile's Nous account reaches, over connectors.* with owner: {type: "account"}. The list is
connectors.catalog joined with connectors.accounts; connectors.list adds only enabled, the
account's policy. Nothing is cached. Verified on a live 0.23.1 host.
- Dead ends are error codes. -32601 is a host without the methods, 4031
CONNECTORS_UNAVAILABLEa host with them turned off or an account without them, 4032NEEDS_NOUS_AUTHa Profile with no usable Nous sign-in. On a host with no Nous account the first connect creates a free guest identity unlessnous.guestis false. - The browser return is the desktop's. The host asks the portal to return every account
sign-in to
hermes://connections/done?status=…&op=…, and a client cannot name its own. Hermex doesn't registerhermes://; the official Hermes app does. So the link opens in a non-ephemeralASWebAuthenticationSessionwithcallback: .customScheme("hermes"), which catches the return and closes itself. AnSFSafariViewControlleror Safari offers to open the official app instead. A chat's session-owned sign-in gets no return at all, because only adesktopsession asks for one. - When the browser closes, however it closed, send
connectors.operation.wakeand read the list again. The accounts are read from the portal, so the answer is current without waiting for the host'sconnection.update. - A sign-in outlives its account. The link lasts about ten minutes (
deadline_at). Removing a pending account leaves its operation open, andconnectors.connecthands that operation and its dead link back until the deadline; the portal answers the link with 404. So after a connect, an operation whoseconnection_idis missing fromconnectors.accountsis settled withconnection.respond(result: {settled_by: "continue"}) and connect is sent once more. - Connect on an app that is already connected answers
state: connected,settled: trueand noconnect_url. - Logos are bundled. The catalog's
logo_urls are SVG only, which UIKit can't decode, so the logos ship inAssets.xcassets/ConnectedApps/<slug>and an app without one shows its initial. Refresh them from the catalog'slogo_urls when the pin advances.
The dashboard mounts the routers of enabled plugins when its process starts
(_mount_plugin_api_routes in hermes_cli/web_server_dashboard.py). At the pin, a plugin
installed or enabled later mounts without a restart: its first unmatched HTTP request under
/api/plugins/<name>/ mounts its router and is answered by it (_try_hot_mount_plugin_api).
The decision is the dashboard's own Profile's, so a plugin enabled only on another Profile
mounts this way only if it's bundled. Older hosts don't do this (it isn't in the 0.21 commit
ca678285), so a missing route can still mean a restart (HermexScreenPlugin.State,
HermexPushProvisioner).
A router that's already mounted is never replaced. A plugin disabled while the dashboard runs
keeps its router behind a per-request gate, and an updated plugin keeps its old HTTP handlers.
So a new or changed route on a mounted plugin appears only after hermes dashboard restarts.
POST /api/gateway/restart restarts only the messaging gateway and doesn't help. The host's
restart_required is about the gateway too, so the Plugins screen's "updated and live now"
doesn't cover a plugin's own HTTP routes. hermex-push 0.4.0 and newer mounts its own restart
route (#934); anything older costs the user one restart on the host, and so does a gateway's
Webapp, whose drain that route skips (#1606).
A plugin adds REST routes, hooks, tools and its own sockets. On a dashboard it adds no RPC
method and no /api/ws event. On a gateway's Webapp it can also register
plugin.<plugin_id>.<name> methods and session events (ctx.register_rpc,
ctx.emit_to_session), advertised as plugin-rpc-v1 in runtime.describe; hermex-push
registers none. So a gap the companion plugin fills is still a REST route, and each new route
on an installed hermex-push costs a restart: ship them in batches, and gate each feature on
/capabilities, never on a version number.