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
+2
View File
@@ -36,6 +36,7 @@ function makeBaseConfig(): Config {
google_chat: undefined,
bluebubbles: undefined,
line: undefined,
feishu: undefined,
} as unknown as Config;
}
@@ -55,6 +56,7 @@ describe('discoverServices', () => {
expect.objectContaining({ name: 'google_chat', status: 'not_configured' }),
expect.objectContaining({ name: 'bluebubbles', status: 'not_configured' }),
expect.objectContaining({ name: 'line', status: 'not_configured' }),
expect.objectContaining({ name: 'feishu', status: 'not_configured' }),
expect.objectContaining({ name: 'cron', status: 'not_configured' }),
expect.objectContaining({ name: 'mcp', status: 'not_configured' }),
expect.objectContaining({ name: 'web_search', status: 'configured' }),
+1
View File
@@ -59,6 +59,7 @@ export function discoverServices(
{ key: 'google_chat', name: 'google_chat', description: 'Google Chat bot' },
{ key: 'bluebubbles', name: 'bluebubbles', description: 'iMessage via BlueBubbles' },
{ key: 'line', name: 'line', description: 'LINE Messaging API bot' },
{ key: 'feishu', name: 'feishu', description: 'Feishu/Lark bot' },
];
for (const { key, name, description } of channelConfigs) {
+14
View File
@@ -52,6 +52,7 @@ import type { TeamsAdapter } from '../channels/teams/adapter.js';
import type { GoogleChatAdapter } from '../channels/googleChat/adapter.js';
import type { BlueBubblesAdapter } from '../channels/bluebubbles/adapter.js';
import type { LineAdapter } from '../channels/line/adapter.js';
import type { FeishuAdapter } from '../channels/feishu/adapter.js';
export interface GatewayServerConfig {
port: number;
@@ -123,6 +124,8 @@ export interface GatewayServerConfig {
blueBubblesHandler?: Pick<BlueBubblesAdapter, 'handleRequest'>;
/** Optional LINE adapter for inbound webhook events. */
lineHandler?: Pick<LineAdapter, 'handleRequest'>;
/** Optional Feishu adapter for inbound webhook events. */
feishuHandler?: Pick<FeishuAdapter, 'handleRequest'>;
}
export class GatewayServer {
@@ -733,6 +736,12 @@ export class GatewayServer {
return;
}
// Feishu events route — bypass gateway auth (Feishu webhook posts directly)
if (this.config.feishuHandler && req.method === 'POST' && req.url?.startsWith('/feishu/events')) {
await this.config.feishuHandler.handleRequest(req, res);
return;
}
// Apply auth to HTTP requests when configured
const authConfig = this.config.auth ?? {};
if (this.config.authHttp !== false && authConfig.token) {
@@ -856,6 +865,11 @@ export class GatewayServer {
this.config.lineHandler = handler;
}
/** Set the Feishu handler for inbound webhook HTTP routes (late binding). */
setFeishuHandler(handler: Pick<FeishuAdapter, 'handleRequest'>): void {
this.config.feishuHandler = handler;
}
private async startDiscovery(host: string, port: number): Promise<void> {
const discovery = this.config.discovery;
if (!discovery?.enabled) {