Skip to content

The agent that grows with you

fix(migrate): shared-ingress adapters declare serves_profile_prefix so migration reports them as notices

Tekniumd76856cc6971
diff --git a/gateway/platforms/bluebubbles.py b/gateway/platforms/bluebubbles.py
index 6755d7bf114..8d497d1bb8a 100644
--- a/gateway/platforms/bluebubbles.py
+++ b/gateway/platforms/bluebubbles.py
@@ -108,6 +108,8 @@ def _ok():
class BlueBubblesAdapter(BasePlatformAdapter):
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
platform = Platform.BLUEBUBBLES
SUPPORTS_MESSAGE_EDITING = False
MAX_MESSAGE_LENGTH = MAX_TEXT_LENGTH
diff --git a/gateway/platforms/msgraph_webhook.py b/gateway/platforms/msgraph_webhook.py
index a891f96380c..3e1a96063fe 100644
--- a/gateway/platforms/msgraph_webhook.py
+++ b/gateway/platforms/msgraph_webhook.py
@@ -98,6 +98,8 @@ def _render_template(template: str, payload: Dict[str, Any]) -> str:
class MSGraphWebhookAdapter(BasePlatformAdapter):
"""Receive Microsoft Graph change notifications and surface them internally."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
def __init__(self, config: PlatformConfig):
super().__init__(config, Platform.MSGRAPH_WEBHOOK)
diff --git a/gateway/platforms/whatsapp_cloud.py b/gateway/platforms/whatsapp_cloud.py
index 016bdd35125..84eb5378a8d 100644
--- a/gateway/platforms/whatsapp_cloud.py
+++ b/gateway/platforms/whatsapp_cloud.py
@@ -155,6 +155,8 @@ def check_whatsapp_cloud_requirements() -> bool:
class WhatsAppCloudAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter):
"""Outbound: Graph ``/<api_version>/<phone_id>/messages``; inbound: aiohttp webhook
server. The mixin comes first so its ``format_message`` overrides the base one."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
splits_long_messages = True # send() chunks via truncate_message()
diff --git a/hermes_cli/gateway_migrate.py b/hermes_cli/gateway_migrate.py
index 02319f91d77..90a965461b3 100644
--- a/hermes_cli/gateway_migrate.py
+++ b/hermes_cli/gateway_migrate.py
@@ -312,6 +312,10 @@ def platform_serves_profile_prefix(platform_value: str) -> bool:
adapter_cls, _ok = _builtin_adapter_import(spec[0], spec[1], spec[2])
return _declares(adapter_cls)
with contextlib.suppress(Exception):
+ # Plugin-shipped adapters (sms, line, teams, feishu, wecom, ...) only exist in the registry
+ # after discovery; a bare CLI process has not run it yet.
+ from hermes_cli.plugins import discover_plugins
+ discover_plugins() # idempotent
from gateway.platform_registry import platform_registry
entry = platform_registry.get(platform_value)
if entry is not None:
diff --git a/plugins/platforms/feishu/adapter.py b/plugins/platforms/feishu/adapter.py
index 4f8ff5d22ab..a19e047c4c6 100644
--- a/plugins/platforms/feishu/adapter.py
+++ b/plugins/platforms/feishu/adapter.py
@@ -1195,6 +1195,8 @@ def _sdk_build(request_cls: Any, **fields: Any) -> Any:
class FeishuAdapter(BasePlatformAdapter):
"""Feishu/Lark bot adapter."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
supports_code_blocks = True # Feishu renders fenced code blocks
splits_long_messages = True # send() chunks via truncate_message(MAX_MESSAGE_LENGTH)
diff --git a/plugins/platforms/line/adapter.py b/plugins/platforms/line/adapter.py
index 1a2807d56d9..dc3e7d760d2 100644
--- a/plugins/platforms/line/adapter.py
+++ b/plugins/platforms/line/adapter.py
@@ -383,6 +383,8 @@ _ENV_SEED_KEYS = (("LINE_HOST", "host"), ("LINE_PUBLIC_URL", "public_url"), ("LI
class LineAdapter(BasePlatformAdapter):
"""LINE Messaging API gateway adapter (no message editing → REQUIRES_EDIT_FINALIZE stays False)."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
def __init__(self, config, **kwargs):
super().__init__(config=config, platform=Platform("line"))
diff --git a/plugins/platforms/sms/adapter.py b/plugins/platforms/sms/adapter.py
index 0b3c000debd..5ec644fb254 100644
--- a/plugins/platforms/sms/adapter.py
+++ b/plugins/platforms/sms/adapter.py
@@ -83,6 +83,8 @@ def check_sms_requirements() -> bool:
class SmsAdapter(BasePlatformAdapter):
"""Twilio SMS <-> Hermes: one session per inbound number; replies always from TWILIO_PHONE_NUMBER."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
MAX_MESSAGE_LENGTH = MAX_SMS_LENGTH
diff --git a/plugins/platforms/teams/adapter.py b/plugins/platforms/teams/adapter.py
index 95dbddd1c84..f487883de1c 100644
--- a/plugins/platforms/teams/adapter.py
+++ b/plugins/platforms/teams/adapter.py
@@ -341,6 +341,8 @@ def _approval_body(cmd: str, desc: str, *, always: bool = False) -> list:
class TeamsAdapter(BasePlatformAdapter):
"""Microsoft Teams adapter using the microsoft-teams-apps SDK."""
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
MAX_MESSAGE_LENGTH = 28000 # Teams text message limit (~28 KB)
splits_long_messages = True # send() chunks via truncate_message()
diff --git a/plugins/platforms/wecom/callback_adapter.py b/plugins/platforms/wecom/callback_adapter.py
index 871f35375e4..5baf8b8505b 100644
--- a/plugins/platforms/wecom/callback_adapter.py
+++ b/plugins/platforms/wecom/callback_adapter.py
@@ -81,6 +81,8 @@ def _ack():
class WecomCallbackAdapter(BasePlatformAdapter):
+ # Answers /p/<profile>/... on the default listener for a served secondary (shared_ingress).
+ serves_profile_prefix: bool = True
def __init__(self, config: PlatformConfig):
super().__init__(config, Platform.WECOM_CALLBACK)
extra = config.extra or {}
diff --git a/tests/hermes_cli/test_gateway_migrate_multiplex.py b/tests/hermes_cli/test_gateway_migrate_multiplex.py
index e6d9c996bbe..520f34cadd5 100644
--- a/tests/hermes_cli/test_gateway_migrate_multiplex.py
+++ b/tests/hermes_cli/test_gateway_migrate_multiplex.py
@@ -140,7 +140,12 @@ def test_serves_profile_prefix_is_read_from_adapter_classes():
assert APIServerAdapter.serves_profile_prefix and WebhookAdapter.serves_profile_prefix
assert gm.platform_serves_profile_prefix("api_server") is True
assert gm.platform_serves_profile_prefix("webhook") is True
- assert gm.platform_serves_profile_prefix("sms") is False
+ # Every adapter that binds through shared_ingress.bind_listener is served at /p/<profile>/
+ # for a secondary, so migrate must report it as a notice, never a blocker.
+ for platform in ("sms", "line", "teams", "bluebubbles", "whatsapp_cloud", "msgraph_webhook"):
+ assert gm.platform_serves_profile_prefix(platform) is True, platform
+ # An outbound-only adapter never declares it (and never needs to).
+ assert gm.platform_serves_profile_prefix("telegram") is False
def test_update_hook_migrates_when_unblocked_and_only_warns_when_blocked(fleet, capsys):