本次提交对频道模块进行了全面重构并新增多项核心功能: 1. 优化适配器状态获取逻辑,修复状态返回空值问题 2. 新增4种频道异常类型,完善错误处理体系 3. 大幅精简Mixin类,移除冗余的抽象方法定义 4. 重构适配器注册系统,统一注册入口并新增内置适配器加载方法 5. 扩展插件系统,新增更多元数据配置项支持 6. 新增线程类型、会话范围等模型定义,扩展事件类型枚举 7. 优化用户映射逻辑,使用PostgreSQL upsert避免重复创建 8. 新增历史消息注入模块,支持多格式历史格式化与缓存管理 9. 新增线程能力配置与各平台预置适配配置 10. 新增线程绑定管理器,支持多类型线程绑定生命周期管理 11. 重构__init__.py,整理导出模块与类型 12. 扩展基础适配器类,新增凭证解析、状态存储等核心方法 13. 重写消息路由器,支持按频道加载策略、安全校验与多命令处理 14. 新增/history、/context、/summary等交互命令实现 15. 优化消息记录与统计逻辑,完善路由调度链路
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
class ChannelException(Exception):
|
|
def __init__(self, message: str, retryable: bool = False, retry_after_ms: int = 0):
|
|
super().__init__(message)
|
|
self.retryable = retryable
|
|
self.retry_after_ms = retry_after_ms
|
|
|
|
|
|
class ChannelNotConnectedError(ChannelException):
|
|
def __init__(self):
|
|
super().__init__("Channel not connected", retryable=True, retry_after_ms=5000)
|
|
|
|
|
|
class ChannelConnectionError(ChannelException):
|
|
def __init__(self, message: str = "Channel connection failed"):
|
|
super().__init__(message, retryable=True, retry_after_ms=5000)
|
|
|
|
|
|
class ChannelAuthenticationError(ChannelException):
|
|
def __init__(self, message: str = "Channel authentication failed"):
|
|
super().__init__(message, retryable=False)
|
|
|
|
|
|
class ChannelRateLimitError(ChannelException):
|
|
def __init__(self, retry_after_ms: int = 60000):
|
|
super().__init__("Rate limited by channel", retryable=True, retry_after_ms=retry_after_ms)
|
|
|
|
|
|
class TokenExpiredError(ChannelException):
|
|
def __init__(self):
|
|
super().__init__("Access token expired", retryable=True, retry_after_ms=1000)
|
|
|
|
|
|
class MessageFormatError(ChannelException):
|
|
def __init__(self):
|
|
super().__init__("Invalid message format", retryable=False)
|
|
|
|
|
|
class DeliveryFailedError(ChannelException):
|
|
def __init__(self, message: str = ""):
|
|
detail = f"Message delivery failed: {message}" if message else "Message delivery failed"
|
|
super().__init__(detail, retryable=True, retry_after_ms=3000)
|
|
|
|
|
|
class ChannelTimeoutError(ChannelException):
|
|
def __init__(self, message: str = "Channel operation timed out"):
|
|
super().__init__(message, retryable=True, retry_after_ms=2000)
|
|
|
|
|
|
class ChannelQuotaExceededError(ChannelException):
|
|
def __init__(self, message: str = "Channel quota exceeded"):
|
|
super().__init__(message, retryable=False)
|
|
|
|
|
|
class MessageTooLargeError(ChannelException):
|
|
def __init__(self, message: str = "Message body exceeds size limit"):
|
|
super().__init__(message, retryable=False)
|