mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-12 03:42:08 +00:00
fix(cli): sanitize bracketed paste markers during setup
Strip bracketed-paste control sequences from setup prompt input so pasted API keys work on Linux and WSL terminals, and add regression tests for normal/password prompts. Closes #16491
This commit is contained in:
parent
8ebb81fd76
commit
02147cc850
2 changed files with 35 additions and 1 deletions
|
|
@ -1,6 +1,28 @@
|
|||
from hermes_cli import setup as setup_mod
|
||||
|
||||
|
||||
def test_prompt_strips_bracketed_paste_markers(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"builtins.input",
|
||||
lambda _prompt="": "\x1b[200~sk-ant-api-key\x1b[201~",
|
||||
)
|
||||
|
||||
value = setup_mod.prompt("API key")
|
||||
|
||||
assert value == "sk-ant-api-key"
|
||||
|
||||
|
||||
def test_password_prompt_strips_bracketed_paste_markers(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"getpass.getpass",
|
||||
lambda _prompt="": "\x1b[200~secret-token\x1b[201~",
|
||||
)
|
||||
|
||||
value = setup_mod.prompt("API key", password=True)
|
||||
|
||||
assert value == "secret-token"
|
||||
|
||||
|
||||
def test_prompt_choice_uses_curses_helper(monkeypatch):
|
||||
monkeypatch.setattr(setup_mod, "_curses_prompt_choice", lambda question, choices, default=0, description=None: 1)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue