ForcePilot/backend/package/yuxi/channels/adapters/wechat/setup_contract.py
Kris 05abecc02b feat(wechat): 新增完整微信渠道适配器实现
该提交实现了支持企业微信、微信公众号、个人微信桥接三种模式的完整微信渠道适配器,包含以下核心模块:
1. 基础认证与配置相关:auth_adapter、config_reload、setup_contract等
2. 消息处理与格式转换:format、attachment_adapter、outbound_adapter等
3. 多模式客户端支持:wecom/mp子模块,包含加解密、消息收发能力
4. 辅助能力:限速器、防抖、会话绑定、事件映射、模板渲染等
5. 扩展能力:二维码登录、消息读取、特权用户、心跳监控等

实现了完整的微信生态对接能力,支持消息收发、事件处理、API调用限流、配置热重载等功能。
2026-05-12 00:51:04 +08:00

78 lines
2.3 KiB
Python

from __future__ import annotations
from typing import Any
WECHAT_SETUP_CONTRACT: dict[str, Any] = {
"channel_id": "wechat",
"setup_steps": [
{
"id": "mode_selection",
"label": "选择模式",
"description": "选择微信接入模式",
"options": [
{
"id": "wecom",
"label": "企业微信 (WeCom)",
"description": "使用企业微信应用消息 API",
"required_fields": ["corp_id", "corp_secret", "agent_id"],
},
{
"id": "mp",
"label": "公众号 (MP)",
"description": "使用微信公众号客服消息 API",
"required_fields": ["app_id", "app_secret"],
},
{
"id": "personal",
"label": "个人微信 (Bridge)",
"description": "通过桥接服务连接个人微信",
"required_fields": ["bridge_url"],
},
],
},
{
"id": "credentials",
"label": "凭证配置",
"description": "输入所选模式的凭证信息",
},
{
"id": "validation",
"label": "连接验证",
"description": "验证凭证有效性,测试微信 API 连通性",
},
{
"id": "webhook",
"label": "Webhook 配置",
"description": "配置服务器回调地址,用于接收微信消息推送",
"optional": True,
},
{
"id": "confirmation",
"label": "确认应用",
"description": "确认配置并保存",
},
],
"health_checks": [
{
"id": "wecom_token_valid",
"label": "企业微信 Token 有效性",
"check": "probe_wecom",
},
{
"id": "mp_token_valid",
"label": "公众号 Token 有效性",
"check": "probe_mp",
},
{
"id": "bridge_healthy",
"label": "桥接服务健康状态",
"check": "probe_bridge",
},
],
}
def get_setup_contract() -> dict[str, Any]:
return dict(WECHAT_SETUP_CONTRACT)