fix(gateway): wire Telegram plugin into gateway plugin host
Some checks failed
ci/woodpecker/push/ci Pipeline failed

Add @mosaic/telegram-plugin dependency to gateway, implement
TelegramChannelPluginAdapter, replace stub warning with real plugin
instantiation, and document all Phase 5 env vars in .env.example.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 19:03:16 -05:00
parent b7a39b45d7
commit 58cfbbe735
3 changed files with 39 additions and 4 deletions

View File

@@ -20,6 +20,7 @@
"@mosaic/coord": "workspace:^",
"@mosaic/db": "workspace:^",
"@mosaic/discord-plugin": "workspace:^",
"@mosaic/telegram-plugin": "workspace:^",
"@mosaic/log": "workspace:^",
"@mosaic/memory": "workspace:^",
"@mosaic/types": "workspace:^",

View File

@@ -7,6 +7,7 @@ import {
type OnModuleInit,
} from '@nestjs/common';
import { DiscordPlugin } from '@mosaic/discord-plugin';
import { TelegramPlugin } from '@mosaic/telegram-plugin';
import { PluginService } from './plugin.service.js';
import type { IChannelPlugin } from './plugin.interface.js';
@@ -26,9 +27,23 @@ class DiscordChannelPluginAdapter implements IChannelPlugin {
}
}
class TelegramChannelPluginAdapter implements IChannelPlugin {
readonly name = 'telegram';
constructor(private readonly plugin: TelegramPlugin) {}
async start(): Promise<void> {
await this.plugin.start();
}
async stop(): Promise<void> {
await this.plugin.stop();
}
}
const DEFAULT_GATEWAY_URL = 'http://localhost:4000';
function createPluginRegistry(logger: Logger): IChannelPlugin[] {
function createPluginRegistry(): IChannelPlugin[] {
const plugins: IChannelPlugin[] = [];
const discordToken = process.env['DISCORD_BOT_TOKEN'];
const discordGuildId = process.env['DISCORD_GUILD_ID'];
@@ -50,8 +65,13 @@ function createPluginRegistry(logger: Logger): IChannelPlugin[] {
const telegramGatewayUrl = process.env['TELEGRAM_GATEWAY_URL'] ?? DEFAULT_GATEWAY_URL;
if (telegramToken) {
logger.warn(
`Telegram plugin requested for ${telegramGatewayUrl}, but @mosaic/telegram-plugin is not implemented yet.`,
plugins.push(
new TelegramChannelPluginAdapter(
new TelegramPlugin({
token: telegramToken,
gatewayUrl: telegramGatewayUrl,
}),
),
);
}
@@ -63,7 +83,7 @@ function createPluginRegistry(logger: Logger): IChannelPlugin[] {
providers: [
{
provide: PLUGIN_REGISTRY,
useFactory: (): IChannelPlugin[] => createPluginRegistry(new Logger('PluginModule')),
useFactory: (): IChannelPlugin[] => createPluginRegistry(),
},
PluginService,
],