refactor(core): restructure conversation, channel and message domains

- Rename chat module to conversation with flow-based architecture
- Move channelidentities into channel/identities subpackage
- Add channel/route for routing logic
- Add message service with event hub
- Add MCP providers: container, directory, schedule
- Refactor Feishu/Telegram adapters with directory and stream support
- Add platform management page and channel badges in web UI
- Update database schema for conversations, messages and channel routes
- Add @memoh/shared package for cross-package type definitions
This commit is contained in:
BBQ
2026-02-12 15:33:09 +08:00
parent 75e2ef0467
commit ca5c6a1866
243 changed files with 21463 additions and 10485 deletions
+1
View File
@@ -0,0 +1 @@
# @memoh/shared
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@memoh/shared",
"version": "1.0.0",
"description": "",
"exports": {
".": "./src/index.ts"
},
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"packageManager": "pnpm@10.27.0"
}
+15
View File
@@ -0,0 +1,15 @@
export interface robot{
description: string
time: Date,
id: string | number,
type: string,
action: 'robot',
state:'thinking'|'generate'|'complete'
}
export interface user{
description: string,
time: Date,
id: number | string,
action:'user'
}
+5
View File
@@ -0,0 +1,5 @@
export * from './model'
export * from './schedule'
export * from './platform'
export * from './mcp'
export * from './chatInfo'
+48
View File
@@ -0,0 +1,48 @@
export interface BaseMCPConnection {
type: string
name: string
}
export interface StdioMCPConnection extends BaseMCPConnection {
type: 'stdio'
command: string
args: string[]
env: Record<string, string>
cwd: string
}
export interface BaseHTTPMCPConnection extends BaseMCPConnection {
url: string
headers: Record<string, string>
}
export interface HTTPMCPConnection extends BaseHTTPMCPConnection {
type: 'http'
}
export interface SSEMCPConnection extends BaseHTTPMCPConnection {
type: 'sse'
}
export type MCPConnection =
| StdioMCPConnection
| HTTPMCPConnection
| SSEMCPConnection
export interface MCPListItem{
id: string;
type: string;
name: string;
config: {
cwd: string;
env: Record<string, string>;
args: string[];
type: string;
command: string;
};
active: boolean;
user: string;
createdAt: string;
updatedAt: string;
}
+101
View File
@@ -0,0 +1,101 @@
export enum ModelClientType {
OPENAI = 'openai',
ANTHROPIC = 'anthropic',
GOOGLE = 'google',
}
export enum ModelType {
CHAT = 'chat',
EMBEDDING = 'embedding',
}
export interface BaseModel {
/**
* @description The unique identifier for the model
* @example 'gpt-4o'
*/
modelId: string
/**
* @description The base URL for the model
* @example 'https://api.openai.com/v1'
*/
baseUrl: string
/**
* @description The API key for the model
* @example 'sk-1234567890'
*/
apiKey: string
/**
* @description The client type for the model
* @enum {ModelClientType}
*/
clientType: ModelClientType
/**
* @description The display name for the model
* @example 'GPT 4o'
*/
name?: string
/**
* @description The model type
* @enum {ModelType}
* @default {ModelType.CHAT}
*/
type?: ModelType
}
export interface EmbeddingModel extends BaseModel {
type?: ModelType.EMBEDDING
/**
* @description The dimensions of the embedding
* @example 1536
*/
dimensions: number
}
export interface ChatModel extends BaseModel {
type?: ModelType.CHAT
}
export type Model = EmbeddingModel | ChatModel
/** Model row type for list/table views. */
export interface ModelList {
apiKey: string,
baseUrl: string,
clientType: 'OpenAI' | 'Anthropic' | 'Google',
modelId: string,
name: string,
type: 'chat' | 'embedding',
id: string,
defaultChatModel: boolean,
defaultEmbeddingModel: boolean,
defaultSummaryModel: boolean
}
export interface ProviderInfo{
api_key: string;
base_url: string;
client_type: string;
metadata: Record<'additionalProp1',object>;
name: string;
}
export interface ModelInfo{
dimensions:number
is_multimodal:boolean
input?: string[]
llm_provider_id:string
model_id:string
name:string
type: string
enable_as?:string
}
export const clientType = ['openai', 'anthropic', 'google', 'ollama'] as const
+7
View File
@@ -0,0 +1,7 @@
export interface Platform {
id: string
name: string
// endpoint: string
config: Record<string, unknown>
active: boolean
}
+8
View File
@@ -0,0 +1,8 @@
export interface Schedule {
id?: string
pattern: string
name: string
description: string
command: string
maxCalls?: number | null
}