Commit Graph

35 Commits

Author SHA1 Message Date
unsupportedpastels
0e74f5bd80 fix(audio): accept the local Desktop runtime ticket on voice stream sockets
The speak and transcribe stream sockets refused the local Desktop's own
credential. They now redeem the interactive runtime ticket through the existing
native gate (no Origin, loopback peer, served profile) and run in the grant's
profile. Desktop sends the ticket as a subprotocol and its main process strips
Origin only for those two paths on a fresh /api/ws reservation.

Rows RT-71, RT-80.

Refs #143547

Co-authored-by: Dolverin <5910064+Dolverin@users.noreply.github.com>
2026-10-25 11:29:33 -04:00
emozilla
e0ff4f8553 fix(chat): the dashboard's legacy /chat socket closes as on main when its child exits
The dashboard's /chat pump without a keep-alive token closed its socket with 4410 when the child
exited, where main closed it normally (1000) whether the child exited or the socket broke. Only
the dashboard's /chat uses this pump, and the Webapp does not need the change, so it closes as
on main again; the keep-alive path keeps reporting an exited child with 4410.
2026-10-25 03:22:41 -07:00
emozilla
aa34b22a75 fix(dashboard): sockets on the standalone dashboard and hermes serve authenticate as on main
Two rules the Webapp needs had been applied to every surface's WebSocket gate. The loopback gate
took a one-use socket ticket before ?token=, so on the standalone dashboard and hermes serve (which
mint no such tickets) a ticket in the URL or the subprotocol was spent and refused, and a stray one
beside a valid session token refused the upgrade. Behind the sign-in gate the server's own
?internal= credential opened only /api/ws and /api/pub, so a gated dashboard refused it on
/api/events, /api/pty, /api/console, the voice streams and plugin sockets such as kanban's, where
main accepts it.

Both rules now apply only on the gateway's Webapp listener (app.state.ui_surface == "webapp"): there
the loopback gate takes the Webapp's socket tickets and the server's credential opens only the
sockets its spawned clients dial. Everywhere else the gate judges ?token= alone on loopback and
accepts ?internal= on every socket behind the sign-in gate, as main does.
2026-10-25 03:22:37 -07:00
emozilla
c7bab35d08 refactor(webapp): one route mints every Webapp socket ticket
A Webapp page minted its one-use socket tickets from three routes that did the same thing with a
different socket name: /api/webapp/gateway-ticket for /api/ws, /api/webapp/terminal-ticket for the
host terminal and /api/webapp/audio-ticket?socket= for the voice streams, each with its own copy of
the surface check, and the renderer had a helper for each.

POST /api/webapp/socket-ticket?socket= now mints them all. A table names each socket (gateway,
host-terminal, speak-stream, transcribe-stream), the surface policy that lets a surface mint it, and
whether the mint checks the profile the page will dial (the gateway socket, as before). An unknown
socket gets 400 and a surface that does not serve the socket gets 404, as before. In the renderer,
ticketedWebsocketUrl() mints the ticket and builds the URL for any of the four sockets. Main's
/api/auth/ws-ticket is unchanged. The tests, fixtures and code comments that named the old routes
now name the new one.
2026-10-25 03:22:37 -07:00
emozilla
0a4b903c52 refactor(webapp): one module owns the browser credential and ends every grant at sign-out
Signing the Webapp out has to end every grant made under the browser credential, and each kind of
grant checked that its own way: socket tickets and tracked sockets compared digests from
web_session_sockets, the cookie login's binding read the token straight from web_server, the Bot
Desktop viewer check and the file tickets each compared a digest by hand, and the sign-out verb set
the token and then called close_all() and revoke_all() itself. A new grant kind was one more place
to forget, which is how a grant outliving sign-out kept coming back.

