ForcePilot/backend/package/yuxi/channels/adapters/wechat/setup_contract.py

78 lines
2.3 KiB
Python
Raw Normal View History

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)