@yeaft/webchat-agent 1.0.348 → 1.0.350

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.
Files changed (41) hide show
  1. package/local-runtime/version.json +1 -1
  2. package/local-runtime/web/app.bundle.js +73 -73
  3. package/local-runtime/web/app.bundle.js.gz +0 -0
  4. package/local-runtime/web/index.html +1 -1
  5. package/package.json +1 -1
  6. package/yeaft/conversation/persist.js +4 -0
  7. package/yeaft/dream/apply.js +59 -30
  8. package/yeaft/dream/output-snapshot.js +8 -4
  9. package/yeaft/dream/prompts/consolidate-topics.md +31 -0
  10. package/yeaft/dream/prompts/create.md +8 -8
  11. package/yeaft/dream/prompts/index.js +4 -2
  12. package/yeaft/dream/prompts/merge-topics.md +35 -0
  13. package/yeaft/dream/prompts/triage-pass1.md +2 -2
  14. package/yeaft/dream/prompts/triage-pass2.md +4 -2
  15. package/yeaft/dream/prompts/update.md +16 -14
  16. package/yeaft/dream/runner.js +69 -13
  17. package/yeaft/dream/segment-extract.js +16 -13
  18. package/yeaft/dream/session-wiring.js +2 -2
  19. package/yeaft/dream/snapshot.js +3 -3
  20. package/yeaft/dream/topic-consolidation.js +316 -0
  21. package/yeaft/dream/triage.js +7 -2
  22. package/yeaft/engine.js +237 -239
  23. package/yeaft/memory/ams-registry.js +42 -61
  24. package/yeaft/memory/ams.js +17 -9
  25. package/yeaft/memory/budget.js +15 -18
  26. package/yeaft/memory/content-backfill.js +118 -0
  27. package/yeaft/memory/index-db.js +10 -3
  28. package/yeaft/memory/keywords.js +25 -7
  29. package/yeaft/memory/preflow.js +26 -9
  30. package/yeaft/memory/segment-store.js +44 -8
  31. package/yeaft/memory/segment-sync.js +8 -4
  32. package/yeaft/memory/segment.js +10 -3
  33. package/yeaft/memory/store.js +88 -38
  34. package/yeaft/memory/summary-store.js +3 -3
  35. package/yeaft/memory/topic-redirect.js +28 -0
  36. package/yeaft/router/continuity.js +12 -3
  37. package/yeaft/session.js +18 -19
  38. package/yeaft/sessions/pre-flow.js +7 -3
  39. package/yeaft/sub-agent/runner.js +10 -1
  40. package/yeaft/work-center/bridge.js +1 -0
  41. package/yeaft/work-center/runner.js +33 -4
@@ -10,7 +10,8 @@ import { resolveWorkItemModel, selectWorkItemVp } from './assignment.js';
10
10
  import { approxTokens } from '../memory/budget.js';
11
11
  import { runPreflow } from '../memory/preflow.js';
12
12
  import { formatPickedForInjection } from '../sessions/pre-flow.js';
13
- import { existsSync, lstatSync, realpathSync } from 'node:fs';
13
+ import { cleanMemoryPromptText } from '../memory/prompt-cleanup.js';
14
+ import { existsSync, lstatSync, readFileSync, realpathSync } from 'node:fs';
14
15
  import path from 'node:path';
15
16
  import { sessionMessageQuotePrompt } from '../session-message-quote.js';
16
17
  import { buildWorkItemAttachmentContext } from './attachments.js';
@@ -767,7 +768,7 @@ function finalizeOwnedIntegration(store, action, run, ownerBootId) {
767
768
  }
768
769
  }
769
770
 
770
- function recallWorkItemMemory(runtime, workItem, action, vp) {
771
+ export function recallWorkItemMemory(runtime, workItem, action, vp) {
771
772
  if (workItem?.reuseMemory === false || !runtime?.memoryIndex) return '';
772
773
  const query = workItemMemoryQuery(workItem, action);
773
774
  if (!query.trim()) return '';
@@ -780,10 +781,15 @@ function recallWorkItemMemory(runtime, workItem, action, vp) {
780
781
  currentTags: [action.type, action.stageId, vp.id].filter(Boolean),
781
782
  topK: 20,
782
783
  budgetTokens: WORK_ITEM_MEMORY_TOKEN_BUDGET,
784
+ canonicalOnly: true,
783
785
  });
784
786
  const allowed = new Set(scopes);
785
787
  if ((result.picked || []).some(entry => !allowed.has(entry.scope))) return '';
786
- const formatted = formatPickedForInjection(result.picked || []);
788
+ const canonical = (result.picked || []).map(entry => {
789
+ const body = readCanonicalMemoryScope(runtime.yeaftDir, entry.scope);
790
+ return body ? { ...entry, body } : null;
791
+ }).filter(Boolean);
792
+ const formatted = formatPickedForInjection(canonical);
787
793
  if (!formatted) return '';
788
794
  return boundedMemoryBlock(escapeMemoryText(formatted));
789
795
  } catch {
@@ -791,6 +797,24 @@ function recallWorkItemMemory(runtime, workItem, action, vp) {
791
797
  }
792
798
  }
793
799
 
800
+ function readCanonicalMemoryScope(yeaftDir, scope) {
801
+ if (!yeaftDir || !isCanonicalMemoryScope(scope)) return '';
802
+ const memoryRoot = path.join(yeaftDir, 'memory');
803
+ const contentPath = path.resolve(memoryRoot, scope, 'content.md');
804
+ if (!isPathInsideOrEqual(memoryRoot, contentPath)) return '';
805
+ if (!existsSync(contentPath) || !lstatSync(contentPath).isFile()) return '';
806
+ return cleanMemoryPromptText(readFileSync(contentPath, 'utf8'));
807
+ }
808
+
809
+ function isCanonicalMemoryScope(scope) {
810
+ const parts = String(scope || '').split('/').filter(Boolean);
811
+ if (parts[0] === 'user' && parts.length === 1) return true;
812
+ if (parts[0] === 'vp' && parts.length >= 2) return true;
813
+ if (!['sessions', 'session', 'group'].includes(parts[0]) || parts.length < 2) return false;
814
+ if (parts.length === 2) return true;
815
+ return ['user', 'vp', 'feature', 'topic'].includes(parts[2]);
816
+ }
817
+
794
818
  export class WorkItemRunner {
795
819
  constructor(options) {
796
820
  this.runtimeProvider = options.runtimeProvider;
@@ -998,7 +1022,12 @@ export class WorkItemRunner {
998
1022
  throw error;
999
1023
  }
1000
1024
  const resolvedModel = resolveWorkItemModel(runtime.config, vp, executionAction.modelPolicy);
1001
- const memoryBlock = recallWorkItemMemory(runtime, workItem, executionAction, vp);
1025
+ const memoryBlock = recallWorkItemMemory(
1026
+ { ...runtime, yeaftDir: runtime.yeaftDir || this.yeaftDir },
1027
+ workItem,
1028
+ executionAction,
1029
+ vp,
1030
+ );
1002
1031
  const workspaceSessionBlock = recallWorkspaceSessionContext({
1003
1032
  yeaftDir: this.yeaftDir,
1004
1033
  conversationStore: runtime.conversationStore,