hermes_cli/browser_credential.py now owns the credential: current(), its generation (a SHA-256
digest), is_current(generation), and rotate(), which replaces the credential and runs the revokers
registered with on_rotate(). Socket tickets, tracked sockets, Bot Desktop viewer tickets, file
tickets and the cookie login's binding record the generation when they are made and check
is_current() when they are used; the open-socket and file-ticket stores register their revokers, and
hermes webapp --sign-out calls rotate(). What signing out ends is unchanged.
2026-10-25 03:22:36 -07:00
emozilla
4e54af5d8d test(webapp): a browser login's access token opens none of the Webapp's token sockets
@teknium1's 56be810f764 makes the WebSocket upgrade's ?token= leg ask
webapp_sign_in.token_works_alone first, as the bearer header does. That commit tests /api/ws. This
one tests every socket on the Webapp's listener that takes a provider token as ?token= (/api/ws,
/api/events, /api/pub, /api/pty and both voice streams): a browser login's access token, copied out
of its cookie, opens none of them before a sign-out or after it. It also tests that a token the
listener gave a native app's sign-in opens a socket that stays open across a sign-out, as the native
app stays signed in.

token_works_alone's docstring, the module docstring, the developer guide and the Desktop guide now
name a socket's ?token= among the places the gateway refuses such a token on its own.
2026-10-25 03:22:36 -07:00
Teknium
f314a662e5 fix(webapp): a browser login's token opens no socket on its own
Greptile finding "Browser tokens survive sign-out": behind the sign-in
gate the WebSocket upgrade's `?token=` leg (web_server_chat._ws_auth_reason)
verified a provider access token without the Webapp's native-sign-in
check the bearer header applies (webapp_sign_in.token_works_alone). A
token copied out of a browser login's cookies therefore still opened
/api/ws (and every other socket behind _ws_auth_reason: /api/pub,
/api/events, /api/pty, /api/console, the audio streams, plugin sockets)
after `hermes webapp --sign-out`, untracked by sign-out.

The leg now runs the same check: on the gateway's Webapp behind the gate
only a token this listener gave a native app's sign-in opens a socket on
its own; the standalone dashboard accepts any provider token, as on main.
_ws_request_view carries the app so the check reads its state.
2026-10-25 03:22:36 -07:00
Teknium
44cc9f4915 fix(webapp): a tab opened on ?profile=<name> sees its own running turn
The Webapp's gateway ticket validated `profile` and then dropped it, so `/api/ws` answered every
request that names no profile for the gateway's launch profile. A tab loaded on `?profile=work`
polled `session.active_list` without a profile, never saw its own running session, and after 45 s
of a quiet tool call showed "Hermes ended this turn without a reply" while the turn kept running.

The ticket now names the profile, and the upgrade binds the socket to that home's authority, the
way a native ticket does (`gateway/run_api.py`). The socket keeps its host scope, so a request that
names another served profile still reaches it. A tab with no profile is unchanged.

Reported by @BearHuddleston on #141864.
2026-10-25 03:22:35 -07:00
emozilla
7a3dda8242 fix(webapp): stream voice in the Webapp on a ticket minted for each voice stream
Streaming voice in the Webapp never streamed: spoken replies and live dictation always fell back to
the whole-reply path. The browser dialed `/api/audio/speak-stream` and `/api/audio/transcribe-stream`
with the one-use ticket it had minted for the gateway socket, and a socket ticket opens only the
socket it was minted for, so both voice streams refused it.

Each voice stream now has a socket name, and the Webapp mints its ticket from
`POST /api/webapp/audio-ticket?socket=speak-stream` or `?socket=transcribe-stream`, on the same
surface and with the same credentials as the gateway ticket. The browser-hosted Desktop asks for one
on every voice dial. A voice stream's ticket opens that stream once and nothing else, and the
gateway's and the host terminal's tickets open neither stream. Native Desktop is unchanged: its
unnamed tickets and session token still open the voice streams.
2026-10-25 03:22:34 -07:00
emozilla
4e2b341187 fix(webapp): signing out behind the sign-in gate signs every browser out
`hermes webapp --sign-out` replaced the browser session token and closed the sockets that token
had opened. On a Webapp behind the sign-in gate (a wildcard bind, or a public URL in front of a
loopback bind) browsers never hold that token: they sign in with the dashboard's password or
OAuth provider and keep that login in cookies. Sign-out reached none of it. After it, a signed-in
browser still read /api/sessions, minted socket tickets, and kept its chat socket and host
terminal open, so signing out to cut off a lost device left that device a live host shell.

