为长任务插件接入后台任务模式

1. 为消息插件新增可配置的前台/后台分发模式,并在 robot 主链路中加入独立后台任务池,避免长任务长期占用前台 20 个消息处理槽位。

2. 放宽插件执行超时上限到 1800 秒,支持 200 秒以上长任务,同时保留熔断、统计和异常记录。

3. 为群聊总结和 AI 绘图启用后台执行配置,并将菜单插件默认输出改回文本模式。
This commit is contained in:
Liu
2026-05-01 11:23:52 +08:00
parent 1b6da6db1f
commit 0d1362f97e
7 changed files with 350 additions and 77 deletions

View File

@@ -4,7 +4,7 @@ command = ["菜单", "功能菜单"]
# 菜单输出模式:
# - text发送文本菜单历史行为
# - image先用 md2image 将 Markdown 渲染为图片后发送
output_mode = "image"
output_mode = "text"
# 图片生成失败时是否回退文本菜单:
# - false严格按图片模式不发送完整菜单文本
# - true优先保证可达失败后改发文本

View File

@@ -94,11 +94,14 @@ class RobotMenuPlugin(MessagePluginInterface):
self.sync_send_timeout_seconds = int(
self._config.get("RobotMenu", {}).get("sync_send_timeout_seconds", 18)
)
# 对外层插件保护显式声明一个更合适的总超时
# 1. 内层菜单发送会在 sync_send_timeout_seconds 内决定“成功发图 / 回退文本 / 返回失败提示”
# 2. 外层 wait_for 必须比内层稍长,给降级发送文本留出缓冲;
# 3. 这样可以避免过去“内外层都卡在 55 秒”时,外层先打断,导致降级逻辑来不及执行
self.plugin_process_timeout_seconds = max(12, self.sync_send_timeout_seconds + 8)
# 只有在图片模式下,菜单插件才需要声明更紧的外层超时预算
# 1. 文本模式本身非常快,没有必要覆盖全局默认超时
# 2. 图片模式下才需要给“渲染 + 文本回退”预留一个略大于内层预算的缓冲
# 3. 这样默认文本模式下不会额外引入无意义的超时特化逻辑
if RobotMenuRenderTool.normalize_output_mode(output_mode) == "image":
self.plugin_process_timeout_seconds = max(12, self.sync_send_timeout_seconds + 8)
elif hasattr(self, "plugin_process_timeout_seconds"):
delattr(self, "plugin_process_timeout_seconds")
# 菜单图片模板文件路径(相对仓库根目录):
# 调整样式和布局时只改模板,不改 Python 逻辑。
self.image_template_path = str(