feat(webui): improve setup flows across chat channels (NAN-112) (#5356)
* feat(webui): improve channel setup flows * fix(webui): refine channel setup interactions (NAN-112) * fix(webui): keep email setup sections channel-owned * fix(webui): remove concrete channel details from shared components * refactor(webui): remove unused channel setup resources * fix(webui): finish channel-owned setup boundaries * fix(webui): update channel switches optimistically * test(channels): remove obsolete absence assertions * fix(webui): flatten channel instance settings disclosure * fix(webui): complete channel setup and connection flows * fix(whatsapp): wait for session database release * fix(webui): preserve scrolling channel controls * fix(webui): stage channel connection checks * fix(channels): align verification actions * fix(email): expose connection checks * fix(webui): align channel field actions * fix(email): verify account credentials * fix(wecom): bypass system proxy for websocket * fix(channels): stabilize async connection cleanup * fix(webui): autosave channel credentials * fix(email): make provider presets non-destructive * test(weixin): isolate persisted QR credentials
This commit is contained in:
1 parent
3cc3012b3a
commit
e8a29a0087
291 files changed
+12194
-3979
No files matched your search
@@ -9,6 +9,7 @@ SETUP_SPEC = ChannelSetupSpec(
|
||||
"botId": field(),
|
||||
"secret": field("secret"),
|
||||
"allowFrom": field("list"),
|
||||
"welcomeMessage": field(),
|
||||
},
|
||||
required=required_fields("botId", "secret"),
|
||||
official_url="https://developer.work.weixin.qq.com/",
|
||||
|
||||
@@ -20,6 +20,7 @@ from nanobot.config.paths import get_media_dir
|
||||
from nanobot.config.schema import Base
|
||||
|
||||
WECOM_AVAILABLE = importlib.util.find_spec("wecom_aibot_sdk") is not None
|
||||
WECOM_WEBSOCKET_HOST = "openws.work.weixin.qq.com"
|
||||
|
||||
# Inbound media safety limit (matching QQ channel defaults)
|
||||
WECOM_DOWNLOAD_MAX_BYTES = 1024 * 1024 * 200 # 200MB
|
||||
@@ -28,6 +29,14 @@ WECOM_DOWNLOAD_MAX_BYTES = 1024 * 1024 * 200 # 200MB
|
||||
_SAFE_NAME_RE = re.compile(r"[^\w.\-()\[\]()【】\u4e00-\u9fff]+", re.UNICODE)
|
||||
|
||||
|
||||
def _bypass_system_proxy(host: str) -> None:
|
||||
"""Keep the WeCom SDK's WebSocket on its direct connection path."""
|
||||
for key in ("NO_PROXY", "no_proxy"):
|
||||
entries = [entry.strip() for entry in os.environ.get(key, "").split(",") if entry.strip()]
|
||||
if host not in entries:
|
||||
os.environ[key] = ",".join([*entries, host])
|
||||
|
||||
|
||||
def _sanitize_filename(name: str, fallback: str = "unnamed") -> str:
|
||||
"""Sanitize filename to avoid traversal and problematic chars."""
|
||||
def _clean(value: str) -> str:
|
||||
@@ -96,6 +105,10 @@ class WecomChannel(BaseChannel):
|
||||
self.logger.error("bot_id and secret not configured")
|
||||
return
|
||||
|
||||
# websockets 15+ automatically uses the system proxy. The current WeCom SDK
|
||||
# doesn't expose its proxy argument and expects this endpoint to connect directly.
|
||||
_bypass_system_proxy(WECOM_WEBSOCKET_HOST)
|
||||
|
||||
from wecom_aibot_sdk import WSClient, generate_req_id
|
||||
|
||||
self._running = True
|
||||
|
||||
@@ -23,8 +23,10 @@ from nanobot.bus.events import OutboundMessage
|
||||
from nanobot.bus.outbound_events import ProgressEvent
|
||||
from nanobot.bus.queue import MessageBus
|
||||
from nanobot.channels.wecom.runtime import (
|
||||
WECOM_WEBSOCKET_HOST,
|
||||
WecomChannel,
|
||||
WecomConfig,
|
||||
_bypass_system_proxy,
|
||||
_sanitize_filename,
|
||||
)
|
||||
|
||||
@@ -58,6 +60,20 @@ def test_sdk_exposes_media_upload_api() -> None:
|
||||
assert callable(WSClient.upload_media)
|
||||
|
||||
|
||||
def test_wecom_websocket_bypasses_system_proxy(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv("NO_PROXY", "localhost,127.0.0.1")
|
||||
|
||||
_bypass_system_proxy(WECOM_WEBSOCKET_HOST)
|
||||
_bypass_system_proxy(WECOM_WEBSOCKET_HOST)
|
||||
|
||||
assert os.environ["NO_PROXY"].split(",") == [
|
||||
"localhost",
|
||||
"127.0.0.1",
|
||||
WECOM_WEBSOCKET_HOST,
|
||||
]
|
||||
assert os.environ["no_proxy"].split(",").count(WECOM_WEBSOCKET_HOST) == 1
|
||||
|
||||
|
||||
def test_sanitize_filename_strips_path_traversal() -> None:
|
||||
assert _sanitize_filename("../../etc/passwd") == "passwd"
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
|
||||
|
||||
export default {
|
||||
presentation: {
|
||||
logoUrl: "https://work.weixin.qq.com/favicon.ico",
|
||||
displayName: "WeCom",
|
||||
initials: "WC",
|
||||
color: "#2F7DFF",
|
||||
logoUrl: "https://work.weixin.qq.com/favicon.ico",
|
||||
setup: {
|
||||
mode: "credentials",
|
||||
docsUrl: chatAppGuideUrl("wecom"),
|
||||
fields: [
|
||||
{ key: "channels.wecom.botId" },
|
||||
{ key: "channels.wecom.secret" },
|
||||
{ key: "channels.wecom.allowFrom" },
|
||||
{ key: "channels.wecom.botId", section: "credentials" },
|
||||
{ key: "channels.wecom.secret", section: "credentials" },
|
||||
{ key: "channels.wecom.allowFrom", section: "access" },
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Use nanobot from WeCom work chats.",
|
||||
"requirements": "WeCom AI bot ID and secret",
|
||||
"setup": {
|
||||
"docsLabel": "Open WeCom setup",
|
||||
"officialLabel": "Open WeCom console",
|
||||
"tryIt": "Send a test message to the WeCom bot.",
|
||||
"summary": "WeCom needs an AI bot ID and secret from the WeCom admin console.",
|
||||
"steps": [
|
||||
"Create an AI bot in WeCom and choose API mode.",
|
||||
"Copy the Bot ID and Secret into nanobot.",
|
||||
"Save and enable WeCom, then send a test message."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "WeCom bot ID",
|
||||
"help": "Copy it from the WeCom AI Bot API mode page."
|
||||
"placeholder": "WeCom bot ID"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Keep the WeCom bot secret private."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Allowed users",
|
||||
"placeholder": "User IDs, comma separated"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Welcome message"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Usa nanobot desde chats de trabajo de WeCom.",
|
||||
"requirements": "Bot ID y Secret del bot de IA de WeCom",
|
||||
"setup": {
|
||||
"docsLabel": "Abrir guía de WeCom",
|
||||
"officialLabel": "Abrir consola de WeCom",
|
||||
"tryIt": "Envía un mensaje de prueba al bot de WeCom.",
|
||||
"summary": "WeCom necesita el ID y el secreto de un bot de IA desde la consola de administración.",
|
||||
"steps": [
|
||||
"Crea un bot de IA en WeCom y elige el modo API.",
|
||||
"Copia el Bot ID y el Secret en nanobot.",
|
||||
"Guarda y activa WeCom; después envía un mensaje de prueba."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "Bot ID de WeCom",
|
||||
"help": "Cópialo de la página del modo API del bot de IA de WeCom."
|
||||
"placeholder": "Bot ID de WeCom"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Mantén privado el secreto del bot de WeCom."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Usuarios permitidos",
|
||||
"placeholder": "ID de usuario separados por comas"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Mensaje de bienvenida"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Utilisez nanobot dans les conversations professionnelles WeCom.",
|
||||
"requirements": "Bot ID et Secret du bot IA WeCom",
|
||||
"setup": {
|
||||
"docsLabel": "Ouvrir le guide WeCom",
|
||||
"officialLabel": "Ouvrir la console WeCom",
|
||||
"tryIt": "Envoyez un message test au bot WeCom.",
|
||||
"summary": "WeCom nécessite l’ID et le secret d’un bot IA depuis la console d’administration.",
|
||||
"steps": [
|
||||
"Créez un bot IA dans WeCom et choisissez le mode API.",
|
||||
"Copiez le Bot ID et le Secret dans nanobot.",
|
||||
"Enregistrez et activez WeCom, puis envoyez un message test."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "Bot ID WeCom",
|
||||
"help": "Copiez-le depuis la page du mode API du bot IA WeCom."
|
||||
"placeholder": "Bot ID WeCom"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Gardez le secret du bot WeCom confidentiel."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Utilisateurs autorisés",
|
||||
"placeholder": "ID utilisateur séparés par des virgules"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Message de bienvenue"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Gunakan nanobot dari chat kerja WeCom.",
|
||||
"requirements": "Bot ID dan Secret bot AI WeCom",
|
||||
"setup": {
|
||||
"docsLabel": "Buka panduan WeCom",
|
||||
"officialLabel": "Buka konsol WeCom",
|
||||
"tryIt": "Kirim pesan uji ke bot WeCom.",
|
||||
"summary": "WeCom memerlukan ID dan secret bot AI dari konsol admin.",
|
||||
"steps": [
|
||||
"Buat bot AI di WeCom dan pilih mode API.",
|
||||
"Salin Bot ID dan Secret ke nanobot.",
|
||||
"Simpan dan aktifkan WeCom, lalu kirim pesan uji."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "Bot ID WeCom",
|
||||
"help": "Salin dari halaman mode API Bot AI WeCom."
|
||||
"placeholder": "Bot ID WeCom"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Jaga kerahasiaan secret bot WeCom."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Pengguna yang diizinkan",
|
||||
"placeholder": "ID pengguna, dipisahkan koma"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Pesan selamat datang"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "WeCom の業務チャットから nanobot を利用します。",
|
||||
"requirements": "WeCom AI ボットの Bot ID と Secret",
|
||||
"setup": {
|
||||
"docsLabel": "WeCom 設定ガイドを開く",
|
||||
"officialLabel": "WeCom コンソールを開く",
|
||||
"tryIt": "WeCom ボットにテストメッセージを送信します。",
|
||||
"summary": "WeCom 管理コンソールの AI ボット ID とシークレットが必要です。",
|
||||
"steps": [
|
||||
"WeCom で AI ボットを作成し、API モードを選択します。",
|
||||
"Bot ID と Secret を nanobot にコピーします。",
|
||||
"保存して WeCom を有効にし、テストメッセージを送信します。"
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "WeCom Bot ID",
|
||||
"help": "WeCom AI ボットの API モードページからコピーします。"
|
||||
"placeholder": "WeCom Bot ID"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "WeCom ボットのシークレットは安全に保管してください。"
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "許可するユーザー",
|
||||
"placeholder": "ユーザー ID(カンマ区切り)"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "ウェルカムメッセージ"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "WeCom 업무 채팅에서 nanobot을 사용합니다.",
|
||||
"requirements": "WeCom AI 봇의 Bot ID와 Secret",
|
||||
"setup": {
|
||||
"docsLabel": "WeCom 설정 가이드 열기",
|
||||
"officialLabel": "WeCom 콘솔 열기",
|
||||
"tryIt": "WeCom 봇에 테스트 메시지를 보내세요.",
|
||||
"summary": "WeCom 관리 콘솔의 AI 봇 ID와 Secret이 필요합니다.",
|
||||
"steps": [
|
||||
"WeCom에서 AI 봇을 만들고 API 모드를 선택하세요.",
|
||||
"Bot ID와 Secret을 nanobot에 복사하세요.",
|
||||
"저장하고 WeCom을 활성화한 다음 테스트 메시지를 보내세요."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "WeCom Bot ID",
|
||||
"help": "WeCom AI 봇 API 모드 페이지에서 복사하세요."
|
||||
"placeholder": "WeCom Bot ID"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "WeCom 봇 Secret을 안전하게 보관하세요."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "허용된 사용자",
|
||||
"placeholder": "사용자 ID, 쉼표로 구분"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "환영 메시지"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Use o nanobot em conversas de trabalho do WeCom.",
|
||||
"requirements": "Bot ID e Secret do bot de IA do WeCom",
|
||||
"setup": {
|
||||
"docsLabel": "Abrir guia do WeCom",
|
||||
"officialLabel": "Abrir console do WeCom",
|
||||
"tryIt": "Envie uma mensagem de teste ao bot do WeCom.",
|
||||
"summary": "O WeCom precisa do ID e do segredo de um bot de IA do console administrativo.",
|
||||
"steps": [
|
||||
"Crie um bot de IA no WeCom e escolha o modo API.",
|
||||
"Copie o Bot ID e o Secret para o nanobot.",
|
||||
"Salve e ative o WeCom; depois, envie uma mensagem de teste."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "Bot ID do WeCom",
|
||||
"help": "Copie da página do modo API do bot de IA do WeCom."
|
||||
"placeholder": "Bot ID do WeCom"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Mantenha privado o segredo do bot do WeCom."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Usuários permitidos",
|
||||
"placeholder": "IDs de usuário separados por vírgulas"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Mensagem de boas-vindas"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
{
|
||||
"description": "Sử dụng nanobot trong các cuộc trò chuyện công việc WeCom.",
|
||||
"requirements": "Bot ID và Secret của bot AI WeCom",
|
||||
"setup": {
|
||||
"docsLabel": "Mở hướng dẫn WeCom",
|
||||
"officialLabel": "Mở bảng điều khiển WeCom",
|
||||
"tryIt": "Gửi tin nhắn thử đến bot WeCom.",
|
||||
"summary": "WeCom cần ID và secret của bot AI từ bảng điều khiển quản trị.",
|
||||
"steps": [
|
||||
"Tạo bot AI trong WeCom và chọn chế độ API.",
|
||||
"Sao chép Bot ID và Secret vào nanobot.",
|
||||
"Lưu và bật WeCom, sau đó gửi tin nhắn thử."
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "Bot ID WeCom",
|
||||
"help": "Sao chép từ trang chế độ API của bot AI WeCom."
|
||||
"placeholder": "Bot ID WeCom"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "Giữ kín khóa Secret của bot WeCom."
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "Người dùng được phép",
|
||||
"placeholder": "ID người dùng, phân tách bằng dấu phẩy"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "Tin nhắn chào mừng"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,23 @@
|
||||
{
|
||||
"displayName": "企业微信",
|
||||
"description": "在企业微信工作会话中使用 nanobot。",
|
||||
"requirements": "企业微信 AI 机器人的 Bot ID 和 Secret",
|
||||
"setup": {
|
||||
"docsLabel": "打开企业微信配置指南",
|
||||
"officialLabel": "打开企业微信管理后台",
|
||||
"tryIt": "向企业微信机器人发送一条测试消息。",
|
||||
"summary": "企业微信需要管理后台中 AI 机器人的 Bot ID 和 Secret。",
|
||||
"steps": [
|
||||
"在企业微信中创建 AI 机器人并选择 API 模式。",
|
||||
"将 Bot ID 和 Secret 复制到 nanobot。",
|
||||
"保存并启用企业微信,然后发送一条测试消息。"
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "企业微信 Bot ID",
|
||||
"help": "从企业微信 AI 机器人 API 模式页面复制。"
|
||||
"placeholder": "企业微信 Bot ID"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "请妥善保管企业微信机器人 Secret。"
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "允许的用户",
|
||||
"placeholder": "用户 ID,用逗号分隔"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "欢迎消息"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,23 @@
|
||||
{
|
||||
"displayName": "企業微信",
|
||||
"description": "在企業微信工作對話中使用 nanobot。",
|
||||
"requirements": "企業微信 AI 機器人的 Bot ID 和 Secret",
|
||||
"setup": {
|
||||
"docsLabel": "開啟企業微信設定指南",
|
||||
"officialLabel": "開啟企業微信管理後台",
|
||||
"tryIt": "向企業微信機器人傳送一則測試訊息。",
|
||||
"summary": "企業微信需要管理後台中 AI 機器人的 Bot ID 和 Secret。",
|
||||
"steps": [
|
||||
"在企業微信中建立 AI 機器人並選擇 API 模式。",
|
||||
"將 Bot ID 和 Secret 複製到 nanobot。",
|
||||
"儲存並啟用企業微信,然後傳送一則測試訊息。"
|
||||
],
|
||||
"fields": {
|
||||
"botId": {
|
||||
"label": "Bot ID",
|
||||
"placeholder": "企業微信 Bot ID",
|
||||
"help": "從企業微信 AI 機器人 API 模式頁面複製。"
|
||||
"placeholder": "企業微信 Bot ID"
|
||||
},
|
||||
"secret": {
|
||||
"label": "Secret",
|
||||
"placeholder": "••••••",
|
||||
"help": "請妥善保管企業微信機器人 Secret。"
|
||||
"placeholder": "••••••"
|
||||
},
|
||||
"allowFrom": {
|
||||
"label": "允許的使用者",
|
||||
"placeholder": "使用者 ID,以逗號分隔"
|
||||
},
|
||||
"welcomeMessage": {
|
||||
"label": "歡迎消息"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user