Skip to content

refactor(gateway): migrate Yuanbao adapter to bundled plugin - #40804

Closed
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:feat/yuanbao-platform-plugin
Closed

refactor(gateway): migrate Yuanbao adapter to bundled plugin#40804
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:feat/yuanbao-platform-plugin

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

What this does

Moves the Yuanbao (元宝) adapter and its protocol/media/sticker companions
from gateway/platforms/yuanbao*.py into a self-contained bundled plugin
under plugins/platforms/yuanbao/, following the Discord / Mattermost /
Home Assistant migration shape.

How

register() supplies the hooks that were per-platform wiring in core:
adapter_factory (run.py factory elif), check_fn (websockets guard),
is_connected (config.py lambda), setup_fn (gateway.py wizard entry),
standalone_sender_fn (send_message_tool dispatch), cron_deliver_env_var.

Yuanbao uses a persistent WebSocket owned by the live gateway adapter, so
unlike HTTP platforms there's no throwaway-client path — the standalone
sender obtains the running singleton via get_active_adapter() and errors
when the gateway isn't running, exactly as the old _send_yuanbao did.
Behavior-preserving.

Out of scope (stays generic, same as every other platform)

Platform.YUANBAO enum literal, the _apply_env_overrides YUANBAO_* bridge,
_is_user_authorized allowlist maps, cron known-platforms set. Yuanbao has
no load_gateway_config YAML block, so no apply_yaml_config_fn.

Tests

4 clean renames (R096 + 3×R100). 272 focused tests pass. No new failures vs
main (pre-existing matrix/telegram xdist flakes excluded). Verified plugin
discovery + full hook surface.

Move the Yuanbao (元宝) adapter and its protocol/media/sticker companions
from gateway/platforms/yuanbao*.py into a self-contained bundled plugin
under plugins/platforms/yuanbao/, following the Discord/Mattermost/Home
Assistant migration shape.

The plugin's register() supplies the hooks that previously lived as
per-platform wiring in core:
  - adapter_factory      -> the elif in gateway/run.py::_create_adapter()
  - check_fn             -> the websockets-availability guard there
  - is_connected         -> the Platform.YUANBAO lambda in gateway/config.py
  - setup_fn             -> the declarative yuanbao entry in hermes_cli/gateway.py
  - standalone_sender_fn -> the Platform.YUANBAO dispatch in send_message_tool
  - cron_deliver_env_var -> YUANBAO_HOME_CHANNEL

Yuanbao speaks a persistent WebSocket owned by the live gateway adapter, so
unlike HTTP platforms there is no throwaway-client path; the standalone
sender obtains the running singleton via get_active_adapter() and errors
when the gateway is not running, exactly as the old _send_yuanbao did.

Deliberately left generic in core (same as every other platform): the
Platform.YUANBAO enum literal, the _apply_env_overrides YUANBAO_* bridge,
the _is_user_authorized allowlist maps, and the cron known-platforms set.
Yuanbao has no load_gateway_config YAML block, so no apply_yaml_config_fn
is needed.

All consumer imports rewritten to plugins.platforms.yuanbao.adapter; the
gateway.platforms.YuanbaoAdapter re-export is repointed for back-compat.
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins labels Jun 6, 2026
@kshitijk4poor
kshitijk4poor deleted the feat/yuanbao-platform-plugin branch August 5, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants