* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule The PLUGIN-COMPAT layer (2776813df3+d63e380324+0a5164cebe) kept pre-#102117 import paths alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader has already been skipping plugins that use the old paths. This removes the layer itself: - 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party names, restored dead definitions) and the three re-export stub modules (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils) - COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step - the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section, the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the `plugins.allow_deprecated_imports` escape hatch An external plugin that still imports an old path now fails to load with its ImportError as the reason in `hermes plugins list`, the same path as any broken plugin. hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect, summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout swap (tests/compat/old_updater_surface.json). In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its `shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed `run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the seam production reads, like every sibling test in that file. * chore: retrigger CI (zero-job startup_failure phantom) * test: drop resolution allowlist rows for the two deleted which() sites hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available (a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires their allowlist entries go with them.
101 lines
3.5 KiB
Python
101 lines
3.5 KiB
Python
"""Secret-capture prompt for the interactive CLI (``_secret_capture_callback`` backend)."""
|
|
|
|
import queue
|
|
import time as _time
|
|
|
|
from hermes_cli.banner import cprint, _DIM, _RST
|
|
from hermes_cli.config import save_env_value_secure
|
|
from hermes_cli.secret_prompt import masked_secret_prompt
|
|
from hermes_constants import display_hermes_home
|
|
|
|
|
|
def _invalidate(cli) -> None:
|
|
if hasattr(cli, "_paint_now"):
|
|
cli._paint_now()
|
|
elif getattr(cli, "_app", None):
|
|
cli._app.invalidate()
|
|
|
|
|
|
def _clear_secret_input(cli) -> None:
|
|
"""Drop stale draft input so Enter never stores it as the secret."""
|
|
try:
|
|
if hasattr(cli, "_clear_secret_input_buffer"):
|
|
cli._clear_secret_input_buffer()
|
|
elif getattr(cli, "_app", None):
|
|
cli._app.current_buffer.reset()
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def _skipped(var_name: str, reason: str, message: str) -> dict:
|
|
return {
|
|
"success": True, "reason": reason, "stored_as": var_name,
|
|
"validated": False, "skipped": True, "message": message}
|
|
|
|
|
|
def _secret_result(var_name: str, value: str) -> dict:
|
|
"""Store ``value`` (or report a skip when empty) and build the callback result dict."""
|
|
if not value:
|
|
cprint(f"\n{_DIM} ⏭ Secret entry skipped{_RST}")
|
|
return _skipped(var_name, "cancelled", "Secret setup was skipped.")
|
|
try:
|
|
stored = save_env_value_secure(var_name, value)
|
|
except ValueError as exc: # a locked or denylisted key: the skill setup only logs it, so say why here
|
|
cprint(f"\n ✗ {exc}")
|
|
raise
|
|
cprint(f"\n{_DIM} ✓ Stored secret in {display_hermes_home()}/.env as {var_name}{_RST}")
|
|
return {
|
|
**stored,
|
|
"skipped": False,
|
|
"message": "Secret stored securely. The secret value was not exposed to the model."}
|
|
|
|
|
|
def prompt_for_secret(cli, var_name: str, prompt: str, metadata=None) -> dict:
|
|
"""Prompt for a secret value through the TUI (e.g. API keys for skills).
|
|
|
|
Returns a dict with keys: success, stored_as, validated, skipped, message. The secret is stored
|
|
in ~/.hermes/.env and never exposed to the model.
|
|
"""
|
|
if not getattr(cli, "_app", None):
|
|
if not hasattr(cli, "_secret_state"):
|
|
cli._secret_state = None
|
|
if not hasattr(cli, "_secret_deadline"):
|
|
cli._secret_deadline = 0
|
|
try:
|
|
value = masked_secret_prompt(f"{prompt} (hidden, ESC or empty Enter to skip): ")
|
|
except (EOFError, KeyboardInterrupt):
|
|
value = ""
|
|
return _secret_result(var_name, value)
|
|
|
|
response_queue = queue.Queue()
|
|
cli._secret_state = {
|
|
"var_name": var_name,
|
|
"prompt": prompt,
|
|
"metadata": metadata or {},
|
|
"response_queue": response_queue}
|
|
cli._secret_deadline = _time.monotonic() + 120
|
|
if hasattr(cli, "_ring_bell"):
|
|
cli._ring_bell(prompt=True, context=f"secret needed ({var_name})")
|
|
_clear_secret_input(cli)
|
|
_invalidate(cli)
|
|
|
|
while True:
|
|
try:
|
|
value = response_queue.get(timeout=1)
|
|
except queue.Empty:
|
|
if cli._secret_deadline - _time.monotonic() <= 0:
|
|
break
|
|
_invalidate(cli)
|
|
continue
|
|
cli._secret_state = None
|
|
cli._secret_deadline = 0
|
|
_invalidate(cli)
|
|
return _secret_result(var_name, value)
|
|
|
|
cli._secret_state = None
|
|
cli._secret_deadline = 0
|
|
_clear_secret_input(cli)
|
|
_invalidate(cli)
|
|
cprint(f"\n{_DIM} ⏱ Timeout — secret capture cancelled{_RST}")
|
|
return _skipped(var_name, "timeout", "Secret setup timed out and was skipped.")
|