Each login on the gateway's Webapp is now bound to the browser session token. A password login
or OAuth callback there also sets the HttpOnly cookie hermes_webapp_signin, the hex
HMAC-SHA256 of "webapp-sign-in" keyed with the current token, with the session cookies' Path,
SameSite and Secure policy; a refresh renews it with them. The gate treats a cookie session on
the Webapp without a matching value as signed out: API requests get 401 with the login URL and
pages go to /login. Replacing the token therefore signs every browser out, whichever provider it
signed in with, and so does the CLI replacing the stored token while no gateway runs.

A request whose binding checked out records the token's digest, and the socket tickets it mints
(chat, host terminal, /api/auth/ws-ticket) carry it. Redeeming such a ticket after a sign-out
opens nothing, and the socket it opens is tracked like a token socket, so sign-out closes it with
4401. The verb now reports whether the gate is on and how many browser sockets it closed. The
standalone dashboard never sets or checks the binding and keeps its logins as before.
2026-10-25 03:22:24 -07:00
emozilla
b7a97cea05 fix(webapp): open browser sockets with one-use tickets and close them on sign-out
A loopback Webapp tab opened its host terminal with the session token in the socket URL, where
logs, history and proxies keep it. An authenticated request now mints a one-use ticket named for
one socket: a chat ticket does not open the host terminal, a terminal ticket does not open the
chat socket, and the host terminal opens only with its own ticket. The Webapp's plugin sockets
use their polling fallback, as the signed-in Webapp already did, so no URL carries the token.

hermes webapp --sign-out replaced the token but left open tabs connected until they reconnected.
The gateway tracks every socket the session token opened, closes them with 4401 on sign-out and
revokes media stream links. Native clients and signed-in browsers stay connected.
2026-10-25 03:22:19 -07:00
Bear Huddleston
b5eb5ee7a8 feat(webapp): carry the browser-hosted Desktop's server pieces from #93508
Carried from BearHuddleston's #93508 onto main. The Webapp relay and the
profile-incarnation fence stay out: carried code follows main's
named-profile rule and refuses a missing or deleted profile home.

- Webapp routes: one-use launch tickets, window handoff, and gateway
  WebSocket tickets minted for the signed-in browser
- Browser surface policy and the SPA document policy
- A host terminal for the browser that survives reconnects
- Staged browser uploads and file tickets; file.attach takes a staged upload
- hermes sessions adopt
- Webapp bundle build helpers and the renderer freshness check
- Regenerated gateway contracts

Co-authored-by: emozilla <emozilla@nousresearch.com>
2026-10-25 03:22:14 -07:00
unsupportedpastels
e35a654f44 docs(plugins): document plugin socket auth, its retry contract and two gate notes
- desktop-plugin-sdk.md: ctx.socket on a local gateway authenticates with
  the native grant its ctx.rest calls carry (minted by main, attached as a
  header to that one dial). Also when the socket keeps retrying, when it
  stops, and when it starts again.
- web_server_chat._ws_auth_reason: a socket that sends
  X-Hermes-Gateway-Ticket is judged by that header alone, so a core socket
  presenting it is refused even with a valid token query credential.
- web_server.py: why the web_server_dashboard import sits mid-module. It is
  not an import cycle (web_server_dashboard reaches back only inside
  functions); the load-bearing part is the middleware registration order.

