Repository navigation
Conversation
Discover Hermes Agent sessions from tui_gateway.slash_worker processes (--session-key in already-scanned command lines) and read session metadata, token counters and the redacted transcript tail from ~/.hermes/state.db via an in-process read-only rusqlite connection (bundled SQLite). Addresses the security feedback that closed graykode#139: - No dynamic code generation: no Python, no string-built SQL, no shell interpolation anywhere; DB access is a readonly rusqlite connection with bound parameters only. - No temp files: everything is read in-process. - Follows the existing collector privacy model from the start: every DB-sourced string (title, cwd, chat tail, tool args) passes through sanitize_terminal_text -> redact_secrets -> truncation. - Fail-closed on symlinked/missing DBs; DB reads cached on the slow tick like OpenCodeCollector. Supports session discovery, token tracking (input/output/cache), status detection (Thinking/Executing/Waiting from transcript tail + CPU), context window % (model lookup table), child processes/ports, git status. Rate limits are N/A for Hermes. Closes graykode#167
AgentSession gained a launch_surface field (Cli/App/Ide) while this branch was open, so the collector no longer compiled. Hermes sessions are matched by their worker process (python -m tui_gateway.slash_worker --session-key <id>), a plain CLI invocation: Hermes ships no desktop-app bundle and no editor extension that vendors that worker, so the collector reports LaunchSurface::Cli.
|
Kept current with main: One adaptation was needed. Verified on the merge:
Ready for review when you have a moment. |
|
Closing this PR for now to keep the review queue tidy, as it has been open for ~116 days without maintainer feedback. The remote branch ( |
Implements the hardened Hermes Agent collector proposed in #167. Closes #167.
What it does
Hermes Agent (Nous Research) sessions are discovered from the
tui_gateway.slash_worker --session-key <id>processes Hermes spawns per active session — parsed from the already-scannedSharedProcessDatacommand lines (token parsing only, no string building). Session metadata, token counters and the transcript tail are read directly from~/.hermes/state.db(orHERMES_HOME/state.db) through an in-process, read-onlyrusqliteconnection with bundled SQLite — nosqlite3CLI or Python required on any platform.Hide via
hidden_agents = ["hermes"]like any other agent.How it addresses the security feedback that closed #139
The previous attempt (PR #139) was closed over four concerns. This implementation addresses each:
SQLITE_OPEN_READ_ONLYconnection; process matching parses tokens from command lines already scanned by the shared snapshot.sanitize_terminal_text→redact_secrets→ truncation exactly like the OpenCode/Claude collectors. Tool results (role='tool') and internalsession_metarows never enter the chat tail.cargo clippy --all-targets -- -D warningspasses.DB rows and transcript tails are cached and refreshed only on the slow tick (~10s), matching the OpenCodeCollector pattern.
Verification
Tested live against running Hermes sessions (Linux):
abtop --once --jsonreports each active session with correct PID ↔ session matching, model, token counters, context %, status (Waiting vs Executing with open tool calls), project dir, prompt summary, tool timeline, and redacted chat tail. 10 new unit tests; full suite: 211 passed.Note:
rusqlite(bundled) is a new dependency — the alternative (sqlite3CLI like OpenCode) would silently fail on machines without the binary, which is why the in-process reader was chosen. Happy to switch if you prefer the CLI pattern.