@yeaft/webchat-agent 0.1.785 → 0.1.787

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.785",
3
+ "version": "0.1.787",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -8,7 +8,8 @@
8
8
  * enumerateGroups() via opts.listGroups()
9
9
  * ↓
10
10
  * for each group with newCount ≥ MIN_NEW_PER_GROUP (auto)
11
- * or > 0 (manual):
11
+ * or > 0 (manual)
12
+ * or prior messages in a scoped manual group rerun:
12
13
  * loadDiff() via opts.loadGroupDiff(groupId, sinceId)
13
14
  * applyOverlap() via opts.loadOverlapPreamble(...)
14
15
  * segment() segmentDiff(...)
@@ -55,7 +56,7 @@ import { tsForBackup, pruneOldSnapshots } from './snapshot.js';
55
56
  * @typedef {Object} RunDreamOpts
56
57
  * @property {string} root — memory root, e.g. ~/.yeaft/memory
57
58
  * @property {boolean} [manual=false] — manual trigger overrides newCount<20 skip
58
- * @property {string[]} [scopeFilter] — optional: only dream these targets (still respects newCount per group; '*' allowed)
59
+ * @property {string[]} [scopeFilter] — optional: only dream these targets; scoped manual group triggers rerun the current group when there are prior messages but no new cursor delta ('*' allowed)
59
60
  * @property {(req: {pass:string, prompt:string, system:string}) => Promise<string>} llm
60
61
  * @property {() => Promise<Array<string>>} listGroups — return all group ids (incl. '_no-group')
61
62
  * @property {(groupId: string) => Promise<number>} countMessages — total message count for a group
@@ -112,7 +113,13 @@ export async function runDream(opts) {
112
113
  const beforeCount = await safeCall(() => opts.countMessages(groupId), 0);
113
114
  const newCount = Math.max(0, beforeCount - (state.messageCount || 0));
114
115
 
115
- if (newCount === 0) {
116
+ const rerunScopedManual = !!opts.manual
117
+ && groupFilter
118
+ && groupFilter.has(groupId)
119
+ && newCount === 0
120
+ && beforeCount > 0;
121
+
122
+ if (newCount === 0 && !rerunScopedManual) {
116
123
  groupsReport.push({ groupId, new: 0, status: 'skipped', reason: 'no-new-messages' });
117
124
  continue;
118
125
  }
@@ -122,12 +129,13 @@ export async function runDream(opts) {
122
129
  }
123
130
 
124
131
  onProgress({ phase: 'load-diff', groupId });
125
- const diffNew = await safeCall(() => opts.loadGroupDiff(groupId, state.lastDreamMessageId), []);
132
+ const diffCursor = rerunScopedManual ? null : state.lastDreamMessageId;
133
+ const diffNew = await safeCall(() => opts.loadGroupDiff(groupId, diffCursor), []);
126
134
  if (!diffNew || diffNew.length === 0) {
127
135
  groupsReport.push({ groupId, new: newCount, status: 'skipped', reason: 'empty-diff' });
128
136
  continue;
129
137
  }
130
- const overlapMessages = state.lastDreamMessageId
138
+ const overlapMessages = state.lastDreamMessageId && !rerunScopedManual
131
139
  ? await safeCall(
132
140
  () => opts.loadOverlapPreamble
133
141
  ? opts.loadOverlapPreamble(groupId, state.lastDreamMessageId, limits.DREAM_OVERLAP)
@@ -171,7 +179,7 @@ export async function runDream(opts) {
171
179
 
172
180
  const tailId = lastMessageId(diffNew);
173
181
  processedGroups.push({ groupId, tailId, beforeCount, newCount, segments: segments.length, actions: actions.length });
174
- groupsReport.push({ groupId, new: newCount, segments: segments.length, actions: actions.length, status: 'triaged' });
182
+ groupsReport.push({ groupId, new: newCount, segments: segments.length, actions: actions.length, status: 'triaged', rerun: rerunScopedManual || undefined });
175
183
  }
176
184
 
177
185
  // 3. merge