Refs #134889 (PLG-1, PLG-8)
Refs #139523
2026-10-16 16:09:35 +00:00
unsupportedpastels
38ceae226d fix(plugins): authenticate Desktop plugin sockets on a local gateway
A local Desktop talks to its gateway with authMode "native" and no static
token, so pluginSocket dialed /api/plugins/<id>/... with an empty ?token=.
The canonical WS gate (web_server_chat._ws_auth_reason) refused every such
upgrade: Kanban stayed on its 60 s poll, third-party ctx.socket was dead, and
the reconnect loop re-dialed every <=30 s forever, keeping an idle-exit
gateway awake.

The plugin socket now rides the credential its REST twin already uses on a
local gateway: the one-use native-http grant in X-Hermes-Gateway-Ticket.

- Gateway: GatewayRuntimeAPI stamps the raw socket peer on WebSocket scopes
  too. PluginApiWebSocketGate redeems the grant once, ahead of routing
  (native_http.redeem_native_ws: the HTTP seam's exact checks - single header,
  no Origin, loopback peer, ready/served profiles, native-http purpose and
  capability - plus the profile selectors, /api/plugins/ paths only), binds
  the grant profile's home and secret scope for the whole connection, and
  requires both that profile's and the launch profile's plugin consent before
  accept. The route's credential check reads that principal and never
  redeems. /api/ws and other core streams keep their purpose-bound credentials.
- Desktop main: hermes:plugin:ws-url mints the grant for the routed profile
  and reserves a one-use dial bound to its origin (scheme, host, port) and
  path. The path is checked one decoded segment at a time (dot segments, an
  encoded slash or backslash, double encoding and bad escapes are refused),
  then parsed with the real URL parser and required to stay under
  /api/plugins/<id>/, and the dial records that parsed path. The webRequest
  hook strips Origin and attaches the header only to an upgrade that matches
  that dial, so the grant can't reach another host or another plugin's
  path. The grant never enters a renderer URL. The redial/mint/prepare
  branch shared by both gateway-socket IPCs moves to
  local-gateway.localGatewayDial (main.ts stays under its line cap).
- Renderer: pluginSocket asks main for the URL when authMode is native, with
  a deadline (a main process that never answers counts as a refused dial),
  and stops after 5 dials in a row that never stay open, including a socket
  that opens and closes at once (polling fallback stays).

Refs #134889 (PLG-1)
Refs #139523
2026-10-16 12:45:38 +00:00
Teknium
408cc0d12e Merge origin/main (#32: 36 commits to cf23a1a5cc) into feat/unified-gateway-runtime
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); no other main commit touches a conflicted file. Resolution: the branch side
of each file plus main's exact autofix (ruff 0.15.10, main's ruff.strict.toml, --fix
--unsafe-fixes). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.
2026-10-09 10:24:04 -07:00
Maciej Lisiewski
2ff58849f4 ci: ruff UP037 fixes 2026-10-09 17:34:38 +02:00
Teknium
276da15e93 perf(gateway): the session listener serves local clients without importing the dashboard app
start_gateway_api imported hermes_cli.web_server (the whole dashboard FastAPI app, ~686 routes)
on the event loop before the session API listened: ~0.57 s of every cold `chat -q`, and it
stalled identify. The listener now serves the ticketed native /api/ws itself (same Host, peer and
loopback checks) and mounts the dashboard on its first request, imported off the loop, running
its own startup then. A gated listener (non-loopback bind or dashboard.public_url) still mounts
the dashboard before it listens; a gateway started without --idle-exit (Desktop, services) loads
it in the background right after READY. The light boundary helpers move to
hermes_cli/web_server_boundary.py (web_server keeps the names); the dashboard's own uvicorn
builder is unchanged, the gateway uses a FastAPI-free build_listener_server.

