mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(cli): show masked feedback for secret prompts
This commit is contained in:
parent
d952b377aa
commit
ec4d6f1823
20 changed files with 310 additions and 61 deletions
|
|
@ -2803,7 +2803,7 @@ def _aux_flow_provider_model(
|
|||
|
||||
def _aux_flow_custom_endpoint(task: str, task_cfg: dict) -> None:
|
||||
"""Prompt for a direct OpenAI-compatible base_url + optional api_key/model."""
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
display_name = next((name for key, name, _ in _all_aux_tasks() if key == task), task)
|
||||
current_base_url = str(task_cfg.get("base_url") or "").strip()
|
||||
|
|
@ -2837,7 +2837,7 @@ def _aux_flow_custom_endpoint(task: str, task_cfg: dict) -> None:
|
|||
return
|
||||
model = model or current_model
|
||||
try:
|
||||
api_key = getpass.getpass(
|
||||
api_key = masked_secret_prompt(
|
||||
"API key (optional, blank = use OPENAI_API_KEY): "
|
||||
).strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
|
|
@ -3561,6 +3561,7 @@ def _model_flow_custom(config):
|
|||
"""
|
||||
from hermes_cli.auth import _save_model_choice, deactivate_provider
|
||||
from hermes_cli.config import get_env_value, load_config, save_config
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
current_url = get_env_value("OPENAI_BASE_URL") or ""
|
||||
current_key = get_env_value("OPENAI_API_KEY") or ""
|
||||
|
|
@ -3576,9 +3577,7 @@ def _model_flow_custom(config):
|
|||
base_url = input(
|
||||
f"API base URL [{current_url or 'e.g. https://api.example.com/v1'}]: "
|
||||
).strip()
|
||||
import getpass
|
||||
|
||||
api_key = getpass.getpass(
|
||||
api_key = masked_secret_prompt(
|
||||
f"API key [{current_key[:8] + '...' if current_key else 'optional'}]: "
|
||||
).strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
|
|
@ -3990,7 +3989,6 @@ def _model_flow_azure_foundry(config, current_model=""):
|
|||
save_config,
|
||||
)
|
||||
from hermes_cli import azure_detect
|
||||
import getpass
|
||||
|
||||
# ── Load current Azure Foundry configuration ─────────────────────
|
||||
model_cfg = config.get("model", {})
|
||||
|
|
@ -4153,8 +4151,10 @@ def _model_flow_azure_foundry(config, current_model=""):
|
|||
token_provider = None
|
||||
else:
|
||||
print()
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
try:
|
||||
api_key = getpass.getpass(
|
||||
api_key = masked_secret_prompt(
|
||||
f"API key [{current_api_key[:8] + '...' if current_api_key else 'required'}]: "
|
||||
).strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
|
|
@ -4725,10 +4725,10 @@ def _model_flow_copilot(config, current_model=""):
|
|||
print(f" Login failed: {exc}")
|
||||
return
|
||||
elif choice == "2":
|
||||
try:
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
new_key = getpass.getpass(" Token (COPILOT_GITHUB_TOKEN): ").strip()
|
||||
try:
|
||||
new_key = masked_secret_prompt(" Token (COPILOT_GITHUB_TOKEN): ").strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
return
|
||||
|
|
@ -4980,10 +4980,9 @@ def _prompt_api_key(pconfig, existing_key: str, provider_id: str = "") -> tuple:
|
|||
``return`` immediately — the user cancelled entry, declined to replace, or
|
||||
cleared the key and is now unconfigured.
|
||||
"""
|
||||
import getpass
|
||||
|
||||
from hermes_cli.auth import LMSTUDIO_NOAUTH_PLACEHOLDER
|
||||
from hermes_cli.config import save_env_value
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
key_env = pconfig.api_key_env_vars[0] if pconfig.api_key_env_vars else ""
|
||||
|
||||
|
|
@ -4993,7 +4992,7 @@ def _prompt_api_key(pconfig, existing_key: str, provider_id: str = "") -> tuple:
|
|||
else:
|
||||
prompt = f"{key_env} (or Enter to cancel): "
|
||||
try:
|
||||
entered = getpass.getpass(prompt).strip()
|
||||
entered = masked_secret_prompt(prompt).strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
return ""
|
||||
|
|
@ -5308,10 +5307,10 @@ def _model_flow_bedrock_api_key(config, region, current_model=""):
|
|||
else:
|
||||
print(f" Endpoint: {mantle_base_url}")
|
||||
print()
|
||||
try:
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
api_key = getpass.getpass(" Bedrock API Key: ").strip()
|
||||
try:
|
||||
api_key = masked_secret_prompt(" Bedrock API Key: ").strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
return
|
||||
|
|
@ -5883,10 +5882,10 @@ def _run_anthropic_oauth_flow(save_env_value):
|
|||
print()
|
||||
print(" If the setup-token was displayed above, paste it here:")
|
||||
print()
|
||||
try:
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
manual_token = getpass.getpass(
|
||||
try:
|
||||
manual_token = masked_secret_prompt(
|
||||
" Paste setup-token (or Enter to cancel): "
|
||||
).strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
|
|
@ -5914,10 +5913,10 @@ def _run_anthropic_oauth_flow(save_env_value):
|
|||
print()
|
||||
print(" Or paste an existing setup-token now (sk-ant-oat-...):")
|
||||
print()
|
||||
try:
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
token = getpass.getpass(" Setup-token (or Enter to cancel): ").strip()
|
||||
try:
|
||||
token = masked_secret_prompt(" Setup-token (or Enter to cancel): ").strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
return False
|
||||
|
|
@ -6032,10 +6031,10 @@ def _model_flow_anthropic(config, current_model=""):
|
|||
print()
|
||||
print(" Get an API key at: https://platform.claude.com/settings/keys")
|
||||
print()
|
||||
try:
|
||||
import getpass
|
||||
from hermes_cli.secret_prompt import masked_secret_prompt
|
||||
|
||||
api_key = getpass.getpass(" API key (sk-ant-...): ").strip()
|
||||
try:
|
||||
api_key = masked_secret_prompt(" API key (sk-ant-...): ").strip()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue