mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-05-20 06:44:46 +02:00
Add files via upload
This commit is contained in:
@@ -2424,11 +2424,8 @@ function renderProcessDetails(messageId, processDetails) {
|
||||
const toolName = data.toolName || (typeof window.t === 'function' ? window.t('chat.unknownTool') : '未知工具');
|
||||
const index = data.index || 0;
|
||||
const total = data.total || 0;
|
||||
const argsHint = typeof window.toolCallArgHint === 'function'
|
||||
? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(data) : {})
|
||||
: '';
|
||||
const callTitle = typeof window.formatToolCallTimelineTitle === 'function'
|
||||
? window.formatToolCallTimelineTitle(toolName, index, total, argsHint)
|
||||
? window.formatToolCallTimelineTitle(toolName, index, total)
|
||||
: (typeof window.t === 'function' ? window.t('chat.callTool', { name: escapeHtml(toolName), index: index, total: total }) : '调用工具: ' + escapeHtml(toolName) + ' (' + index + '/' + total + ')');
|
||||
itemTitle = agPx + '🔧 ' + callTitle;
|
||||
} else if (eventType === 'tool_result') {
|
||||
|
||||
@@ -1592,9 +1592,7 @@ function handleStreamEvent(event, progressElement, progressId,
|
||||
const index = toolInfo.index || 0;
|
||||
const total = toolInfo.total || 0;
|
||||
const toolCallId = toolInfo.toolCallId || null;
|
||||
const toolCallArgs = parseToolCallArgsFromData(toolInfo);
|
||||
const toolCallHint = toolCallArgHint(toolCallArgs);
|
||||
const toolCallTitle = formatToolCallTimelineTitle(toolName, index, total, toolCallHint);
|
||||
const toolCallTitle = formatToolCallTimelineTitle(toolName, index, total);
|
||||
const toolCallItemId = addTimelineItem(timeline, 'tool_call', {
|
||||
title: timelineAgentBracketPrefix(toolInfo) + '🔧 ' + toolCallTitle,
|
||||
message: event.message,
|
||||
@@ -2531,38 +2529,14 @@ function parseToolCallArgsFromData(data) {
|
||||
return args;
|
||||
}
|
||||
|
||||
function toolCallArgHint(args) {
|
||||
if (!args || typeof args !== 'object') return '';
|
||||
const method = args.method != null ? String(args.method).trim().toUpperCase() : '';
|
||||
const url = args.url || args.URL || args.target || args.uri;
|
||||
if (url != null && String(url).trim() !== '') {
|
||||
let s = String(url).trim();
|
||||
if (method) s = method + ' ' + s;
|
||||
return s.length > 56 ? s.slice(0, 53) + '...' : s;
|
||||
}
|
||||
if (method) {
|
||||
return method;
|
||||
}
|
||||
const cmd = args.command || args.cmd || args.script;
|
||||
if (cmd != null && String(cmd).trim() !== '') {
|
||||
const s = String(cmd).trim();
|
||||
return s.length > 48 ? s.slice(0, 45) + '...' : s;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function formatToolCallTimelineTitle(toolName, index, total, argsHint) {
|
||||
function formatToolCallTimelineTitle(toolName, index, total) {
|
||||
const name = toolName || (typeof window.t === 'function' ? window.t('chat.unknownTool') : '未知工具');
|
||||
const idx = index || 0;
|
||||
const tot = total || 0;
|
||||
let base;
|
||||
if (typeof window.t === 'function') {
|
||||
base = window.t('chat.callTool', { name: name, index: idx, total: tot });
|
||||
} else {
|
||||
base = '调用工具: ' + name + (tot ? ' (' + idx + '/' + tot + ')' : '');
|
||||
return window.t('chat.callTool', { name: name, index: idx, total: tot });
|
||||
}
|
||||
const hint = (argsHint && String(argsHint).trim()) ? String(argsHint).trim() : '';
|
||||
return hint ? (base + ' · ' + hint) : base;
|
||||
return '调用工具: ' + name + (tot ? ' (' + idx + '/' + tot + ')' : '');
|
||||
}
|
||||
|
||||
function buildToolResultSectionHtml(data, opts) {
|
||||
@@ -2741,7 +2715,6 @@ window.attachToolResultToCall = attachToolResultToCall;
|
||||
window.mergeToolResultIntoCallItem = mergeToolResultIntoCallItem;
|
||||
window.formatToolCallTimelineTitle = formatToolCallTimelineTitle;
|
||||
window.parseToolCallArgsFromData = parseToolCallArgsFromData;
|
||||
window.toolCallArgHint = toolCallArgHint;
|
||||
window.buildToolResultSectionHtml = buildToolResultSectionHtml;
|
||||
|
||||
// 更新工具调用状态
|
||||
@@ -2810,11 +2783,6 @@ function addTimelineItem(timeline, type, options) {
|
||||
if (d.toolCallId != null && String(d.toolCallId).trim() !== '') {
|
||||
item.dataset.toolCallId = String(d.toolCallId).trim();
|
||||
}
|
||||
const callArgs = parseToolCallArgsFromData(d);
|
||||
const argHint = toolCallArgHint(callArgs);
|
||||
if (argHint) {
|
||||
item.dataset.toolArgHint = argHint;
|
||||
}
|
||||
const merged = options.mergedResult || d._mergedResult;
|
||||
if (merged) {
|
||||
item.dataset.toolResultMerged = '1';
|
||||
@@ -4320,9 +4288,8 @@ function refreshProgressAndTimelineI18n() {
|
||||
const name = (item.dataset.toolName != null && item.dataset.toolName !== '') ? item.dataset.toolName : _t('chat.unknownTool');
|
||||
const index = parseInt(item.dataset.toolIndex, 10) || 0;
|
||||
const total = parseInt(item.dataset.toolTotal, 10) || 0;
|
||||
const hint = item.dataset.toolArgHint || '';
|
||||
const callTitle = typeof formatToolCallTimelineTitle === 'function'
|
||||
? formatToolCallTimelineTitle(name, index, total, hint)
|
||||
? formatToolCallTimelineTitle(name, index, total)
|
||||
: _t('chat.callTool', { name: name, index: index, total: total });
|
||||
titleSpan.textContent = ap + '\uD83D\uDD27 ' + callTitle;
|
||||
} else if (type === 'tool_result' && (item.dataset.toolName !== undefined || item.dataset.toolSuccess !== undefined)) {
|
||||
|
||||
@@ -1666,11 +1666,8 @@ function buildWebshellTimelineItemFromDetail(detail) {
|
||||
var tn = data.toolName || ((typeof window.t === 'function') ? window.t('chat.unknownTool') : '未知工具');
|
||||
var idx = data.index || 0;
|
||||
var total = data.total || 0;
|
||||
var wsHint = typeof window.toolCallArgHint === 'function'
|
||||
? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(data) : {})
|
||||
: '';
|
||||
var wsCallTitle = typeof window.formatToolCallTimelineTitle === 'function'
|
||||
? window.formatToolCallTimelineTitle(tn, idx, total, wsHint)
|
||||
? window.formatToolCallTimelineTitle(tn, idx, total)
|
||||
: ((typeof window.t === 'function') ? window.t('chat.callTool', { name: tn, index: idx, total: total }) : ('调用: ' + tn + (total ? ' (' + idx + '/' + total + ')' : '')));
|
||||
title = ap + '🔧 ' + wsCallTitle;
|
||||
} else if (eventType === 'tool_result') {
|
||||
@@ -3064,11 +3061,8 @@ function runWebshellAiSend(conn, inputEl, sendBtn, messagesContainer) {
|
||||
var tn = _ed.toolName || '未知工具';
|
||||
var idx = _ed.index || 0;
|
||||
var total = _ed.total || 0;
|
||||
var wsHintLive = typeof window.toolCallArgHint === 'function'
|
||||
? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(_ed) : {})
|
||||
: '';
|
||||
var callTitle = typeof window.formatToolCallTimelineTitle === 'function'
|
||||
? window.formatToolCallTimelineTitle(tn, idx, total, wsHintLive)
|
||||
? window.formatToolCallTimelineTitle(tn, idx, total)
|
||||
: (wsTOr('chat.callTool', '') || ('调用工具: ' + tn + (total ? ' (' + idx + '/' + total + ')' : '')));
|
||||
var callItem = appendTimelineItem('tool_call', webshellAgentPx(_ed) + '🔧 ' + callTitle, _em || '', _ed);
|
||||
if (_ed.toolCallId && callItem) {
|
||||
|
||||
Reference in New Issue
Block a user