Add channel management system with Telegram adapter#1
Closed
HaraldBregu wants to merge 12 commits into
Closed
Conversation
Persist messaging-channel configs (id/type/token/allowFrom/enabled) in electron-store, mirroring the existing Provider lifecycle. Introduce a ChannelAdapter interface with a dispatch-callback contract so adapters never import the assistant module. Wire the existing TelegramAdapter to route inbound text to AssistantRegistry.get(DEFAULT_ASSISTANT_ID).send and reply via grammy. Register a ChannelManager service that owns adapter lifecycles, started after IPC bootstrap so config edits hot-apply via new app:get-channels / app:add-channel / app:delete-channel IPC. https://claude.ai/code/session_01R6i53ytUebsbZFZhF4ZuoB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a complete channel management system that enables the application to handle multiple messaging adapters (starting with Telegram). It includes a new
ChannelManagerthat owns the lifecycle of channel adapters, integrates channels into the store layer, and refactors the Telegram adapter to work within this new architecture.Key Changes
New Channel Manager (
src/main/channels/manager.ts): Centralized lifecycle management for all messaging channel adapters. Handles spawning, stopping, and updating adapters based on store state. Dispatches inbound messages to the default Assistant and routes replies back through the originating adapter.Channel Adapter Interface (
src/main/channels/adapter.ts): Defines the contract for channel implementations withstart(),stop(), and dispatch capabilities.Refactored Telegram Adapter:
ChannelAdapterinterfacedispatchcallback to decouple from the assistant moduleStore Layer Integration:
Channeltype support toStoreSchemachannels.tsmodule with normalization and validation utilitiesStoreServicemethods:getChannels(),getChannelById(),addChannel(),deleteChannel()Input Validation (
ChannelValidatorsinsrc/main/shared/validators.ts):Implementation Details
ChannelManagerdecouples adapters from the assistant module through aChannelDispatchcallback, allowing adapters to remain independent of business logichttps://claude.ai/code/session_01R6i53ytUebsbZFZhF4ZuoB