mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-04 07:31:58 +00:00
feat(telegram): support quick-command-only menus
This commit is contained in:
parent
e80d3084e5
commit
b1acf80e17
7 changed files with 144 additions and 3 deletions
|
|
@ -270,6 +270,25 @@ class TestLoadGatewayConfig:
|
|||
|
||||
assert config.quick_commands == {"limits": {"type": "exec", "command": "echo ok"}}
|
||||
|
||||
def test_bridges_telegram_command_menu_from_config_yaml(self, tmp_path, monkeypatch):
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
config_path = hermes_home / "config.yaml"
|
||||
config_path.write_text(
|
||||
"telegram:\n"
|
||||
" command_menu: quick_commands_only\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert (
|
||||
config.platforms[Platform.TELEGRAM].extra["command_menu"]
|
||||
== "quick_commands_only"
|
||||
)
|
||||
|
||||
def test_bridges_group_sessions_per_user_from_config_yaml(self, tmp_path, monkeypatch):
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from hermes_cli.commands import (
|
|||
slack_subcommand_map,
|
||||
telegram_bot_commands,
|
||||
telegram_menu_commands,
|
||||
telegram_quick_menu_commands,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1153,6 +1154,47 @@ class TestTelegramMenuCommands:
|
|||
# No empty string in menu names
|
||||
assert "" not in menu_names
|
||||
|
||||
def test_quick_menu_commands_include_profile_quick_commands_only(self):
|
||||
menu, hidden = telegram_quick_menu_commands(
|
||||
{
|
||||
"agent-health": {
|
||||
"type": "exec",
|
||||
"command": "echo ok",
|
||||
"description": "Show agent health",
|
||||
},
|
||||
"hidden": {
|
||||
"type": "exec",
|
||||
"command": "echo hidden",
|
||||
"description": "Hidden command",
|
||||
"show_in_telegram_menu": False,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert hidden == 0
|
||||
assert menu == [("agent_health", "Show agent health")]
|
||||
|
||||
def test_quick_menu_commands_sanitize_dedupe_and_trim_descriptions(self):
|
||||
menu, hidden = telegram_quick_menu_commands(
|
||||
{
|
||||
"agent-health": {
|
||||
"description": "A" * 80,
|
||||
},
|
||||
"agent_health": {
|
||||
"description": "Duplicate after sanitization",
|
||||
},
|
||||
"+++": {
|
||||
"description": "Sanitizes to empty",
|
||||
},
|
||||
},
|
||||
max_commands=1,
|
||||
)
|
||||
|
||||
assert hidden == 0
|
||||
assert len(menu) == 1
|
||||
assert menu[0][0] == "agent_health"
|
||||
assert menu[0][1] == ("A" * 37) + "..."
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Backward-compat aliases
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue