From b9bf8f62d4cec6658459a394edfd28ef3f1c8340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Wed, 20 May 2026 17:48:42 +0800 Subject: [PATCH] Add files via upload --- web/static/i18n/en-US.json | 4 ++-- web/static/i18n/zh-CN.json | 4 ++-- web/static/js/chat.js | 26 +++++++++++++++++++++++ web/static/js/monitor.js | 1 + web/static/js/settings.js | 43 ++++++++++++++++++++++++++++++++------ web/templates/index.html | 15 +++++++------ 6 files changed, 77 insertions(+), 16 deletions(-) diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json index 0cf458e7..4b92fc12 100644 --- a/web/static/i18n/en-US.json +++ b/web/static/i18n/en-US.json @@ -1690,8 +1690,8 @@ "multiAgentPeLoop": "plan_execute outer loop limit", "multiAgentPeLoopPlaceholder": "0 uses Eino default (10)", "multiAgentPeLoopHint": "Only for plan_execute; max execute↔replan rounds.", - "multiAgentRobotUse": "Use multi-agent for WeCom / DingTalk / Lark bots", - "multiAgentRobotUseHint": "Requires 'Enable multi-agent' to be checked; usage and cost will be higher.", + "multiAgentRobotMode": "Default conversation mode for bots", + "multiAgentRobotModeHint": "Execution mode for WeCom / DingTalk / Lark bot messages. Deep / Plan-Execute / Supervisor require multi-agent to be enabled.", "multiAgentBatchUse": "Use multi-agent for batch task queues", "multiAgentBatchUseHint": "When enabled, each sub-task executed by queue in Task Management will run through Eino DeepAgent (requires multi-agent).", "enableKnowledge": "Enable knowledge retrieval", diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json index 556bd3a7..d6910e8b 100644 --- a/web/static/i18n/zh-CN.json +++ b/web/static/i18n/zh-CN.json @@ -1679,8 +1679,8 @@ "multiAgentPeLoop": "plan_execute 外层循环上限", "multiAgentPeLoopPlaceholder": "0 表示 Eino 默认 10", "multiAgentPeLoopHint": "仅 plan_execute 有效;execute 与 replan 之间的最大轮次。", - "multiAgentRobotUse": "企业微信 / 钉钉 / 飞书机器人也使用多代理", - "multiAgentRobotUseHint": "需同时勾选「启用多代理」;调用量与成本更高。", + "multiAgentRobotMode": "机器人默认对话模式", + "multiAgentRobotModeHint": "企业微信 / 钉钉 / 飞书机器人每条消息使用的执行模式;Deep / Plan-Execute / Supervisor 需启用多代理。", "multiAgentBatchUse": "批量任务队列也使用多代理", "multiAgentBatchUseHint": "开启后,任务管理中按队列执行的每个子任务将走 Eino DeepAgent(需启用多代理)。", "enableKnowledge": "启用知识检索功能", diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 8fcb357b..ddf15c4a 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -3064,6 +3064,27 @@ function getConversationGroup(dateObj, todayStart, sevenDaysCutoff, yesterdaySta } // 加载对话 +/** 轻量加载会话后,拉取最后一条助手消息的 process_details(机器人等无 SSE 场景) */ +async function prefetchLastAssistantProcessDetails() { + const nodes = document.querySelectorAll('#chat-messages .message.assistant'); + if (!nodes.length) return; + const last = nodes[nodes.length - 1]; + if (!last || !last.id) return; + const container = document.getElementById('process-details-' + last.id); + if (!container || container.dataset.lazyNotLoaded !== '1') return; + const backendId = last.dataset && last.dataset.backendMessageId; + if (!backendId || typeof apiFetch !== 'function') return; + const res = await apiFetch('/api/messages/' + encodeURIComponent(String(backendId)) + '/process-details'); + const j = await res.json().catch(() => ({})); + if (!res.ok || !Array.isArray(j.processDetails) || j.processDetails.length === 0) return; + if (typeof renderProcessDetails === 'function') { + renderProcessDetails(last.id, j.processDetails); + } + if (typeof window.expandProcessDetailsTimeline === 'function') { + window.expandProcessDetailsTimeline(last.id); + } +} + async function loadConversation(conversationId) { const seq = ++loadConversationRequestSeq; try { @@ -3283,6 +3304,11 @@ async function loadConversation(conversationId) { .catch((e) => { console.warn('attachRunningTaskEventStream on loadConversation failed', e); }); + } else if (seq === loadConversationRequestSeq && currentConversationId === conversationId) { + // 机器人等非 Web 流式来源:会话已结束或未注册任务时,按需拉取最后一条助手消息的过程详情 + prefetchLastAssistantProcessDetails().catch((e) => { + console.warn('prefetchLastAssistantProcessDetails failed', e); + }); } } catch (error) { console.error('加载对话失败:', error); diff --git a/web/static/js/monitor.js b/web/static/js/monitor.js index 5d121883..0ff3199a 100644 --- a/web/static/js/monitor.js +++ b/web/static/js/monitor.js @@ -2511,6 +2511,7 @@ async function attachRunningTaskEventStream(conversationId) { window.attachRunningTaskEventStream = attachRunningTaskEventStream; window.taskReplayProgressId = taskReplayProgressId; +window.expandProcessDetailsTimeline = expandProcessDetailsTimeline; /** 从工具参数提取短摘要(URL/命令等),便于同名工具批量调用时区分 */ function parseToolCallArgsFromData(data) { diff --git a/web/static/js/settings.js b/web/static/js/settings.js index aea5be88..06f221b1 100644 --- a/web/static/js/settings.js +++ b/web/static/js/settings.js @@ -31,6 +31,19 @@ let toolsPagination = { let c2NavSyncedOnce = false; +/** 根据是否启用多代理,禁用/启用机器人模式中的 Eino 编排选项 */ +function syncRobotAgentModeSelectOptions(multiEnabled) { + const sel = document.getElementById('multi-agent-robot-mode'); + if (!sel) return; + ['deep', 'plan_execute', 'supervisor'].forEach(function (v) { + const opt = sel.querySelector('option[value="' + v + '"]'); + if (opt) opt.disabled = !multiEnabled; + }); + if (!multiEnabled && ['deep', 'plan_execute', 'supervisor'].indexOf(sel.value) >= 0) { + sel.value = 'react'; + } +} + /** 首次进入仪表盘等页面前拉一次配置,隐藏侧栏 C2(避免禁用后仍显示) */ window.syncC2NavOnceFromServer = async function syncC2NavOnceFromServer() { if (c2NavSyncedOnce || typeof apiFetch === 'undefined') { @@ -198,14 +211,27 @@ async function loadConfig(loadTools = true) { const ma = currentConfig.multi_agent || {}; const maEn = document.getElementById('multi-agent-enabled'); - if (maEn) maEn.checked = ma.enabled === true; + if (maEn) { + maEn.checked = ma.enabled === true; + if (!maEn.dataset.robotModeBound) { + maEn.dataset.robotModeBound = '1'; + maEn.addEventListener('change', function () { + syncRobotAgentModeSelectOptions(maEn.checked); + }); + } + } const maPeLoop = document.getElementById('multi-agent-pe-loop'); if (maPeLoop) { const v = ma.plan_execute_loop_max_iterations; maPeLoop.value = (v !== undefined && v !== null && !Number.isNaN(Number(v))) ? String(Number(v)) : '0'; } - const maRobot = document.getElementById('multi-agent-robot-use'); - if (maRobot) maRobot.checked = ma.robot_use_multi_agent === true; + const maRobotMode = document.getElementById('multi-agent-robot-mode'); + if (maRobotMode) { + let mode = (ma.robot_default_agent_mode || 'react').trim().toLowerCase(); + if (mode === 'single') mode = 'react'; + maRobotMode.value = mode; + syncRobotAgentModeSelectOptions(ma.enabled === true); + } // 填充知识库配置 const knowledgeEnabledCheckbox = document.getElementById('knowledge-enabled'); @@ -1133,9 +1159,14 @@ async function applySettings() { const peRaw = document.getElementById('multi-agent-pe-loop')?.value; const peParsed = parseInt(peRaw, 10); const peLoop = Number.isNaN(peParsed) ? 0 : Math.max(0, peParsed); + const maEnabled = document.getElementById('multi-agent-enabled')?.checked === true; + let robotMode = document.getElementById('multi-agent-robot-mode')?.value || 'react'; + if (!maEnabled && ['deep', 'plan_execute', 'supervisor'].indexOf(robotMode) >= 0) { + robotMode = 'react'; + } return { - enabled: document.getElementById('multi-agent-enabled')?.checked === true, - robot_use_multi_agent: document.getElementById('multi-agent-robot-use')?.checked === true, + enabled: maEnabled, + robot_default_agent_mode: robotMode, batch_use_multi_agent: currentConfig?.multi_agent?.batch_use_multi_agent === true, plan_execute_loop_max_iterations: peLoop }; @@ -1384,7 +1415,7 @@ async function saveToolsConfig() { agent: currentConfig.agent || {}, multi_agent: { enabled: currentConfig?.multi_agent?.enabled === true, - robot_use_multi_agent: currentConfig?.multi_agent?.robot_use_multi_agent === true, + robot_default_agent_mode: currentConfig?.multi_agent?.robot_default_agent_mode || 'react', batch_use_multi_agent: currentConfig?.multi_agent?.batch_use_multi_agent === true, plan_execute_loop_max_iterations: Number(currentConfig?.multi_agent?.plan_execute_loop_max_iterations || 0), tool_search_always_visible_tools: Array.from(alwaysVisibleToolNames).filter(name => !alwaysVisibleBuiltinToolNames.has(name)) diff --git a/web/templates/index.html b/web/templates/index.html index 41916a23..5b65e8fb 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -2144,12 +2144,15 @@ 仅 orchestration=plan_execute 时有效;execute 与 replan 之间的最大轮次。