Cold `chat -q` (fresh home, loopback stub, archive trees, loaded host, 3 reps): base 4.59 s,
with this and the adapter fix 3.76 s, main 3.34 s.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#issuecomment-6073624820
(cherry picked from commit e90fa09fd682b729123fd9d1103f99af5ed869d9)
2026-10-09 07:08:21 -07:00
Teknium
65bec86e37 Merge origin/main (#27: 19 commits to 517b5e10fe) into feat/unified-gateway-runtime
45 conflicts, all from #135177 (lefthook + `ruff check --fix` over 2,366 files). No other main commit
touches a conflicted file. Resolution: the branch side of each file, then main's exact autofix
(ruff 0.15.10, `--config ./ruff.strict.toml --fix`) on it — rewrites only (typing generics, noqa
drops, import forms), no import removed. tests/cron/test_bot_chat_cli_home.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 12:09:24 -07:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
Teknium
9595c3f345 fix: standalone tui_gateway.entry refuses a home a gateway already owns
No product surface launches the stdio entry any more (Ink and Desktop attach
to the profile gateway via ui-tui/scripts/gateway_bootstrap.py), but dev
harnesses still run it (apps/desktop/e2e/real-session-builder.ts,
scripts/probe_active_session_exclusivity.py) and it opens the launch home's
state.db as a writer. Run beside a live gateway it was a second writer on the
canonical store.

main() now takes the gateway's own gateway.lock reservation for the launch
home before anything opens state.db, exits 1 with a crash-log reason when the
home is owned, and releases it at exit. Holding the lock also keeps a gateway
from starting on the home while the entry writes. The e2e builder runs on a
sandbox home and closes before Desktop boots, so it is unaffected; the
exclusivity probe now asserts the startup refusal (verified live: all
checks pass). Fix the stale web_server_chat comment claiming gatewayClient
spawns its own entry.

(cherry picked from commit 4f21d3a8f758a8c1af22310a28f8665b3cb533ce)
2026-10-06 16:21:16 -07:00
Teknium
1e500ebce2 Merge origin/main (#16: 4,465 commits to 9dcab1e440) into feat/unified-gateway-runtime
99 conflicted files resolved in nine area lanes (Desktop composer, Desktop renderer/shared
client, Electron main, Ink, tui_gateway, gateway, state, CLI/config, cron/tools/CI). The
unified runtime's architecture wins where it deliberately replaced a mechanism (pool,
fallback lanes, claim poller, renderer queue); every orthogonal main change is kept, ported
into the <stem>_<topic> sibling that now owns relocated code.

Notable ports and repairs in this merge:
- tui_gateway/server.py relocated regions: atomic _attach_built_agent (#49852), slash ranking
  registry names, minted-key helpers methods_session.py calls, request_overrides, service tier.
- gateway/run_turn*.py: i18n accessors for the removed reply constants, first-contact
  internal/DM rule, rotated-compression persist, fast-mode tiers, prompt-pin rehydration.
- webhook: route_from_chat_id decodes main's opaque webhook:v2 chat ids (old ids still read).
- ws.py: main's per-connection dispatch queue with authority-first dispatch inside it.
- state: schema event for runtime revision renumbered to 31; worker mirrors updated for
  main's message uid/merge fields, on_contended lease arg, compression columns.
- config: branch's bot_chat_delivery_timeout removal renumbered v47 -> v50.
- Electron: primary-profile pin, redirect header scoping, remote fetchJsonForBackend, SSH
  teardown on profile delete, held-update dial gate restored (lost in earlier merges).
- Desktop: canonical clarify.request mapped to main's questions[] card; replay truncation vs
  snapshot_required; periodic secondary prune tick restored; DELETE already_absent restored.
- cron/tools: diagnostic category on cron failure notices restored; owner_holds_delivery
  ported onto the authority; admitted receipts can no longer be cancelled locally.
2026-10-06 14:24:24 -07:00
kshitijk4poor
1cb25c3e33 refactor(dashboard): single origin_mismatch return in WS origin guard
Gate finding (quality, Low): the ValueError branch added for malformed
Origin authorities copy-pasted the origin_mismatch reason f-string, so the
format lived in two places. Map the parse failure to parsed=None and let
the existing mismatch return handle it. Behaviour unchanged (still fails
closed with 4403 origin_mismatch).
2026-10-03 16:54:59 +05:30
itsflownium
8a0dfcf29f fix(dashboard): reject malformed URL authorities
urlparse raises ValueError on bracketed authorities like "http://[::1" or
"https://[not-an-ip]:80". Three user-input boundaries let that escape:
the WebSocket Origin guard, /api/media/proxy and the custom-endpoint
base_url save, turning a bad header/param into an unhandled 500 instead of
a clean rejection. Fail closed there: 4403 origin_mismatch for the WS
guard, HTTP 400 for the two routes.

Salvaged from #131323 (net diff; the interim loopback-origin exemption the
PR added and then removed is squashed out).
2026-10-03 16:54:59 +05:30
Brooklyn Nicholson
063de859dd fix(auth): accept provider-verified session tokens in gated WS auth
Gated mode accepted only browser-minted ws-tickets and server-internal
credentials, but a token-mode Remote desktop connection bakes its
stored session token into ?token= (buildGatewayWsUrl) — so the WS
upgrade to /api/ws 403'd forever against a password-gated server even
though the same token authenticates REST fine. The REST bearer leg
already verifies session tokens via _verify_access_token; the WS leg
was the only inconsistent gate.

Gated ?token= is now verified against the dashboard auth session
providers (the same verify_session seam), stamps {user_id, provider}
identity, and audits success/failure (TOKEN_AUTH_SUCCESS/FAILURE). The
legacy in-process _SESSION_TOKEN stays rejected; a ProviderError (all
providers unreachable) rejects with token_unavailable instead of
crashing the upgrade; the bot-desktop display-ticket guard is kept.

Co-authored-by: salch-cred <141555468+salch-cred@users.noreply.github.com>
2026-09-29 21:39:17 -05:00
teknium1
b0aa41586e Merge commit '09fbc27a4a93' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/electron/backend-dial-claim.test.ts
#	apps/desktop/electron/gateway-file-download-transport.test.ts
#	apps/desktop/electron/pool-limits.test.ts
#	apps/desktop/electron/pool-spawn-coordinator.test.ts
#	apps/desktop/electron/quit-guard.test.ts
#	apps/desktop/src/app/chat/composer/controls.test.tsx
#	apps/desktop/src/components/notifications.test.tsx
#	apps/desktop/src/plugins/hermes-bots/group-chat-view.inline-code.test.tsx
#	apps/desktop/src/sdk/profile-routing.test.ts
#	apps/desktop/src/store/gateway-spawn-priority.test.ts
#	apps/desktop/src/store/profile.test.ts
#	gateway/run.py
#	gateway/run_turn.py
#	gateway/status.py
#	hermes_cli/dashboard_auth/ws_tickets.py
#	hermes_cli/web_routers/sessions.py
#	tests/agent/test_secret_scope_tier1_migration.py
#	tests/cron/test_bot_chat_delivery_child_env.py
#	tests/cron/test_bot_chat_warning_replay.py
#	tests/cron/test_codex_execution_paths.py
#	tests/cron/test_cron_bot_chat_delivery.py
#	tests/cron/test_cron_empty_payload.py
#	tests/cron/test_cron_mcp_toolset_empty_block.py
#	tests/cron/test_cron_memory_contract.py
#	tests/cron/test_cron_no_agent.py
#	tests/cron/test_cron_request_overrides.py
#	tests/cron/test_cron_workdir.py
#	tests/cron/test_run_one_job.py
#	tests/cron/test_scheduler.py
#	tests/cron/test_sessiondb_init_hang.py
#	tests/desktop/test_bots_chat_live_append.py
#	tests/gateway/test_api_server_runs_extraction.py
#	tests/gateway/test_approval_prompt_redaction.py
#	tests/gateway/test_auto_reset_clean_context.py
#	tests/gateway/test_auto_reset_evicts_cached_agent.py
#	tests/gateway/test_compression_deferred_soft_result.py
#	tests/gateway/test_compression_session_id_persistence.py
#	tests/gateway/test_control_socket_windows_live.py
#	tests/gateway/test_fallback_chain_reload.py
#	tests/gateway/test_model_switch_after_auto_reset.py
#	tests/gateway/test_session_hygiene.py
#	tests/gateway/test_warning_wiring_conservation.py
#	tests/hermes_cli/test_backup.py
#	tests/hermes_cli/test_chat_q_exit_clear.py
#	tests/hermes_cli/test_cli_preloaded_skills.py
#	tests/hermes_cli/test_cron.py
#	tests/hermes_cli/test_ensure_gateway_service.py
#	tests/hermes_cli/test_kanban_gateway_restart_handoff.py
#	tests/hermes_cli/test_observational_sessiondb_modes.py
#	tests/hermes_cli/test_profiles_sidebar_cache.py
#	tests/hermes_cli/test_sessions_export_md_cli.py
#	tests/hermes_cli/test_single_query_session_finalize.py
#	tests/hermes_cli/test_web_server.py
#	tests/hermes_state/test_hermes_state.py
#	tests/tools/test_bot_live_owner_delivery.py
#	tests/tools/test_bot_mode_dm.py
#	tests/tools/test_bot_retry_policy.py
#	tests/tools/test_bot_turn_lock.py
#	tests/tui_gateway/test_bot_live_owner_delivery.py
#	tests/tui_gateway/test_compute_host_turn_protocol.py
#	tui_gateway/server.py
#	ui-tui/src/__tests__/createSlashHandler.test.ts
#	ui-tui/src/__tests__/submissionCore.test.ts
#	ui-tui/src/app/useSessionLifecycle.ts
2026-09-23 07:47:09 -07:00
teknium1
7ed6534c7e Merge origin/main: browser fence composed with the dispatch/retry split (#115184); server registration, i18n, contracts 2026-09-23 03:25:06 -07:00
teknium1
d9ca819cc4 Inspired by Amp: pick the workspace a dashboard chat starts in
A fresh dashboard /chat always spawned the TUI in the dashboard process's
launch directory, so from a phone or any browser there was no way to aim
a new session at a specific repository. Amp's runners now serve many
directories and the web composer offers a picker of the runner's projects
and discovered git checkouts; this ports that mechanism onto the surface
Hermes already has: the dashboard is the phone/web front, the host's
projects.db + repo-discovery cache are the served directories.

- GET /api/chat/workspaces: the profile's projects (with folders) and
  discovered repos (session-derived + scanned), default_cwd, home;
  ?scan=1 rescans desktop.repo_scan_roots on the host, so headless
  installs (no Desktop to populate the cache) discover repos too.
- /api/pty?cwd=<dir>: validated (existing directory, fail-closed 400
  via the PTY error path) and forwarded to the TUI child as HERMES_CWD
  (self-spawned gateway cwd) + HERMES_TUI_CWD (explicit cwd on
  session.create for the dashboard's in-memory gateway, whose own cwd
  is the launch dir). Resumed sessions ignore it.
- ui-tui: session.create carries cwd when HERMES_TUI_CWD is set, so
  /new inside a dashboard chat stays in the picked workspace too.
- web: workspace selector in the Chat rail above "New chat" (projects,
  repos by recency, Other path…, rescan), remembered per profile in
  localStorage; 17 locales.
- docs: web-dashboard.md rail + REST sections.

Live E2E: real `hermes dashboard` under a scratch HOME with two git
repos under desktop.repo_scan_roots -> /api/chat/workspaces?scan=1
lists both; /api/pty?cwd=repo-a -> TUI status bar shows ~/code/repo-a;
/api/pty?cwd=<missing> -> "Working directory does not exist" + close.
2026-09-23 03:12:04 -07:00
teknium1
223ad499a9 fix(bot-screen): a display ticket is not a gateway login on /api/ws
/api/ws consumed any ticket and stamped its identity; display.observe mints
provider "bot-desktop" tickets for viewers who may only be watching a screen,
so one of those redeemed on /api/ws became a full authenticated session.
Refuse bot-desktop tickets in _ws_auth_reason (reported as ticket_invalid, same
as the display route refuses gateway tickets).

(cherry picked from commit 753c3c35975fe1efab4a5bbc8bc6bbc9532b8521)
2026-09-12 18:58:22 -07:00
Teknium
6b8a6d4c35 fix: isolate authenticated gateway owners by provider and issuer 2026-09-10 05:17:39 -07:00
Gille
a99340c247 fix(dashboard): prevent PTY input from blocking event loop (#93565)
* fix(dashboard): prevent PTY input from blocking event loop

* fix(win-pty): don't terminate a healthy ConPTY on write cancellation; log leaked write workers

Review follow-up to the backpressure fix.

CancelledError on WinPtyBridge.write() ran the same path as a timeout and
force-terminated the ConPTY. Cancellation means the owning socket went away
mid-write, which is the keep-alive session's normal reattach case, not a
wedged child; killing the process there defeats the PTY-outlives-socket
design. Give the in-flight write the shutdown grace window and only
terminate if it never lands.

When terminate() fails to unblock pywinpty, the worker stays parked in the
default executor. That was swallowed by a bare except; log it so a slow
thread-pool starvation is diagnosable.

---------

Co-authored-by: Austin Pickett <pickett.austin@gmail.com>
2026-09-04 20:24:24 -04:00
Teknium
5f1feb5344 simplify(compat): web_server — drop 221 re-exports (config/status/shutil/run_in_threadpool, lifecycle, 13 web_server_<concern> blocks, 47 route-handler legacy re-exports); web_deps.late()/LateState() take an owning-module arg; concern modules import each other directly (62 lazy sites) 2026-09-03 14:21:32 -07:00
Teknium
e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium
92e52684d1 refactor(web): tools _bad_request helper, skills hub helpers, sessions flag table, docstring compaction
- tools: _bad_request() for 16 status_code=400 raises; payload built in worker;
  drop _terminal_backend_names/_model_catalog_section one-shot helpers
- sessions: _RENAME_FLAG_SETTERS table (4 flags incl. unread), keyset export
  loop tightened, compression_root/lineage_tip compacted
- web_server_chat: single try/except for both PTY bridge imports,
  contextlib.suppress for swallow-all blocks
- docstrings/comments compacted by hand (every WHY kept); AST-neutral packing
2026-09-02 22:21:05 -07:00
Teknium
4d9007cd17 refactor(web): simplify sessions/tools/skills/chat routers and session-db helpers
- sessions: table-driven prune filters, shared scope kwargs, _project_for_display,
  _compact_json, _is_compression_edge, dedup 404 detail, flag-setter table
- web_server_sessions: descendants CTE via db._conn + dict(zip) rows,
  _is_stale_schema_error, compact docs
- tools: _BACKEND_PROBES dispatch table, _env_value/_category_providers helpers
- skills: _hub_sources/_resolve_hub_skill/_hub_lookup/_flag helpers, _API_SOURCE_IDS
- web_server_chat: _ws_client_is_allowed delegates to _ws_client_reason,
  _server_internal_ws_url unifies gateway/sidecar URL builders, _reject/_stamp_identity
- layout compaction (AST-neutral), docstring compaction keeping every WHY
2026-09-02 21:12:22 -07:00
Teknium
5608fe7cdf refactor(web_server): extract chat/PTY/WS-auth cluster to web_server_chat 2026-09-02 15:36:53 -07:00