@xcanwin/manyoyo 6.2.7 → 6.2.8
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/lib/web/frontend/app.js +12 -37
- package/lib/web/frontend/chat-behavior.js +59 -1
- package/lib/web/server.js +13 -6
- package/package.json +1 -1
package/lib/web/frontend/app.js
CHANGED
|
@@ -387,35 +387,6 @@
|
|
|
387
387
|
return status;
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
function buildStructuredTraceResidualLines(message) {
|
|
391
|
-
const lines = String(message && message.content ? message.content : '')
|
|
392
|
-
.split('\n')
|
|
393
|
-
.map(function (line) {
|
|
394
|
-
return String(line || '').trim();
|
|
395
|
-
})
|
|
396
|
-
.filter(Boolean);
|
|
397
|
-
const traceEvents = Array.isArray(message && message.traceEvents) ? message.traceEvents : [];
|
|
398
|
-
const consumed = new Map();
|
|
399
|
-
traceEvents.forEach(function (traceEvent) {
|
|
400
|
-
const key = traceEvent && traceEvent.text ? String(traceEvent.text).trim() : '';
|
|
401
|
-
if (!key) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
consumed.set(key, (consumed.get(key) || 0) + 1);
|
|
405
|
-
});
|
|
406
|
-
return lines.filter(function (line) {
|
|
407
|
-
if (!line || line === '[执行过程]') {
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
const remaining = consumed.get(line) || 0;
|
|
411
|
-
if (remaining > 0) {
|
|
412
|
-
consumed.set(line, remaining - 1);
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
return true;
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
|
|
419
390
|
function resolveTraceTone(traceEvent) {
|
|
420
391
|
const kind = traceEvent && traceEvent.kind ? String(traceEvent.kind) : '';
|
|
421
392
|
if (kind === 'command') return 'command';
|
|
@@ -586,20 +557,24 @@
|
|
|
586
557
|
const container = document.createElement('div');
|
|
587
558
|
container.className = 'trace-structured';
|
|
588
559
|
|
|
560
|
+
const messageId = message && message.id ? message.id : '';
|
|
561
|
+
const pending = Boolean(state.agentRun.active && state.agentRun.traceMessageId === messageId);
|
|
562
|
+
|
|
589
563
|
const flow = document.createElement('div');
|
|
590
564
|
flow.className = 'trace-flow';
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
565
|
+
if (pending) {
|
|
566
|
+
window.ManyoyoChatBehavior.buildStructuredTraceResidualLines(message).forEach(function (line) {
|
|
567
|
+
flow.appendChild(createResidualTraceCard(line));
|
|
568
|
+
});
|
|
569
|
+
}
|
|
594
570
|
const traceEvents = Array.isArray(message && message.traceEvents) ? message.traceEvents : [];
|
|
595
|
-
|
|
571
|
+
const mergedTraceEvents = window.ManyoyoChatBehavior.mergeToolTraceEvents(traceEvents);
|
|
572
|
+
mergedTraceEvents.forEach(function (traceEvent) {
|
|
596
573
|
flow.appendChild(createTraceEventCard(traceEvent));
|
|
597
574
|
});
|
|
598
575
|
|
|
599
|
-
const
|
|
600
|
-
const
|
|
601
|
-
const summaryInfo = window.ManyoyoChatBehavior.summarizeTraceFlow(traceEvents, { pending });
|
|
602
|
-
const hasError = traceEvents.some(function (event) {
|
|
576
|
+
const summaryInfo = window.ManyoyoChatBehavior.summarizeTraceFlow(mergedTraceEvents, { pending });
|
|
577
|
+
const hasError = mergedTraceEvents.some(function (event) {
|
|
603
578
|
return event && event.kind === 'error';
|
|
604
579
|
});
|
|
605
580
|
const defaultOpen = hasError;
|
|
@@ -22,6 +22,62 @@
|
|
|
22
22
|
return trimmed ? `${trimmed} · MANYOYO Web` : 'MANYOYO Web';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function buildStructuredTraceResidualLines(message) {
|
|
26
|
+
const lines = String(message && message.content ? message.content : '')
|
|
27
|
+
.split('\n')
|
|
28
|
+
.map(line => String(line || '').trim())
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
const traceEvents = Array.isArray(message && message.traceEvents) ? message.traceEvents : [];
|
|
31
|
+
const consumed = new Map();
|
|
32
|
+
traceEvents.forEach(traceEvent => {
|
|
33
|
+
const text = traceEvent && traceEvent.text ? String(traceEvent.text) : '';
|
|
34
|
+
if (!text) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
text.split('\n').forEach(subLine => {
|
|
38
|
+
const key = String(subLine || '').trim();
|
|
39
|
+
if (!key) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
consumed.set(key, (consumed.get(key) || 0) + 1);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return lines.filter(line => {
|
|
46
|
+
if (!line || line === '[执行过程]') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const remaining = consumed.get(line) || 0;
|
|
50
|
+
if (remaining > 0) {
|
|
51
|
+
consumed.set(line, remaining - 1);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const MERGEABLE_TRACE_KINDS = new Set(['tool', 'command', 'mcp']);
|
|
59
|
+
|
|
60
|
+
function mergeToolTraceEvents(traceEvents) {
|
|
61
|
+
const events = Array.isArray(traceEvents) ? traceEvents : [];
|
|
62
|
+
const result = [];
|
|
63
|
+
const indexByKey = new Map();
|
|
64
|
+
events.forEach(event => {
|
|
65
|
+
const kind = event && event.kind ? String(event.kind) : '';
|
|
66
|
+
const toolId = event && event.toolId ? String(event.toolId) : '';
|
|
67
|
+
if (MERGEABLE_TRACE_KINDS.has(kind) && toolId) {
|
|
68
|
+
const key = `${kind}:${toolId}`;
|
|
69
|
+
if (indexByKey.has(key)) {
|
|
70
|
+
const index = indexByKey.get(key);
|
|
71
|
+
result[index] = Object.assign({}, result[index], event);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
indexByKey.set(key, result.length);
|
|
75
|
+
}
|
|
76
|
+
result.push(event);
|
|
77
|
+
});
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
25
81
|
function mergeTraceIntoReply(messages) {
|
|
26
82
|
const list = Array.isArray(messages) ? messages : [];
|
|
27
83
|
const result = [];
|
|
@@ -44,6 +100,8 @@
|
|
|
44
100
|
isNearBottom,
|
|
45
101
|
summarizeTraceFlow,
|
|
46
102
|
buildDocumentTitle,
|
|
47
|
-
mergeTraceIntoReply
|
|
103
|
+
mergeTraceIntoReply,
|
|
104
|
+
mergeToolTraceEvents,
|
|
105
|
+
buildStructuredTraceResidualLines
|
|
48
106
|
};
|
|
49
107
|
}());
|
package/lib/web/server.js
CHANGED
|
@@ -1483,6 +1483,7 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1483
1483
|
const mcpServer = pickFirstString(item.server);
|
|
1484
1484
|
const mcpTool = pickFirstString(item.tool);
|
|
1485
1485
|
const itemStatus = pickFirstString(item.status);
|
|
1486
|
+
const toolId = pickFirstString(item.id);
|
|
1486
1487
|
|
|
1487
1488
|
function shortenText(value, maxChars = 140) {
|
|
1488
1489
|
const raw = clipText(stripAnsi(String(value || '')).replace(/\s+/g, ' ').trim(), maxChars);
|
|
@@ -1558,14 +1559,16 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1558
1559
|
return createTraceEvent('tool', `[工具开始] ${toolName || 'tool_call'}`, {
|
|
1559
1560
|
phase: 'started',
|
|
1560
1561
|
status: pickDisplayStatus('in_progress'),
|
|
1561
|
-
toolName: toolName || 'tool_call'
|
|
1562
|
+
toolName: toolName || 'tool_call',
|
|
1563
|
+
toolId
|
|
1562
1564
|
});
|
|
1563
1565
|
}
|
|
1564
1566
|
if (itemType === 'command_execution') {
|
|
1565
1567
|
return createTraceEvent('command', `[命令开始] ${commandText || 'command_execution'}`, {
|
|
1566
1568
|
phase: 'started',
|
|
1567
1569
|
status: pickDisplayStatus('in_progress'),
|
|
1568
|
-
command: commandText || 'command_execution'
|
|
1570
|
+
command: commandText || 'command_execution',
|
|
1571
|
+
toolId
|
|
1569
1572
|
});
|
|
1570
1573
|
}
|
|
1571
1574
|
if (itemType === 'mcp_tool_call') {
|
|
@@ -1583,7 +1586,8 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1583
1586
|
arguments: item.arguments && typeof item.arguments === 'object' && !Array.isArray(item.arguments)
|
|
1584
1587
|
? item.arguments
|
|
1585
1588
|
: null,
|
|
1586
|
-
argumentSummary: summary
|
|
1589
|
+
argumentSummary: summary,
|
|
1590
|
+
toolId
|
|
1587
1591
|
}
|
|
1588
1592
|
);
|
|
1589
1593
|
}
|
|
@@ -1612,7 +1616,8 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1612
1616
|
return createTraceEvent('tool', `[工具完成] ${toolName || 'tool_call'}`, {
|
|
1613
1617
|
phase: 'completed',
|
|
1614
1618
|
status: pickDisplayStatus('completed'),
|
|
1615
|
-
toolName: toolName || 'tool_call'
|
|
1619
|
+
toolName: toolName || 'tool_call',
|
|
1620
|
+
toolId
|
|
1616
1621
|
});
|
|
1617
1622
|
}
|
|
1618
1623
|
if (itemType === 'command_execution') {
|
|
@@ -1622,7 +1627,8 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1622
1627
|
status: pickDisplayStatus(suffix),
|
|
1623
1628
|
command: commandText || 'command_execution',
|
|
1624
1629
|
exitCode: typeof item.exit_code === 'number' ? item.exit_code : null,
|
|
1625
|
-
result: item.aggregated_output !== undefined ? item.aggregated_output : null
|
|
1630
|
+
result: item.aggregated_output !== undefined ? item.aggregated_output : null,
|
|
1631
|
+
toolId
|
|
1626
1632
|
});
|
|
1627
1633
|
}
|
|
1628
1634
|
if (itemType === 'mcp_tool_call') {
|
|
@@ -1642,7 +1648,8 @@ function prepareCodexTraceEvent(payload) {
|
|
|
1642
1648
|
: null,
|
|
1643
1649
|
argumentSummary: summary,
|
|
1644
1650
|
result: item.result !== undefined ? item.result : null,
|
|
1645
|
-
error: item.error !== undefined ? item.error : null
|
|
1651
|
+
error: item.error !== undefined ? item.error : null,
|
|
1652
|
+
toolId
|
|
1646
1653
|
}
|
|
1647
1654
|
);
|
|
1648
1655
|
}
|