From 7c067a1cb3e31516a4978cbf61c6e5d166670938 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Thu, 2 Apr 2026 13:56:51 +0800 Subject: [PATCH] feat: support disabled_adapters list in system config Adds 'system.disabled_adapters' config option (list of adapter names). Disabled adapters are excluded from both the adapter registry and API responses, preventing users from creating bots with those adapters. Example config: system: disabled_adapters: - aiocqhttp - dingtalk --- src/langbot/pkg/platform/botmgr.py | 10 ++++++++++ src/langbot/templates/config.yaml | 1 + 2 files changed, 11 insertions(+) diff --git a/src/langbot/pkg/platform/botmgr.py b/src/langbot/pkg/platform/botmgr.py index f9907b84..7daa1067 100644 --- a/src/langbot/pkg/platform/botmgr.py +++ b/src/langbot/pkg/platform/botmgr.py @@ -241,12 +241,22 @@ class PlatformManager: # delete all bot log images await self.ap.storage_mgr.storage_provider.delete_dir_recursive('bot_log_images') + disabled_adapters = self.ap.instance_config.data.get('system', {}).get('disabled_adapters', []) or [] + self.adapter_components = self.ap.discover.get_components_by_kind('MessagePlatformAdapter') adapter_dict: dict[str, type[abstract_platform_adapter.AbstractMessagePlatformAdapter]] = {} for component in self.adapter_components: + if component.metadata.name in disabled_adapters: + continue adapter_dict[component.metadata.name] = component.get_python_component_class() self.adapter_dict = adapter_dict + # Filter out disabled adapters from components list (for API responses) + if disabled_adapters: + self.adapter_components = [ + c for c in self.adapter_components if c.metadata.name not in disabled_adapters + ] + # initialize websocket adapter websocket_adapter_class = self.adapter_dict['websocket'] websocket_logger = EventLogger(name='websocket-adapter', ap=self.ap) diff --git a/src/langbot/templates/config.yaml b/src/langbot/templates/config.yaml index c622405d..7b7e59fe 100644 --- a/src/langbot/templates/config.yaml +++ b/src/langbot/templates/config.yaml @@ -20,6 +20,7 @@ system: edition: community recovery_key: '' allow_modify_login_info: true + disabled_adapters: [] limitation: max_bots: -1 max_pipelines: -1