mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
feat: add 'View full command' option to dangerous command approval (#887)
When a dangerous command is detected and the user is prompted for approval, long commands are truncated (80 chars in fallback, 70 chars in the TUI). Users had no way to see the full command before deciding. This adds a 'View full command' option across all approval interfaces: - CLI fallback (tools/approval.py): [v]iew option in the prompt menu. Shows the full command and re-prompts for approval decision. - CLI TUI (cli.py): 'Show full command' choice in the arrow-key selection panel. Expands the command display in-place and removes the view option after use. - CLI callbacks (callbacks.py): 'view' choice added to the list when the command exceeds 70 characters. - Gateway (gateway/run.py): 'full', 'show', 'view' responses reveal the complete command while keeping the approval pending. Includes 7 new tests covering view-then-approve, view-then-deny, short command fallthrough, and double-view behavior. Closes community feedback about the 80-char cap on dangerous commands.
This commit is contained in:
19
cli.py
19
cli.py
@@ -3824,7 +3824,17 @@ class HermesCLI:
|
||||
selected = state["selected"]
|
||||
choices = state["choices"]
|
||||
if 0 <= selected < len(choices):
|
||||
state["response_queue"].put(choices[selected])
|
||||
chosen = choices[selected]
|
||||
if chosen == "view":
|
||||
# Toggle full command display without closing the prompt
|
||||
state["show_full"] = True
|
||||
# Remove the "view" option since it's been used
|
||||
state["choices"] = [c for c in choices if c != "view"]
|
||||
if state["selected"] >= len(state["choices"]):
|
||||
state["selected"] = len(state["choices"]) - 1
|
||||
event.app.invalidate()
|
||||
return
|
||||
state["response_queue"].put(chosen)
|
||||
self._approval_state = None
|
||||
event.app.invalidate()
|
||||
return
|
||||
@@ -4372,13 +4382,18 @@ class HermesCLI:
|
||||
description = state["description"]
|
||||
choices = state["choices"]
|
||||
selected = state.get("selected", 0)
|
||||
show_full = state.get("show_full", False)
|
||||
|
||||
cmd_display = command[:70] + '...' if len(command) > 70 else command
|
||||
if show_full or len(command) <= 70:
|
||||
cmd_display = command
|
||||
else:
|
||||
cmd_display = command[:70] + '...'
|
||||
choice_labels = {
|
||||
"once": "Allow once",
|
||||
"session": "Allow for this session",
|
||||
"always": "Add to permanent allowlist",
|
||||
"deny": "Deny",
|
||||
"view": "Show full command",
|
||||
}
|
||||
preview_lines = _wrap_panel_text(description, 60)
|
||||
preview_lines.extend(_wrap_panel_text(cmd_display, 60))
|
||||
|
||||
Reference in New Issue
Block a user