feat: channel gateway implementation and multi-bot refactor

- Refactor channel manager with support for Sender/Receiver interfaces and hot-swappable adapters.
- Implement identity routing and pre-authentication logic for inbound messages.
- Update database schema to support bot pre-auth keys and extended channel session metadata.
- Add Telegram and Feishu channel configuration and adapter enhancements.
- Update Swagger documentation and internal handlers for channel management.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BBQ
2026-02-06 14:41:54 +08:00
parent 0bba6d2913
commit 5a35ef34ac
106 changed files with 7910 additions and 3044 deletions
+17 -12
View File
@@ -5,17 +5,22 @@ import { createGoogleGenerativeAI } from '@ai-sdk/google'
import { ClientType, ModelConfig } from './types'
export const createModel = (model: ModelConfig) => {
const apiKey = model.apiKey.toLowerCase().trim()
const baseURL = model.baseUrl.toLowerCase().trim()
const modelId = model.modelId.toLowerCase().trim()
const clients = {
[ClientType.OpenAI]: createOpenAI,
[ClientType.OpenAICompatible]: createOpenAI,
[ClientType.Anthropic]: createAnthropic,
[ClientType.Google]: createGoogleGenerativeAI,
const apiKey = model.apiKey.trim()
const baseURL = model.baseUrl.trim()
const modelId = model.modelId.trim()
switch (model.clientType) {
case ClientType.OpenAI:
case ClientType.OpenAICompatible: {
const provider = createOpenAI({ apiKey, baseURL })
// Use .chat() to call /chat/completions (not /responses which only OpenAI supports)
return provider.chat(modelId)
}
case ClientType.Anthropic:
return createAnthropic({ apiKey, baseURL })(modelId)
case ClientType.Google:
return createGoogleGenerativeAI({ apiKey, baseURL })(modelId)
default:
return createAiGateway({ apiKey, baseURL })(modelId)
}
return (clients[model.clientType] ?? createAiGateway)({
apiKey,
baseURL,
})(modelId)
}