@yeaft/webchat-agent 0.1.601 → 0.1.603
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/memory/dream-scheduler.js +32 -0
- package/unify/web-bridge.js +43 -6
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { dreamShard } from './dream-shard.js';
|
|
25
25
|
import { checkRecompression } from './recompression.js';
|
|
26
26
|
import { runUserDreamJob } from './user-memory-store.js';
|
|
27
|
+
import { runDreamTick } from '../dream-v2/tick.js';
|
|
27
28
|
|
|
28
29
|
/** Default idle timeout before dream triggers (ms). */
|
|
29
30
|
export const DREAM_IDLE_MS = 30 * 60 * 1000; // 30 min
|
|
@@ -158,6 +159,37 @@ export function createDreamScheduler(opts = {}) {
|
|
|
158
159
|
// Non-fatal
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
// Phase 8 PR-F: dream-v2 diff-gated scope-summary refresh
|
|
163
|
+
// (DESIGN.md §9.14). The legacy dreamShard pipeline above
|
|
164
|
+
// refreshed shard summaries; this final tick walks the scope
|
|
165
|
+
// tree (user/group/vp/task), computes per-scope sigs, and only
|
|
166
|
+
// re-runs the refresh hook for scopes whose content changed.
|
|
167
|
+
// Refresh-only in v1 (no prune/demote — DESIGN §8 line 395).
|
|
168
|
+
if (memoryDir) {
|
|
169
|
+
try {
|
|
170
|
+
const scopes = [{ kind: 'user', scopeDir: 'user' }];
|
|
171
|
+
if (group?.id) scopes.push({ kind: 'group', id: group.id, scopeDir: `groups/${group.id}` });
|
|
172
|
+
const tickResult = await runDreamTick({
|
|
173
|
+
root: memoryDir,
|
|
174
|
+
scopes,
|
|
175
|
+
refresh: async (_scope) => {
|
|
176
|
+
// v1 refresh hook: no-op placeholder. The actual scope
|
|
177
|
+
// summary refresh continues to flow through the legacy
|
|
178
|
+
// shard / user-dream paths above; this tick only
|
|
179
|
+
// exercises the diff-gate + cursor write so future hook
|
|
180
|
+
// implementations can plug in without re-wiring.
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
result.dreamV2Tick = {
|
|
184
|
+
ran: tickResult.ran.length,
|
|
185
|
+
skipped: tickResult.skipped.length,
|
|
186
|
+
errors: tickResult.errors.length,
|
|
187
|
+
};
|
|
188
|
+
} catch {
|
|
189
|
+
// Non-fatal
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
161
193
|
messagesSinceLastDream = 0;
|
|
162
194
|
lastDreamAt = Date.now();
|
|
163
195
|
onDreamEnd?.(vpId, { ...result, trigger });
|
package/unify/web-bridge.js
CHANGED
|
@@ -28,6 +28,7 @@ import ctx from '../context.js';
|
|
|
28
28
|
import { getThreadStore, MAIN_THREAD_ID } from './threads/store.js';
|
|
29
29
|
import { handleVpSubscribe } from './vp/vp-bridge.js';
|
|
30
30
|
import { createVp, updateVp, deleteVp, readVp, VpCrudError } from './vp/vp-crud.js';
|
|
31
|
+
import { scanVpLibrary } from './vp/vp-store.js';
|
|
31
32
|
import { createRouter } from './routing/router.js';
|
|
32
33
|
import { handleUnifyTaskMessage as _handleUnifyTaskMessage } from './task-message.js';
|
|
33
34
|
import {
|
|
@@ -1256,18 +1257,54 @@ export async function handleUnifyGroupChat(msg) {
|
|
|
1256
1257
|
* Returns `undefined` when we have nothing to inject — keeps the legacy
|
|
1257
1258
|
* single-agent path identical to before.
|
|
1258
1259
|
*/
|
|
1259
|
-
function buildVpQueryOpts({ vpId, groupCoordinator, groupId }) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1260
|
+
export function buildVpQueryOpts({ vpId, groupCoordinator, groupId }) {
|
|
1261
|
+
// PR-G fix (Option A): when no vpId is supplied, resolve a default so the
|
|
1262
|
+
// engine still receives a vpPersona and the system prompt speaks as the
|
|
1263
|
+
// VP — not as legacy Yeaft. Resolution order:
|
|
1264
|
+
// 1. caller-supplied vpId (group/coordinator dispatch)
|
|
1265
|
+
// 2. open group's defaultVpId (`groupCoordinator.group.getMeta()`)
|
|
1266
|
+
// 3. session config `defaultVpId` (~/.yeaft/config.json)
|
|
1267
|
+
// 4. first VP in the local library (scanVpLibrary)
|
|
1268
|
+
// Cold-start (empty library) returns undefined — engine then falls back
|
|
1269
|
+
// to the legacy Yeaft identity, which is the intentional baseline only
|
|
1270
|
+
// when no VP is available at all.
|
|
1271
|
+
let resolvedVpId = vpId;
|
|
1272
|
+
if (!resolvedVpId) {
|
|
1273
|
+
try {
|
|
1274
|
+
const meta = groupCoordinator && groupCoordinator.group
|
|
1275
|
+
&& typeof groupCoordinator.group.getMeta === 'function'
|
|
1276
|
+
? groupCoordinator.group.getMeta() : null;
|
|
1277
|
+
if (meta && typeof meta.defaultVpId === 'string' && meta.defaultVpId) {
|
|
1278
|
+
resolvedVpId = meta.defaultVpId;
|
|
1279
|
+
}
|
|
1280
|
+
} catch { /* coordinator inspection is best-effort */ }
|
|
1281
|
+
}
|
|
1282
|
+
if (!resolvedVpId) {
|
|
1283
|
+
const cfgDefault = session?.config?.defaultVpId;
|
|
1284
|
+
if (typeof cfgDefault === 'string' && cfgDefault.trim()) {
|
|
1285
|
+
resolvedVpId = cfgDefault.trim();
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
if (!resolvedVpId) {
|
|
1289
|
+
try {
|
|
1290
|
+
const lib = scanVpLibrary();
|
|
1291
|
+
if (Array.isArray(lib) && lib.length > 0 && lib[0].vpId) {
|
|
1292
|
+
resolvedVpId = lib[0].vpId;
|
|
1293
|
+
}
|
|
1294
|
+
} catch { /* library scan is best-effort */ }
|
|
1295
|
+
}
|
|
1296
|
+
if (!resolvedVpId) return undefined;
|
|
1297
|
+
|
|
1298
|
+
const out = { senderVpId: resolvedVpId };
|
|
1262
1299
|
if (typeof groupId === 'string' && groupId.trim()) {
|
|
1263
1300
|
out.groupId = groupId.trim();
|
|
1264
1301
|
}
|
|
1265
1302
|
try {
|
|
1266
|
-
const vp = readVp(
|
|
1303
|
+
const vp = readVp(resolvedVpId);
|
|
1267
1304
|
if (vp) {
|
|
1268
1305
|
out.vpPersona = {
|
|
1269
|
-
vpId,
|
|
1270
|
-
displayName: vp.displayName ||
|
|
1306
|
+
vpId: resolvedVpId,
|
|
1307
|
+
displayName: vp.displayName || resolvedVpId,
|
|
1271
1308
|
role: vp.role || '',
|
|
1272
1309
|
persona: vp.persona || '',
|
|
1273
1310
|
};
|