The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(platforms): bundled authorization env names hold when the live entry lacks them
Tekniumb95c4861b2d6
diff --git a/gateway/authz_mixin.py b/gateway/authz_mixin.pyindex 6de9adb3e3f..b9f4ed90fbe 100644--- a/gateway/authz_mixin.py+++ b/gateway/authz_mixin.py@@ -53,6 +53,12 @@ def _env_truthy(name: str) -> bool:return _auth_env(name).lower() in _TRUTHY+def authz_field(name, field, entry):+ """Late-bound :func:`gateway.platform_env.authz_field` (entry field, else the bundled declaration)."""+ from gateway.platform_env import authz_field as _field+ return _field(name, field, entry)++def _registry_entry(platform):"""Platform-registry entry for a (plugin) platform, or None. Discovers first (idempotent): theallowlist env names live only on the entry, so an undiscovered process must not read "no list"."""@@ -497,7 +503,7 @@ class GatewayAuthorizationMixin:# under multiplex only the default profile's list reaches the env (first-writer-wins# bridge), so read the live adapter's.entry = _registry_entry(source.platform)- if entry and entry.allowed_users_env:+ if authz_field(source.platform.value, "allowed_users_env", entry):# Buzz) carry the same operator-configured allowlist in# ``PlatformConfig.extra.allowed_users``. An absent/empty entry changes nothing here β the# default-deny below still applies. See #82871, #98738.@@ -567,7 +573,7 @@ class GatewayAuthorizationMixin:with contextlib.suppress(Exception):from hermes_cli.plugins import discover_pluginsdiscover_plugins()- allow_bots_var = getattr(_registry_entry(source.platform), "allow_bots_env", "")+ allow_bots_var = authz_field(source.platform.value, "allow_bots_env", _registry_entry(source.platform)) or ""if allow_bots_var:extra = {}with contextlib.suppress(Exception):@@ -660,8 +666,8 @@ class GatewayAuthorizationMixin:return Falseentry = _registry_entry(source.platform)- platform_allow_env = getattr(entry, "allowed_users_env", "") or ""- platform_allow_all_var = getattr(entry, "allow_all_env", "") or ""+ platform_allow_env = authz_field(source.platform.value, "allowed_users_env", entry) or ""+ platform_allow_all_var = authz_field(source.platform.value, "allow_all_env", entry) or ""if platform_allow_all_var and _env_truthy(platform_allow_all_var):return True# Adapter-verified role auth (Discord DISCORD_ALLOWED_ROLES). ``is True``: no MagicMock pass.@@ -743,7 +749,7 @@ class GatewayAuthorizationMixin:return "pair"if dm_policy in {"allowlist", "disabled"}:return "ignore"- env_key = (getattr(_registry_entry(platform), "allowed_users_env", "") or ""+ env_key = (authz_field(platform.value, "allowed_users_env", _registry_entry(platform)) or ""if platform in _ALLOWLIST_SUPPRESSES_PAIRING else "")allowlist_keys = [env_key, _GROUP_USER_ENV.get(platform), _GROUP_CHAT_ENV.get(platform), *allowlist_keys]if any(key and _auth_env(key).strip() for key in allowlist_keys):diff --git a/gateway/pairing.py b/gateway/pairing.pyindex d2721678045..d4a7737fe14 100644--- a/gateway/pairing.py+++ b/gateway/pairing.py@@ -72,8 +72,9 @@ def _allowlist_env_for_platform(platform: str) -> Optional[str]:from hermes_cli.plugins import discover_pluginsdiscover_plugins() # idempotentwith contextlib.suppress(Exception):+ from gateway.platform_env import authz_fieldfrom gateway.platform_registry import platform_registry- return platform_registry.get(platform).allowed_users_env or None+ return authz_field(platform, "allowed_users_env", platform_registry.get(platform)) or Nonereturn Nonediff --git a/gateway/platform_env.py b/gateway/platform_env.pyindex e9626a7fe28..04257911d7d 100644--- a/gateway/platform_env.py+++ b/gateway/platform_env.py@@ -211,3 +211,22 @@ def bundled_env_rows(name: str) -> Optional[tuple]:return Nonereturn (tuple(getattr(module, f"{prefix}ENV_OVERRIDES", ()) or ()),tuple(getattr(module, f"{prefix}ENV_ENABLE_CREDENTIALS", ()) or ()))+++def bundled_authz(name: str) -> dict:+ """``AUTHZ`` (allowlist / allow-all / allow-bots / own-policy env names) a bundled platform+ plugin declares in its ``gateway_env.py``, read without the plugin; {} for other names."""+ from gateway.config import Platform+ directory, prefix = _BUNDLED_ENV_SIBLINGS.get(name, (name, ""))+ if directory not in Platform._scan_bundled_plugin_platforms()[0]:+ return {}+ module = _bundled_gateway_env_module(directory)+ return dict(getattr(module, f"{prefix}AUTHZ", None) or {}) if module is not None else {}+++def authz_field(name: str, field: str, entry: Any = None) -> Any:+ """*entry*'s authorization env field, else the bundled plugin's declaration. A user plugin+ overriding a bundled platform, safe mode or a disabled plugin then still gate on the names core+ always enforced for it; never looser than the bundled adapter."""+ value = getattr(entry, field, None) if entry is not None else None+ return value or bundled_authz(str(name or "").strip().lower()).get(field)diff --git a/gateway/run_startup.py b/gateway/run_startup.pyindex d047cecd879..b244ef7167d 100644--- a/gateway/run_startup.py+++ b/gateway/run_startup.py@@ -62,27 +62,17 @@ def recover_left_core_at_gateway_start() -> None:def _own_policy_envs(platform) -> Optional[tuple]:- """``(dm_policy_env, group_policy_env, allow_all_env)`` when the plugin's PlatformEntry declares- ``own_policy_env`` (an enabled platform's lookup imports only that adapter, which the gateway- builds anyway), else None. A bundled platform with NO entry (plugin disabled / failed to load)- fails CLOSED on the ``<NAME>_*`` names (allow-all: the one its manifest declares, e.g. QQ's- ``QQ_ALLOW_ALL_USERS``): its config can still enable it, and enabling the plugin later re-wires- the adapter into the live gateway without re-running the startup check."""+ """``(dm_policy_env, group_policy_env, allow_all_env)`` for a platform that declares+ ``own_policy_env``, else None. The live entry wins; a bundled platform whose entry is absent+ (plugin disabled, safe mode) or lacks the field (a user plugin overriding it) falls back to the+ names its ``gateway_env.AUTHZ`` declares, so the startup refusal never weakens."""+ from gateway.platform_env import authz_fieldfrom gateway.platform_registry import platform_registryentry = platform_registry.get(platform.value)- if entry is None and platform.value in Platform._scan_bundled_plugin_platforms()[0]:- prefix, declared = platform.value.upper(), []- with suppress(Exception):- from utils import fast_safe_load- manifest = Path(__file__).resolve().parent.parent / "plugins" / "platforms" / platform.value / "plugin.yaml"- data = fast_safe_load(manifest.read_text(encoding="utf-8-sig")) or {}- declared = [str(e.get("name", "")) for e in (*data.get("requires_env", ()), *data.get("optional_env", ()))- if isinstance(e, dict) and str(e.get("name", "")).endswith("_ALLOW_ALL_USERS")]- allow_all = declared[0] if len(declared) == 1 else f"{prefix}_ALLOW_ALL_USERS"- return f"{prefix}_DM_POLICY", f"{prefix}_GROUP_POLICY", allow_all- if entry is None or entry.own_policy_env is None:+ own = authz_field(platform.value, "own_policy_env", entry)+ if not own:return None- return (*entry.own_policy_env, entry.allow_all_env)+ return (*own, authz_field(platform.value, "allow_all_env", entry))class GatewayStartupMixin:diff --git a/hermes_cli/profile_channels.py b/hermes_cli/profile_channels.pyindex ac04c4a71a2..e8d74bcdd37 100644--- a/hermes_cli/profile_channels.py+++ b/hermes_cli/profile_channels.py@@ -144,11 +144,21 @@ def _cred_row_envs(row) -> set[str]:def config_env_table_keys(entries: Iterable = ()) -> dict[str, str]:"""``{ENV_KEY: platform_id}`` for the names the gateway env overrides read outright: core's- enable-credential sets plus, for each given registry entry, its ``env_enable_credentials`` and- every ``EnvCred`` row of its ``env_overrides``. With no *entries* it is registry-free (core rows- only), so it stays cheap at import time; raises if the core table cannot be read."""+ enable-credential sets plus, for each given registry entry and every bundled platform plugin+ (its ``gateway_env.py`` read from file, no adapter import), its ``env_enable_credentials`` and+ every ``EnvCred`` row of its ``env_overrides``. Registry-free without *entries*, so it stays+ cheap at import time; raises if the core table cannot be read."""+ from types import SimpleNamespace+from gateway import config_env- from gateway.platform_env import EnvCred+ from gateway.config import Platform+ from gateway.platform_env import _BUNDLED_ENV_SIBLINGS, EnvCred, bundled_env_rows+ entries = list(entries)+ given = {getattr(entry, "name", "") for entry in entries}+ for name in sorted((set(Platform._scan_bundled_plugin_platforms()[0]) | set(_BUNDLED_ENV_SIBLINGS)) - given):+ rows = bundled_env_rows(name)+ if rows:+ entries.append(SimpleNamespace(name=name, env_overrides=rows[0], env_enable_credentials=rows[1]))keys: dict[str, str] = {}for platform, names in config_env._ENV_ENABLE_CREDENTIALS.items():keys.update(dict.fromkeys(names, platform.value))diff --git a/hermes_cli/web_routers/messaging.py b/hermes_cli/web_routers/messaging.pyindex 8a03ceedc3c..d336daa23ee 100644--- a/hermes_cli/web_routers/messaging.py+++ b/hermes_cli/web_routers/messaging.py@@ -944,12 +944,13 @@ def _platform_authz_env_names(platform_id: str) -> tuple[str, str]:with contextlib.suppress(Exception):from gateway.platform_registry import platform_registry+ from gateway.platform_env import authz_field+entry = platform_registry.get(platform_id)- if entry is not None:- if getattr(entry, "trusted_inbound", False) is True:- return "", ""- allowed = getattr(entry, "allowed_users_env", "") or ""- allow_all = getattr(entry, "allow_all_env", "") or ""+ if entry is not None and getattr(entry, "trusted_inbound", False) is True:+ return "", ""+ allowed = authz_field(platform_id, "allowed_users_env", entry) or ""+ allow_all = authz_field(platform_id, "allow_all_env", entry) or ""return allowed, allow_alldiff --git a/plugins/platforms/bluebubbles/adapter.py b/plugins/platforms/bluebubbles/adapter.pyindex a473535df1c..eb6c8987bd6 100644--- a/plugins/platforms/bluebubbles/adapter.py+++ b/plugins/platforms/bluebubbles/adapter.py@@ -710,7 +710,6 @@ def register(ctx) -> None:config_connected_fn=config_connected_extra("server_url", "password"),required_env=["BLUEBUBBLES_SERVER_URL", "BLUEBUBBLES_PASSWORD"], install_hint=_INSTALL_HINT,setup_fn=interactive_setup,- allowed_users_env="BLUEBUBBLES_ALLOWED_USERS", allow_all_env="BLUEBUBBLES_ALLOW_ALL_USERS",cron_deliver_env_var="BLUEBUBBLES_HOME_CHANNEL",standalone_sender_fn=_standalone_send, # out-of-process cron / send_message# 0 = send_message does not pre-chunk: the adapter's send() splits per paragraph and@@ -719,5 +718,5 @@ def register(ctx) -> None:platform_hint=_PLATFORM_HINT,display_tier="low",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/bluebubbles/gateway_env.py b/plugins/platforms/bluebubbles/gateway_env.pyindex 78053a15099..9fc563a2ce9 100644--- a/plugins/platforms/bluebubbles/gateway_env.py+++ b/plugins/platforms/bluebubbles/gateway_env.py@@ -21,3 +21,10 @@ ENV_OVERRIDES = (),home_step(Platform.BLUEBUBBLES, "BLUEBUBBLES_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "BLUEBUBBLES_ALLOWED_USERS",+ "allow_all_env": "BLUEBUBBLES_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/dingtalk/adapter.py b/plugins/platforms/dingtalk/adapter.pyindex 8eb6a5ed11f..d96fa9e984b 100644--- a/plugins/platforms/dingtalk/adapter.py+++ b/plugins/platforms/dingtalk/adapter.py@@ -858,10 +858,9 @@ def register(ctx) -> None:dashboard_env_vars=("DINGTALK_CLIENT_ID", "DINGTALK_CLIENT_SECRET"),ensure_deps_fn=ensure_dingtalk_deps, is_connected=_is_connected, validate_config=_is_connected,required_env=["DINGTALK_CLIENT_ID", "DINGTALK_CLIENT_SECRET"], install_hint="pip install 'dingtalk-stream>=0.20' httpx",- setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, allowed_users_env="DINGTALK_ALLOWED_USERS",- allow_all_env="DINGTALK_ALLOW_ALL_USERS", cron_deliver_env_var="DINGTALK_HOME_CHANNEL",+ setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, cron_deliver_env_var="DINGTALK_HOME_CHANNEL",standalone_sender_fn=_standalone_send, emoji="π³", allow_update_command=True,display_tier="low",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/dingtalk/gateway_env.py b/plugins/platforms/dingtalk/gateway_env.pyindex 6cfdbd80aa8..aa4ee5c660d 100644--- a/plugins/platforms/dingtalk/gateway_env.py+++ b/plugins/platforms/dingtalk/gateway_env.py@@ -11,3 +11,10 @@ ENV_OVERRIDES = (home="DINGTALK_HOME_CHANNEL",),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "DINGTALK_ALLOWED_USERS",+ "allow_all_env": "DINGTALK_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.pyindex 3f02e64e6c0..bf36f07b4dd 100644--- a/plugins/platforms/discord/adapter.py+++ b/plugins/platforms/discord/adapter.py@@ -7393,9 +7393,6 @@ def register(ctx) -> None:# into ``DISCORD_*`` env vars that the adapter reads via ``os.getenv()``. Replaces the hardcoded# block that used to live in ``gateway/config.py``. Hook contract: #24836.apply_yaml_config_fn=_apply_yaml_config,- allowed_users_env="DISCORD_ALLOWED_USERS",- allow_all_env="DISCORD_ALLOW_ALL_USERS",- allow_bots_env="DISCORD_ALLOW_BOTS",cron_deliver_env_var="DISCORD_HOME_CHANNEL",# Out-of-process cron delivery via REST, else ``deliver=discord`` jobs fail with "No live adapter".standalone_sender_fn=_standalone_send,@@ -7407,5 +7404,5 @@ def register(ctx) -> None:# "-# " subtext reads as metadata.display_overrides={"reasoning_style": "subtext"},env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/discord/gateway_env.py b/plugins/platforms/discord/gateway_env.pyindex 9414ab2b664..484e2ac0ddb 100644--- a/plugins/platforms/discord/gateway_env.py+++ b/plugins/platforms/discord/gateway_env.py@@ -10,3 +10,11 @@ ENV_OVERRIDES = (home_step(Platform.DISCORD, "DISCORD_HOME_CHANNEL"),reply_mode_step(Platform.DISCORD, "DISCORD_REPLY_TO_MODE"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "DISCORD_ALLOWED_USERS",+ "allow_all_env": "DISCORD_ALLOW_ALL_USERS",+ "allow_bots_env": "DISCORD_ALLOW_BOTS",+}diff --git a/plugins/platforms/email/adapter.py b/plugins/platforms/email/adapter.pyindex 76ff8c70ae4..d1090b64544 100644--- a/plugins/platforms/email/adapter.py+++ b/plugins/platforms/email/adapter.py@@ -1021,11 +1021,10 @@ def register(ctx) -> None:dashboard_env_vars=("EMAIL_ADDRESS", "EMAIL_PASSWORD", "EMAIL_IMAP_HOST", "EMAIL_SMTP_HOST"),dashboard_required_env=("EMAIL_ADDRESS", "EMAIL_PASSWORD", "EMAIL_IMAP_HOST", "EMAIL_SMTP_HOST"),required_env=["EMAIL_ADDRESS", "EMAIL_PASSWORD", "EMAIL_SMTP_HOST"],- install_hint="Email uses the Python stdlib (smtplib/imaplib) β no extra deps", allowed_users_env="EMAIL_ALLOWED_USERS",- allow_all_env="EMAIL_ALLOW_ALL_USERS", cron_deliver_env_var="EMAIL_HOME_ADDRESS", standalone_sender_fn=_standalone_send,+ install_hint="Email uses the Python stdlib (smtplib/imaplib) β no extra deps", cron_deliver_env_var="EMAIL_HOME_ADDRESS", standalone_sender_fn=_standalone_send,max_message_length=50_000, pii_safe=True, emoji="π§", allow_update_command=True,platform_hint=_PLATFORM_HINT,display_tier="minimal",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/email/gateway_env.py b/plugins/platforms/email/gateway_env.pyindex fe5d82d568a..6671945cae6 100644--- a/plugins/platforms/email/gateway_env.py+++ b/plugins/platforms/email/gateway_env.py@@ -11,3 +11,10 @@ ENV_OVERRIDES = (),home_step(Platform.EMAIL, "EMAIL_HOME_ADDRESS"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "EMAIL_ALLOWED_USERS",+ "allow_all_env": "EMAIL_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/feishu/adapter.py b/plugins/platforms/feishu/adapter.pyindex db270577c12..97a383140fe 100644--- a/plugins/platforms/feishu/adapter.py+++ b/plugins/platforms/feishu/adapter.py@@ -4491,13 +4491,11 @@ def register(ctx) -> None:is_connected=_is_connected, validate_config=_is_connected,required_env=["FEISHU_APP_ID", "FEISHU_APP_SECRET"],install_hint="Run `hermes setup` to install Feishu support.", setup_fn=interactive_setup,- apply_yaml_config_fn=_apply_yaml_config, allowed_users_env="FEISHU_ALLOWED_USERS",- allow_all_env="FEISHU_ALLOW_ALL_USERS", cron_deliver_env_var="FEISHU_HOME_CHANNEL",+ apply_yaml_config_fn=_apply_yaml_config, cron_deliver_env_var="FEISHU_HOME_CHANNEL",standalone_sender_fn=_standalone_send, max_message_length=8000, emoji="πͺ½",allow_update_command=True,- allow_bots_env="FEISHU_ALLOW_BOTS",platform_hint=PLATFORM_HINT,display_tier="medium",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/feishu/gateway_env.py b/plugins/platforms/feishu/gateway_env.pyindex 21a04cce3b6..fefcbdee9e5 100644--- a/plugins/platforms/feishu/gateway_env.py+++ b/plugins/platforms/feishu/gateway_env.py@@ -15,3 +15,11 @@ ENV_OVERRIDES = (home="FEISHU_HOME_CHANNEL",),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "FEISHU_ALLOWED_USERS",+ "allow_all_env": "FEISHU_ALLOW_ALL_USERS",+ "allow_bots_env": "FEISHU_ALLOW_BOTS",+}diff --git a/plugins/platforms/matrix/adapter.py b/plugins/platforms/matrix/adapter.pyindex b1dcefa20e5..981d9be834f 100644--- a/plugins/platforms/matrix/adapter.py+++ b/plugins/platforms/matrix/adapter.py@@ -3266,12 +3266,11 @@ def register(ctx) -> None:**DASHBOARD_CARD,ensure_deps_fn=ensure_matrix_deps, is_connected=_is_connected,required_env=["MATRIX_HOMESERVER", "MATRIX_ACCESS_TOKEN"], install_hint="pip install 'mautrix[encryption]'",- setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, allowed_users_env="MATRIX_ALLOWED_USERS",- allow_all_env="MATRIX_ALLOW_ALL_USERS", cron_deliver_env_var="MATRIX_HOME_ROOM",+ setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, cron_deliver_env_var="MATRIX_HOME_ROOM",standalone_sender_fn=_standalone_send, max_message_length=DEFAULT_MAX_MESSAGE_LENGTH, emoji="π",allow_update_command=True,platform_hint=PLATFORM_HINT,display_tier="medium",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/matrix/gateway_env.py b/plugins/platforms/matrix/gateway_env.pyindex 05f055c927e..883332a2000 100644--- a/plugins/platforms/matrix/gateway_env.py+++ b/plugins/platforms/matrix/gateway_env.py@@ -24,3 +24,10 @@ ENV_OVERRIDES = (),home_step(Platform.MATRIX, "MATRIX_HOME_ROOM"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "MATRIX_ALLOWED_USERS",+ "allow_all_env": "MATRIX_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/mattermost/adapter.py b/plugins/platforms/mattermost/adapter.pyindex 81f2f66a5cb..611c13185f3 100644--- a/plugins/platforms/mattermost/adapter.py+++ b/plugins/platforms/mattermost/adapter.py@@ -736,12 +736,11 @@ def register(ctx) -> None:is_connected=_is_connected, required_env=["MATTERMOST_URL", "MATTERMOST_TOKEN"],install_hint="pip install aiohttp", setup_fn=interactive_setup,apply_yaml_config_fn=_apply_yaml_config, # YAMLβenv bridge (see _YAML_BRIDGE)- allowed_users_env="MATTERMOST_ALLOWED_USERS", allow_all_env="MATTERMOST_ALLOW_ALL_USERS",cron_deliver_env_var="MATTERMOST_HOME_CHANNEL",standalone_sender_fn=_standalone_send, # out-of-process cron; without it `deliver=mattermost` failsmax_message_length=MAX_POST_LENGTH, emoji="π¬", allow_update_command=True,platform_hint=_PLATFORM_HINT,display_tier="medium",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/mattermost/gateway_env.py b/plugins/platforms/mattermost/gateway_env.pyindex 14a92e67489..78512223bd1 100644--- a/plugins/platforms/mattermost/gateway_env.py+++ b/plugins/platforms/mattermost/gateway_env.py@@ -12,3 +12,10 @@ ENV_OVERRIDES = (),home_step(Platform.MATTERMOST, "MATTERMOST_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "MATTERMOST_ALLOWED_USERS",+ "allow_all_env": "MATTERMOST_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/qqbot/gateway_env.py b/plugins/platforms/qqbot/gateway_env.pyindex b2dc3ce71af..6f3b74753a0 100644--- a/plugins/platforms/qqbot/gateway_env.py+++ b/plugins/platforms/qqbot/gateway_env.py@@ -36,3 +36,11 @@ ENV_OVERRIDES = (then=_home,),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "QQ_ALLOWED_USERS",+ "allow_all_env": "QQ_ALLOW_ALL_USERS",+ "own_policy_env": ("", ""),+}diff --git a/plugins/platforms/qqbot/register.py b/plugins/platforms/qqbot/register.pyindex 7399a625067..ba93d28c6f2 100644--- a/plugins/platforms/qqbot/register.py+++ b/plugins/platforms/qqbot/register.py@@ -147,14 +147,11 @@ def register(ctx) -> None:required_env=["QQ_APP_ID", "QQ_CLIENT_SECRET"],install_hint="QQBot: aiohttp/httpx missing or QQ_APP_ID/QQ_CLIENT_SECRET not configured",setup_fn=setup_qqbot,- allowed_users_env="QQ_ALLOWED_USERS",- allow_all_env="QQ_ALLOW_ALL_USERS",emoji="π§",cron_deliver_env_var="QQBOT_HOME_CHANNEL",standalone_sender_fn=standalone_send,# QQ's dm/group policy is YAML-only (no env var); QQ_ALLOW_ALL_USERS is still the opt-in.- own_policy_env=("", ""),platform_hint=_PLATFORM_HINT,env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/signal/gateway_env.py b/plugins/platforms/signal/gateway_env.pyindex f11f1476b29..bba7dd89725 100644--- a/plugins/platforms/signal/gateway_env.py+++ b/plugins/platforms/signal/gateway_env.py@@ -15,3 +15,10 @@ ENV_OVERRIDES = (),home_step(Platform.SIGNAL, "SIGNAL_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "SIGNAL_ALLOWED_USERS",+ "allow_all_env": "SIGNAL_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/signal/register.py b/plugins/platforms/signal/register.pyindex c050b89017a..208008ec208 100644--- a/plugins/platforms/signal/register.py+++ b/plugins/platforms/signal/register.py@@ -65,7 +65,6 @@ def register(ctx) -> None:is_connected=_is_connected, required_env=["SIGNAL_HTTP_URL", "SIGNAL_ACCOUNT"],config_connected_fn=config_connected_extra("http_url"),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",# Out-of-process sends speak raw JSON-RPC and bypass SignalAdapter.send()'s chunking, so# send_message splits at the adapter's limit through this field.@@ -74,5 +73,5 @@ def register(ctx) -> None:platform_hint=_PLATFORM_HINT,display_tier="low",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.pyindex 4d4127dae08..2cbfc819207 100644--- a/plugins/platforms/slack/adapter.py+++ b/plugins/platforms/slack/adapter.py@@ -6932,8 +6932,6 @@ def register(ctx) -> None:# env vars that the adapter reads via os.getenv(). Replaces the hardcoded block in# gateway/config.py. Hook contract: #24849.apply_yaml_config_fn=_apply_yaml_config,- allowed_users_env="SLACK_ALLOWED_USERS",- allow_all_env="SLACK_ALLOW_ALL_USERS",cron_deliver_env_var="SLACK_HOME_CHANNEL",# Out-of-process cron delivery; without it deliver=slack cron jobs fail with# "No live adapter" when cron runs apart from the gateway.@@ -6942,11 +6940,10 @@ def register(ctx) -> None:max_message_length=39000,emoji="πΌ",allow_update_command=True,- allow_bots_env="SLACK_ALLOW_BOTS",platform_hint=PLATFORM_HINT,display_tier="medium",# Bolt posts cannot be edited like CLI; "new"/"all" spam permanent lines.display_overrides={"tool_progress": "off", "long_running_notifications": False, "busy_ack_detail": False},env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/slack/gateway_env.py b/plugins/platforms/slack/gateway_env.pyindex ff3906ef9b9..31b3b265a9e 100644--- a/plugins/platforms/slack/gateway_env.py+++ b/plugins/platforms/slack/gateway_env.py@@ -21,3 +21,11 @@ def _home(config: GatewayConfig) -> None:ENV_ENABLE_CREDENTIALS = ("SLACK_BOT_TOKEN",)ENV_OVERRIDES = (EnvCred(Platform.SLACK, ("SLACK_BOT_TOKEN",), token="SLACK_BOT_TOKEN"), _home)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "SLACK_ALLOWED_USERS",+ "allow_all_env": "SLACK_ALLOW_ALL_USERS",+ "allow_bots_env": "SLACK_ALLOW_BOTS",+}diff --git a/plugins/platforms/sms/gateway_env.py b/plugins/platforms/sms/gateway_env.pyindex d0c46226871..4e51a9788be 100644--- a/plugins/platforms/sms/gateway_env.py+++ b/plugins/platforms/sms/gateway_env.py@@ -13,3 +13,10 @@ ENV_OVERRIDES = (EnvCred(Platform.SMS, ("TWILIO_ACCOUNT_SID",), then=_api_key),home_step(Platform.SMS, "SMS_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "SMS_ALLOWED_USERS",+ "allow_all_env": "SMS_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.pyindex 85412fbcb6f..b11c2bdb65b 100644--- a/plugins/platforms/telegram/adapter.py+++ b/plugins/platforms/telegram/adapter.py@@ -7315,15 +7315,13 @@ def register(ctx) -> None:name="telegram", label="Telegram", adapter_factory=_build_adapter, check_fn=telegram_deps_present,**DASHBOARD_CARD,ensure_deps_fn=check_telegram_requirements, is_connected=_is_connected, required_env=["TELEGRAM_BOT_TOKEN"],- install_hint=t("platform.telegram.install_hint"), setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config,- allowed_users_env="TELEGRAM_ALLOWED_USERS", allow_all_env="TELEGRAM_ALLOW_ALL_USERS", cron_deliver_env_var="TELEGRAM_HOME_CHANNEL",+ install_hint=t("platform.telegram.install_hint"), setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, cron_deliver_env_var="TELEGRAM_HOME_CHANNEL",standalone_sender_fn=_standalone_send, max_message_length=4096, emoji="βοΈ", allow_update_command=True,- allow_bots_env="TELEGRAM_ALLOW_BOTS",platform_hint=PLATFORM_HINT,display_tier="high",# Mobile inbox: quiet tool_progress / busy-ack, but keep interim commentary and heartbeats.display_overrides={"tool_progress": "off", "busy_ack_detail": False},target_ref_syntax_fn=parse_send_target,env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/telegram/gateway_env.py b/plugins/platforms/telegram/gateway_env.pyindex f8d84b6b894..0ce876ad408 100644--- a/plugins/platforms/telegram/gateway_env.py+++ b/plugins/platforms/telegram/gateway_env.py@@ -17,3 +17,11 @@ ENV_OVERRIDES = (_fallback_ips,home_step(Platform.TELEGRAM, "TELEGRAM_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "TELEGRAM_ALLOWED_USERS",+ "allow_all_env": "TELEGRAM_ALLOW_ALL_USERS",+ "allow_bots_env": "TELEGRAM_ALLOW_BOTS",+}diff --git a/plugins/platforms/wecom/adapter.py b/plugins/platforms/wecom/adapter.pyindex e3e071aa31c..c8237f9b398 100644--- a/plugins/platforms/wecom/adapter.py+++ b/plugins/platforms/wecom/adapter.py@@ -858,15 +858,14 @@ def register(ctx) -> None:dashboard_env_vars=("WECOM_BOT_ID", "WECOM_SECRET"),dashboard_required_env=("WECOM_BOT_ID",),is_connected=_is_connected, validate_config=_is_connected, required_env=["WECOM_BOT_ID", "WECOM_SECRET"],- setup_fn=interactive_setup, allowed_users_env="WECOM_ALLOWED_USERS", allow_all_env="WECOM_ALLOW_ALL_USERS",+ setup_fn=interactive_setup,cron_deliver_env_var="WECOM_HOME_CHANNEL", standalone_sender_fn=_standalone_send, max_message_length=4000, **common,- own_policy_env=("WECOM_DM_POLICY", "WECOM_GROUP_POLICY"),platform_hint=_WECOM_PLATFORM_HINT,display_tier="low",# Non-editable, but its native "stream" msgtype gives a typing animation + cumulative updates.display_overrides={"streaming": True},env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)from plugins.platforms.wecom.callback_adapter import check_wecom_callback_requirements, ensure_wecom_callback_requirementsctx.register_platform(@@ -883,9 +882,8 @@ def register(ctx) -> None:),check_fn=check_wecom_callback_requirements, ensure_deps_fn=ensure_wecom_callback_requirements,is_connected=_callback_is_connected, validate_config=_callback_is_connected,- required_env=["WECOM_CALLBACK_CORP_ID", "WECOM_CALLBACK_CORP_SECRET"],- allowed_users_env="WECOM_CALLBACK_ALLOWED_USERS", allow_all_env="WECOM_CALLBACK_ALLOW_ALL_USERS", **common,+ required_env=["WECOM_CALLBACK_CORP_ID", "WECOM_CALLBACK_CORP_SECRET"], **common,display_tier="low",env_overrides=gateway_env.CALLBACK_ENV_OVERRIDES,- env_enable_credentials=gateway_env.CALLBACK_ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.CALLBACK_ENV_ENABLE_CREDENTIALS, **gateway_env.CALLBACK_AUTHZ,)diff --git a/plugins/platforms/wecom/gateway_env.py b/plugins/platforms/wecom/gateway_env.pyindex cc59112c5ca..3d9dfea900b 100644--- a/plugins/platforms/wecom/gateway_env.py+++ b/plugins/platforms/wecom/gateway_env.py@@ -26,3 +26,15 @@ CALLBACK_ENV_OVERRIDES = (),),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "WECOM_ALLOWED_USERS",+ "allow_all_env": "WECOM_ALLOW_ALL_USERS",+ "own_policy_env": ("WECOM_DM_POLICY", "WECOM_GROUP_POLICY"),+}+CALLBACK_AUTHZ = {+ "allowed_users_env": "WECOM_CALLBACK_ALLOWED_USERS",+ "allow_all_env": "WECOM_CALLBACK_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/weixin/adapter.py b/plugins/platforms/weixin/adapter.pyindex 3ebf6e79ed2..7cb0cba8b62 100644--- a/plugins/platforms/weixin/adapter.py+++ b/plugins/platforms/weixin/adapter.py@@ -1415,14 +1415,13 @@ def register(ctx) -> None:dashboard_env_vars=("WEIXIN_ACCOUNT_ID", "WEIXIN_TOKEN", "WEIXIN_BASE_URL"),is_connected=_is_connected, required_env=["WEIXIN_ACCOUNT_ID", "WEIXIN_TOKEN"], install_hint=_INSTALL_HINT,config_connected_fn=_config_connected,- setup_fn=interactive_setup, allowed_users_env="WEIXIN_ALLOWED_USERS", allow_all_env="WEIXIN_ALLOW_ALL_USERS",+ setup_fn=interactive_setup,cron_deliver_env_var="WEIXIN_HOME_CHANNEL",# Out-of-process send_message/cron; the adapter's own send() chunks (MAX_MESSAGE_LENGTH), so# max_message_length stays 0: send_message hands the full text + all media to one native send.standalone_sender_fn=_standalone_send, max_message_length=0, emoji="π¬", allow_update_command=True,- own_policy_env=("WEIXIN_DM_POLICY", "WEIXIN_GROUP_POLICY"),platform_hint=_PLATFORM_HINT,display_tier="low",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/weixin/gateway_env.py b/plugins/platforms/weixin/gateway_env.pyindex e146e7b0ded..28d69044aa6 100644--- a/plugins/platforms/weixin/gateway_env.py+++ b/plugins/platforms/weixin/gateway_env.py@@ -17,3 +17,11 @@ ENV_OVERRIDES = (home="WEIXIN_HOME_CHANNEL", home_strip=True,),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "WEIXIN_ALLOWED_USERS",+ "allow_all_env": "WEIXIN_ALLOW_ALL_USERS",+ "own_policy_env": ("WEIXIN_DM_POLICY", "WEIXIN_GROUP_POLICY"),+}diff --git a/plugins/platforms/whatsapp/adapter.py b/plugins/platforms/whatsapp/adapter.pyindex 85aeef7c2be..2279c8ef268 100644--- a/plugins/platforms/whatsapp/adapter.py+++ b/plugins/platforms/whatsapp/adapter.py@@ -1262,13 +1262,11 @@ def register(ctx) -> None:dashboard_required_env=(),is_connected=_is_connected, required_env=["WHATSAPP_ENABLED"],install_hint="WhatsApp requires a Node.js bridge β see the WhatsApp messaging docs",- setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, allowed_users_env="WHATSAPP_ALLOWED_USERS",- allow_all_env="WHATSAPP_ALLOW_ALL_USERS", cron_deliver_env_var="WHATSAPP_HOME_CHANNEL",+ setup_fn=interactive_setup, apply_yaml_config_fn=_apply_yaml_config, cron_deliver_env_var="WHATSAPP_HOME_CHANNEL",standalone_sender_fn=_standalone_send, max_message_length=4096, emoji="π¬", allow_update_command=True,- own_policy_env=("WHATSAPP_DM_POLICY", "WHATSAPP_GROUP_POLICY"),platform_hint=_PLATFORM_HINT,# Baileys bridge supports /edit.display_tier="medium",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/whatsapp/gateway_env.py b/plugins/platforms/whatsapp/gateway_env.pyindex 4c6439872b4..666ad8d9d0b 100644--- a/plugins/platforms/whatsapp/gateway_env.py+++ b/plugins/platforms/whatsapp/gateway_env.py@@ -20,3 +20,11 @@ def _enabled_flag(config: GatewayConfig) -> None:ENV_ENABLE_CREDENTIALS = ("WHATSAPP_ENABLED",)ENV_OVERRIDES = (_enabled_flag, home_step(Platform.WHATSAPP, "WHATSAPP_HOME_CHANNEL"))++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "WHATSAPP_ALLOWED_USERS",+ "allow_all_env": "WHATSAPP_ALLOW_ALL_USERS",+ "own_policy_env": ("WHATSAPP_DM_POLICY", "WHATSAPP_GROUP_POLICY"),+}diff --git a/plugins/platforms/whatsapp_cloud/adapter.py b/plugins/platforms/whatsapp_cloud/adapter.pyindex 70e7c0d4924..ce81898f130 100644--- a/plugins/platforms/whatsapp_cloud/adapter.py+++ b/plugins/platforms/whatsapp_cloud/adapter.py@@ -1114,11 +1114,10 @@ def register(ctx) -> None:config_connected_fn=config_connected_extra("phone_number_id", "access_token"),required_env=["WHATSAPP_CLOUD_PHONE_NUMBER_ID", "WHATSAPP_CLOUD_ACCESS_TOKEN"],install_hint="aiohttp/httpx missing β reinstall hermes-agent", setup_fn=_interactive_setup,- allowed_users_env="WHATSAPP_CLOUD_ALLOWED_USERS", allow_all_env="WHATSAPP_CLOUD_ALLOW_ALL_USERS",cron_deliver_env_var="WHATSAPP_CLOUD_HOME_CHANNEL", emoji="π±", allow_update_command=False,platform_hint=_PLATFORM_HINT,# Adapter lacks edit_message; promote once it lands.display_tier="low",env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/plugins/platforms/whatsapp_cloud/gateway_env.py b/plugins/platforms/whatsapp_cloud/gateway_env.pyindex 11be6c75572..7e58d074974 100644--- a/plugins/platforms/whatsapp_cloud/gateway_env.py+++ b/plugins/platforms/whatsapp_cloud/gateway_env.py@@ -18,3 +18,10 @@ ENV_OVERRIDES = (),home_step(Platform.WHATSAPP_CLOUD, "WHATSAPP_CLOUD_HOME_CHANNEL"),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "WHATSAPP_CLOUD_ALLOWED_USERS",+ "allow_all_env": "WHATSAPP_CLOUD_ALLOW_ALL_USERS",+}diff --git a/plugins/platforms/yuanbao/gateway_env.py b/plugins/platforms/yuanbao/gateway_env.pyindex 6ef7b167906..9eccc15ad99 100644--- a/plugins/platforms/yuanbao/gateway_env.py+++ b/plugins/platforms/yuanbao/gateway_env.py@@ -18,3 +18,11 @@ ENV_OVERRIDES = (home="YUANBAO_HOME_CHANNEL",),)++# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the+# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.+AUTHZ = {+ "allowed_users_env": "YUANBAO_ALLOWED_USERS",+ "allow_all_env": "YUANBAO_ALLOW_ALL_USERS",+ "own_policy_env": ("YUANBAO_DM_POLICY", "YUANBAO_GROUP_POLICY"),+}diff --git a/plugins/platforms/yuanbao/register.py b/plugins/platforms/yuanbao/register.pyindex 614a9d1292d..2565a7c97cc 100644--- a/plugins/platforms/yuanbao/register.py+++ b/plugins/platforms/yuanbao/register.py@@ -103,11 +103,9 @@ def register(ctx) -> None:check_fn=check_yuanbao_requirements, is_connected=_is_connected,config_connected_fn=config_connected_extra("app_id", "app_secret"),required_env=["YUANBAO_APP_ID", "YUANBAO_APP_SECRET"], install_hint=_INSTALL_HINT,- setup_fn=interactive_setup, allowed_users_env="YUANBAO_ALLOWED_USERS",- allow_all_env="YUANBAO_ALLOW_ALL_USERS", cron_deliver_env_var="YUANBAO_HOME_CHANNEL",+ setup_fn=interactive_setup, cron_deliver_env_var="YUANBAO_HOME_CHANNEL",standalone_sender_fn=_standalone_send, emoji="π", allow_update_command=False,- own_policy_env=("YUANBAO_DM_POLICY", "YUANBAO_GROUP_POLICY"),platform_hint=_PLATFORM_HINT,env_overrides=gateway_env.ENV_OVERRIDES,- env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS,+ env_enable_credentials=gateway_env.ENV_ENABLE_CREDENTIALS, **gateway_env.AUTHZ,)diff --git a/tests/gateway/test_platform_bundled_authz_fallback.py b/tests/gateway/test_platform_bundled_authz_fallback.pynew file mode 100644index 00000000000..08ccf0dcb90--- /dev/null+++ b/tests/gateway/test_platform_bundled_authz_fallback.py@@ -0,0 +1,54 @@+"""Authorization env names of bundled platforms survive a registry entry that lacks them.++They live in each plugin's ``gateway_env.AUTHZ`` (read by core straight from the file) and reach the+registry through ``register()``. A user plugin overriding a bundled platform, safe mode or a+disabled plugin must still gate on them: core's own tables always did."""++import dataclasses++import pytest++from gateway.config import Platform+from gateway.platform_env import _BUNDLED_ENV_SIBLINGS, bundled_authz++_FIELDS = ("allowed_users_env", "allow_all_env", "allow_bots_env", "own_policy_env")+++def _bundled_with_authz():+ names = set(Platform._scan_bundled_plugin_platforms()[0]) | set(_BUNDLED_ENV_SIBLINGS)+ return sorted(name for name in names if bundled_authz(name))+++def test_registered_entries_carry_exactly_the_file_declaration():+ from gateway.platform_registry import platform_registry+ from hermes_cli.plugins import discover_plugins++ discover_plugins()+ names = _bundled_with_authz()+ assert {"telegram", "weixin", "wecom_callback", "qqbot"} <= set(names)+ for name in names:+ entry = platform_registry.get(name)+ declared = bundled_authz(name)+ assert entry is not None, name+ assert {f: getattr(entry, f) for f in declared} == declared, name++[email protected]("name", ["telegram", "weixin"])+def test_override_without_fields_still_gates_on_bundled_names(name, monkeypatch):+ from gateway import pairing, run_startup+ from gateway.platform_registry import platform_registry+ from hermes_cli.plugins import discover_plugins++ discover_plugins()+ bare = dataclasses.replace(+ platform_registry.get(name), allowed_users_env="", allow_all_env="", allow_bots_env="",+ own_policy_env=None)+ monkeypatch.setattr(platform_registry, "get", lambda value: bare if value == name else None)++ declared = bundled_authz(name)+ assert pairing._allowlist_env_for_platform(name) == declared["allowed_users_env"]+ own = run_startup._own_policy_envs(Platform(name))+ if "own_policy_env" in declared:+ assert own == (*declared["own_policy_env"], declared["allow_all_env"])+ else:+ assert own is Nonediff --git a/tools/environments/local_env_policy.py b/tools/environments/local_env_policy.pyindex 3dfb9988171..64e12c38b68 100644--- a/tools/environments/local_env_policy.py+++ b/tools/environments/local_env_policy.py@@ -110,12 +110,10 @@ def _build_adapter_secret_env() -> frozenset:CORE_DECLARED_ENV_NAMES, OPTIONAL_ENV_VARS, PLATFORM_SECRET_ENV_SUFFIXES, platform_manifest_secret_envs)from hermes_cli.profile_channels import config_env_table_keys# Read in code only, declared nowhere else: the Microsoft Graph app secret and webhook- # clientState, the QQ bot's speech-to-text key, and secrets only a plugin's ``env_overrides``- # reads (Feishu webhook keys, Yuanbao's legacy app key). Those rows live on the adapter's- # PlatformEntry, which this import-time policy cannot load without importing every adapter;- # tests/gateway/test_platform_env_overrides.py pins that every such secret is listed here.- names: set[str] = {"MSGRAPH_CLIENT_SECRET", "MSGRAPH_WEBHOOK_CLIENT_STATE", "QQ_STT_API_KEY",- "FEISHU_ENCRYPT_KEY", "FEISHU_VERIFICATION_TOKEN", "YUANBAO_APP_KEY"}+ # clientState and the QQ bot's speech-to-text key. Secrets only a plugin's ``env_overrides``+ # reads (Feishu webhook keys, Yuanbao's legacy app key) come from config_env_table_keys(),+ # which reads every bundled plugin's gateway_env.py without importing its adapter.+ names: set[str] = {"MSGRAPH_CLIENT_SECRET", "MSGRAPH_WEBHOOK_CLIENT_STATE", "QQ_STT_API_KEY"}names.update(name.upper() for name, meta in OPTIONAL_ENV_VARS.items()if name in CORE_DECLARED_ENV_NAMESand meta.get("category") == "messaging" and meta.get("password"))