@yeaft/webchat-agent 0.1.808 → 0.1.810
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/unify/web-bridge.js +37 -8
package/package.json
CHANGED
package/unify/web-bridge.js
CHANGED
|
@@ -1653,6 +1653,10 @@ function maybeTransitionVpStatus(hctx, state) {
|
|
|
1653
1653
|
* @param {object} event — engine event (text_delta / tool_call / …)
|
|
1654
1654
|
* @param {{assistantTextParts:string[], toolCallsAccum:Array, toolResultsAccum:Array, thinkingBlocksAccum?:Array, resetQueryTimer:Function, groupId?:string, vpId?:string, turnId?:string}} hctx
|
|
1655
1655
|
*/
|
|
1656
|
+
export function __testHandleEngineEvent(event, hctx) {
|
|
1657
|
+
return handleEngineEvent(event, hctx);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1656
1660
|
function handleEngineEvent(event, hctx) {
|
|
1657
1661
|
hctx.resetQueryTimer();
|
|
1658
1662
|
const envelope = {
|
|
@@ -1773,14 +1777,39 @@ function handleEngineEvent(event, hctx) {
|
|
|
1773
1777
|
break;
|
|
1774
1778
|
|
|
1775
1779
|
case 'turn_end':
|
|
1776
|
-
// turn_end
|
|
1777
|
-
//
|
|
1778
|
-
//
|
|
1779
|
-
//
|
|
1780
|
-
//
|
|
1781
|
-
//
|
|
1782
|
-
|
|
1783
|
-
|
|
1780
|
+
// Most engine turn_end events are internal loop boundaries. A normal
|
|
1781
|
+
// tool_use stop means "run tools, then call the adapter again", so it
|
|
1782
|
+
// must NOT end the VP's visible turn. route_forward is different: the
|
|
1783
|
+
// tool has handed control to another VP and Engine.query will not
|
|
1784
|
+
// stream more text for this VP. Settle the current VP immediately so
|
|
1785
|
+
// the roster row does not sit on "thinking" until later result cleanup.
|
|
1786
|
+
if (event.stopReason === 'tool_handoff' && event.detail?.kind === 'route_forward') {
|
|
1787
|
+
try {
|
|
1788
|
+
if (hctx.thread) {
|
|
1789
|
+
hctx.thread.status = 'idle';
|
|
1790
|
+
hctx.thread.updatedAt = Date.now();
|
|
1791
|
+
}
|
|
1792
|
+
getVpStatusBroker().settleIdle({
|
|
1793
|
+
groupId: hctx.groupId || null,
|
|
1794
|
+
vpId: hctx.vpId,
|
|
1795
|
+
threadId: hctx.threadId || 'main',
|
|
1796
|
+
title: hctx.thread?.title || '',
|
|
1797
|
+
messageCount: hctx.thread?.messageIds?.length || 0,
|
|
1798
|
+
});
|
|
1799
|
+
} catch (err) {
|
|
1800
|
+
console.warn('[Unify] vp-status settleIdle (route_forward) failed:', err?.message || err);
|
|
1801
|
+
}
|
|
1802
|
+
sendUnifyEvent({
|
|
1803
|
+
type: 'vp_turn_end',
|
|
1804
|
+
groupId: hctx.groupId,
|
|
1805
|
+
vpId: hctx.vpId,
|
|
1806
|
+
threadId: hctx.threadId || event.threadId || 'main',
|
|
1807
|
+
turnId: hctx.turnId,
|
|
1808
|
+
stopReason: event.stopReason,
|
|
1809
|
+
detail: event.detail || null,
|
|
1810
|
+
ts: Date.now(),
|
|
1811
|
+
}, envelope);
|
|
1812
|
+
}
|
|
1784
1813
|
break;
|
|
1785
1814
|
|
|
1786
1815
|
case 'usage':
|