Platform setup_fn code (bundled QQ Bot, Weixin, Signal and the community QQ
plugin) imported _print_setup_header, _confirm_reconfigure,
_offer_home_channel, _save_env_values and _prompt_csv from
hermes_cli.gateway_setup_wizard. They are now print_setup_header,
confirm_reconfigure, offer_home_channel, save_env_values and prompt_csv; every
internal caller moves (no aliases). Bundled QQ setup drops the private _gw()
facade for hermes_cli.setup / cli_output / config primitives.
Every bundled adapter built its client from three private pieces:
gateway.platforms.base._ssrf_redirect_guard, tools.url_safety's
create_ssrf_safe_async_client and _http_client_limits.platform_httpx_limits.
The redirect guard becomes public (ssrf_redirect_guard; callers renamed, no
alias) and gateway.platforms.helpers.platform_http_client(**kw) composes all
three, with the guard ahead of any caller response hooks. QQ Bot and WeCom
move to it.
Two authz behaviours were hard-coded on Platform.QQBOT/TELEGRAM/... in
gateway/authz_mixin.py (_GROUP_CHAT_ENV, _ALLOWLIST_SUPPRESSES_PAIRING), so a
plugin-registered platform could not get them and removing the bundled QQ
adapter would silently drop QQ_GROUP_ALLOWED_USERS gating and change pairing.
PlatformEntry gains group_allowed_chats_env and allowlist_suppresses_pairing;
authz_mixin reads them through authz_field (live entry, else the bundled
gateway_env.AUTHZ). Every bundled platform that was in the old tables declares
them in its AUTHZ, so behaviour is unchanged.
Independent review found the allowlist, the open-policy startup refusal, the pairing-noise
rule and `hermes pairing revoke` reading only the live PlatformEntry: a user plugin overriding a
bundled platform without the fields, safe mode or a disabled plugin then gated on nothing
(looser than main, whose core tables always applied).
Each bundled plugin now declares them once as `gateway_env.AUTHZ` (passed to register() with
**), and `gateway.platform_env.authz_field` answers from the entry, else from that file (read
without the plugin package). Probed main vs head: 208/208 authz decisions identical in normal,
safe-mode, plugin-disabled and user-override modes; revoke drops the user in all four.
The terminal secret blocklist and config_env_table_keys() read the same files, which removes the
three hand-listed plugin secrets in local_env_policy.
Move the per-platform `_Cred` rows of `_ENV_STEPS`, their helper steps and the
`_ENV_ENABLE_CREDENTIALS` rows for every plugin-backed platform (telegram, discord,
slack, whatsapp, whatsapp_cloud, signal, mattermost, matrix, email, sms, dingtalk,
feishu, wecom, wecom_callback, weixin, bluebubbles, qqbot, yuanbao) out of
gateway/config_env.py into each plugin's `gateway_env.py`, attached via two new
PlatformEntry fields: `env_overrides` (ordered steps) and `env_enable_credentials`.
`gateway/platform_env.py` holds the declarative `EnvCred` row and shared parsers.
`_apply_env_overrides` runs the rows of entries with activation evidence (same gate
as the plugin enable pass, computed once). Core-only rows (api_server, webhook,
msgraph_webhook, relay) stay in config_env. profile_channels reads the rows from
registry entries; the import-time terminal secret blocklist lists the three secrets
only those rows read, pinned by a new invariant test.
Resulting GatewayConfig and explicit-disable warnings are identical (differential
oracle, 100 fixtures); only env-created insertion order of api_server/webhook/
msgraph_webhook relative to plugin platforms changes.
The Channels page catalog (_PLATFORM_OVERRIDES) and the PUT env-value validators
(_ENV_VALUE_RULES) duplicated per-platform data the bundled platform plugins can
declare. Each plugin now declares its card on its PlatformEntry (new dashboard
block: dashboard_label, dashboard_description, docs_url, dashboard_env_vars,
dashboard_required_env, env_value_rules); core keeps static rows only for the
core-only platforms (api_server, webhook, msgraph_webhook, relay).
Telegram/Slack validators move into their plugins. The PUT route resolves the
rules right after _require_platform (catalog build already materialized every
entry, so nothing extra is imported) and before entering _profile_scope, where
the registry's profile overlay may not hold the entry.
Adapters over their size cap (discord, feishu, matrix, slack, telegram) keep the
card in a sibling dashboard_card.py, imported relatively so no second canonical
copy of the adapter module loads; surplus blank lines offset the two added lines.
Behaviour identity: differential oracle over the real route handlers (GET
/api/messaging/platforms root + profile, PUT valid/invalid per rule root +
profile) is byte-identical to base.
Delete the per-platform tables in tools/send_message_targets.py (_PLATFORM_PARSERS, 14 rows) and
tools/send_message_tool.py (_PLUGIN_STANDALONE_MEDIA, _TEXT_SENDERS, plus the discord-always and
whatsapp-mentions ladders). Each bundled plugin now declares them on its PlatformEntry:
- target_ref_syntax_fn: the old parser, body unchanged. A new field rather than parse_target_ref_fn
because that field is an authority (strict under pass_unresolved_references, no "not explicit"
sentinel, not re-applied to channel-directory hits) and reusing it would change react/cron
behaviour for ntfy/buzz/photon.
- standalone_send: StandaloneSendPolicy (label, media, all_sends, captionable,
empty_list_between_chunks, forward_force_document, mentions, text_direct).
Shared builders and the NOT_EXPLICIT sentinel live in gateway/platforms/send_targets.py so plugins
import no core-private helpers. Lookups discover plugins first when the name is not registered yet
(fresh CLI/cron process). Differential oracle (33 platforms x 48 refs, 10 send cases each): base and
head output identical.
PLATFORM_HINTS (agent/prompt_builder.py) and _PLATFORM_DEFAULTS (gateway/display_config.py)
duplicated per-platform data for every bundled messaging plugin. Both consumers already fell
back to the registry (PlatformEntry.platform_hint / display_tier), so the plugin rows move onto
each plugin's register() call and the core tables keep only core surfaces (cron, cli, tui,
desktop, api_server hints; webhook, api_server display rows).
New PlatformEntry field display_overrides: per-key defaults layered over display_tier (telegram,
discord, slack, wecom had tier + tweaks). Hint text is copied byte-for-byte (the shared
_MEDIA_NATIVE fragment is inlined); a base-vs-head oracle of platform_hint() and
resolve_display_setting()/resolve_tool_progress() for every platform, with and without user
display overrides, is byte-identical. Oversize adapters keep the hint in adapter_hint.py.
_ALLOW_BOTS_ENV (authz_mixin) and _OWN_POLICY_OPEN_ENV (run) duplicated data the
platform plugins own. PlatformEntry gains allow_bots_env and own_policy_env; the
discord/feishu/telegram/slack and wecom/weixin/yuanbao/qqbot/whatsapp plugins
declare them and both tables are deleted.
Both consumers run an idempotent discover_plugins() first so a hand-built config
or bare runner still sees the entries. The bot bypass fails closed with no entry.
The open-policy startup check fails closed for a bundled platform whose plugin is
disabled or failed to load (conventional <NAME>_* names, manifest-declared
allow-all): config can still enable such a platform, and a later plugin enable
re-wires its adapter without re-running the startup check.
_own_policy_envs lives in run_startup.py to keep run.py under its line cap;
small offsets in the discord/slack/feishu/telegram plugin files for the same reason.
Delete the hand-written per-platform rows that duplicated data every bundled
platform plugin already declares on its PlatformEntry:
- gateway/config.py `_PLATFORM_CONNECTED_CHECKERS`: the weixin, whatsapp_cloud,
signal, bluebubbles, qqbot and yuanbao rows move to a new narrow
`PlatformEntry.config_connected_fn` (verdict from the merged PlatformConfig
alone, no env fallback, owns the token shortcut so Weixin can refuse a bare
token). Core-only rows (api_server, webhook, msgraph_webhook, relay) stay.
- gateway/pairing.py `_PLATFORM_ALLOWLIST_ENV` and the derived authz maps
`_ALLOWED_USERS_ENV` / `_ALLOW_ALL_ENV`: read `allowed_users_env` /
`allow_all_env` (discovering plugins first). The unauthorized-DM
"allowlist set -> ignore" default keeps its historical platform set as a
names-only frozenset so irc/teams/... DM behaviour does not change.
- cron `_HOME_TARGET_ENV_VARS`: env var from `cron_deliver_env_var`; the
origin-fallback / deliver=all order is kept as a names-only priority tuple.
`_KNOWN_DELIVERY_PLATFORMS` keeps only webhook and wecom_callback (no cron var).
- hermes status `_PLATFORM_LABELS`: plugin labels already overrode every row;
discover first and use them alone.
- dashboard `_platform_authz_env_names` drops its read of the pairing table.
Differential oracle (connected matrix, pairing/dashboard env lookup,
_is_user_authorized + unauthorized-DM matrix, cron known/home/resolve/all,
hermes status platform section, hermes dump) is identical on base and head.
The six adapters now live at new paths, so the ratchet reads their moved
functions as new code held to today's targets:
- Standalone senders (bluebubbles, qqbot, weixin, yuanbao) are real
catch-all boundaries that turn any failure into an error result; they now
log the traceback at debug (behaviour unchanged).
- The Signal and Weixin setup wizards' catch-alls get reviewed waivers: any
probe/QR failure is shown to the user, who decides.
- QQ Bot's media existence check runs off the event loop (ASYNC240).
- Yuanbao's registration block moves to plugins/platforms/yuanbao/register.py
so adapter.py stays at main's size cap; it imports the adapter by its
canonical name, keeping one YuanbaoAdapter class object.
With signal, weixin, bluebubbles, qqbot, yuanbao and whatsapp_cloud now
bundled platform plugins, gateway/platforms/ keeps only the base class and
the HTTP ingress adapters (api_server, webhook, msgraph_webhook). (The
now-unused _gateway_platform_module helper and the setup wizard's
second-credential map were dropped while integrating the weixin and
yuanbao "drop core wiring" commits.)
- ffmpeg calls in the Signal and QQ adapters get stdin=DEVNULL: they now
sit under plugins/, which check_subprocess_stdin scans (gateway/ is not
scanned), and ffmpeg reads stdin for its interactive keys.
- Setup wizard: collapse the blank lines left by the removed static rows.
- Developer docs (EN + zh-Hans) describe gateway/platforms/ as core base +
HTTP ingress adapters and list the six platforms under plugins/platforms/.
is_connected now falls back to env_is_connected(QQ_APP_ID, QQ_CLIENT_SECRET)
(.env-backed, scope-aware), so 'hermes gateway setup' shows QQ Bot as
configured for a .env-only profile, matching base.
(cherry picked from commit 19968fb98a96a99e59212fea7cf3129c81c5b7df)
- plugin.yaml name qqbot-platform (bundled-plugin convention)
- drop env_enablement/apply_yaml_config hooks and platform_hint: core
config_env _ENV_STEPS and PLATFORM_HINTS still own them, the hooks were
new behaviour (markdown/env seeding) the move must not add
- drop validate_config/max_message_length: base never config-gated or
chunked QQ in send_message (REST sender truncates at 4000)
- install_hint carries the old _BUILTIN_ADAPTERS warning text
- drop the _send_qqbot compat alias
- replace env-seeding tests with a registration-shape test
(cherry picked from commit b34a6d21e42d934555a2e6243c9a126dc0d5de42)
QQ Bot is a messaging platform, so its adapter, setup, and standalone sender belong in plugins/platforms/qqbot behind one register() entry. The core keeps the shipped-platform name lists, so webhook, cron, and prompt hints still treat qqbot as built-in.
(cherry picked from commit a7eb428aad0cc69ea098747b435e1e0e1d7e3b67)