feat(wecom): 数字员工与企业设置页新增批量删除工具功能,修复企微 Webhook 配置,企业微信多账号支持与智能机器人短链接修复。#277
feat(wecom): 数字员工与企业设置页新增批量删除工具功能,修复企微 Webhook 配置,企业微信多账号支持与智能机器人短链接修复。#277ThomasOscar wants to merge 15 commits intodataelement:mainfrom
Conversation
- 新增 DELETE /api/tools/agent-tools/bulk API,支持批量删除 Agent 工具分配 - 添加 admin/super_admin 角色权限验证和租户隔离检查 - 实现部分失败处理机制,返回 deleted 数量和 errors 数组 - 添加请求数量限制(最多50条),防止滥用 - 添加操作日志记录,含时间戳便于审计追踪 - 前端 AgentDetail.tsx 添加批量选择 UI 和确认弹窗 - 前端 EnterpriseSettings.tsx 添加批量删除 UI - 新增国际化翻译 keys
问题: - 配置Webhook模式后仍显示WebSocket连接状态 - Webhook URL无法正确显示 解决方案: - 后端:优先使用前端指定的connection_mode,避免自动检测错误 - 后端:添加消息发送结果日志,便于调试 - 前端:添加Webhook模式状态显示 - 前端:优雅处理Webhook URL获取失败 - 前端:确保查询失效完成再重置表单 测试: - WebSocket模式:使用Bot ID + Secret配置,显示WebSocket状态 - Webhook模式:使用CorpID + Secret + Token + EncodingAESKey配置,显示Webhook URL
|
Thanks for the PR! The WeCom webhook fix looks good, but the bulk delete feature has several issues that need to be resolved before we can merge. Required Fixes1. Wrong role names — bulk delete endpoint returns 403 for all valid adminsThe permission check uses role names that don't exist in our system: # Current (broken) — these roles don't exist
if current_user.role not in ("admin", "super_admin"):
...
if current_user.role != "super_admin" and ...:
...Our platform uses if current_user.role not in ("org_admin", "platform_admin"):
...
if current_user.role != "platform_admin" and ...:
...2. Async lazy-loading crash (
|
|
感谢您反馈问题,我现在去解决这些问题。 |
## 修改内容 ### 1. 修复角色名称 - 将 "admin", "super_admin" 改为 "org_admin", "platform_admin" - 原代码会导致所有合法管理员收到 403 错误 ### 2. 修复 N+1 查询和 MissingGreenlet 问题 - 将循环逐个查询改为单次 JOIN 查询 - 一次性获取 AgentTool 和 Agent,避免懒加载崩溃 ### 3. 添加英文翻译 - 补充 en.json 中批量删除功能的翻译 - 包含 agent.tools 和 enterprise.tools 命名空间 ### 4. 将 Emoji 替换为 Tabler 图标 - 将 🗑️、🤖、🔌 替换为 IconTrash、IconRobot、IconPlug - 遵循项目使用 Tabler 图标的规范 ## 为什么使用 JOIN 而非 selectinload? 审核者建议使用 selectinload(AgentTool.agent),但 AgentTool 模型 未定义 "agent" relationship。我们选择 JOIN 查询而非添加 relationship,原因如下: 1. 最小改动原则 - 无需修改数据模型 2. 项目中已有 JOIN 用法(如 list_agent_installed_tools 函数) 3. 避免添加 relationship 可能带来的副作用
合并上游的 A2A (Agent-to-Agent) 会话发送者标签显示逻辑: - 引入 showSenderLabel 和 resolvedAvatarText 变量 - 保留 IconRobot 图标替换 emoji 的改进 - 在 Agent 对话中正确区分 "本 Agent" 和 "其他参与者" 关键变更: - ChatMessageItem 组件新增 thisAgentName 参数 - 当发送者不是当前 Agent 时显示发送者标签 - 头像文字根据发送者身份动态计算
合并上游对 ChatMessageItem 组件的重构: - 使用 senderLabel, avatarText, forceSenderLabel 参数替代 thisAgentName - 组件内部逻辑简化,由调用方计算标签和头像文字 - 保留 IconRobot 图标替换 emoji 的改进 关键变更: - ChatMessageItem 组件参数更新为上游格式 - 在 A2A 会话中正确传递 senderLabel 和 forceSenderLabel - 普通聊天会话使用默认参数值
保留 IconRobot 图标替换 emoji 的改进,同时使用上游一致的变量命名
解决合并冲突: 1. 保留 IconRobot 图标(遵循项目不使用 emoji 的规范) 2. 合并上游的 isHumanReadonly 逻辑,支持人类只读会话 3. 统一处理 A2A 和人类只读两种场景的发送者标签显示 关键变更: - showSenderLabel 使用 IconRobot 图标显示发送者名称 - senderLabel 和 avatarText 参数支持两种场景 - forceSenderLabel 合并两种条件
移除合并冲突遗留的重复代码: - 删除重复的 resolvedAvatarText/resolvedSenderLabel/showSenderLabel 声明 - 修复 useMemo 依赖数组引用未定义变量的问题
我已经按照您的要求修改了代码,你看看还有没有问题。 |
- Change port from 3008 to 3030 - Add allowedHosts for localhost and clawith.yunxmao.com - Fix proxy target from localhost:8008 to backend:8000 (Docker network)
## Features - Add WeCom multi-account support with three communication modes: - 智能机器人-长连接 (WebSocket) - 智能机器人-短链接 (Webhook) - 企业应用 (Webhook) - Add WeComAccountManager component for account management - Add test button for bot webhook mode to generate URL before verification ## Bug Fixes - Fix bot webhook reply: use response_url for active reply instead of passive reply - Fix message format parsing: support both JSON and XML formats - Fix encrypted response for bot webhook callbacks ## Changes - backend/app/api/wecom.py: - Add response_url extraction and active reply mechanism - Add dual format parsing (JSON/XML) - Add multi-account webhook handlers - backend/app/services/wecom_stream.py: add multi-account WebSocket support - frontend/src/components/WeComAccountManager.tsx: new multi-account UI - frontend/src/pages/AgentCreate.tsx: integrate multi-account config
- Add WeComAccountManager component integration for multi-account support - Initialize wecomAccounts state from backend config - Replace old wecom UI with new multi-account manager - Exclude wecom from generic webhook URL display
## Bug Fixes - Fix bot webhook URL verification: add URL decode for parameters - Fix "保存并生成 URL" button to actually save config to backend - Fix signature verification by properly decoding URL-encoded parameters ## UI Improvements - Remove alert/confirm dialogs, use ConfirmModal component instead - Hide "配置说明" and "Edit/Disconnect" buttons for WeCom (using WeComAccountManager) - All modes now close modal after save (removed special handling for bot_webhook) ## Changes - backend/app/api/wecom.py: add URL decode for verification parameters, improve logging - frontend/src/components/WeComAccountManager.tsx: - Add ConfirmModal for delete confirmation - Save config to backend in handleTestWebhook - Simplify handleSave to close modal for all modes - frontend/src/components/ChannelConfig.tsx: hide legacy UI elements for WeCom
- Add wecomMultiAccount translation keys to zh.json - Add corresponding English translations to en.json - Fixes issue: Missing English translations
任务概览
功能一:智能体工具的批量删除
DELETE /api/tools/agent-tools/bulk)功能二:企业微信 Webhook 配置修复
connection_mode(连接模式)。企业微信多账号支持,支持三种通信模式新增功能
WeComAccountManager组件管理多账号Bug修复
response_url主动回复(markdown格式)UI改进
ConfirmModal组件替代原生alert/confirm弹窗i18n
wecomMultiAccount文件变更:数字员工与企业设置页新增批量删除工具功能
backend/app/api/tools.py- 实现批量删除接口frontend/src/pages/AgentDetail.tsx- 数字员工页面的批量删除 UIfrontend/src/pages/EnterpriseSettings.tsx- 企业设置页面的批量删除 UIfrontend/src/i18n/zh.json- 中文翻译文案backend/app/api/wecom.py- 优化连接模式的优先级逻辑frontend/src/components/ChannelConfig.tsx- Webhook 状态显示组件文件变更:企业微信多账号支持,支持三种通信模式
backend/app/api/wecom.py- URL验证、消息处理、签名验证backend/app/services/wecom_stream.py- 多账号WebSocket支持frontend/src/components/WeComAccountManager.tsx- 新增多账号管理组件frontend/src/components/ChannelConfig.tsx- 集成新组件frontend/src/pages/AgentCreate.tsx- 创建页面集成frontend/src/i18n/zh.json- 中文翻译frontend/src/i18n/en.json- 英文翻译智能体工具批量删除测试
企业微信多账号支持,支持三种通信模式测试