Skip to content

refactor(gateway): migrate Signal adapter to bundled plugin - #41061

Closed
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:feat/signal-platform-plugin
Closed

refactor(gateway): migrate Signal adapter to bundled plugin#41061
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:feat/signal-platform-plugin

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

What this does

Moves the Signal adapter and its rate-limit companion from
gateway/platforms/signal*.py into a self-contained bundled plugin under
plugins/platforms/signal/, following the Discord / Mattermost / Home
Assistant / Yuanbao migration shape.

How

register() supplies the hooks that were per-platform wiring in core:
adapter_factory, check_fn, is_connected, setup_fn, apply_yaml_config_fn
(the signal: require_mention YAML key), standalone_sender_fn,
cron_deliver_env_var.

The signal-cli JSON-RPC sender — attachment batching + the shared
SignalAttachmentScheduler rate-limit state — moved into the plugin as
_standalone_send. tools/send_message_tool.py keeps a thin _send_signal
shim adapting the legacy (extra, …) signature, so the in-module media +
chunk dispatch paths are unchanged. Signal is HTTP to a signal-cli daemon,
so cron delivery works out-of-process (no live gateway required).

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

Platform.SIGNAL enum literal, the _apply_env_overrides SIGNAL_* bridge,
the _is_user_authorized allowlist maps (SIGNAL_ALLOWED_USERS +
SIGNAL_GROUP_ALLOWED_USERS stay there).

Tests

Renames R081 (adapter) + R100 (rate-limit companion). 339 focused tests pass.
Updated the connection-checker guard test to exclude bundled-plugin platforms
whose is_connected lives in the plugin. No new failures vs main (pre-existing
matrix/telegram xdist flakes excluded).

Move the Signal adapter and its rate-limit companion from
gateway/platforms/signal*.py into a self-contained bundled plugin under
plugins/platforms/signal/, following the Discord/Mattermost/Home
Assistant/Yuanbao migration shape.

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             -> check_signal_requirements guard there
  - is_connected         -> the Platform.SIGNAL lambda in gateway/config.py
  - setup_fn             -> _setup_signal + _PLATFORMS entry + _builtin_setup_fn
  - apply_yaml_config_fn -> the signal_cfg block in load_gateway_config()
  - standalone_sender_fn -> _send_signal in tools/send_message_tool.py
  - cron_deliver_env_var -> SIGNAL_HOME_CHANNEL

The full signal-cli JSON-RPC sender (attachment batching + the shared
SignalAttachmentScheduler rate-limit state) moved into the plugin as
_standalone_send; tools/send_message_tool.py keeps a thin _send_signal shim
that adapts the legacy (extra, ...) signature so the in-module media + chunk
dispatch paths are unchanged. Signal is HTTP to a signal-cli daemon, so unlike
WebSocket-singleton platforms cron delivery works out-of-process.

Deliberately left generic in core: the Platform.SIGNAL enum literal, the
_apply_env_overrides SIGNAL_* bridge, and the _is_user_authorized allowlist
maps (SIGNAL_ALLOWED_USERS + SIGNAL_GROUP_ALLOWED_USERS stay there).

All consumer imports rewritten to plugins.platforms.signal.{adapter,
signal_rate_limit}. Updated the connection-checker guard test to exclude
bundled-plugin platforms whose is_connected lives in the plugin.
@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 platform/signal Signal CLI adapter comp/plugins Plugin system and bundled plugins labels Jun 7, 2026
signal is now a bundled plugin; its PlatformEntry already permits /update via
allow_update_command (defaults True), honored by the registry fallback in
_handle_update_command. The hardcoded Platform.SIGNAL entry in
_UPDATE_ALLOWED_PLATFORMS is therefore redundant. Same cleanup as NousResearch#32525
did for Discord/Mattermost.
@kshitijk4poor

Copy link
Copy Markdown
Collaborator Author

Follow-up to #32525: now that the migrated-platform /update allowlist cleanup landed, this PR drops Platform.SIGNAL from _UPDATE_ALLOWED_PLATFORMS. As a bundled plugin, signal's PlatformEntry.allow_update_command (default True) is already honored by the registry fallback in _handle_update_command, so the hardcoded frozenset entry is redundant. No behavior change — /update from a signal chat still works; test_update_command.py passes (35/35).

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 platform/signal Signal CLI adapter type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants