ForcePilot/backend/package/yuxi/channels/contract/dtos/capability.py
Kris 0d067d61d3 chore: 批量更新契约与实现,修复多处细节问题
本次提交包含多类代码优化与修复:
1. 重命名适配器协议类:WebhookTestable→WebhookTestAdapter、AttachmentUploadable→AttachmentUploadAdapter,并同步更新所有引用
2. 为飞书/企业微信插件添加凭证克隆能力开关配置
3. 修复飞书入站适配器URL解析错误,使用hostname替代host属性
4. 新增批量发送消息DTO与已读状态DTO
5. 新增插件目录列表接口与插件能力校验规则
6. 修复权限阶段配置,添加analytics权限映射
7. 优化健康检查、限流模块的环境变量配置支持
8. 修复配对过期扫描器参数名不匹配问题
9. 优化日志调用、文档注释与代码可读性
10. 移除废弃的AuditExportTask聚合根与相关导入
2026-07-02 18:27:06 +08:00

96 lines
4.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.

"""能力 DTO。
定义渠道能力相关的不可变值对象,包括渠道能力集合与能力探测结果。
所有 DTO 均为 ``dataclass(frozen=True)``,仅依赖标准库,用于渠道
能力声明、探测与降级决策。
"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class ChannelCapabilities:
"""渠道能力集合。
描述渠道支持的能力集合,包括富消息、流式、输入指示、消息编辑、
消息撤回、提及、命令、目录查询、配置诊断、白名单管理与消息操作能力
(表情反应 / 置顶 / 卡片更新),媒体能力(入站/出站图片/视频),
以及渠道级内容长度上限,用于适配器能力声明与降级决策。
字段:
rich_message: 是否支持富消息(默认 False
streaming: 是否支持流式(默认 False
typing_indicator: 是否支持输入指示(默认 False
message_edit: 是否支持消息编辑(默认 False
message_recall: 是否支持消息撤回(默认 False
mention: 是否支持提及(默认 False
command: 是否支持命令(默认 FalseFR-15
directory: 是否支持目录查询(默认 FalseFR-14
doctor: 是否支持配置诊断与自动修复(默认 FalseFR-17
whitelist: 是否支持白名单管理(默认 FalseFR-18
supports_reaction: 是否支持表情反应(默认 FalseFR-12
supports_pin: 是否支持置顶(默认 FalseFR-12
supports_card_update: 是否支持卡片更新(默认 FalseFR-12
supports_image_inbound: 是否支持入站图片(默认 FalseFR-43
supports_video_inbound: 是否支持入站视频(默认 FalseFR-43
supports_image_outbound: 是否支持出站图片(默认 FalseFR-43
supports_video_outbound: 是否支持出站视频(默认 FalseFR-43
max_message_length: 单条消息最大文本长度FR19-P0-5 渠道级内容
长度校验,默认 4096。出站管道据此对超长内容做截断或分片
决策,未声明的渠道沿用默认值。
lifecycle: 是否实现账户生命周期适配器(默认 FalseAL-01
supports_qr_login: 是否支持扫码登录(默认 FalseQR-02
agent_collaboration: 是否支持多 Agent 协作(默认 False
FR-AgentCollab。声明为 True 时要求 mention_adapters 非空
FR-21 契约一致性)。
supports_credential_cloning: 是否允许在账户克隆时复制凭据字段
(默认 FalseACC-CLONE。声明为 False 时 ``include_credentials=True``
的克隆请求将被 handler 拒绝RuleViolationErrorfail-closed
防止凭据经克隆路径泄露。
"""
rich_message: bool = False
streaming: bool = False
typing_indicator: bool = False
message_edit: bool = False
message_recall: bool = False
mention: bool = False
command: bool = False
directory: bool = False
doctor: bool = False
whitelist: bool = False
supports_reaction: bool = False
supports_pin: bool = False
supports_card_update: bool = False
supports_image_inbound: bool = False
supports_video_inbound: bool = False
supports_image_outbound: bool = False
supports_video_outbound: bool = False
max_message_length: int = 4096
lifecycle: bool = False
supports_qr_login: bool = False
agent_collaboration: bool = False
supports_credential_cloning: bool = False
@dataclass(frozen=True)
class CapabilityResult:
"""能力探测结果。
描述单项能力的探测结果,包括声明层、证明层与降级标记,用于能力
探测流程的决策与审计。
字段:
capability: 能力名称。
declared: 声明层是否支持。
proven: 证明层是否验证通过(默认 False
degraded: 是否降级(默认 False
"""
capability: str
declared: bool
proven: bool = False
degraded: bool = False