"""Slash-command handlers for the interactive CLI (``HermesCLI`` inherits ``CLICommandsMixin``). cli.py-internal symbols (``_cprint``/``_ACCENT``/``save_config_value``…) are imported LAZILY inside the helpers/handlers via ``from cli import ...`` — cli.py imports this module (cycle otherwise). """ from __future__ import annotations import argparse import atexit import io import json import os import shlex import subprocess import tempfile import threading import time import uuid from contextlib import redirect_stdout, suppress from io import StringIO from datetime import datetime from urllib.parse import urlparse from rich import box as rich_box from rich.markup import escape as _escape from rich.panel import Panel from hermes_constants import display_hermes_home from hermes_state_ids import new_session_id as mint_session_id from agent.i18n import t from agent.message_metadata import message_identity from agent.turn_context import extract_api_content_sidecar from hermes_cli.cli_agent_setup_mixin import _gateway_open, _retire_agent from hermes_cli.cli_commands_session_tools import ( CLICommandsSessionToolsMixin, _TTYBuf, _accent, _accent_line, _command_arg, _cp, _dim, _dim_line, _gt, _lines, _pr, _probe, _rollback_kept, _save, _say_block, _shlex_args, _t, _tn) from hermes_cli.cli_session_switch import ( _end_current_session, _sync_agent_to_session) from hermes_cli.browser_connect import ( DEFAULT_BROWSER_CDP_URL, discover_local_cdp_url, find_free_debug_port, is_browser_debug_ready, launch_chrome_debug, local_port_in_use, manual_chrome_debug_command) from hermes_cli.cli_browser_gateway import _normalize_cdp_url # Output helpers. Slash-command text is user-visible: every literal below is load-bearing. _FAILED = object() def _attempt(label: str, errors, fn, *args, **kwargs): """``fn(*args, **kwargs)``, or ``_FAILED`` after printing ``