@yeaft/webchat-agent 1.0.212 → 1.0.214

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.
@@ -1176,12 +1176,15 @@ function isPersistedInternalMessage(m) {
1176
1176
  * @param {object} m — record from conversationStore.loadRecent*()
1177
1177
  * @returns {object|null} history-shape entry, or null to skip
1178
1178
  */
1179
- function projectPersistedToHistoryEntry(m) {
1179
+ function projectPersistedToHistoryEntry(m, { includeReflections = false } = {}) {
1180
1180
  if (!m) return null;
1181
1181
  if (m.role !== 'user' && m.role !== 'assistant' && m.role !== 'tool') return null;
1182
- if (isPersistedInternalMessage(m)) return null;
1182
+ if (isPersistedInternalMessage(m) && !(includeReflections && m._reflection === true)) return null;
1183
1183
  const entry = { role: m.role, content: m.role === 'tool' ? m.content : __testNormalizePersistedVisibleContent(m.content) };
1184
- if (m.id) entry.id = m.id;
1184
+ if (m.id) {
1185
+ entry.id = m.id;
1186
+ entry._persistedMessageId = m.id;
1187
+ }
1185
1188
  entry.threadId = m.threadId || m.turnId || 'main';
1186
1189
  if (m.turnId) entry.turnId = m.turnId;
1187
1190
  if (m.imageAssetAnchor) entry.imageAssetAnchor = true;
@@ -1441,14 +1444,18 @@ function hydrateGroupHistory(sessionId) {
1441
1444
  if (!session?.conversationStore || !sessionId) return [];
1442
1445
  let recent;
1443
1446
  try {
1444
- recent = session.conversationStore.loadRecentBySession(sessionId);
1447
+ recent = session.conversationStore.loadRecentBySession(
1448
+ sessionId,
1449
+ undefined,
1450
+ { includeReflections: true },
1451
+ );
1445
1452
  } catch (err) {
1446
1453
  console.warn('[Yeaft] hydrateGroupHistory failed (sessionId=%s):', sessionId, err?.message || err);
1447
1454
  return [];
1448
1455
  }
1449
1456
  const out = [];
1450
1457
  for (const m of recent || []) {
1451
- const entry = projectPersistedToHistoryEntry(m);
1458
+ const entry = projectPersistedToHistoryEntry(m, { includeReflections: true });
1452
1459
  if (entry) out.push(entry);
1453
1460
  }
1454
1461
  return out;
@@ -5079,7 +5086,7 @@ async function runVpTurn({ prompt, promptParts = null, sessionId, vpId, threadId
5079
5086
  vpTurnId: turnId,
5080
5087
  drainPendingUserMessages: () => {
5081
5088
  if (!thread || !Array.isArray(thread.pendingQueries) || thread.pendingQueries.length === 0) return [];
5082
- return thread.pendingQueries.splice(0);
5089
+ return thread.pendingQueries.splice(0).map(item => ({ ...item, persisted: true }));
5083
5090
  },
5084
5091
  ...queryOpts,
5085
5092
  })) {