Add LINE channel adapter with webhook ingress and gating

This commit is contained in:
William Valentin
2026-02-16 13:02:26 -08:00
parent a954d7e136
commit 76d44a74bf
15 changed files with 584 additions and 5 deletions
+34
View File
@@ -23,6 +23,7 @@ describe('registerChannels', () => {
setTeamsHandler: vi.fn(),
setGoogleChatHandler: vi.fn(),
setBlueBubblesHandler: vi.fn(),
setLineHandler: vi.fn(),
};
registerChannels({
@@ -36,4 +37,37 @@ describe('registerChannels', () => {
expect(names).toContain('mattermost');
expect(names).toContain('webchat');
});
it('registers LINE adapter when configured', () => {
const config = configSchema.parse({
telegram: { bot_token: 'test-token', allowed_chat_ids: [1] },
models: { default: { provider: 'anthropic', model: 'claude-3' } },
line: {
channel_access_token: 'line-token',
channel_secret: 'line-secret',
allowed_source_ids: ['U123'],
},
});
const channelRegistry = new ChannelRegistry();
const gateway = {
setWebhookHandler: vi.fn(),
setGmailHandler: vi.fn(),
setTeamsHandler: vi.fn(),
setGoogleChatHandler: vi.fn(),
setBlueBubblesHandler: vi.fn(),
setLineHandler: vi.fn(),
};
registerChannels({
config,
channelRegistry,
hookEngine: new HookEngine(config.hooks),
gateway: gateway as unknown as Parameters<typeof registerChannels>[0]['gateway'],
});
const names = channelRegistry.list().map((adapter) => adapter.name);
expect(names).toContain('line');
expect(gateway.setLineHandler).toHaveBeenCalledTimes(1);
});
});
+14 -1
View File
@@ -1,6 +1,6 @@
import type { Config } from '../config/index.js';
import type { HookEngine } from '../hooks/index.js';
import { ChannelRegistry, TelegramAdapter, WebChatAdapter, DiscordAdapter, SlackAdapter, WhatsAppAdapter, MatrixAdapter, SignalAdapter, MattermostAdapter, TeamsAdapter, GoogleChatAdapter, BlueBubblesAdapter, PairingManager } from '../channels/index.js';
import { ChannelRegistry, TelegramAdapter, WebChatAdapter, DiscordAdapter, SlackAdapter, WhatsAppAdapter, MatrixAdapter, SignalAdapter, MattermostAdapter, TeamsAdapter, GoogleChatAdapter, BlueBubblesAdapter, LineAdapter, PairingManager } from '../channels/index.js';
import { CronScheduler, WebhookHandler, GmailWatcher } from '../automation/index.js';
import type { GatewayServer } from '../gateway/index.js';
@@ -154,6 +154,19 @@ export function registerChannels(deps: ChannelsDeps): ChannelsResult {
gateway.setBlueBubblesHandler(blueBubblesAdapter);
}
// Register LINE adapter (if configured)
if (config.line) {
const lineAdapter = new LineAdapter({
channelAccessToken: config.line.channel_access_token,
channelSecret: config.line.channel_secret,
allowedSourceIds: config.line.allowed_source_ids.length > 0 ? config.line.allowed_source_ids : undefined,
requireMention: config.line.require_mention,
mentionName: config.line.mention_name,
});
channelRegistry.register(lineAdapter);
gateway.setLineHandler(lineAdapter);
}
// Register WebChat adapter (wraps the gateway)
const webChatAdapter = new WebChatAdapter({ gateway });
channelRegistry.register(webChatAdapter);