Refactor communication channels into a unified adapter framework#212
Refactor communication channels into a unified adapter framework#212blackhammer116 wants to merge 18 commits into
Conversation
…small doc for running import-kb script without docker, reverted lib_llb_ext to core version, cleaned DockerFile
… find the argument embeddingprovider in import-kb script
Restore auth.is_auth_enabled() + auth.verify_token() proxy logic in
BaseChannel._is_allowed_message, replacing the OMEGACLAW_AUTH_SECRET env-var approach introduced by the refactor.
Restore proxy API base URL overrides in start() for Telegram
({proxy}/telegram), Slack ({proxy}/slack), and Mattermost
({proxy}/mattermost) to match pre-refactor behaviour.
Feat/channel refactor
vsbogd
left a comment
There was a problem hiding this comment.
-
This PR contains two different types of changes: the refactoring of the existing channels and introducing registry of channels. I would split these two parts on two different changes.
-
I would not try to abstract the channel implementation into the
BaseChannelclass at least on the API level. The_run_loopmethod is an abstraction which doesn't cover the all possible implementations. For example one could have a communication channel without_run_loopat all for examplemock.pywhich is present in OmegaClaw-Core doesn't use such loop at all.
The BaseChannel can be a good abstraction some of the channels, but the high-level API we have is sendMessage/removeMessage and BaseChannel doesn't provide the way to implement this abstraction.
- The registry of the channels which is introduced requires modification each time when new integration is added which contradicts to our goal to have ability adding the new channel integration without modifying the core. Channel configuration should not be visible in the code outside of the channel implementation by the same reason.
Hey @vsbogd, this was just a draft PR for discussion purposes I don't have any intention of merging the code to core at this stage, that being said mock.py would be accommodated easily this is just to show that initialization of comm channels can be abstracted and they can take a single unified architecture while having their own different flavors. I'm assuming by Since the overall plan is to move the Again this PR is just to show you the idea of how we can structure it, this does not represent the final implementation. |
|
Closing this as it communication channel registry part is part of #222 |
Description
This PR refactors the communication channel layer to provide a common adapter interface across all supported messaging backends (IRC, Telegram, Slack, and Mattermost). The goal is to reduce duplicated logic, simplify channel integration, and make adding new communication backends significantly easier.
Main changes
Introduce
BaseChannelAdd a common
BaseChannelabstract class that encapsulates shared functionality:Channel-specific implementations now only need to implement their transport logic (
_run_loop) and message sending.Add channel registry
channels_registry.pyas a central entry point for channel initialization.Refactor existing adapters
Refactor the following adapters to inherit from
BaseChannel:This removes a significant amount of duplicated code while preserving existing behavior.
Simplify MeTTa integration
src/channels.mettahas been simplified to interact with a single registry instead of containing channel-specific branching logic.Initialization now becomes:
channels_registry.start(...)Sending and receiving messages are similarly routed through the registry, reducing the MeTTa code considerably.
Library updates
lib_omegaclaw.metta.BaseChannelandchannels_registrymodules.Benefits
Notes
The refactor is intended to preserve existing behavior while restructuring the implementation. Aside from the unified initialization path and centralized configuration, channel functionality should remain unchanged.
Checklist