本次提交包含多项优化与新增功能: 1. 清理多个文件中多余的空行与导入顺序 2. 修复voice.py中的多行字符串格式化问题 3. 新增微信公众号被动回复构建函数与配置项 4. 新增企业微信markdown消息发送支持 5. 新增消息去重TTL与最大条目配置 6. 新增markdown文本截断工具函数 7. 新增微信授权与OAuth相关工具方法 8. 重构消息去重逻辑,使用DedupPolicy替代本地字典实现 9. 新增子账号多租户支持功能 10. 新增消息动作处理适配器,支持send/reply等操作 11. 修复token持久化逻辑,新增状态存储支持
77 lines
2.3 KiB
Python
77 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)
|