ForcePilot/backend/package/yuxi/channels/contract/__init__.py
Kris 742299cb07 chore: 批量清理报告相关代码并完成多项功能迭代
本次提交包含多维度代码优化与功能增强:
1.  移除报告模块冗余导入与枚举,清理报表相关代码
2.  新增扫码登录支持方法与飞书适配器适配
3.  完善异常日志与健康检查信息
4.  扩展目录、配对管理、能力查询等接口
5.  优化出站管道与事务提交后钩子逻辑
6.  修复飞书消息解析与响应空值问题
7.  重构配置更新与服务账号创建逻辑
8.  统一传输错误分类契约与错误基类扩展
2026-07-06 20:49:35 +08:00

332 lines
8.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""多渠道网关契约层入口。
契约层是横切层所有层core/application/adapters/framework均可依赖
自身不得依赖任何实现层。本包聚合驱动端口、被驱动端口、DTO、错误类型、
渠道插件协议等子模块,提供统一导出入口。
子包分组:
- **端口**ports25 个驱动端口 + 28 个被驱动端口,定义核心与外部边界
的交互契约,使用 ``typing.Protocol`` + ``@runtime_checkable`` 风格声明。
- **DTO**dtos38 个模块的跨层共享不可变值对象(``dataclass(frozen=True)``
覆盖渠道、消息、路由、身份、会话、健康、配置、审计、插件等全场景。
- **错误**errorsClient / Server / Domain 三大类错误层级,禁止原生异常
穿透至核心层。
- **插件协议**plugin渠道插件协议组合式适配器契约包含插件入口、
清单、能力声明与证明、生命周期钩子、扩展点协议与 15 个适配器协议。
入参 / 出参均为契约层不可变值对象,不泄露领域实体引用。
"""
from __future__ import annotations
# DTOdtos核心跨层共享值对象按使用频率选取主要类型
from yuxi.channels.contract.dtos import (
AdminSendCmd,
AdminSendResult,
Attachment,
ChannelAccount,
ChannelHealth,
ChannelSession,
ChannelType,
ControlCmd,
ControlResult,
ConversationId,
FailureDetail,
HealthQuery,
InboundMessageCmd,
InboundResult,
LifecycleCmd,
LifecycleResult,
Message,
MessageContent,
MessageFormat,
MessageId,
Operator,
OperatorRole,
RawEvent,
RequestId,
SaveMessageCmd,
SkipDetail,
TraceContext,
TraceId,
)
# 错误类型errorsbase / client / server / domain
from yuxi.channels.contract.errors import (
AuthError,
BotLoopBudgetExceededError,
CapabilityNotProvenError,
ChannelDegradedError,
ClientError,
ConfigNotHotReloadableError,
ConfigRestartRequiredError,
ConfigRollbackError,
ConfigValidationError,
ConfigVersionConflictError,
ConflictError,
DependencyError,
DmDeniedError,
DomainError,
Error,
InternalError,
NotFoundError,
OperationTimeoutError,
PairingExpiredError,
PermissionDeniedError,
PluginAlreadyRegisteredError,
PluginFailedError,
PluginNotFoundError,
RateLimitError,
RuleViolationError,
SchemaInitializationError,
ServerError,
ValidationError,
)
# 插件协议pluginmanifest / entry / capability / lifecycle / extension_point / adapters
from yuxi.channels.contract.plugin import (
CHANNEL_ENTRY,
CapabilityDeclaration,
CapabilityProof,
CapabilityProver,
ChannelManifest,
CommandAdapter,
ConfigField,
ConfigSource,
ConflictStrategy,
DirectoryAdapter,
DoctorAdapter,
EventSubscription,
FailurePolicy,
FailureStrategy,
IdentityResolverAdapter,
InboundAdapter,
LifecycleHook,
LifecycleHookHandler,
LifecycleState,
MentionAdapter,
MessageOpsAdapter,
OutboundAdapter,
PluginDependency,
PluginHost,
PluginManifest,
ResourceQuota,
RichMessageAdapter,
SessionAdapter,
Stage,
StageSlot,
StatusAdapter,
StreamingAdapter,
ToolsAdapter,
WhitelistAdapter,
WizardAdapter,
)
# 端口ports26 个驱动端口 + 27 个被驱动端口
from yuxi.channels.contract.ports import (
AccountManagementPort,
AdminMessagePort,
AgentManagementPort,
AgentRunExecutionPort,
AgentRunPort,
AnalyticsViewPort,
AuditLogRepositoryPort,
AuditQueryPort,
CachePort,
CapabilityQueryPort,
ChannelAccountRepositoryPort,
ChannelContextProviderPort,
ChannelLoginPort,
ChannelSessionRepositoryPort,
ChannelToolExecutorPort,
CloseablePort,
ConfigManagementPort,
ConfigPort,
ContentReviewPort,
ContentReviewQueryPort,
ConversationPort,
DashboardViewPort,
DirectoryPort,
DoctorPort,
EventPublisherPort,
HealthAggregatorPort,
HealthCheckPort,
IdempotencyRepositoryPort,
IdentityResolverPort,
InboundMessagePort,
LoggerPort,
MaskingPort,
MessageManagementPort,
MessageOpsPort,
OutboxManagementPort,
OutboxRepositoryPort,
PairingManagementPort,
PairingRepositoryPort,
PersistenceHealthPort,
PersistencePort,
PingablePort,
PluginLifecycleManagerPort,
PluginLifecyclePort,
PluginManagementPort,
QueuePort,
SessionManagementPort,
TracerPort,
TransactionPort,
UserBindingPort,
UserIdentityRepositoryPort,
WhitelistCommandPort,
WhitelistManagementPort,
WizardPort,
)
__all__ = [
# 端口ports
"AccountManagementPort",
"AdminMessagePort",
"AgentManagementPort",
"AgentRunExecutionPort",
"AgentRunPort",
"AnalyticsViewPort",
"AuditLogRepositoryPort",
"AuditQueryPort",
"CachePort",
"CapabilityQueryPort",
"ChannelAccountRepositoryPort",
"ChannelContextProviderPort",
"ChannelLoginPort",
"ChannelSessionRepositoryPort",
"ChannelToolExecutorPort",
"CloseablePort",
"ConfigManagementPort",
"ConfigPort",
"ContentReviewPort",
"ContentReviewQueryPort",
"ConversationPort",
"DashboardViewPort",
"DirectoryPort",
"DoctorPort",
"EventPublisherPort",
"HealthAggregatorPort",
"HealthCheckPort",
"IdempotencyRepositoryPort",
"IdentityResolverPort",
"InboundMessagePort",
"LoggerPort",
"MaskingPort",
"MessageManagementPort",
"MessageOpsPort",
"OutboxManagementPort",
"OutboxRepositoryPort",
"PairingManagementPort",
"PairingRepositoryPort",
"PersistenceHealthPort",
"PersistencePort",
"PingablePort",
"PluginLifecycleManagerPort",
"PluginLifecyclePort",
"PluginManagementPort",
"QueuePort",
"SessionManagementPort",
"TransactionPort",
"TracerPort",
"UserBindingPort",
"UserIdentityRepositoryPort",
"WhitelistCommandPort",
"WhitelistManagementPort",
"WizardPort",
# 错误类型errors
"AuthError",
"BotLoopBudgetExceededError",
"CapabilityNotProvenError",
"ChannelDegradedError",
"ClientError",
"ConfigNotHotReloadableError",
"ConfigRestartRequiredError",
"ConfigRollbackError",
"ConfigValidationError",
"ConfigVersionConflictError",
"ConflictError",
"DependencyError",
"DmDeniedError",
"DomainError",
"Error",
"InternalError",
"NotFoundError",
"PairingExpiredError",
"PermissionDeniedError",
"PluginAlreadyRegisteredError",
"PluginFailedError",
"PluginNotFoundError",
"RateLimitError",
"RuleViolationError",
"SchemaInitializationError",
"ServerError",
"OperationTimeoutError",
"ValidationError",
# 插件协议plugin
"CHANNEL_ENTRY",
"CapabilityDeclaration",
"CapabilityProof",
"CapabilityProver",
"ChannelManifest",
"CommandAdapter",
"ConfigField",
"ConflictStrategy",
"ConfigSource",
"DirectoryAdapter",
"DoctorAdapter",
"EventSubscription",
"FailurePolicy",
"FailureStrategy",
"IdentityResolverAdapter",
"InboundAdapter",
"LifecycleHook",
"LifecycleHookHandler",
"LifecycleState",
"MentionAdapter",
"MessageOpsAdapter",
"OutboundAdapter",
"PluginDependency",
"PluginHost",
"PluginManifest",
"ResourceQuota",
"RichMessageAdapter",
"SessionAdapter",
"Stage",
"StageSlot",
"StatusAdapter",
"StreamingAdapter",
"ToolsAdapter",
"WhitelistAdapter",
"WizardAdapter",
# DTOdtos核心类型
"AdminSendCmd",
"AdminSendResult",
"Attachment",
"ChannelAccount",
"ChannelHealth",
"ChannelSession",
"ChannelType",
"ControlCmd",
"ControlResult",
"ConversationId",
"FailureDetail",
"HealthQuery",
"InboundMessageCmd",
"InboundResult",
"LifecycleCmd",
"LifecycleResult",
"Message",
"MessageContent",
"MessageFormat",
"MessageId",
"Operator",
"OperatorRole",
"RawEvent",
"RequestId",
"SaveMessageCmd",
"SkipDetail",
"TraceContext",
"TraceId",
]