diff --git a/gateway/platforms/qqbot/adapter.py b/gateway/platforms/qqbot/adapter.py index 5447d99d99609..81a500ec249ab 100644 --- a/gateway/platforms/qqbot/adapter.py +++ b/gateway/platforms/qqbot/adapter.py @@ -2672,6 +2672,7 @@ class QQAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Send a button-based exec-approval prompt for a dangerous command. @@ -2682,6 +2683,7 @@ class QQAdapter(BasePlatformAdapter): adapter's interaction callback (:meth:`_default_interaction_dispatch`). """ del metadata # QQ doesn't have thread_id / DM targeting overrides. + del allow_session # QQ's 3-button keyboard has no session tier (once/always/deny). if smart_denied: description += " Owner override applies to this one operation only." diff --git a/gateway/platforms/whatsapp_cloud.py b/gateway/platforms/whatsapp_cloud.py index b284e23dc47a6..2387280923468 100644 --- a/gateway/platforms/whatsapp_cloud.py +++ b/gateway/platforms/whatsapp_cloud.py @@ -820,6 +820,7 @@ class WhatsAppCloudAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Render a dangerous-command approval prompt with native buttons. @@ -832,7 +833,7 @@ class WhatsAppCloudAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter): if self._http_client is None: return SendResult(success=False, error="Not connected") - del allow_permanent # This adapter already offers one-shot Approve / Deny only. + del allow_permanent, allow_session # This adapter already offers one-shot Approve / Deny only. # WhatsApp body caps at 1024 chars; reserve room for the # framing prose around the command. cmd = command or "" diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.py index c31b928ad8473..f843565cc771a 100644 --- a/plugins/platforms/discord/adapter.py +++ b/plugins/platforms/discord/adapter.py @@ -6454,6 +6454,7 @@ class DiscordAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[dict] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """ @@ -6529,6 +6530,7 @@ class DiscordAdapter(BasePlatformAdapter): require_admin=require_admin, admin_user_ids=admin_user_ids, allow_permanent=allow_permanent, + allow_session=allow_session, smart_denied=smart_denied, ) @@ -7793,6 +7795,7 @@ def _define_discord_view_classes() -> None: require_admin: bool = False, admin_user_ids: Optional[set] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ): super().__init__(timeout=_read_discord_prompt_timeout()) @@ -7807,7 +7810,7 @@ def _define_discord_view_classes() -> None: str(a).strip() for a in (admin_user_ids or set()) if str(a).strip() } self.resolved = False - if smart_denied: + if smart_denied or not allow_session: self.remove_item(self.allow_session) self.remove_item(self.allow_always) elif not allow_permanent: diff --git a/plugins/platforms/feishu/adapter.py b/plugins/platforms/feishu/adapter.py index cd2007a96d652..519c9afa413cb 100644 --- a/plugins/platforms/feishu/adapter.py +++ b/plugins/platforms/feishu/adapter.py @@ -2004,6 +2004,7 @@ class FeishuAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Send an interactive card with approval buttons. @@ -2028,7 +2029,7 @@ class FeishuAdapter(BasePlatformAdapter): } actions = [_btn("✅ Allow Once", "approve_once", "primary")] - if not smart_denied: + if not smart_denied and allow_session: actions.append(_btn("✅ Session", "approve_session")) if allow_permanent: actions.append(_btn("✅ Always", "approve_always")) diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 02b7363d93c9a..bde89f4ad1afd 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -3802,6 +3802,7 @@ class SlackAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Send a Block Kit approval prompt with interactive buttons. @@ -3838,7 +3839,7 @@ class SlackAdapter(BasePlatformAdapter): "value": session_key, }, ] - if not smart_denied: + if not smart_denied and allow_session: actions.append({ "type": "button", "text": {"type": "plain_text", "text": "Allow Session"}, diff --git a/plugins/platforms/teams/adapter.py b/plugins/platforms/teams/adapter.py index 1c02917f6ef05..e870dfb8ffb79 100644 --- a/plugins/platforms/teams/adapter.py +++ b/plugins/platforms/teams/adapter.py @@ -1099,6 +1099,7 @@ class TeamsAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Send an Adaptive Card approval prompt with Allow/Deny buttons.""" @@ -1117,7 +1118,7 @@ class TeamsAdapter(BasePlatformAdapter): title="Allow Once", verb="hermes_approve", data={**btn_data_base, "hermes_action": "approve_once"}, style="positive", )] - if not smart_denied: + if not smart_denied and allow_session: actions.append(ExecuteAction( title="Allow Session", verb="hermes_approve", data={**btn_data_base, "hermes_action": "approve_session"}, diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py index 91366ff87b547..09f97598e2647 100644 --- a/plugins/platforms/telegram/adapter.py +++ b/plugins/platforms/telegram/adapter.py @@ -5021,6 +5021,7 @@ class TelegramAdapter(BasePlatformAdapter): description: str = "dangerous command", metadata: Optional[Dict[str, Any]] = None, allow_permanent: bool = True, + allow_session: bool = True, smart_denied: bool = False, ) -> SendResult: """Send an inline-keyboard approval prompt with interactive buttons. @@ -5055,7 +5056,7 @@ class TelegramAdapter(BasePlatformAdapter): buttons = [ InlineKeyboardButton("✅ Allow Once", callback_data=f"ea:once:{approval_id}") ] - if not smart_denied: + if not smart_denied and allow_session: buttons.append( InlineKeyboardButton("✅ Session", callback_data=f"ea:session:{approval_id}") )