The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): CLI `screen stop` honors a human takeover; --force to override
teknium1e4a9e7f21e8c
diff --git a/hermes_cli/subcommands/computer_use_screen.py b/hermes_cli/subcommands/computer_use_screen.pyindex d2bb5d6d026..996614763ca 100644--- a/hermes_cli/subcommands/computer_use_screen.py+++ b/hermes_cli/subcommands/computer_use_screen.py@@ -47,8 +47,12 @@ def _screen_start(args) -> int:def _screen_stop(args) -> int:from tools.bot_desktop import runtimeif runtime.is_supported_host():+ # Same door as display.stop: a human mid-takeover is never yanked by a runbook or a stray+ # `screen stop`; the decision is taken under the lease lock so a takeover cannot race it.from tools.bot_desktop import lease- lease.release()+ if lease.release(unless_human=not bool(getattr(args, "force", False))).holder == lease.HUMAN:+ print("Bot Desktop: a human holds this screen; re-run with --force to take it down anyway.")+ return 1print("Bot Desktop: stopped" if runtime.stop() else "Bot Desktop: was not running")return 0@@ -108,7 +112,8 @@ def build_screen_parser(computer_use_sub, add_json_flag) -> None:st = sub.add_parser("status", help="Show whether this profile's screen is installed/running and who holds control")add_json_flag(st, "Emit the status payload as JSON.")sub.add_parser("start", help="Start this profile's screen")- sub.add_parser("stop", help="Stop this profile's screen (hands control back to the agent first)")+ stop = sub.add_parser("stop", help="Stop this profile's screen (hands control back to the agent first)")+ stop.add_argument("--force", action="store_true", help="Stop even while a human holds control from Hermes Desktop")inst = sub.add_parser("install", help="Install TigerVNC + Xfce core via the host package manager")inst.add_argument("-y", "--yes", action="store_true", help="Do not ask before running the package manager")diff --git a/tests/hermes_cli/test_bot_desktop_screen_stop.py b/tests/hermes_cli/test_bot_desktop_screen_stop.pyindex 84542ea6202..81482c81829 100644--- a/tests/hermes_cli/test_bot_desktop_screen_stop.py+++ b/tests/hermes_cli/test_bot_desktop_screen_stop.py@@ -1,4 +1,4 @@-"""The documented CLI stop is also recovery for a disconnected viewer's lease."""+"""The documented CLI stop --force is also recovery for a disconnected viewer's lease."""import argparse@@ -13,6 +13,24 @@ def test_screen_stop_hands_back_even_when_the_desktop_has_already_exited():parser = argparse.ArgumentParser()build_screen_parser(parser.add_subparsers(), lambda sub, help_text: sub.add_argument('--json', action='store_true'))lease.acquire('disconnected-viewer')- args = parser.parse_args(['screen', 'stop'])+ args = parser.parse_args(['screen', 'stop', '--force'])assert args.screen_func(args) == 0assert lease.get().holder == lease.AGENT++[email protected]_only+def test_screen_stop_refuses_while_a_human_holds_unless_forced(monkeypatch):+ """Same door as display.stop: a runbook or stray `screen stop` must not yank a live takeover."""+ from tools.bot_desktop import lease, runtime++ stopped: list = []+ monkeypatch.setattr(runtime, "stop", lambda: stopped.append(1) or True)+ parser = argparse.ArgumentParser()+ build_screen_parser(parser.add_subparsers(), lambda sub, help_text: sub.add_argument('--json', action='store_true'))+ lease.acquire('human-at-keyboard')+ args = parser.parse_args(['screen', 'stop'])+ assert args.screen_func(args) == 1+ assert lease.get().holder == lease.HUMAN and not stopped+ args = parser.parse_args(['screen', 'stop', '--force'])+ assert args.screen_func(args) == 0+ assert lease.get().holder == lease.AGENT and stopped