@yeaft/webchat-agent 0.1.809 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.809",
3
+ "version": "0.1.810",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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 variants are handled by the outer loop (result /
1777
- // end_turn semantics). PR #793 removed the `group_handoff`
1778
- // wire event that the frontend used to render a "↪ 已转交给"
1779
- // pill the Route tool chip (rendered from the tool_call
1780
- // envelope already on the wire) is the single source of truth
1781
- // for hand-off UX. If a future feature (notification toast,
1782
- // typing-chain animation, …) needs the structured payload,
1783
- // re-emit a wire event here from `event.detail`.
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':