feat(plugins): native platform handler registration for every gateway platform - #59217
Merged
Conversation
…ister_telegram_handler Mirrors the Slack precedent (register_slack_action_handler): plugins queue a factory at register() time; the Telegram adapter invokes each factory with (application, adapter) at connect() time, before the core handlers register, so pattern-scoped plugin handlers take precedence for their own updates while everything else falls through unchanged. Factories are isolated — a raising plugin cannot prevent Telegram from connecting. Unblocks standalone plugins that need PTB update types the core adapter doesn't route (Telegram Business API secretary bots, custom callback prefixes, chat-member events) without touching core files.
…ry gateway platform ctx.register_platform_handler(platform, factory) — the generic surface for plugins to wire native handlers into any platform adapter at connect() time. Factories receive (native, adapter): the platform's client/app object (PTB Application, discord.py Bot, slack_bolt AsyncApp, Teams App, DingTalkStreamClient, aiohttp web.Application) or None for adapters with no separate native object. - BasePlatformAdapter._wire_plugin_handlers(native): shared, isolated invocation helper — a raising plugin cannot block a platform connect. - All 27 connectable adapters call it: telegram/slack/teams/line/ api_server/msgraph_webhook wire before their dispatch tables freeze; the rest hook at connect success. - register_telegram_handler and get_telegram_handler_factories retained as thin back-compat aliases over the telegram bucket. - Source-invariant test guarantees every adapter with connect() keeps calling the hook.
…t adapters Platforms added to main after the original branch was cut; keeps the source invariant (every connectable adapter calls _wire_plugin_handlers) true, and adds qqbot to the invariant test's gateway list.
teknium1
force-pushed
the
feat/generic-platform-handlers
branch
from
August 27, 2026 14:20
11647ec to
2d3afd7
Compare
Contributor
૮ >ﻌ< ა ci reviewran on 2d3afd7 — feat(plugins): wire plugin platform handlers into a2a, buzz,
|
This was referenced Aug 27, 2026
Closed
vKongv
added a commit
to pebble-tech/hermes-agent
that referenced
this pull request
Sep 6, 2026
Callback registration already landed in NousResearch#59217. Keep the outbound send() reply_markup surface so plugins do not bypass adapter policy.
cursor Bot
pushed a commit
to pebble-tech/hermes-agent
that referenced
this pull request
Sep 7, 2026
…h#59217 Callback registration landed upstream in NousResearch#59217; feat/telegram-plugin-callback-handlers now only carries send() reply_markup. The old test_telegram_plugin_callback_handlers file is not on the rebased feature branch, so sync focused-tests failed with 'file or directory not found'. Co-authored-by: Kong Ka Weng <mgongzai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every gateway platform now supports plugin-registered native handlers via
ctx.register_platform_handler(platform, factory)— the generalization of #59159's Telegram-only hook to all 27 connectable adapters.Stacks on #59159 (includes its commit); this PR's own change is the generic surface + fleet-wide wiring.
How it works
(factory, plugin_name)per platform; the platform's adapter invokes factories atconnect()time with(native, adapter).nativeis the platform's real client object where one exists — PTBApplication, discord.pycommands.Bot, slack_boltAsyncApp, TeamsApp,DingTalkStreamClient, lark client, aiohttpweb.Application(line / api_server / msgraph_webhook, wired before the router freezes) — andNonefor adapters with no separate native object (signal, whatsapp bridge, irc, email, sms, ntfy, wecom, weixin, bluebubbles, yuanbao, ...), where the adapter handle is the surface.BasePlatformAdapter._wire_plugin_handlers(): a raising factory is logged and the platform still connects.register_telegram_handler/get_telegram_handler_factoriesretained as thin back-compat aliases.What this enables (as plugins, zero core edits)
Discord reaction/member-event bots, Slack event/shortcut/command listeners beyond Block Kit, Matrix custom event types, Teams card flows, custom webhook routes on the aiohttp platforms, Telegram Business secretary bots (https://github.com/NousResearch/hermes-telegram-business), and any platform-native interactivity a plugin wants to own under its own scoped namespace.
Changes
hermes_cli/plugins.py:register_platform_handler()+ keyed factory store +get_platform_handler_factories(); telegram methods become aliases.gateway/platforms/base.py: shared_wire_plugin_handlers(native)helper.connect().tests/gateway/test_platform_plugin_handlers.py(renamed from the telegram-only file): 16 tests — validation, normalization, per-platform scoping, alias, copy semantics, force-clear, invocation args, fault isolation, native=None path, plus a source invariant asserting every connectable adapter calls the hook.Validation
tests/gateway/+tests/hermes_cli/test_plugins.py(443 files)Infographic