@yeaft/webchat-agent 1.0.23 → 1.0.24

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": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,6 +17,11 @@ export const VALID_STATES = new Set([
17
17
  ]);
18
18
 
19
19
  const RUNNING_STATES = new Set(['typing', 'thinking', 'streaming', 'tool']);
20
+
21
+ export function isVpStatusRunning(state) {
22
+ return RUNNING_STATES.has(state || 'idle');
23
+ }
24
+
20
25
  const STATE_PRIORITY = ['tool', 'streaming', 'thinking', 'typing', 'error', 'idle'];
21
26
  const MAX_RETAINED_THREADS_PER_VP = 20;
22
27
  const COMPLETED_TTL_MS = 30 * 60 * 1000;
@@ -52,7 +57,7 @@ export function createVpStatusBroker({ send, now = Date.now } = {}) {
52
57
  }
53
58
  }
54
59
 
55
- const runningThreadCount = rows.filter(r => RUNNING_STATES.has(r.state)).length;
60
+ const runningThreadCount = rows.filter(r => isVpStatusRunning(r.state)).length;
56
61
  const latest = rows[0] || null;
57
62
  return {
58
63
  sessionId: sessionId || null,
@@ -83,14 +88,14 @@ export function createVpStatusBroker({ send, now = Date.now } = {}) {
83
88
  }
84
89
  const cutoff = now() - COMPLETED_TTL_MS;
85
90
  for (const [key, row] of rows) {
86
- if (RUNNING_STATES.has(row.state)) continue;
91
+ if (isVpStatusRunning(row.state)) continue;
87
92
  if ((row.updatedAt || row.since || 0) < cutoff) threads.delete(key);
88
93
  }
89
94
  const remaining = rows
90
95
  .filter(([key]) => threads.has(key))
91
96
  .sort((a, b) => (b[1].updatedAt || b[1].since || 0) - (a[1].updatedAt || a[1].since || 0));
92
97
  for (const [key, row] of remaining.slice(MAX_RETAINED_THREADS_PER_VP)) {
93
- if (!RUNNING_STATES.has(row.state)) threads.delete(key);
98
+ if (!isVpStatusRunning(row.state)) threads.delete(key);
94
99
  }
95
100
  }
96
101
 
@@ -66,7 +66,7 @@ import { isHiddenConversationRow } from './conversation/internal-control.js';
66
66
  import { sliceLastNTurns } from './turn-utils.js';
67
67
  import { pairSanitize } from './pair-sanitize.js';
68
68
  import { filterSnapshotForVp } from './snapshot-filter.js';
69
- import { createVpStatusBroker } from './vp-status-broker.js';
69
+ import { createVpStatusBroker, isVpStatusRunning } from './vp-status-broker.js';
70
70
  import { classifyThread as defaultClassifyThread, fallbackTitle } from './vp/thread-classifier.js';
71
71
  import { listMcpServers, upsertMcpServer, removeMcpServer } from './config-api.js';
72
72
  import { buildMcpFlattenedTools } from './tools/mcp-tools.js';
@@ -1851,7 +1851,7 @@ function decorateSessionsWithRuntimeState(sessions) {
1851
1851
  const sessionId = status?.sessionId || status?.groupId || null;
1852
1852
  if (!sessionId) continue;
1853
1853
  const state = status.state || 'idle';
1854
- const running = !['idle', 'offline', 'completed', 'failed', 'aborted'].includes(state);
1854
+ const running = isVpStatusRunning(state);
1855
1855
  const updatedAt = status.updatedAt || status.since || Date.now();
1856
1856
  const prev = bySession.get(sessionId) || { running: false, runningVpCount: 0, latestActivityAt: 0 };
1857
1857
  if (running) prev.runningVpCount += 1;
@@ -5296,6 +5296,13 @@ export const __testHooks = {
5296
5296
  vpAborts.clear();
5297
5297
  vpInboxes.clear();
5298
5298
  },
5299
+ resetVpStatusBroker() {
5300
+ if (vpStatusBroker) vpStatusBroker.reset();
5301
+ },
5302
+ seedVpStatus(status) {
5303
+ return getVpStatusBroker().transition(status);
5304
+ },
5305
+ decorateSessionsWithRuntimeState,
5299
5306
  seedQueuedVpTurn({ sessionId = 'session-test', vpId = 'vp-test', threadId = 'main', turnId = 'turn-test' } = {}) {
5300
5307
  const key = threadKey(sessionId, vpId, threadId);
5301
5308
  const inbox = vpInboxes.get(key) || [];