myagent-ai 1.20.12 → 1.20.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/api_server.py +18 -8
- package/web/ui/chat/flow_engine.js +5 -1
package/package.json
CHANGED
package/web/api_server.py
CHANGED
|
@@ -279,11 +279,12 @@ class ApiServer:
|
|
|
279
279
|
mgr.config.auto_accept = cfg.auto_accept
|
|
280
280
|
logger.info("通信管理器已热更新")
|
|
281
281
|
|
|
282
|
-
def _hot_reload_chat_platforms(self):
|
|
282
|
+
async def _hot_reload_chat_platforms(self):
|
|
283
283
|
"""热更新聊天平台:重新加载所有平台配置到 ChatBotManager
|
|
284
284
|
|
|
285
|
-
[v1.20.7] 修复: 调用 setup_platforms
|
|
285
|
+
[v1.20.7] 修复: 调用 setup_platforms 时会自动停止被禁用的平台并启动新启用的平台。
|
|
286
286
|
[v1.20.9] 修复: chat_manager 为 None 时懒创建,修复首次启用平台不生效的问题。
|
|
287
|
+
[v1.20.12] 改为 async 并补启未运行的 bot,修复首次启用平台后 bot 不启动的问题。
|
|
287
288
|
"""
|
|
288
289
|
if not self.core.chat_manager:
|
|
289
290
|
from chatbot.manager import ChatBotManager
|
|
@@ -291,11 +292,20 @@ class ApiServer:
|
|
|
291
292
|
logger.info("聊天平台管理器已懒创建")
|
|
292
293
|
mgr = self.core.chat_manager
|
|
293
294
|
platform_configs = self.core.config_mgr.config.chat_platforms
|
|
294
|
-
# setup_platforms 会自动对比新旧配置,停止被移除/禁用的 bot,启动新启用的 bot
|
|
295
295
|
handler = mgr._message_handler if hasattr(mgr, '_message_handler') else None
|
|
296
296
|
if not handler and hasattr(self.core, '_handle_chat_message'):
|
|
297
297
|
handler = self.core._handle_chat_message
|
|
298
|
+
if not handler:
|
|
299
|
+
logger.warning("聊天平台消息处理器为 None,平台可能无法处理消息")
|
|
298
300
|
mgr.setup_platforms(platform_configs, handler)
|
|
301
|
+
# [v1.20.12] 补启未运行的 bot
|
|
302
|
+
enabled_keys = [cfg.id or cfg.platform for cfg in platform_configs if cfg.enabled]
|
|
303
|
+
for key in enabled_keys:
|
|
304
|
+
if key in mgr._bots and key not in mgr._bot_tasks:
|
|
305
|
+
bot = mgr._bots.get(key)
|
|
306
|
+
if bot:
|
|
307
|
+
logger.info(f"补启动聊天平台: {key}")
|
|
308
|
+
asyncio.create_task(mgr._run_bot(key, bot), name=f"bot_{key}")
|
|
299
309
|
logger.info("聊天平台配置已热更新")
|
|
300
310
|
|
|
301
311
|
def _setup_routes(self):
|
|
@@ -3711,7 +3721,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3711
3721
|
self.core.config_mgr.config.chat_platforms.append(cp)
|
|
3712
3722
|
self.core.config_mgr.save()
|
|
3713
3723
|
# 热更新聊天平台
|
|
3714
|
-
self._hot_reload_chat_platforms()
|
|
3724
|
+
await self._hot_reload_chat_platforms()
|
|
3715
3725
|
logger.info(f"新增聊天平台: {cp.display_name} (id={cp.id})")
|
|
3716
3726
|
return web.json_response({"ok": True, "id": cp.id, "platform": platform_name, "display_name": cp.display_name, "hot_reload": True})
|
|
3717
3727
|
|
|
@@ -3753,7 +3763,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3753
3763
|
logger.info(f"平台 ID 变更: {old_id} -> {cp.id}")
|
|
3754
3764
|
self.core.config_mgr.save()
|
|
3755
3765
|
# 热更新聊天平台
|
|
3756
|
-
self._hot_reload_chat_platforms()
|
|
3766
|
+
await self._hot_reload_chat_platforms()
|
|
3757
3767
|
logger.info(f"聊天平台配置已更新: {cp.display_name} (id={cp.id})")
|
|
3758
3768
|
return web.json_response({"ok": True, "id": cp.id, "hot_reload": True})
|
|
3759
3769
|
|
|
@@ -3766,7 +3776,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3766
3776
|
platforms.pop(i)
|
|
3767
3777
|
self.core.config_mgr.save()
|
|
3768
3778
|
# 热更新聊天平台
|
|
3769
|
-
self._hot_reload_chat_platforms()
|
|
3779
|
+
await self._hot_reload_chat_platforms()
|
|
3770
3780
|
logger.info(f"已删除聊天平台: {cp.display_name} (id={cp.id})")
|
|
3771
3781
|
return web.json_response({"ok": True, "hot_reload": True})
|
|
3772
3782
|
return web.json_response({"error": f"平台 {name} 不存在"}, status=404)
|
|
@@ -3783,7 +3793,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3783
3793
|
cp.enabled = data.get("enabled", not cp.enabled)
|
|
3784
3794
|
self.core.config_mgr.save()
|
|
3785
3795
|
# 热更新聊天平台
|
|
3786
|
-
self._hot_reload_chat_platforms()
|
|
3796
|
+
await self._hot_reload_chat_platforms()
|
|
3787
3797
|
logger.info(f"聊天平台 {cp.display_name} 已{'启用' if cp.enabled else '禁用'}")
|
|
3788
3798
|
return web.json_response({"ok": True, "enabled": cp.enabled, "id": cp.id, "hot_reload": True})
|
|
3789
3799
|
|
|
@@ -6566,7 +6576,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
6566
6576
|
self._hot_reload_llm()
|
|
6567
6577
|
self._hot_reload_executor()
|
|
6568
6578
|
self._hot_reload_communication()
|
|
6569
|
-
self._hot_reload_chat_platforms()
|
|
6579
|
+
await self._hot_reload_chat_platforms()
|
|
6570
6580
|
|
|
6571
6581
|
logger.info(f"安全保存配置: ok={result.get('ok')}")
|
|
6572
6582
|
return web.json_response(result)
|
|
@@ -1853,9 +1853,13 @@ async function sendMessage(opts) {
|
|
|
1853
1853
|
(evt.content ? evt.content.substring(0, 100) : '');
|
|
1854
1854
|
} else if (evt.type === 'v2_file') {
|
|
1855
1855
|
// [v1.16.17] Agent is sending a file to the user
|
|
1856
|
+
// [v1.20.12] 修复: 后端发送 file_id,前端渲染代码期望 id
|
|
1856
1857
|
if (evt.data) {
|
|
1857
1858
|
if (!state.messages[msgIdx]._files) state.messages[msgIdx]._files = [];
|
|
1858
|
-
|
|
1859
|
+
var fd = evt.data;
|
|
1860
|
+
// 归一化: 后端用 file_id,渲染代码用 id
|
|
1861
|
+
if (fd.file_id && !fd.id) fd.id = fd.file_id;
|
|
1862
|
+
state.messages[msgIdx]._files.push(fd);
|
|
1859
1863
|
throttledStreamUpdate(msgIdx);
|
|
1860
1864
|
}
|
|
1861
1865
|
} else if (evt.type === 'v2_media') {
|