@yeaft/webchat-agent 0.1.602 → 0.1.604
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/engine.js +7 -5
- package/unify/web-bridge.js +43 -6
package/package.json
CHANGED
package/unify/engine.js
CHANGED
|
@@ -537,11 +537,13 @@ export class Engine {
|
|
|
537
537
|
const budget = this.#config.messageTokenBudget || 8192;
|
|
538
538
|
const compactCfg = (this.#config && this.#config.compact) || {};
|
|
539
539
|
|
|
540
|
-
// Phase 8 PR-
|
|
541
|
-
//
|
|
542
|
-
//
|
|
543
|
-
//
|
|
544
|
-
|
|
540
|
+
// Phase 8 PR-H: orchestrator is now the default. The legacy
|
|
541
|
+
// shouldConsolidate / consolidate path remains reachable as an
|
|
542
|
+
// explicit fallback via `config.compact.useLegacy=true` for parity
|
|
543
|
+
// testing during migration. evaluateCompactTriggers (DESIGN §4.1)
|
|
544
|
+
// and runCompact (DESIGN §4.2) own the live path.
|
|
545
|
+
const useLegacy = compactCfg.useLegacy === true || compactCfg.useOrchestrator === false;
|
|
546
|
+
if (!useLegacy) {
|
|
545
547
|
return this.#runOrchestratorCompact(budget, compactCfg);
|
|
546
548
|
}
|
|
547
549
|
|
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
|
};
|