Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def _scan_bundled_plugin_platforms(cls) -> set:
"sms",
"whatsapp_cloud",
"line",
"teams",
})

# Platforms whose port-binding status depends on connection mode. Feishu in
Expand Down
1 change: 1 addition & 0 deletions hermes_cli/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2825,6 +2825,7 @@ def _git_path(path: str) -> str:
"sms": ("webhook_port", 8080),
"whatsapp_cloud": ("webhook_port", 8090),
"line": ("port", 8646),
"teams": ("port", 3978),
}

# Platform states that mean the adapter is NOT serving its port right now.
Expand Down
41 changes: 41 additions & 0 deletions tests/gateway/test_multiplex_adapter_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,47 @@ async def _connect(adapter, platform):
assert second == 1
assert runner._profile_adapters["later"][photon] is later

def test_port_binding_set_covers_known_listeners(self):
from gateway.run import _PORT_BINDING_PLATFORM_VALUES

# Every adapter that binds a TCP port must be in the guard set.
for platform in (
"webhook",
"api_server",
"msgraph_webhook",
"feishu",
"wecom_callback",
"bluebubbles",
"sms",
"whatsapp_cloud",
"line",
"teams",
):
assert platform in _PORT_BINDING_PLATFORM_VALUES

@pytest.mark.asyncio
async def test_secondary_teams_uses_degradable_error(self, monkeypatch):
from gateway.config import GatewayConfig, Platform, PlatformConfig
from gateway.run import SecondaryPortBindingConfigError

runner = GatewayRunner.__new__(GatewayRunner)
runner.config = GatewayConfig(multiplex_profiles=True)
runner._profile_adapters = {}

reviewer_cfg = GatewayConfig(multiplex_profiles=True)
reviewer_cfg.platforms = {
Platform("teams"): PlatformConfig(enabled=True, extra={"port": 3978}),
}
monkeypatch.setattr(
"gateway.config.load_gateway_config", lambda: reviewer_cfg
)

with pytest.raises(SecondaryPortBindingConfigError) as exc_info:
await runner._start_one_profile_adapters("reviewer", "/tmp/x", {})
assert "teams" in str(exc_info.value)
assert "reviewer" in str(exc_info.value)
assert "reviewer" not in runner._profile_adapters


class TestFeishuPortBindingConditional:
"""Feishu websocket mode does NOT bind a port; only webhook mode does (#52563)."""
Expand Down