@memberjunction/ai-agents 3.1.1 → 3.3.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.
Files changed (32) hide show
  1. package/dist/PayloadFeedbackManager.d.ts +3 -1
  2. package/dist/PayloadFeedbackManager.d.ts.map +1 -1
  3. package/dist/PayloadFeedbackManager.js +61 -7
  4. package/dist/PayloadFeedbackManager.js.map +1 -1
  5. package/dist/__tests__/agent-memory-features.test.d.ts +71 -0
  6. package/dist/__tests__/agent-memory-features.test.d.ts.map +1 -0
  7. package/dist/__tests__/agent-memory-features.test.js +513 -0
  8. package/dist/__tests__/agent-memory-features.test.js.map +1 -0
  9. package/dist/__tests__/chat-handling-option.test.d.ts +28 -0
  10. package/dist/__tests__/chat-handling-option.test.d.ts.map +1 -0
  11. package/dist/__tests__/chat-handling-option.test.js +183 -0
  12. package/dist/__tests__/chat-handling-option.test.js.map +1 -0
  13. package/dist/agent-context-injector.d.ts +16 -1
  14. package/dist/agent-context-injector.d.ts.map +1 -1
  15. package/dist/agent-context-injector.js +162 -11
  16. package/dist/agent-context-injector.js.map +1 -1
  17. package/dist/base-agent.d.ts.map +1 -1
  18. package/dist/base-agent.js +31 -3
  19. package/dist/base-agent.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +6 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/memory-cleanup-agent.d.ts +25 -0
  25. package/dist/memory-cleanup-agent.d.ts.map +1 -0
  26. package/dist/memory-cleanup-agent.js +237 -0
  27. package/dist/memory-cleanup-agent.js.map +1 -0
  28. package/dist/memory-manager-agent.d.ts +10 -2
  29. package/dist/memory-manager-agent.d.ts.map +1 -1
  30. package/dist/memory-manager-agent.js +647 -83
  31. package/dist/memory-manager-agent.js.map +1 -1
  32. package/package.json +17 -12
@@ -32,6 +32,7 @@ const aiengine_1 = require("@memberjunction/aiengine");
32
32
  const actions_1 = require("@memberjunction/actions");
33
33
  const ai_engine_base_1 = require("@memberjunction/ai-engine-base");
34
34
  const agent_context_injector_1 = require("./agent-context-injector");
35
+ const ai_reranker_1 = require("@memberjunction/ai-reranker");
35
36
  const ai_core_plus_1 = require("@memberjunction/ai-core-plus");
36
37
  const AgentRunner_1 = require("./AgentRunner");
37
38
  const PayloadManager_1 = require("./PayloadManager");
@@ -510,6 +511,8 @@ class BaseAgent {
510
511
  return { notes: [], examples: [] };
511
512
  }
512
513
  const injector = new agent_context_injector_1.AgentContextInjector();
514
+ const rerankerConfigJson = agent.Get('RerankerConfiguration');
515
+ const rerankerConfig = ai_reranker_1.RerankerService.Instance.parseConfiguration(rerankerConfigJson);
513
516
  const notes = agent.InjectNotes
514
517
  ? await injector.GetNotesForContext({
515
518
  agentId: agent.ID,
@@ -518,9 +521,15 @@ class BaseAgent {
518
521
  currentInput: input,
519
522
  strategy: agent.NoteInjectionStrategy,
520
523
  maxNotes: agent.MaxNotesToInject || 5,
521
- contextUser: contextUser
524
+ contextUser: contextUser,
525
+ rerankerConfig,
526
+ observability: this._agentRun ? {
527
+ agentRunID: this._agentRun.ID,
528
+ stepNumber: (this._agentRun.Steps?.length || 0) + 1
529
+ } : undefined
522
530
  })
523
531
  : [];
532
+ this.logStatus(`BaseAgent: Got ${notes.length} notes from injector`, true);
524
533
  const examples = agent.InjectExamples
525
534
  ? await injector.GetExamplesForContext({
526
535
  agentId: agent.ID,
@@ -2294,6 +2303,23 @@ The context is now within limits. Please retry your request with the recovered c
2294
2303
  if (params.testRunId) {
2295
2304
  this._agentRun.TestRunID = params.testRunId;
2296
2305
  }
2306
+ if (params.userScope) {
2307
+ if (params.userScope.primaryEntityName) {
2308
+ const primaryEntity = this._metadata.Entities.find(e => e.Name === params.userScope.primaryEntityName);
2309
+ if (primaryEntity) {
2310
+ this._agentRun.PrimaryScopeEntityID = primaryEntity.ID;
2311
+ }
2312
+ else {
2313
+ (0, core_1.LogError)(`UserScope: Entity "${params.userScope.primaryEntityName}" not found in metadata`);
2314
+ }
2315
+ }
2316
+ if (params.userScope.primaryRecordId) {
2317
+ this._agentRun.PrimaryScopeRecordID = params.userScope.primaryRecordId;
2318
+ }
2319
+ if (params.userScope.secondary && Object.keys(params.userScope.secondary).length > 0) {
2320
+ this._agentRun.SecondaryScopes = JSON.stringify(params.userScope.secondary);
2321
+ }
2322
+ }
2297
2323
  if (!await this._agentRun.Save()) {
2298
2324
  const errorMessage = JSON.stringify((0, global_1.CopyScalarsAndArrays)(this._agentRun.LatestResult));
2299
2325
  throw new Error(`Failed to create agent run record: Details: ${errorMessage}`);
@@ -3007,7 +3033,7 @@ The context is now within limits. Please retry your request with the recovered c
3007
3033
  };
3008
3034
  await this.finalizeStepEntity(stepEntity, subAgentResult.success, subAgentResult.agentRun?.ErrorMessage, outputData);
3009
3035
  if (subAgentResult.agentRun?.FinalStep === 'Chat') {
3010
- return {
3036
+ const chatStep = {
3011
3037
  step: 'Chat',
3012
3038
  terminate: true,
3013
3039
  message: subAgentResult.agentRun?.Message || null,
@@ -3017,6 +3043,7 @@ The context is now within limits. Please retry your request with the recovered c
3017
3043
  actionableCommands: subAgentResult.actionableCommands,
3018
3044
  automaticCommands: subAgentResult.automaticCommands
3019
3045
  };
3046
+ return await this.validateChatNextStep(params, chatStep, mergedPayload, this._agentRun, stepEntity);
3020
3047
  }
3021
3048
  const subAgentSummary = {
3022
3049
  agentName: params.agent.Name,
@@ -3222,7 +3249,7 @@ The context is now within limits. Please retry your request with the recovered c
3222
3249
  }
3223
3250
  await this.finalizeStepEntity(stepEntity, subAgentResult.success, subAgentResult.agentRun?.ErrorMessage, outputData);
3224
3251
  if (subAgentResult.agentRun?.FinalStep === 'Chat') {
3225
- return {
3252
+ const chatStep = {
3226
3253
  step: 'Chat',
3227
3254
  terminate: true,
3228
3255
  message: subAgentResult.agentRun?.Message || null,
@@ -3232,6 +3259,7 @@ The context is now within limits. Please retry your request with the recovered c
3232
3259
  actionableCommands: subAgentResult.actionableCommands,
3233
3260
  automaticCommands: subAgentResult.automaticCommands
3234
3261
  };
3262
+ return await this.validateChatNextStep(params, chatStep, mergedPayload, this._agentRun, stepEntity);
3235
3263
  }
3236
3264
  const subAgentSummary = {
3237
3265
  agentName: params.agent.Name,