mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
fix(platforms): clear home channel when setup prompt left blank
Blank (or whitespace-only) answers to the home-channel prompt in the interactive setup wizards previously left any previously saved *_HOME_CHANNEL / *_HOME_ROOM env value in place, so operators could not clear a stale home channel by re-running setup. Strip the prompt input and call remove_env_value() on blank answers across the Discord, Slack, Feishu, Matrix, Mattermost, WeCom and WhatsApp plugin setup wizards, with per-adapter wizard tests covering set/clear/whitespace flows. Squash of the three commits from PR #58421 (setup-wizard fix, matrix/ wecom extension, and 6-adapter test coverage) — one commit per contributor on this salvage branch. Fixes #12423 Salvaged from #58421
This commit is contained in:
parent
ee62aab1a7
commit
241bc112e8
14 changed files with 696 additions and 35 deletions
|
|
@ -9272,7 +9272,7 @@ def interactive_setup() -> None:
|
|||
the plugin's import surface stays small, prompts for the bot token,
|
||||
captures an allowlist, and offers to set a home channel.
|
||||
"""
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
prompt_yes_no,
|
||||
|
|
@ -9336,9 +9336,12 @@ def interactive_setup() -> None:
|
|||
print_info(" To get a channel ID: right-click a channel → Copy Channel ID")
|
||||
print_info(" (requires Developer Mode in Discord settings)")
|
||||
print_info(" You can also set this later by typing /set-home in a Discord channel.")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)").strip()
|
||||
if home_channel:
|
||||
save_env_value("DISCORD_HOME_CHANNEL", home_channel)
|
||||
else:
|
||||
if remove_env_value("DISCORD_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
|
||||
|
||||
def _apply_yaml_config(yaml_cfg: dict, discord_cfg: dict) -> dict | None:
|
||||
|
|
|
|||
|
|
@ -5520,7 +5520,7 @@ def interactive_setup() -> None:
|
|||
Replaces the central _setup_feishu in hermes_cli/gateway.py and the static
|
||||
_PLATFORMS["feishu"] dict. CLI helpers are lazy-imported.
|
||||
"""
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.setup import prompt_choice
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
|
|
@ -5671,10 +5671,17 @@ def interactive_setup() -> None:
|
|||
save_env_value("FEISHU_GROUP_POLICY", "disabled")
|
||||
print_info("Group chats disabled.")
|
||||
|
||||
home_channel = prompt("Home chat ID (optional, for cron/notifications)", password=False)
|
||||
print_info(
|
||||
"Leave blank to clear a previously saved home channel "
|
||||
"(cron / notifications)."
|
||||
)
|
||||
home_channel = prompt("Home chat ID (optional, for cron/notifications)", password=False).strip()
|
||||
if home_channel:
|
||||
save_env_value("FEISHU_HOME_CHANNEL", home_channel)
|
||||
print_success(f"Home channel set to {home_channel}")
|
||||
else:
|
||||
if remove_env_value("FEISHU_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
|
||||
print_success("🪽 Feishu / Lark configured!")
|
||||
print_info(f"App ID: {app_id}")
|
||||
|
|
|
|||
|
|
@ -4610,7 +4610,7 @@ def interactive_setup() -> None:
|
|||
and the static _PLATFORMS["matrix"] dict. CLI helpers are lazy-imported."""
|
||||
import shutil
|
||||
import sys as _sys
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
prompt_yes_no,
|
||||
|
|
@ -4700,9 +4700,13 @@ def interactive_setup() -> None:
|
|||
print_info("📬 Home Room: where Hermes delivers cron job results and notifications.")
|
||||
print_info(" Room IDs look like !abc123:server (shown in Element room settings)")
|
||||
print_info(" You can also set this later by typing /set-home in a Matrix room.")
|
||||
home_room = prompt("Home room ID (leave empty to set later with /set-home)")
|
||||
print_info("Leave blank to clear a previously saved home room (cron / notifications).")
|
||||
home_room = prompt("Home room ID (leave empty to set later with /set-home)").strip()
|
||||
if home_room:
|
||||
save_env_value("MATRIX_HOME_ROOM", home_room)
|
||||
else:
|
||||
if remove_env_value("MATRIX_HOME_ROOM"):
|
||||
print_info("Home room cleared.")
|
||||
|
||||
|
||||
def _apply_yaml_config(yaml_cfg: dict, matrix_cfg: dict) -> dict | None:
|
||||
|
|
|
|||
|
|
@ -1136,7 +1136,7 @@ def interactive_setup() -> None:
|
|||
``hermes_cli/setup.py::_setup_mattermost`` function this migration
|
||||
removes.
|
||||
"""
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
prompt_yes_no,
|
||||
|
|
@ -1181,9 +1181,12 @@ def interactive_setup() -> None:
|
|||
print_info("📬 Home Channel: where Hermes delivers cron job results and notifications.")
|
||||
print_info(" To get a channel ID: click channel name → View Info → copy the ID")
|
||||
print_info(" You can also set this later by typing /set-home in a Mattermost channel.")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)").strip()
|
||||
if home_channel:
|
||||
save_env_value("MATTERMOST_HOME_CHANNEL", home_channel)
|
||||
else:
|
||||
if remove_env_value("MATTERMOST_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
print_info(" Open config in your editor: hermes config edit")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8729,7 +8729,7 @@ def interactive_setup() -> None:
|
|||
offers to set a home channel. Replaces ``hermes_cli/setup.py::_setup_slack``.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
prompt_yes_no,
|
||||
|
|
@ -8831,9 +8831,12 @@ def interactive_setup() -> None:
|
|||
print_info(" To get a channel ID: open the channel in Slack, then right-click")
|
||||
print_info(" the channel name → Copy link — the ID starts with C (e.g. C01ABC2DE3F).")
|
||||
print_info(" You can also set this later by typing /set-home in a Slack channel.")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)")
|
||||
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)").strip()
|
||||
if home_channel:
|
||||
save_env_value("SLACK_HOME_CHANNEL", home_channel.strip())
|
||||
save_env_value("SLACK_HOME_CHANNEL", home_channel)
|
||||
else:
|
||||
if remove_env_value("SLACK_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
|
||||
|
||||
def _apply_yaml_config(yaml_cfg: dict, slack_cfg: dict) -> dict | None:
|
||||
|
|
|
|||
|
|
@ -1731,7 +1731,7 @@ def interactive_setup() -> None:
|
|||
Replaces hermes_cli/gateway.py::_setup_wecom and the static
|
||||
_PLATFORMS["wecom"] dict. CLI helpers are lazy-imported.
|
||||
"""
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.setup import prompt_choice
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
|
|
@ -1829,10 +1829,13 @@ def interactive_setup() -> None:
|
|||
else:
|
||||
print_info("Skipped — configure later with 'hermes gateway setup'")
|
||||
|
||||
home = prompt("Home chat ID (optional, for cron/notifications)", password=False)
|
||||
home = prompt("Home chat ID (optional, for cron/notifications)", password=False).strip()
|
||||
if home:
|
||||
save_env_value("WECOM_HOME_CHANNEL", home)
|
||||
print_success(f"Home channel set to {home}")
|
||||
else:
|
||||
if remove_env_value("WECOM_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
|
||||
print_success("💬 WeCom configured!")
|
||||
|
||||
|
|
|
|||
|
|
@ -1672,7 +1672,7 @@ def interactive_setup() -> None:
|
|||
static _PLATFORMS["whatsapp"] dict. CLI helpers are lazy-imported so the
|
||||
plugin's module-load surface stays minimal.
|
||||
"""
|
||||
from hermes_cli.config import get_env_value, save_env_value
|
||||
from hermes_cli.config import get_env_value, remove_env_value, save_env_value
|
||||
from hermes_cli.cli_output import (
|
||||
prompt,
|
||||
prompt_yes_no,
|
||||
|
|
@ -1705,9 +1705,12 @@ def interactive_setup() -> None:
|
|||
save_env_value("WHATSAPP_ALLOWED_USERS", allowed_users.replace(" ", ""))
|
||||
print_success("WhatsApp allowlist configured")
|
||||
|
||||
home_channel = prompt("Home chat ID for cron delivery (leave empty to skip)")
|
||||
home_channel = prompt("Home chat ID for cron delivery (leave empty to skip)").strip()
|
||||
if home_channel:
|
||||
save_env_value("WHATSAPP_HOME_CHANNEL", home_channel.strip())
|
||||
save_env_value("WHATSAPP_HOME_CHANNEL", home_channel)
|
||||
else:
|
||||
if remove_env_value("WHATSAPP_HOME_CHANNEL"):
|
||||
print_info("Home channel cleared.")
|
||||
|
||||
|
||||
def _apply_yaml_config(yaml_cfg: dict, whatsapp_cfg: dict) -> dict | None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue