@memberjunction/ai-agents 5.41.0 → 5.43.0
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/README.md +10 -0
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
- package/dist/agent-types/flow-agent-type.js +10 -2
- package/dist/agent-types/flow-agent-type.js.map +1 -1
- package/dist/base-agent.d.ts +57 -51
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +239 -187
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +44 -2
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +133 -100
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/realtime/bridge-realtime-session-factory.d.ts +111 -0
- package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -0
- package/dist/realtime/bridge-realtime-session-factory.js +163 -0
- package/dist/realtime/bridge-realtime-session-factory.js.map +1 -0
- package/dist/realtime/bridge-room-transcript-sink.d.ts +63 -0
- package/dist/realtime/bridge-room-transcript-sink.d.ts.map +1 -0
- package/dist/realtime/bridge-room-transcript-sink.js +151 -0
- package/dist/realtime/bridge-room-transcript-sink.js.map +1 -0
- package/dist/realtime/realtime-client-session-service.d.ts +148 -6
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
- package/dist/realtime/realtime-client-session-service.js +241 -35
- package/dist/realtime/realtime-client-session-service.js.map +1 -1
- package/dist/realtime/realtime-coagent-config.d.ts +142 -7
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
- package/dist/realtime/realtime-coagent-config.js +176 -8
- package/dist/realtime/realtime-coagent-config.js.map +1 -1
- package/dist/realtime/realtime-tool-broker.d.ts +15 -0
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
- package/dist/realtime/realtime-tool-broker.js +22 -0
- package/dist/realtime/realtime-tool-broker.js.map +1 -1
- package/dist/realtime/realtime-turn-moderator.d.ts +103 -0
- package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -0
- package/dist/realtime/realtime-turn-moderator.js +266 -0
- package/dist/realtime/realtime-turn-moderator.js.map +1 -0
- package/package.json +17 -17
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,9 @@ export * from './MJAIAgentRequestEntityServer.js';
|
|
|
43
43
|
export * from './KnowledgeAgent.js';
|
|
44
44
|
export * from './ClientToolRequestManager.js';
|
|
45
45
|
export * from './realtime/realtime-session-runner.js';
|
|
46
|
+
export * from './realtime/bridge-realtime-session-factory.js';
|
|
47
|
+
export * from './realtime/bridge-room-transcript-sink.js';
|
|
48
|
+
export * from './realtime/realtime-turn-moderator.js';
|
|
46
49
|
export { RealtimeToolBroker, RealtimeToolBrokerDeps, ExecutedToolCall, DelegatedRunArtifact } from './realtime/realtime-tool-broker.js';
|
|
47
50
|
export * from './realtime/realtime-client-session-service.js';
|
|
48
51
|
export * from './realtime/realtime-coagent-config.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,c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 @@ export * from './MJAIAgentRequestEntityServer.js';
|
|
|
43
43
|
export * from './KnowledgeAgent.js';
|
|
44
44
|
export * from './ClientToolRequestManager.js';
|
|
45
45
|
export * from './realtime/realtime-session-runner.js';
|
|
46
|
+
export * from './realtime/bridge-realtime-session-factory.js';
|
|
47
|
+
export * from './realtime/bridge-room-transcript-sink.js';
|
|
48
|
+
export * from './realtime/realtime-turn-moderator.js';
|
|
46
49
|
// Broker-unique exports. The shared tool-execution contract (INVOKE_TARGET_AGENT_TOOL_NAME,
|
|
47
50
|
// DelegateToTargetRequest, DelegatedResult, ToolExecutionResult, loggers) is surfaced via the
|
|
48
51
|
// runner's `export *` above, so only the broker-specific symbols are named here to avoid a
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AA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ClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,4FAA4F;AAC5F,8FAA8F;AAC9F,2FAA2F;AAC3F,8BAA8B;AAC9B,OAAO,EAAE,kBAAkB,EAAkE,MAAM,iCAAiC,CAAC;AACrI,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAE3D,wDAAwD;AACxD,OAAO,EACL,eAAe,EAEf,0BAA0B,EAG1B,WAAW,GACZ,MAAM,6BAA6B,CAAC"}
|
|
@@ -379,7 +379,20 @@ export declare class MemoryManagerAgent extends BaseAgent {
|
|
|
379
379
|
*/
|
|
380
380
|
private pruneStaleReferences;
|
|
381
381
|
/**
|
|
382
|
-
*
|
|
382
|
+
* Collect auto-generated, non-immutable `Active` notes that are candidates for orphan
|
|
383
|
+
* pruning, oldest first.
|
|
384
|
+
*
|
|
385
|
+
* Served from the `AIEngine` cache rather than a `RunView`: `AIEngine.Instance.AgentNotes`
|
|
386
|
+
* holds the full note pool, loaded unfiltered as entity objects and kept current via
|
|
387
|
+
* `BaseEntity` save/delete events, so an equivalent in-memory filter/sort/cap avoids both a
|
|
388
|
+
* DB round-trip and the "Entity Already in Engine" redundancy-telemetry warning each cycle.
|
|
389
|
+
* Note `.filter()` returns a fresh array, so the subsequent `.sort()` never reorders the
|
|
390
|
+
* engine's cached array. The result is projected to plain {@link PruneCandidateNote} rows —
|
|
391
|
+
* we never hand a cached `BaseEntity` instance to a mutating caller; `pruneStaleReferences`
|
|
392
|
+
* re-`Load()`s a fresh, owned entity before archiving.
|
|
393
|
+
*
|
|
394
|
+
* @param maxRows Hard cap on candidates returned this cycle (oldest-`__mj_CreatedAt` first).
|
|
395
|
+
* @returns Lightweight projection rows for orphan-reference evaluation.
|
|
383
396
|
*/
|
|
384
397
|
private loadPruneCandidateNotes;
|
|
385
398
|
/**
|
|
@@ -426,6 +439,25 @@ export declare class MemoryManagerAgent extends BaseAgent {
|
|
|
426
439
|
private summarizeDecayFactors;
|
|
427
440
|
/** Archive notes and examples past their explicit ExpiresAt timestamp, regardless of decay score. */
|
|
428
441
|
private archiveExpiredItems;
|
|
442
|
+
/**
|
|
443
|
+
* Find notes and examples whose explicit `ExpiresAt` timestamp has passed, so the
|
|
444
|
+
* archival pass can expire them regardless of decay score.
|
|
445
|
+
*
|
|
446
|
+
* Served from the `AIEngine` caches (`AgentNotes` / `AgentExamples`) instead of a batched
|
|
447
|
+
* `RunViews`: both pools are loaded unfiltered as entity objects and kept current via
|
|
448
|
+
* `BaseEntity` events, so an in-memory filter/cap reproduces the former queries while
|
|
449
|
+
* removing two DB round-trips and the pair of "Entity Already in Engine" redundancy
|
|
450
|
+
* warnings they emitted. Rows are projected to plain shapes; `archiveExpiredNote` /
|
|
451
|
+
* `archiveExpiredExample` re-`Load()` a fresh, owned entity before mutating.
|
|
452
|
+
*
|
|
453
|
+
* Notes include `Provisional` (via {@link IsInjectableNoteStatus} — the same Active+Provisional
|
|
454
|
+
* predicate used by the read-path injection queries) so the TTL safety net on in-flight
|
|
455
|
+
* agent writes is enforced: a provisional note the hardening pass never reaches must still
|
|
456
|
+
* expire.
|
|
457
|
+
*
|
|
458
|
+
* @param nowISO Current time as an ISO string; items with `ExpiresAt` strictly before this are expired.
|
|
459
|
+
* @returns A `[expiredNotes, expiredExamples]` tuple of projection rows (each capped at 200).
|
|
460
|
+
*/
|
|
429
461
|
private loadExpiredItems;
|
|
430
462
|
private archiveExpiredNote;
|
|
431
463
|
private archiveExpiredExample;
|
|
@@ -440,7 +472,17 @@ export declare class MemoryManagerAgent extends BaseAgent {
|
|
|
440
472
|
*/
|
|
441
473
|
private applyProportionalDecay;
|
|
442
474
|
/**
|
|
443
|
-
* Fetch notes and examples
|
|
475
|
+
* Fetch decay-candidate notes and examples from the AIEngine caches.
|
|
476
|
+
*
|
|
477
|
+
* Served from `AIEngine.Instance.AgentNotes` / `AgentExamples` (loaded unfiltered as
|
|
478
|
+
* entity objects and kept current via BaseEntity events), filtered/capped in-memory to
|
|
479
|
+
* mirror the former RunViews — avoids two "Entity Already in Engine" redundancy warnings
|
|
480
|
+
* and a DB round-trip per maintenance cycle. We project to plain candidate rows; the
|
|
481
|
+
* actual decay/archival re-Loads fresh entities.
|
|
482
|
+
*
|
|
483
|
+
* @returns A `[activeNotes, activeExamples]` tuple of decay-candidate projection rows
|
|
484
|
+
* (auto-generated `Active` notes capped at 1000; auto-generated `Active` examples
|
|
485
|
+
* scoring below 50, capped at 500).
|
|
444
486
|
*/
|
|
445
487
|
private loadDecayCandidates;
|
|
446
488
|
/**
|
|
@@ -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;AAEzC,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"memory-manager-agent.d.ts","sourceRoot":"","sources":["../src/memory-manager-agent.ts"],"names":[],"m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,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA8CjE;;;;OAIG;cACa,gBAAgB,CAC5B,IAAI,EAAE,mBAAmB,EACzB,YAAY,EAAE,wBAAwB,GAAG,SAAS,EAClD,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,QAAQ,GACtB,OAAO,CAAC,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;IAsD7C;;;;;;;OAOG;YACW,oBAAoB;YAsBpB,kBAAkB;YAoBlB,qBAAqB;IAqCnC,qFAAqF;YACvE,uBAAuB;YAiBvB,qBAAqB;IAyBnC;;;OAGG;YACW,sBAAsB;YAStB,aAAa;YAoBb,aAAa;IAwB3B,4EAA4E;IAC5E,OAAO,CAAC,uBAAuB;IAU/B;;;OAGG;YACW,oBAAoB;IA0FlC;;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;CA0LnE"}
|
|
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var MemoryManagerAgent_1;
|
|
8
8
|
import { BaseAgent } from './base-agent.js';
|
|
9
9
|
import { RegisterClass, CleanAndParseJSON } from '@memberjunction/global';
|
|
10
|
-
import { RunView, RunQuery, LogError, LogStatus } from '@memberjunction/core';
|
|
11
|
-
import {
|
|
10
|
+
import { RunView, RunQuery, LogError, LogStatus, LogStatusEx } from '@memberjunction/core';
|
|
11
|
+
import { IsInjectableNoteStatus } from '@memberjunction/core-entities';
|
|
12
12
|
import { AIPromptRunner } from '@memberjunction/ai-prompts';
|
|
13
13
|
import { AIPromptParams } from '@memberjunction/ai-core-plus';
|
|
14
14
|
import { AIEngine } from '@memberjunction/aiengine';
|
|
@@ -307,7 +307,9 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
307
307
|
MaxRows: 1000 // Limit to 1000 conversations per run
|
|
308
308
|
}, contextUser);
|
|
309
309
|
if (!result.Success || !result.Results || result.Results.length === 0) {
|
|
310
|
-
|
|
310
|
+
// Verbose-only: the common no-op outcome. The engine's "✅ Completed (Nms)" line already
|
|
311
|
+
// signals the run finished with no work; surfacing "why" is a verbose diagnostic detail.
|
|
312
|
+
LogStatusEx({ message: 'Memory Manager: No conversations with new activity found', verboseOnly: true });
|
|
311
313
|
return [];
|
|
312
314
|
}
|
|
313
315
|
// Parse the query results into ConversationWithRatings objects
|
|
@@ -1266,20 +1268,26 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
1266
1268
|
// Event-driven trigger: consolidate when at least `noteCountTrigger` new notes
|
|
1267
1269
|
// have been added system-wide since the last Memory Manager run.
|
|
1268
1270
|
//
|
|
1269
|
-
// NOTE: this
|
|
1271
|
+
// NOTE: this count intentionally does NOT filter by AgentID. The `agentId` parameter
|
|
1270
1272
|
// here is the Memory Manager's own ID (passed from `params.agent.ID` at the call
|
|
1271
1273
|
// site), not the agent that owns the notes. Filtering the count by MM's own agent
|
|
1272
1274
|
// ID would never match anything because MM doesn't own notes — it processes notes
|
|
1273
1275
|
// belonging to other (memory-enabled) agents.
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1276
|
+
//
|
|
1277
|
+
// AIEngineBase caches `MJ: AI Agent Notes` unfiltered as full entity objects
|
|
1278
|
+
// (`AIEngine.Instance.AgentNotes`) and keeps that cache current via BaseEntity
|
|
1279
|
+
// save/delete events, so we count in-memory instead of a `count_only` RunView. This
|
|
1280
|
+
// avoids the "Entity Already in Engine" redundancy telemetry warning and a DB
|
|
1281
|
+
// round-trip on every maintenance cycle. Mirrors the cached-note filtering used
|
|
1282
|
+
// elsewhere in this class (e.g. buildMaintenanceSummary).
|
|
1283
|
+
const lastRunMs = lastRun.getTime();
|
|
1284
|
+
const newNoteCount = AIEngine.Instance.AgentNotes.filter(n => n.IsAutoGenerated &&
|
|
1285
|
+
n.Status === 'Active' &&
|
|
1286
|
+
n.__mj_CreatedAt != null &&
|
|
1287
|
+
new Date(n.__mj_CreatedAt).getTime() > lastRunMs).length;
|
|
1288
|
+
if (newNoteCount >= CONSOLIDATION_CONFIG.noteCountTrigger) {
|
|
1281
1289
|
if (this._verbose) {
|
|
1282
|
-
LogStatus(`Memory Manager: Event-driven consolidation trigger fired (${
|
|
1290
|
+
LogStatus(`Memory Manager: Event-driven consolidation trigger fired (${newNoteCount} new notes >= ${CONSOLIDATION_CONFIG.noteCountTrigger} threshold since last MM run)`);
|
|
1283
1291
|
}
|
|
1284
1292
|
return { shouldRun: true, triggerType: 'event' };
|
|
1285
1293
|
}
|
|
@@ -1988,7 +1996,7 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
1988
1996
|
async pruneStaleReferences(contextUser) {
|
|
1989
1997
|
const maxPerCycle = STALE_PRUNING_CONFIG.maxNotesPerRun;
|
|
1990
1998
|
const result = { notesArchived: 0, orphanedAgents: 0, orphanedUsers: 0, orphanedCompanies: 0, orphanedConversations: 0 };
|
|
1991
|
-
const notes =
|
|
1999
|
+
const notes = this.loadPruneCandidateNotes(maxPerCycle * 2);
|
|
1992
2000
|
if (notes.length === 0) {
|
|
1993
2001
|
return result;
|
|
1994
2002
|
}
|
|
@@ -2005,22 +2013,33 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2005
2013
|
return result;
|
|
2006
2014
|
}
|
|
2007
2015
|
/**
|
|
2008
|
-
*
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2016
|
+
* Collect auto-generated, non-immutable `Active` notes that are candidates for orphan
|
|
2017
|
+
* pruning, oldest first.
|
|
2018
|
+
*
|
|
2019
|
+
* Served from the `AIEngine` cache rather than a `RunView`: `AIEngine.Instance.AgentNotes`
|
|
2020
|
+
* holds the full note pool, loaded unfiltered as entity objects and kept current via
|
|
2021
|
+
* `BaseEntity` save/delete events, so an equivalent in-memory filter/sort/cap avoids both a
|
|
2022
|
+
* DB round-trip and the "Entity Already in Engine" redundancy-telemetry warning each cycle.
|
|
2023
|
+
* Note `.filter()` returns a fresh array, so the subsequent `.sort()` never reorders the
|
|
2024
|
+
* engine's cached array. The result is projected to plain {@link PruneCandidateNote} rows —
|
|
2025
|
+
* we never hand a cached `BaseEntity` instance to a mutating caller; `pruneStaleReferences`
|
|
2026
|
+
* re-`Load()`s a fresh, owned entity before archiving.
|
|
2027
|
+
*
|
|
2028
|
+
* @param maxRows Hard cap on candidates returned this cycle (oldest-`__mj_CreatedAt` first).
|
|
2029
|
+
* @returns Lightweight projection rows for orphan-reference evaluation.
|
|
2030
|
+
*/
|
|
2031
|
+
loadPruneCandidateNotes(maxRows) {
|
|
2032
|
+
return AIEngine.Instance.AgentNotes
|
|
2033
|
+
.filter(n => n.IsAutoGenerated && n.Status === 'Active' && (n.ProtectionTier || 'Standard') !== 'Immutable')
|
|
2034
|
+
.sort((a, b) => new Date(a.__mj_CreatedAt).getTime() - new Date(b.__mj_CreatedAt).getTime())
|
|
2035
|
+
.slice(0, maxRows)
|
|
2036
|
+
.map(n => ({
|
|
2037
|
+
ID: n.ID,
|
|
2038
|
+
AgentID: n.AgentID,
|
|
2039
|
+
UserID: n.UserID,
|
|
2040
|
+
CompanyID: n.CompanyID,
|
|
2041
|
+
SourceConversationID: n.SourceConversationID
|
|
2042
|
+
}));
|
|
2024
2043
|
}
|
|
2025
2044
|
/**
|
|
2026
2045
|
* Build in-memory lookup caches of which referenced users/companies/conversations still
|
|
@@ -2199,7 +2218,7 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2199
2218
|
const result = { notesExpired: 0, examplesExpired: 0 };
|
|
2200
2219
|
const md = this.ProviderToUse;
|
|
2201
2220
|
const nowISO = new Date().toISOString();
|
|
2202
|
-
const [expiredNotes, expiredExamples] =
|
|
2221
|
+
const [expiredNotes, expiredExamples] = this.loadExpiredItems(nowISO);
|
|
2203
2222
|
for (const note of expiredNotes) {
|
|
2204
2223
|
if ((note.ProtectionTier || 'Standard') === 'Immutable')
|
|
2205
2224
|
continue;
|
|
@@ -2212,31 +2231,36 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2212
2231
|
}
|
|
2213
2232
|
return result;
|
|
2214
2233
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2234
|
+
/**
|
|
2235
|
+
* Find notes and examples whose explicit `ExpiresAt` timestamp has passed, so the
|
|
2236
|
+
* archival pass can expire them regardless of decay score.
|
|
2237
|
+
*
|
|
2238
|
+
* Served from the `AIEngine` caches (`AgentNotes` / `AgentExamples`) instead of a batched
|
|
2239
|
+
* `RunViews`: both pools are loaded unfiltered as entity objects and kept current via
|
|
2240
|
+
* `BaseEntity` events, so an in-memory filter/cap reproduces the former queries while
|
|
2241
|
+
* removing two DB round-trips and the pair of "Entity Already in Engine" redundancy
|
|
2242
|
+
* warnings they emitted. Rows are projected to plain shapes; `archiveExpiredNote` /
|
|
2243
|
+
* `archiveExpiredExample` re-`Load()` a fresh, owned entity before mutating.
|
|
2244
|
+
*
|
|
2245
|
+
* Notes include `Provisional` (via {@link IsInjectableNoteStatus} — the same Active+Provisional
|
|
2246
|
+
* predicate used by the read-path injection queries) so the TTL safety net on in-flight
|
|
2247
|
+
* agent writes is enforced: a provisional note the hardening pass never reaches must still
|
|
2248
|
+
* expire.
|
|
2249
|
+
*
|
|
2250
|
+
* @param nowISO Current time as an ISO string; items with `ExpiresAt` strictly before this are expired.
|
|
2251
|
+
* @returns A `[expiredNotes, expiredExamples]` tuple of projection rows (each capped at 200).
|
|
2252
|
+
*/
|
|
2253
|
+
loadExpiredItems(nowISO) {
|
|
2254
|
+
const nowMs = new Date(nowISO).getTime();
|
|
2255
|
+
const expiredNotes = AIEngine.Instance.AgentNotes
|
|
2256
|
+
.filter(n => IsInjectableNoteStatus(n.Status) && n.ExpiresAt != null && new Date(n.ExpiresAt).getTime() < nowMs)
|
|
2257
|
+
.slice(0, 200)
|
|
2258
|
+
.map(n => ({ ID: n.ID, ExpiresAt: n.ExpiresAt, ProtectionTier: n.ProtectionTier || 'Standard' }));
|
|
2259
|
+
const expiredExamples = AIEngine.Instance.AgentExamples
|
|
2260
|
+
.filter(e => e.Status === 'Active' && e.ExpiresAt != null && new Date(e.ExpiresAt).getTime() < nowMs)
|
|
2261
|
+
.slice(0, 200)
|
|
2262
|
+
.map(e => ({ ID: e.ID, ExpiresAt: e.ExpiresAt }));
|
|
2263
|
+
return [expiredNotes, expiredExamples];
|
|
2240
2264
|
}
|
|
2241
2265
|
async archiveExpiredNote(note, md, contextUser) {
|
|
2242
2266
|
const noteToArchive = await md.GetEntityObject('MJ: AI Agent Notes', contextUser);
|
|
@@ -2267,7 +2291,7 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2267
2291
|
const result = { notesDecayed: 0, notesArchived: 0, examplesDecayed: 0, examplesArchived: 0 };
|
|
2268
2292
|
const stats = { decayFactors: [], protectedPreserved: 0, ephemeralAccelerated: 0 };
|
|
2269
2293
|
const md = this.ProviderToUse;
|
|
2270
|
-
const [activeNotes, activeExamples] =
|
|
2294
|
+
const [activeNotes, activeExamples] = this.loadDecayCandidates();
|
|
2271
2295
|
for (const note of activeNotes) {
|
|
2272
2296
|
await this.decayOneNote(note, archiveEnabledAgentIds, md, contextUser, result, stats);
|
|
2273
2297
|
}
|
|
@@ -2277,36 +2301,43 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2277
2301
|
return { ...result, stats };
|
|
2278
2302
|
}
|
|
2279
2303
|
/**
|
|
2280
|
-
* Fetch notes and examples
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2304
|
+
* Fetch decay-candidate notes and examples from the AIEngine caches.
|
|
2305
|
+
*
|
|
2306
|
+
* Served from `AIEngine.Instance.AgentNotes` / `AgentExamples` (loaded unfiltered as
|
|
2307
|
+
* entity objects and kept current via BaseEntity events), filtered/capped in-memory to
|
|
2308
|
+
* mirror the former RunViews — avoids two "Entity Already in Engine" redundancy warnings
|
|
2309
|
+
* and a DB round-trip per maintenance cycle. We project to plain candidate rows; the
|
|
2310
|
+
* actual decay/archival re-Loads fresh entities.
|
|
2311
|
+
*
|
|
2312
|
+
* @returns A `[activeNotes, activeExamples]` tuple of decay-candidate projection rows
|
|
2313
|
+
* (auto-generated `Active` notes capped at 1000; auto-generated `Active` examples
|
|
2314
|
+
* scoring below 50, capped at 500).
|
|
2315
|
+
*/
|
|
2316
|
+
loadDecayCandidates() {
|
|
2317
|
+
const activeNotes = AIEngine.Instance.AgentNotes
|
|
2318
|
+
.filter(n => n.IsAutoGenerated && n.Status === 'Active')
|
|
2319
|
+
.slice(0, 1000)
|
|
2320
|
+
.map(n => ({
|
|
2321
|
+
ID: n.ID,
|
|
2322
|
+
ImportanceScore: n.ImportanceScore,
|
|
2323
|
+
ProtectionTier: n.ProtectionTier || 'Standard',
|
|
2324
|
+
LastAccessedAt: n.LastAccessedAt,
|
|
2325
|
+
__mj_CreatedAt: n.__mj_CreatedAt,
|
|
2326
|
+
AccessCount: n.AccessCount,
|
|
2327
|
+
AgentID: n.AgentID
|
|
2328
|
+
}));
|
|
2329
|
+
const activeExamples = AIEngine.Instance.AgentExamples
|
|
2330
|
+
.filter(e => e.IsAutoGenerated && e.Status === 'Active' && (e.SuccessScore ?? 0) < 50)
|
|
2331
|
+
.slice(0, 500)
|
|
2332
|
+
.map(e => ({
|
|
2333
|
+
ID: e.ID,
|
|
2334
|
+
SuccessScore: e.SuccessScore,
|
|
2335
|
+
LastAccessedAt: e.LastAccessedAt,
|
|
2336
|
+
__mj_CreatedAt: e.__mj_CreatedAt,
|
|
2337
|
+
AccessCount: e.AccessCount,
|
|
2338
|
+
AgentID: e.AgentID
|
|
2339
|
+
}));
|
|
2340
|
+
return [activeNotes, activeExamples];
|
|
2310
2341
|
}
|
|
2311
2342
|
/**
|
|
2312
2343
|
* Apply proportional decay to a single note. Archives if the decayed score drops below
|
|
@@ -2396,19 +2427,19 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2396
2427
|
maxNotesPerRun: HARDENING_CONFIG.maxNotesPerRun
|
|
2397
2428
|
});
|
|
2398
2429
|
try {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2430
|
+
// Served from AIEngine.Instance.AgentNotes (loaded unfiltered as entity
|
|
2431
|
+
// objects and kept current via BaseEntity + remote-invalidate events),
|
|
2432
|
+
// filtered/ordered/capped in-memory to mirror the former RunView. This
|
|
2433
|
+
// avoids the "Entity Already in Engine" redundancy warning and a DB
|
|
2434
|
+
// round-trip every MM cycle, matching loadDecayCandidates/loadExpiredItems.
|
|
2435
|
+
// Provisional agent notes are in-flight writes already reflected in the
|
|
2436
|
+
// cache, and hardenSingleNote mutates+saves these entities directly —
|
|
2437
|
+
// consistent with the dedupe path, which already saves cached note
|
|
2438
|
+
// instances returned by FindSimilarAgentNotes.
|
|
2439
|
+
const provisionalNotes = AIEngine.Instance.AgentNotes
|
|
2440
|
+
.filter(n => n.Status === 'Provisional' && n.AuthorType === 'Agent')
|
|
2441
|
+
.sort((a, b) => new Date(a.__mj_CreatedAt).getTime() - new Date(b.__mj_CreatedAt).getTime())
|
|
2442
|
+
.slice(0, HARDENING_CONFIG.maxNotesPerRun);
|
|
2412
2443
|
if (provisionalNotes.length === 0) {
|
|
2413
2444
|
await this.FinalizeRunStep(step, true, { ...counters, provisionalCount: 0 });
|
|
2414
2445
|
return counters;
|
|
@@ -2766,7 +2797,9 @@ let MemoryManagerAgent = MemoryManagerAgent_1 = class MemoryManagerAgent extends
|
|
|
2766
2797
|
this._agentRunID = this.AgentRun?.ID || null;
|
|
2767
2798
|
this._stepCounter = 0;
|
|
2768
2799
|
this._contextUser = params.contextUser || null;
|
|
2769
|
-
|
|
2800
|
+
// Verbose-only: the scheduling engine's always-on "▶️ Starting / ✅ Completed" lines already
|
|
2801
|
+
// mark that this run began/ended. On routine no-op runs this internal trace is just noise.
|
|
2802
|
+
LogStatusEx({ message: 'Memory Manager: Starting analysis cycle', verboseOnly: true });
|
|
2770
2803
|
// Phase 1: the last-run-time and the memory-enabled agent set are independent — load in
|
|
2771
2804
|
// parallel (avoids two back-to-back sequential RunViews flagged by the parallelization telemetry).
|
|
2772
2805
|
const [lastRunTime, agentsUsingMemory] = await Promise.all([
|