The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): Xvnc cut-text cap matches the bridge, NOPASSWD install covered, bridge design notes
teknium1717e4c2fe738
diff --git a/hermes_cli/web_routers/display.py b/hermes_cli/web_routers/display.pyindex 4733b69ca1d..78265a3eddf 100644--- a/hermes_cli/web_routers/display.py+++ b/hermes_cli/web_routers/display.py@@ -9,6 +9,13 @@ only from the viewer that currently holds the lease. noVNC's ``viewOnly`` is UX;A lease change closes the evicted viewer's socket with 4000 ``control-taken`` so its UI drops back toWatch mode and reconnects.++Design notes. The ticket rides in the query string on purpose: noVNC's Websock owns the socket and+cannot negotiate a subprotocol or add a header, and the ticket is single-use and expires in 30 s, so+a logged URL is spent by the time anyone reads it. The bridge's input gate re-reads ``lease.json`` at+most every ``_LEASE_REFRESH_S`` (250 ms) between in-process ``on_change`` callbacks: that bounds how+long another PROCESS's takeover can go unnoticed, and is the price of not stat-ing the lease file on+the event loop for every pointer move."""from __future__ import annotationsdiff --git a/tests/tools/test_bot_desktop_install.py b/tests/tools/test_bot_desktop_install.pyindex a3e5392a66a..486faf955f5 100644--- a/tests/tools/test_bot_desktop_install.py+++ b/tests/tools/test_bot_desktop_install.py@@ -86,7 +86,7 @@ def test_timeout_kills_the_package_managers_whole_process_group(monkeypatch):def gone() -> bool: # /proc-based: a reparented orphan sits outside our subtree, where os.kill(pid, 0) is guardedtry:- return "Z" in (Path(f"/proc/{child}/stat").read_text().rsplit(")", 1)[1].split() or ["Z"])[0]+ return "Z" in (Path(f"/proc/{child}/stat").read_text(encoding="utf-8").rsplit(")", 1)[1].split() or ["Z"])[0]except OSError:return True@@ -97,3 +97,31 @@ def test_timeout_kills_the_package_managers_whole_process_group(monkeypatch):else:subprocess.run(["kill", "-9", str(child)], check=False)pytest.fail("grandchild survived the install timeout")+++def test_passwordless_sudo_runs_the_install_without_asking_for_a_password(monkeypatch):+ """A host with NOPASSWD sudo must not pop the masked password card — the card blocks the install+ for up to five minutes on an answer nobody needs to give — and the package command still runs+ and streams its output."""+ monkeypatch.setattr(install, "_sudo_nopasswd", lambda: True)+ spawned: list[list[str]] = []++ class _Proc:+ pid = 4242+ stdin = __import__("io").StringIO()++ def __init__(self, argv, **kw):+ spawned.append(argv)+ self.stdout = iter(["Reading package lists...\n", "Done\n"])++ def wait(self):+ return 0++ monkeypatch.setattr(install.subprocess, "Popen", _Proc)+ monkeypatch.setattr(install.os, "killpg", lambda *a: None)+ lines: list[str] = []+ code = install.install_packages(ask_password=lambda: pytest.fail("sudo password asked despite NOPASSWD"),+ on_line=lines.append)+ assert code == 0+ assert spawned and spawned[0][:1] == ["sudo"] and "-S" not in spawned[0]+ assert "Done" in linesdiff --git a/tests/tools/test_bot_desktop_launcher_xvnc.py b/tests/tools/test_bot_desktop_launcher_xvnc.pyindex c2861796c24..9db7f0651de 100644--- a/tests/tools/test_bot_desktop_launcher_xvnc.py+++ b/tests/tools/test_bot_desktop_launcher_xvnc.py@@ -38,4 +38,7 @@ def test_xvnc_never_sends_the_holders_clipboard_to_watchers(tmp_path):argv = argv_log.read_text(encoding="utf-8").split("\n")assert "-SendCutText=0" in argv, argvassert not any(a.startswith("-AcceptCutText") for a in argv), "paste into the screen must keep working"+ # Xvnc's own cut-text cap and the bridge filter's must agree, or one side drops a paste the other admits.+ from tools.bot_desktop.rfb_filter import _MAX_CUT_TEXT+ assert int(argv[argv.index("-MaxCutText") + 1]) == _MAX_CUT_TEXT, argvassert not os.path.exists(tmp_path / "rfb.sock") # stub never bound it; nothing leakeddiff --git a/tools/bot_desktop/launcher.sh b/tools/bot_desktop/launcher.shindex 4efecdaf9c4..ee5c487a5a2 100755--- a/tools/bot_desktop/launcher.sh+++ b/tools/bot_desktop/launcher.sh@@ -225,10 +225,11 @@ done# only by processes running as this user (the gateway's WebSocket bridge does the real authentication;# same-UID processes, the bot's own terminal tool included, are inside that boundary by design).# -SendCutText=0: watchers must never receive the holder's clipboard; -AcceptCutText stays on so-# paste INTO the screen keeps working.+# paste INTO the screen keeps working. -MaxCutText caps a client cut-text at 256 KiB — the same bound+# the bridge enforces (tools/bot_desktop/rfb_filter.py _MAX_CUT_TEXT); keep the two in sync.Xvnc "$DISPLAY" -geometry "$GEOM" -depth "$DEPTH" -dpi 96 \-rfbport -1 -rfbunixpath "$HERMES_BD_SOCKET" -rfbunixmode 0600 \- -SecurityTypes None -AlwaysShared -AcceptSetDesktopSize -FrameRate 30 -SendCutText=0 \+ -SecurityTypes None -AlwaysShared -AcceptSetDesktopSize -FrameRate 30 -SendCutText=0 -MaxCutText 262144 \-desktop "hermes:$HERMES_BD_PROFILE" -auth "$XAUTHORITY" -nolisten tcp \-Log '*:stderr:30' 2> >(grep -v --line-buffered 'Could not resolve keysym' >&2) &XVNC_PID=$!diff --git a/tools/bot_desktop/rfb_filter.py b/tools/bot_desktop/rfb_filter.pyindex b4d4a63e2c4..6fe9127559a 100644--- a/tools/bot_desktop/rfb_filter.py+++ b/tools/bot_desktop/rfb_filter.py@@ -30,8 +30,9 @@ _SET_ENCODINGS = 2_CLIENT_CUT_TEXT = 6_FENCE = 248-# TigerVNC's default MaxCutText. The length is client-declared (int32); without a cap a watcher-# with a ticket but no lease could make the bridge buffer ~2 GiB waiting for a payload.+# TigerVNC's default MaxCutText, and the value launcher.sh passes as ``-MaxCutText`` so Xvnc and+# the bridge agree (keep the two in sync). The length is client-declared (int32); without a cap a+# watcher with a ticket but no lease could make the bridge buffer ~2 GiB waiting for a payload._MAX_CUT_TEXT = 256 * 1024