@memberjunction/ai-agents 4.2.0 → 4.3.1

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 (30) hide show
  1. package/README.md +4 -0
  2. package/dist/agent-context-injector.d.ts +63 -23
  3. package/dist/agent-context-injector.d.ts.map +1 -1
  4. package/dist/agent-context-injector.js +205 -55
  5. package/dist/agent-context-injector.js.map +1 -1
  6. package/dist/base-agent.d.ts +36 -2
  7. package/dist/base-agent.d.ts.map +1 -1
  8. package/dist/base-agent.js +189 -13
  9. package/dist/base-agent.js.map +1 -1
  10. package/dist/memory-manager-agent.d.ts +47 -0
  11. package/dist/memory-manager-agent.d.ts.map +1 -1
  12. package/dist/memory-manager-agent.js +389 -51
  13. package/dist/memory-manager-agent.js.map +1 -1
  14. package/package.json +16 -18
  15. package/dist/__tests__/action-changes.test.d.ts +0 -15
  16. package/dist/__tests__/action-changes.test.d.ts.map +0 -1
  17. package/dist/__tests__/action-changes.test.js +0 -394
  18. package/dist/__tests__/action-changes.test.js.map +0 -1
  19. package/dist/__tests__/agent-memory-features.test.d.ts +0 -123
  20. package/dist/__tests__/agent-memory-features.test.d.ts.map +0 -1
  21. package/dist/__tests__/agent-memory-features.test.js +0 -596
  22. package/dist/__tests__/agent-memory-features.test.js.map +0 -1
  23. package/dist/__tests__/agent-type-prompt-params.test.d.ts +0 -14
  24. package/dist/__tests__/agent-type-prompt-params.test.d.ts.map +0 -1
  25. package/dist/__tests__/agent-type-prompt-params.test.js +0 -583
  26. package/dist/__tests__/agent-type-prompt-params.test.js.map +0 -1
  27. package/dist/__tests__/chat-handling-option.test.d.ts +0 -54
  28. package/dist/__tests__/chat-handling-option.test.d.ts.map +0 -1
  29. package/dist/__tests__/chat-handling-option.test.js +0 -222
  30. package/dist/__tests__/chat-handling-option.test.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import { BaseAgent } from './base-agent.js';
2
+ import { UserInfo } from '@memberjunction/core';
2
3
  import { ExecuteAgentParams, AgentConfiguration, BaseAgentNextStep } from '@memberjunction/ai-core-plus';
3
4
  /**
4
5
  * Memory Manager Agent - automatically extracts notes and examples from conversations.
@@ -69,6 +70,52 @@ export declare class MemoryManagerAgent extends BaseAgent {
69
70
  * Inherits scope from source agent run and applies scopeLevel to determine scope specificity.
70
71
  */
71
72
  private CreateNoteRecords;
73
+ /**
74
+ * Collapse merge candidates with identical content into a single candidate
75
+ * carrying all merge target IDs. This prevents duplicate active notes when
76
+ * a contradiction invalidates multiple existing notes (e.g., "I hate pizza"
77
+ * replacing both a pepperoni note and a mushrooms note).
78
+ */
79
+ private collapseMergeCandidates;
80
+ /**
81
+ * Determine whether consolidation should run based on CONSOLIDATION_CONFIG.frequency.
82
+ * Uses AIAgentRun history instead of static in-memory state so that timing
83
+ * survives process restarts and works correctly across clustered instances.
84
+ *
85
+ * Supports:
86
+ * - 'every-run': Always run
87
+ * - 'hourly': Run if 1+ hour since last completed MM run
88
+ * - 'daily': Run if 24+ hours since last completed MM run
89
+ * - number: Run every N completed MM runs
90
+ */
91
+ private shouldRunConsolidation;
92
+ /**
93
+ * Consolidate related notes into single, comprehensive notes.
94
+ * This method finds clusters of similar notes and synthesizes them.
95
+ *
96
+ * @param agentId Optional - consolidate notes for a specific agent only
97
+ * @param contextUser The context user for database operations
98
+ * @returns Number of notes consolidated (archived)
99
+ */
100
+ consolidateRelatedNotes(agentId: string | null, contextUser: UserInfo): Promise<{
101
+ consolidated: number;
102
+ archived: number;
103
+ }>;
104
+ /**
105
+ * Find clusters of semantically similar notes suitable for consolidation.
106
+ * Each cluster contains notes that exceed the similarity threshold and meet the minimum cluster size.
107
+ */
108
+ private findConsolidationClusters;
109
+ /**
110
+ * Process a single consolidation cluster: run the LLM prompt, create the consolidated note,
111
+ * and revoke source notes.
112
+ */
113
+ private processConsolidationCluster;
114
+ /**
115
+ * Apply scope fields to a consolidated note based on the LLM's scope recommendation.
116
+ * Mirrors the scoping logic in CreateNoteRecords.
117
+ */
118
+ private applyScopeToConsolidatedNote;
72
119
  /**
73
120
  * Create example records from extracted data.
74
121
  * Inherits scope from source agent run and applies scopeLevel to determine scope specificity.
@@ -1 +1 @@
1
- {"version":3,"file":"memory-manager-agent.d.ts","sourceRoot":"","sources":["../src/memory-manager-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAYzC,OAAO,EAAkB,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAyB,MAAM,8BAA8B,CAAC;AAmHhJ;;;;GAIG;AACH,qBACa,kBAAmB,SAAQ,SAAS;IAC7C,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAkB;IAClC,0CAA0C;IAC1C,OAAO,CAAC,WAAW,CAAuB;IAC1C,iDAAiD;IACjD,OAAO,CAAC,YAAY,CAAa;IACjC,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAyB;IAE7C;;;OAGG;YACW,aAAa;IAyC3B;;OAEG;YACW,eAAe;IAoC7B;;;OAGG;YACW,cAAc;IAoB5B;;;OAGG;YACW,qBAAqB;IA0BnC;;;;OAIG;YACW,gCAAgC;IA8E9C;;;OAGG;YACW,sBAAsB;IAuCpC;;;;OAIG;YACW,6BAA6B;IA4C3C;;;OAGG;YACW,qBAAqB;IA6QnC;;;OAGG;YACW,eAAe;IAgJ7B;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;;OAGG;YACW,iBAAiB;IAkI/B;;;OAGG;YACW,oBAAoB;IAoGlC;;OAEG;cACa,oBAAoB,CAAC,CAAC,GAAG,GAAG,EACxC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,kBAAkB,GAC3B,OAAO,CAAC;QAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC;CAgLnE"}
1
+ {"version":3,"file":"memory-manager-agent.d.ts","sourceRoot":"","sources":["../src/memory-manager-agent.ts"],"names":[],"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