mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
The messaging gateway logs every inbound message to gateway.log, but its dashboard/TUI twin (gui.log) was nearly silent: the dashboard FastAPI app had host-header/auth-gate/auth middlewares but no access log, and 3 of 4 WebSocket endpoints logged nothing at all. Worst of these, /api/pty logged 'pty accepted' on connect but was completely silent on close — a PTY EOF (backend crash), a send failure, or a client drop left no trace, so user-reported 'chat disconnected / TUI froze' was unreproducible. Extend the convention tui_gateway/ws.py::handle_ws already establishes (a structured 'ws closed peer=... reason=... <counters>' line) across the whole surface, at the same INFO granularity as gateway.log, into the gui.log that is already sized for it (10MB x5): - HTTP access-log middleware (registered LIFO-outermost so it captures the final status, including 400/401 from the middlewares above): one INFO line per request with method, path, status, latency, request id, peer. Path only, never the query string (tokens ride in query on some routes). UA/referer at DEBUG (-v). Reads/echoes X-Request-ID for client/proxy correlation. - /api/pty: structured close line covering all exit paths (client_disconnect | pty_eof | send_failed | error) with duration and bytes_in/out counters. - /api/pub + /api/events: accept + structured close (reason/duration/frames) + all reject paths. - /api/ws: reject paths logged; request id threaded into handle_ws and stamped on its accept/close lines so a WS session correlates with the HTTP upgrade. Metadata only — no request/response bodies, no WS frame payloads, no headers/cookies on the INFO lines. Opt-in body capture is a separate change so this stays clear of the debug-share privacy surface. handle_ws gains an optional rid=None arg, backward-compatible with the stdio entry-point (tui_gateway.entry) which calls handle_ws(ws). Tests (behavior-contract style, not frozen strings): HTTP access line shape + query-string redaction + 401-still-logged + X-Request-ID round-trip; WS accept/close lines for /api/pub and /api/events; WS reject logging; rid propagation through handle_ws. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| entry.py | ||
| event_publisher.py | ||
| render.py | ||
| server.py | ||
| slash_worker.py | ||
| transport.py | ||
| ws.py | ||