Add Feishu channel adapter with webhook and send path

This commit is contained in:
William Valentin
2026-02-16 13:07:45 -08:00
parent 376f74550e
commit 891ccb696e
16 changed files with 644 additions and 6 deletions
+36
View File
@@ -24,6 +24,7 @@ describe('registerChannels', () => {
setGoogleChatHandler: vi.fn(),
setBlueBubblesHandler: vi.fn(),
setLineHandler: vi.fn(),
setFeishuHandler: vi.fn(),
};
registerChannels({
@@ -57,6 +58,7 @@ describe('registerChannels', () => {
setGoogleChatHandler: vi.fn(),
setBlueBubblesHandler: vi.fn(),
setLineHandler: vi.fn(),
setFeishuHandler: vi.fn(),
};
registerChannels({
@@ -70,4 +72,38 @@ describe('registerChannels', () => {
expect(names).toContain('line');
expect(gateway.setLineHandler).toHaveBeenCalledTimes(1);
});
it('registers Feishu adapter when configured', () => {
const config = configSchema.parse({
telegram: { bot_token: 'test-token', allowed_chat_ids: [1] },
models: { default: { provider: 'anthropic', model: 'claude-3' } },
feishu: {
app_id: 'cli_a1b2c3',
app_secret: 'secret',
allowed_chat_ids: ['oc_123'],
},
});
const channelRegistry = new ChannelRegistry();
const gateway = {
setWebhookHandler: vi.fn(),
setGmailHandler: vi.fn(),
setTeamsHandler: vi.fn(),
setGoogleChatHandler: vi.fn(),
setBlueBubblesHandler: vi.fn(),
setLineHandler: vi.fn(),
setFeishuHandler: 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('feishu');
expect(gateway.setFeishuHandler).toHaveBeenCalledTimes(1);
});
});
+16 -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, LineAdapter, PairingManager } from '../channels/index.js';
import { ChannelRegistry, TelegramAdapter, WebChatAdapter, DiscordAdapter, SlackAdapter, WhatsAppAdapter, MatrixAdapter, SignalAdapter, MattermostAdapter, TeamsAdapter, GoogleChatAdapter, BlueBubblesAdapter, LineAdapter, FeishuAdapter, PairingManager } from '../channels/index.js';
import { CronScheduler, WebhookHandler, GmailWatcher } from '../automation/index.js';
import type { GatewayServer } from '../gateway/index.js';
@@ -167,6 +167,21 @@ export function registerChannels(deps: ChannelsDeps): ChannelsResult {
gateway.setLineHandler(lineAdapter);
}
// Register Feishu adapter (if configured)
if (config.feishu) {
const feishuAdapter = new FeishuAdapter({
appId: config.feishu.app_id,
appSecret: config.feishu.app_secret,
webhookToken: config.feishu.webhook_token,
allowedChatIds: config.feishu.allowed_chat_ids.length > 0 ? config.feishu.allowed_chat_ids : undefined,
requireMention: config.feishu.require_mention,
mentionName: config.feishu.mention_name,
endpoint: config.feishu.endpoint,
});
channelRegistry.register(feishuAdapter);
gateway.setFeishuHandler(feishuAdapter);
}
// Register WebChat adapter (wraps the gateway)
const webChatAdapter = new WebChatAdapter({ gateway });
channelRegistry.register(webChatAdapter);