Skip to content

The agent that grows with you

fix(signal, weixin): setup menu reads .env-only credentials like the old core rows

Tekniumbdda3763cd0e
diff --git a/plugins/platforms/signal/adapter.py b/plugins/platforms/signal/adapter.py
index 98977156928..ac1fa5f88af 100644
--- a/plugins/platforms/signal/adapter.py
+++ b/plugins/platforms/signal/adapter.py
@@ -39,7 +39,7 @@ from plugins.platforms.signal.signal_rate_limit import (
SIGNAL_BATCH_PACING_NOTICE_THRESHOLD, SIGNAL_MAX_ATTACHMENTS_PER_MSG, SIGNAL_RATE_LIMIT_MAX_ATTEMPTS,
SignalRateLimitError, _extract_retry_after_seconds, _format_wait, _is_signal_rate_limit_error,
_signal_send_timeout, get_scheduler)
-from gateway.platforms._shared import get_scoped_secret as _sig_secret
+from gateway.platforms._shared import env_is_connected, get_scoped_secret as _sig_secret
from utils import TRUTHY_STRINGS
logger = logging.getLogger(__name__)
@@ -173,6 +173,16 @@ def validate_signal_config(config: PlatformConfig) -> bool:
return bool(http_url and account)
+_env_configured = env_is_connected("SIGNAL_HTTP_URL", "SIGNAL_ACCOUNT")
+
+
+def _is_connected(config: PlatformConfig) -> bool:
+ """URL + account from config/scoped env, else ``.env``: a plain CLI process never loads ``.env``
+ into the environment, and the old static setup row read it, so a ``.env``-only profile stays
+ "configured" in ``hermes gateway setup``."""
+ return validate_signal_config(config) or _env_configured(config)
+
+
class SignalAdapter(BasePlatformAdapter):
"""Signal messenger adapter using signal-cli HTTP daemon."""
@@ -1006,7 +1016,7 @@ def register(ctx) -> None:
ctx.register_platform(
name="signal", label="Signal", adapter_factory=SignalAdapter,
check_fn=check_signal_requirements, validate_config=_validate_config,
- is_connected=validate_signal_config, required_env=["SIGNAL_HTTP_URL", "SIGNAL_ACCOUNT"],
+ is_connected=_is_connected, required_env=["SIGNAL_HTTP_URL", "SIGNAL_ACCOUNT"],
install_hint="Signal: runtime requirements not met", setup_fn=_interactive_setup,
allowed_users_env="SIGNAL_ALLOWED_USERS", allow_all_env="SIGNAL_ALLOW_ALL_USERS",
cron_deliver_env_var="SIGNAL_HOME_CHANNEL",
diff --git a/plugins/platforms/weixin/adapter.py b/plugins/platforms/weixin/adapter.py
index 106b6d9f6f0..01aaa89b624 100644
--- a/plugins/platforms/weixin/adapter.py
+++ b/plugins/platforms/weixin/adapter.py
@@ -38,7 +38,7 @@ from gateway.platforms.base import (
from gateway.platforms.event import MessageEvent, MessageType
from hermes_constants import get_hermes_home
from utils import atomic_json_write
-from gateway.platforms._shared import extra_or_secret as _extra_or_env, get_scoped_secret as _wx_secret
+from gateway.platforms._shared import env_is_connected, extra_or_secret as _extra_or_env, get_scoped_secret as _wx_secret
def _extra_or_secret(extra: dict[str, Any], key: str, default: str = "") -> str:
@@ -1251,13 +1251,17 @@ async def send_weixin_direct(
_INSTALL_HINT = "Weixin: aiohttp/cryptography not installed"
+_env_configured = env_is_connected("WEIXIN_ACCOUNT_ID", "WEIXIN_TOKEN")
+
+
def _is_connected(config: Any) -> bool:
"""Account ID AND token, from ``config`` or the scoped ``WEIXIN_*`` env (``gateway/config.py``'s
- Weixin connected check reads the same pair)."""
+ Weixin connected check reads the same pair), else ``.env``, which a plain CLI process never loads
+ into the environment (the old static setup row read it)."""
extra = getattr(config, "extra", None) or {}
account = _extra_or_secret(extra, "account_id")
token = str(getattr(config, "token", None) or extra.get("token") or _wx_secret("WEIXIN_TOKEN", "")).strip()
- return bool(account and token)
+ return bool(account and token) or _env_configured(config)
async def _standalone_send(pconfig: Any, chat_id: str, message: str, *, thread_id: Optional[str] = None,
diff --git a/tests/hermes_cli/test_gateway_setup_moved_platforms_status.py b/tests/hermes_cli/test_gateway_setup_moved_platforms_status.py
new file mode 100644
index 00000000000..59cd8a792c1
--- /dev/null
+++ b/tests/hermes_cli/test_gateway_setup_moved_platforms_status.py
@@ -0,0 +1,36 @@
+"""Setup-menu status for the messaging platforms that moved from core into bundled plugins.
+
+The old static wizard rows read credentials through ``get_env_value`` (``.env``-backed), so a profile whose
+credentials live only in ``.env`` showed "configured". A plain CLI process never loads ``.env`` into
+``os.environ``, so a plugin ``is_connected`` that reads only the scoped environment reports "not configured"
+for the same profile.
+"""
+
+import pytest
+
+# platform -> the credential env vars the old static rows (or config_env enablement) required.
+_CREDENTIALS = {
+ "signal": {"SIGNAL_HTTP_URL": "http://127.0.0.1:8080", "SIGNAL_ACCOUNT": "+15550001111"},
+ "weixin": {"WEIXIN_ACCOUNT_ID": "[email protected]", "WEIXIN_TOKEN": "tok"},
+ "bluebubbles": {"BLUEBUBBLES_SERVER_URL": "http://127.0.0.1:1234", "BLUEBUBBLES_PASSWORD": "pw"},
+ "qqbot": {"QQ_APP_ID": "1", "QQ_CLIENT_SECRET": "s"},
+ "yuanbao": {"YUANBAO_APP_ID": "a", "YUANBAO_APP_SECRET": "s"},
+ "whatsapp_cloud": {"WHATSAPP_CLOUD_PHONE_NUMBER_ID": "1", "WHATSAPP_CLOUD_ACCESS_TOKEN": "t"},
+}
+
+
[email protected]("platform", sorted(_CREDENTIALS))
+def test_dotenv_only_credentials_show_configured(monkeypatch, platform):
+ import hermes_cli.gateway as gateway_mod
+
+ for creds in _CREDENTIALS.values():
+ for name in creds:
+ monkeypatch.delenv(name, raising=False)
+ row = next(p for p in gateway_mod._all_platforms() if p["key"] == platform)
+ assert row.get("_registry_entry") is not None, f"{platform} should come from its bundled plugin"
+
+ monkeypatch.setattr(gateway_mod, "get_env_value", lambda name: None)
+ assert gateway_mod._platform_status(row) == "not configured"
+
+ monkeypatch.setattr(gateway_mod, "get_env_value", _CREDENTIALS[platform].get)
+ assert gateway_mod._platform_status(row) == "configured"