/** * IM 渠道类型定义 * * 从 @cicctencent/agent-midway 迁移至 @cicctencent/agent-server。 * 定义渠道适配器接口和通用类型,支持飞书、钉钉、企业微信等 IM 平台。 */ /** 渠道类型 */ export type ChannelType = 'feishu' | 'dingtalk' | 'wecom'; /** 渠道配置 */ export interface ChannelConfig { /** 渠道类型 */ type: ChannelType; /** 渠道名称 */ name: string; /** 是否启用 */ enabled: boolean; /** Webhook URL(接收消息的端点) */ webhookUrl?: string; /** 验证 Token */ token?: string; /** 应用 ID */ appId?: string; /** 应用密钥 */ appSecret?: string; /** 接收者 ID 类型 */ receiveIdType?: string; /** 飞书 Agent ID */ agentId?: string; /** 企业微信 Agent ID */ wecomAgentId?: string; /** 额外配置 */ extra?: Record; } /** 解析后的消息 */ export interface ReceivedMessage { /** 会话 ID(用于关联上下文) */ sessionId: string; /** 消息文本内容 */ message: string; /** 发送者 ID */ senderId: string; /** 发送者名称 */ senderName: string; /** 原始消息体 */ raw: any; } /** 渠道状态 */ export interface ChannelStatus { /** 渠道类型 */ type: ChannelType; /** 渠道名称 */ name: string; /** 是否启用 */ enabled: boolean; /** 是否已初始化 */ initialized: boolean; /** 最后活跃时间 */ lastActiveAt?: number; /** 错误信息 */ error?: string; } /** 渠道适配器接口 */ export interface ChannelAdapter { /** 渠道类型 */ readonly type: ChannelType; /** 初始化适配器 */ init(config: ChannelConfig): Promise; /** 发送消息 */ sendMessage(config: ChannelConfig, receiveId: string, message: string): Promise; /** 接收并解析消息 */ receiveMessage(body: any, headers?: any): Promise; /** 获取配置(脱敏后) */ getConfig(): ChannelConfig; /** 验证签名 */ verifySignature(body: any, headers: any, config: ChannelConfig): boolean; /** Webhook 验证挑战(飞书 URL 验证等) */ verifyChallenge?(body: any, config: ChannelConfig): any | null; } /** 渠道配置存储接口 */ export interface ChannelConfigStore { /** 获取所有渠道配置 */ getAll(): Promise>; /** 获取单个渠道配置 */ get(type: ChannelType): Promise; /** 更新渠道配置 */ update(type: ChannelType, data: Partial): Promise; } //# sourceMappingURL=channel-types.d.ts.map