feat: add --quiet/-Q flag for programmatic single-query mode
Adds -Q/--quiet to `hermes chat` for use by external orchestrators (Paperclip, scripts, CI). When combined with -q, suppresses: - Banner and ASCII art - Spinner animations - Tool preview lines (┊ prefix) Only outputs: - The agent's final response text - A parseable 'session_id: <id>' line for session resumption Usage: hermes chat -q 'Do something' -Q Used by: Paperclip adapter (@nousresearch/paperclip-adapter-hermes)
This commit is contained in:
parent
d502952bac
commit
23270d41b9
2 changed files with 24 additions and 4 deletions
22
cli.py
22
cli.py
|
|
@ -4356,6 +4356,7 @@ def main(
|
||||||
base_url: str = None,
|
base_url: str = None,
|
||||||
max_turns: int = None,
|
max_turns: int = None,
|
||||||
verbose: bool = False,
|
verbose: bool = False,
|
||||||
|
quiet: bool = False,
|
||||||
compact: bool = False,
|
compact: bool = False,
|
||||||
list_tools: bool = False,
|
list_tools: bool = False,
|
||||||
list_toolsets: bool = False,
|
list_toolsets: bool = False,
|
||||||
|
|
@ -4498,10 +4499,23 @@ def main(
|
||||||
|
|
||||||
# Handle single query mode
|
# Handle single query mode
|
||||||
if query:
|
if query:
|
||||||
cli.show_banner()
|
if quiet:
|
||||||
cli.console.print(f"[bold blue]Query:[/] {query}")
|
# Quiet mode: suppress banner, spinner, tool previews.
|
||||||
cli.chat(query)
|
# Only print the final response and parseable session info.
|
||||||
cli._print_exit_summary()
|
cli.tool_progress_mode = "off"
|
||||||
|
cli.agent = cli._init_agent()
|
||||||
|
if cli.agent:
|
||||||
|
cli.agent.quiet_mode = True
|
||||||
|
result = cli.agent.run_conversation(query)
|
||||||
|
response = result.get("final_response", "") if isinstance(result, dict) else str(result)
|
||||||
|
if response:
|
||||||
|
print(response)
|
||||||
|
print(f"\nsession_id: {cli.session_id}")
|
||||||
|
else:
|
||||||
|
cli.show_banner()
|
||||||
|
cli.console.print(f"[bold blue]Query:[/] {query}")
|
||||||
|
cli.chat(query)
|
||||||
|
cli._print_exit_summary()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Run interactive mode
|
# Run interactive mode
|
||||||
|
|
|
||||||
|
|
@ -486,6 +486,7 @@ def cmd_chat(args):
|
||||||
"provider": getattr(args, "provider", None),
|
"provider": getattr(args, "provider", None),
|
||||||
"toolsets": args.toolsets,
|
"toolsets": args.toolsets,
|
||||||
"verbose": args.verbose,
|
"verbose": args.verbose,
|
||||||
|
"quiet": getattr(args, "quiet", False),
|
||||||
"query": args.query,
|
"query": args.query,
|
||||||
"resume": getattr(args, "resume", None),
|
"resume": getattr(args, "resume", None),
|
||||||
"worktree": getattr(args, "worktree", False),
|
"worktree": getattr(args, "worktree", False),
|
||||||
|
|
@ -1918,6 +1919,11 @@ For more help on a command:
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Verbose output"
|
help="Verbose output"
|
||||||
)
|
)
|
||||||
|
chat_parser.add_argument(
|
||||||
|
"-Q", "--quiet",
|
||||||
|
action="store_true",
|
||||||
|
help="Quiet mode for programmatic use: suppress banner, spinner, and tool previews. Only output the final response and session info."
|
||||||
|
)
|
||||||
chat_parser.add_argument(
|
chat_parser.add_argument(
|
||||||
"--resume", "-r",
|
"--resume", "-r",
|
||||||
metavar="SESSION_ID",
|
metavar="SESSION_ID",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue