@memberjunction/ai-agent-manager 2.112.0 → 2.113.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @memberjunction/ai-agent-manager@2.112.0 build
2
+ > @memberjunction/ai-agent-manager@2.113.0 build
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,15 +1,38 @@
1
1
  # @memberjunction/ai-agent-manager
2
2
 
3
+ ## 2.113.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0968067: Migration
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [7f8390e]
12
+ - Updated dependencies [c0bb238]
13
+ - Updated dependencies [4436cd2]
14
+ - @memberjunction/ai-agents@2.113.0
15
+ - @memberjunction/ai-core-plus@2.113.0
16
+ - @memberjunction/core-entities@2.113.0
17
+ - @memberjunction/global@2.113.0
18
+ - @memberjunction/core@2.113.0
19
+
3
20
  ## 2.112.0
4
21
 
22
+ ### Minor Changes
23
+
24
+ - 2ac2120: Migration
25
+
5
26
  ### Patch Changes
6
27
 
7
28
  - 621960a: Patch
29
+ - Updated dependencies [2ac2120]
8
30
  - Updated dependencies [c126b59]
9
31
  - Updated dependencies [ed74bb8]
32
+ - @memberjunction/ai-agents@2.112.0
10
33
  - @memberjunction/global@2.112.0
11
34
  - @memberjunction/ai-core-plus@2.112.0
12
- - @memberjunction/ai-agents@2.112.0
35
+ - @memberjunction/core@2.112.0
13
36
  - @memberjunction/core-entities@2.112.0
14
37
 
15
38
  ## 2.110.1
@@ -1,4 +1,4 @@
1
- import { UserInfo } from '@memberjunction/global';
1
+ import { UserInfo } from '@memberjunction/core';
2
2
  import { AgentSpec } from '@memberjunction/ai-core-plus';
3
3
  /**
4
4
  * Represents a single database mutation performed by AgentSpecSync
@@ -1 +1 @@
1
- {"version":3,"file":"agent-spec-sync.d.ts","sourceRoot":"","sources":["../src/agent-spec-sync.ts"],"names":[],"mappings":"A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,CAAC,mBAAmB,CAAC;IAgE5E;;;;;;;OAOG;YACW,eAAe;IAwH7B;;;;;;;;;;OAUG;YACW,WAAW;IAkDzB;;;;;;;;;;OAUG;YACW,aAAa;IAc3B;;;;;;;;;;;;;;OAcG;YACW,iBAAiB;IA2C/B;;;;;;;;;;OAUG;YACW,mBAAmB;IAsDjC;;;;;;;;;;OAUG;YACW,WAAW;IAkIzB;;;;;;;;;OASG;YACW,SAAS;IAwHvB;;;;;;;;;OASG;YACW,aAAa;IA8E3B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAgDtB;;;;;;;;;;;;;;;OAeG;IACI,MAAM,IAAI,SAAS;IAI1B;;;;OAIG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;OAIG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED;;;;;;;;;;;;;;OAcG;IACI,SAAS,IAAI,IAAI;IAIxB;;;;;;;;;;;;;;;;OAgBG;IACI,UAAU,IAAI,IAAI;IAMzB;;;;;;;;;;OAUG;YACW,wBAAwB;IAuEtC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,eAAe;IAsCvB;;;;;;;;;;;;;;OAcG;YACW,aAAa;IAuH3B;;;;;;;;;;;;;;OAcG;YACW,gBAAgB;CAmBjC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentSpecSync = void 0;
4
- const global_1 = require("@memberjunction/global");
4
+ const core_1 = require("@memberjunction/core");
5
5
  /**
6
6
  * AgentSpecSync provides a high-level interface for working with AI Agent metadata in MemberJunction.
7
7
  *
@@ -91,7 +91,7 @@ class AgentSpecSync {
91
91
  Name: '',
92
92
  StartingPayloadValidationMode: 'Fail',
93
93
  Actions: [],
94
- SubAgents: [],
94
+ SubAgents: []
95
95
  };
96
96
  }
97
97
  this._contextUser = contextUser;
@@ -106,7 +106,7 @@ class AgentSpecSync {
106
106
  Entity: entity,
107
107
  Operation: operation,
108
108
  ID: id,
109
- Description: description,
109
+ Description: description
110
110
  });
111
111
  }
112
112
  /**
@@ -171,11 +171,11 @@ class AgentSpecSync {
171
171
  */
172
172
  static async LoadByName(agentName, contextUser, includeSubAgents = true) {
173
173
  // Find agent by name
174
- const rv = new global_1.RunView();
174
+ const rv = new core_1.RunView();
175
175
  const result = await rv.RunView({
176
176
  EntityName: 'AI Agents',
177
177
  ExtraFilter: `Name='${agentName.replace(/'/g, "''")}'`,
178
- ResultType: 'entity_object',
178
+ ResultType: 'entity_object'
179
179
  }, contextUser);
180
180
  if (!result.Success) {
181
181
  throw new Error(`Failed to find agent by name: ${result.ErrorMessage}`);
@@ -230,8 +230,8 @@ class AgentSpecSync {
230
230
  * @throws {Error} If agent is not found
231
231
  */
232
232
  async loadFromEntities(agentId, includeSubAgents) {
233
- const md = new global_1.Metadata();
234
- const rv = new global_1.RunView();
233
+ const md = new core_1.Metadata();
234
+ const rv = new core_1.RunView();
235
235
  // Step 1: Load the main agent entity
236
236
  const agentEntity = await md.GetEntityObject('AI Agents', this._contextUser);
237
237
  const loaded = await agentEntity.Load(agentId);
@@ -245,32 +245,32 @@ class AgentSpecSync {
245
245
  EntityName: 'AI Agent Actions',
246
246
  ExtraFilter: `AgentID='${agentId}'`,
247
247
  OrderBy: 'Status, ActionID',
248
- ResultType: 'entity_object',
248
+ ResultType: 'entity_object'
249
249
  },
250
250
  {
251
251
  EntityName: 'AI Agents',
252
252
  ExtraFilter: `ParentID='${agentId}'`,
253
253
  OrderBy: 'ExecutionOrder, Name',
254
- ResultType: 'entity_object',
254
+ ResultType: 'entity_object'
255
255
  },
256
256
  {
257
257
  EntityName: 'MJ: AI Agent Relationships',
258
258
  ExtraFilter: `AgentID='${agentId}' AND Status='Active'`,
259
259
  OrderBy: '__mj_CreatedAt',
260
- ResultType: 'entity_object',
260
+ ResultType: 'entity_object'
261
261
  },
262
262
  {
263
263
  EntityName: 'MJ: AI Agent Prompts',
264
264
  ExtraFilter: `AgentID='${agentId}'`,
265
265
  OrderBy: 'ExecutionOrder',
266
- ResultType: 'entity_object',
266
+ ResultType: 'entity_object'
267
267
  },
268
268
  {
269
269
  EntityName: 'MJ: AI Agent Steps',
270
270
  ExtraFilter: `AgentID='${agentId}'`,
271
271
  OrderBy: 'Name',
272
- ResultType: 'entity_object',
273
- },
272
+ ResultType: 'entity_object'
273
+ }
274
274
  ], this._contextUser);
275
275
  // Check for errors
276
276
  if (!actionsResult.Success) {
@@ -297,7 +297,7 @@ class AgentSpecSync {
297
297
  EntityName: 'MJ: AI Agent Step Paths',
298
298
  ExtraFilter: `OriginStepID IN (${stepIds})`,
299
299
  OrderBy: 'Priority DESC',
300
- ResultType: 'entity_object',
300
+ ResultType: 'entity_object'
301
301
  }, this._contextUser);
302
302
  if (!pathsResult.Success) {
303
303
  throw new Error(`Failed to load step paths: ${pathsResult.ErrorMessage}`);
@@ -308,7 +308,7 @@ class AgentSpecSync {
308
308
  pathsResult = {
309
309
  Success: true,
310
310
  Results: [],
311
- RowCount: 0,
311
+ RowCount: 0
312
312
  };
313
313
  }
314
314
  // Step 2c: Load full AI Prompt records to get PromptText, PromptRole, PromptPosition
@@ -320,7 +320,7 @@ class AgentSpecSync {
320
320
  EntityName: 'AI Prompts',
321
321
  ExtraFilter: `ID IN (${promptIds})`,
322
322
  OrderBy: 'Name',
323
- ResultType: 'entity_object',
323
+ ResultType: 'entity_object'
324
324
  }, this._contextUser);
325
325
  if (!fullPromptsResult.Success) {
326
326
  throw new Error(`Failed to load AI prompts: ${fullPromptsResult.ErrorMessage}`);
@@ -331,7 +331,7 @@ class AgentSpecSync {
331
331
  fullPromptsResult = {
332
332
  Success: true,
333
333
  Results: [],
334
- RowCount: 0,
334
+ RowCount: 0
335
335
  };
336
336
  }
337
337
  // Step 3: Map entities to raw spec format
@@ -351,11 +351,11 @@ class AgentSpecSync {
351
351
  subAgentSpec.SubAgent = {
352
352
  ...fullSubAgentSpec,
353
353
  // Ensure we preserve any relationship-specific overrides
354
- StartingPayloadValidationMode: subAgentSpec.SubAgent.StartingPayloadValidationMode || fullSubAgentSpec.StartingPayloadValidationMode,
354
+ StartingPayloadValidationMode: subAgentSpec.SubAgent.StartingPayloadValidationMode || fullSubAgentSpec.StartingPayloadValidationMode
355
355
  };
356
356
  }
357
357
  catch (error) {
358
- (0, global_1.LogError)(`Failed to load sub-agent ${subAgentSpec.SubAgent.ID}: ${error instanceof Error ? error.message : String(error)}`);
358
+ (0, core_1.LogError)(`Failed to load sub-agent ${subAgentSpec.SubAgent.ID}: ${error instanceof Error ? error.message : String(error)}`);
359
359
  // Continue with partial data rather than failing completely
360
360
  }
361
361
  }
@@ -424,18 +424,18 @@ class AgentSpecSync {
424
424
  FunctionalRequirements: agent.FunctionalRequirements || null,
425
425
  TechnicalDesign: agent.TechnicalDesign || null,
426
426
  // Map actions
427
- Actions: actions.map((action) => this.mapActionEntityToSpec(action)),
427
+ Actions: actions.map(action => this.mapActionEntityToSpec(action)),
428
428
  // Map sub-agents (both child and related)
429
429
  SubAgents: [
430
- ...childAgents.map((child) => this.mapChildAgentToSpec(child)),
431
- ...relatedAgents.map((rel) => this.mapRelatedAgentToSpec(rel)),
430
+ ...childAgents.map(child => this.mapChildAgentToSpec(child)),
431
+ ...relatedAgents.map(rel => this.mapRelatedAgentToSpec(rel))
432
432
  ],
433
433
  // Map prompts (agent-level prompts for Loop agents)
434
- Prompts: agentPrompts.map((agentPrompt) => this.mapPromptEntityToSpec(agentPrompt, fullPrompts)),
434
+ Prompts: agentPrompts.map(agentPrompt => this.mapPromptEntityToSpec(agentPrompt, fullPrompts)),
435
435
  // Map steps (for Flow agents)
436
- Steps: steps.map((step) => this.mapStepEntityToSpec(step)),
436
+ Steps: steps.map(step => this.mapStepEntityToSpec(step)),
437
437
  // Map paths (for Flow agents)
438
- Paths: paths.map((path) => this.mapPathEntityToSpec(path)),
438
+ Paths: paths.map(path => this.mapPathEntityToSpec(path))
439
439
  };
440
440
  return spec;
441
441
  }
@@ -456,7 +456,7 @@ class AgentSpecSync {
456
456
  ResultExpirationMode: action.ResultExpirationMode || undefined,
457
457
  CompactMode: action.CompactMode || undefined,
458
458
  CompactLength: action.CompactLength || undefined,
459
- CompactPromptID: action.CompactPromptID || null,
459
+ CompactPromptID: action.CompactPromptID || null
460
460
  };
461
461
  }
462
462
  /**
@@ -472,8 +472,8 @@ class AgentSpecSync {
472
472
  SubAgent: {
473
473
  ID: childAgent.ID,
474
474
  Name: childAgent.Name || '',
475
- StartingPayloadValidationMode: 'Fail',
476
- },
475
+ StartingPayloadValidationMode: 'Fail'
476
+ }
477
477
  };
478
478
  }
479
479
  /**
@@ -489,12 +489,12 @@ class AgentSpecSync {
489
489
  SubAgent: {
490
490
  ID: relationship.SubAgentID,
491
491
  Name: relationship.SubAgent || '',
492
- StartingPayloadValidationMode: 'Fail',
492
+ StartingPayloadValidationMode: 'Fail'
493
493
  },
494
494
  AgentRelationshipID: relationship.ID,
495
495
  SubAgentInputMapping: this.parseJsonField(relationship.SubAgentInputMapping),
496
496
  SubAgentOutputMapping: this.parseJsonField(relationship.SubAgentOutputMapping),
497
- SubAgentContextPaths: this.parseJsonField(relationship.SubAgentContextPaths),
497
+ SubAgentContextPaths: this.parseJsonField(relationship.SubAgentContextPaths)
498
498
  };
499
499
  }
500
500
  /**
@@ -515,7 +515,7 @@ class AgentSpecSync {
515
515
  PromptID: agentPrompt.PromptID || '',
516
516
  PromptText: '',
517
517
  PromptRole: 'System',
518
- PromptPosition: 'First',
518
+ PromptPosition: 'First'
519
519
  };
520
520
  }
521
521
  return {
@@ -523,7 +523,7 @@ class AgentSpecSync {
523
523
  PromptID: fullPrompt.ID || '',
524
524
  PromptText: fullPrompt.TemplateText || '',
525
525
  PromptRole: fullPrompt.PromptRole || 'System',
526
- PromptPosition: fullPrompt.PromptPosition || 'First',
526
+ PromptPosition: fullPrompt.PromptPosition || 'First'
527
527
  };
528
528
  }
529
529
  /**
@@ -544,7 +544,7 @@ class AgentSpecSync {
544
544
  SubAgentID: step.SubAgentID || undefined,
545
545
  PromptID: step.PromptID || undefined,
546
546
  ActionInputMapping: this.parseJsonField(step.ActionInputMapping),
547
- ActionOutputMapping: this.parseJsonField(step.ActionOutputMapping),
547
+ ActionOutputMapping: this.parseJsonField(step.ActionOutputMapping)
548
548
  };
549
549
  }
550
550
  /**
@@ -561,7 +561,7 @@ class AgentSpecSync {
561
561
  DestinationStepID: path.DestinationStepID,
562
562
  Condition: path.Condition || undefined,
563
563
  Description: path.Description || undefined,
564
- Priority: path.Priority,
564
+ Priority: path.Priority
565
565
  };
566
566
  }
567
567
  // ===== SAVING METHODS =====
@@ -598,7 +598,7 @@ class AgentSpecSync {
598
598
  return {
599
599
  agentId: this.spec.ID,
600
600
  success: true,
601
- mutations: [],
601
+ mutations: []
602
602
  };
603
603
  }
604
604
  try {
@@ -629,7 +629,7 @@ class AgentSpecSync {
629
629
  return {
630
630
  agentId,
631
631
  success: true,
632
- mutations: this.getMutations(),
632
+ mutations: this.getMutations()
633
633
  };
634
634
  }
635
635
  catch (error) {
@@ -637,7 +637,7 @@ class AgentSpecSync {
637
637
  return {
638
638
  agentId: this.spec.ID || '',
639
639
  success: false,
640
- mutations: this.getMutations(),
640
+ mutations: this.getMutations()
641
641
  };
642
642
  }
643
643
  }
@@ -650,7 +650,7 @@ class AgentSpecSync {
650
650
  * @throws {Error} If validation fails or save fails
651
651
  */
652
652
  async saveAgentEntity(validate) {
653
- const md = new global_1.Metadata();
653
+ const md = new core_1.Metadata();
654
654
  const agentEntity = await md.GetEntityObject('AI Agents', this._contextUser);
655
655
  // Track if this is an update or create
656
656
  const isUpdate = !!this.spec.ID;
@@ -683,8 +683,12 @@ class AgentSpecSync {
683
683
  // Serialize JSON fields
684
684
  agentEntity.PayloadDownstreamPaths = JSON.stringify(this.spec.PayloadDownstreamPaths || ['*']);
685
685
  agentEntity.PayloadUpstreamPaths = JSON.stringify(this.spec.PayloadUpstreamPaths || ['*']);
686
- agentEntity.PayloadSelfReadPaths = this.spec.PayloadSelfReadPaths ? JSON.stringify(this.spec.PayloadSelfReadPaths) : null;
687
- agentEntity.PayloadSelfWritePaths = this.spec.PayloadSelfWritePaths ? JSON.stringify(this.spec.PayloadSelfWritePaths) : null;
686
+ agentEntity.PayloadSelfReadPaths = this.spec.PayloadSelfReadPaths
687
+ ? JSON.stringify(this.spec.PayloadSelfReadPaths)
688
+ : null;
689
+ agentEntity.PayloadSelfWritePaths = this.spec.PayloadSelfWritePaths
690
+ ? JSON.stringify(this.spec.PayloadSelfWritePaths)
691
+ : null;
688
692
  agentEntity.PayloadScope = this.spec.PayloadScope || null;
689
693
  // Validation fields
690
694
  agentEntity.FinalPayloadValidation = this.spec.FinalPayloadValidation || null;
@@ -720,7 +724,7 @@ class AgentSpecSync {
720
724
  if (validate) {
721
725
  const validation = agentEntity.Validate();
722
726
  if (!validation.Success) {
723
- const errors = validation.Errors.map((e) => e.Message).join(', ');
727
+ const errors = validation.Errors.map(e => e.Message).join(', ');
724
728
  throw new Error(`Agent validation failed: ${errors}`);
725
729
  }
726
730
  }
@@ -750,7 +754,7 @@ class AgentSpecSync {
750
754
  if (!this.spec.Actions || this.spec.Actions.length === 0) {
751
755
  return;
752
756
  }
753
- const md = new global_1.Metadata();
757
+ const md = new core_1.Metadata();
754
758
  for (const actionSpec of this.spec.Actions) {
755
759
  const actionEntity = await md.GetEntityObject('AI Agent Actions', this._contextUser);
756
760
  // Track if this is an update or create
@@ -826,7 +830,7 @@ class AgentSpecSync {
826
830
  // Set ParentID in the sub-agent spec before creating it
827
831
  const childSpec = {
828
832
  ...SubAgentSpec.SubAgent,
829
- ParentID: parentId,
833
+ ParentID: parentId
830
834
  };
831
835
  // Recursively create the sub-agent using AgentSpecSync
832
836
  const childSync = new AgentSpecSync(childSpec, this._contextUser);
@@ -842,7 +846,7 @@ class AgentSpecSync {
842
846
  // Set ParentID in the sub-agent spec
843
847
  const childSpec = {
844
848
  ...SubAgentSpec.SubAgent,
845
- ParentID: parentId,
849
+ ParentID: parentId
846
850
  };
847
851
  // Recursively update the sub-agent using AgentSpecSync
848
852
  // This ensures all fields including FunctionalRequirements and TechnicalDesign are updated
@@ -865,7 +869,7 @@ class AgentSpecSync {
865
869
  * @throws {Error} If relationship save fails
866
870
  */
867
871
  async saveRelatedSubAgent(agentId, SubAgentSpec) {
868
- const md = new global_1.Metadata();
872
+ const md = new core_1.Metadata();
869
873
  const relationshipEntity = await md.GetEntityObject('MJ: AI Agent Relationships', this._contextUser);
870
874
  // Load existing if ID provided
871
875
  const isUpdate = !!SubAgentSpec.AgentRelationshipID;
@@ -922,8 +926,8 @@ class AgentSpecSync {
922
926
  return;
923
927
  }
924
928
  console.log(`💬 savePrompts: Processing ${this.spec.Prompts.length} prompt(s)...`);
925
- const md = new global_1.Metadata();
926
- const rv = new global_1.RunView();
929
+ const md = new core_1.Metadata();
930
+ const rv = new core_1.RunView();
927
931
  // Step 1: Create or update AIPrompt records
928
932
  for (let i = 0; i < this.spec.Prompts.length; i++) {
929
933
  const promptSpec = this.spec.Prompts[i];
@@ -981,7 +985,7 @@ class AgentSpecSync {
981
985
  const existingJunctionResult = await rv.RunView({
982
986
  EntityName: 'MJ: AI Agent Prompts',
983
987
  ExtraFilter: `AgentID='${agentId}' AND PromptID='${promptEntity.ID}'`,
984
- ResultType: 'entity_object',
988
+ ResultType: 'entity_object'
985
989
  }, this._contextUser);
986
990
  let agentPromptEntity;
987
991
  let isJunctionUpdate = false;
@@ -1028,7 +1032,7 @@ class AgentSpecSync {
1028
1032
  return;
1029
1033
  }
1030
1034
  console.log(`🔷 saveSteps: Processing ${this.spec.Steps.length} step(s)...`);
1031
- const md = new global_1.Metadata();
1035
+ const md = new core_1.Metadata();
1032
1036
  for (const stepSpec of this.spec.Steps) {
1033
1037
  const stepEntity = await md.GetEntityObject('MJ: AI Agent Steps', this._contextUser);
1034
1038
  // Load existing if ID provided
@@ -1081,16 +1085,18 @@ class AgentSpecSync {
1081
1085
  // Map Action I/O mappings for Flow agent action steps
1082
1086
  // Handle ActionInputMapping - convert object to JSON string if needed
1083
1087
  if (stepSpec.ActionInputMapping) {
1084
- stepEntity.ActionInputMapping =
1085
- typeof stepSpec.ActionInputMapping === 'string' ? stepSpec.ActionInputMapping : JSON.stringify(stepSpec.ActionInputMapping);
1088
+ stepEntity.ActionInputMapping = typeof stepSpec.ActionInputMapping === 'string'
1089
+ ? stepSpec.ActionInputMapping
1090
+ : JSON.stringify(stepSpec.ActionInputMapping);
1086
1091
  }
1087
1092
  else {
1088
1093
  stepEntity.ActionInputMapping = null;
1089
1094
  }
1090
1095
  // Handle ActionOutputMapping - convert object to JSON string if needed
1091
1096
  if (stepSpec.ActionOutputMapping) {
1092
- stepEntity.ActionOutputMapping =
1093
- typeof stepSpec.ActionOutputMapping === 'string' ? stepSpec.ActionOutputMapping : JSON.stringify(stepSpec.ActionOutputMapping);
1097
+ stepEntity.ActionOutputMapping = typeof stepSpec.ActionOutputMapping === 'string'
1098
+ ? stepSpec.ActionOutputMapping
1099
+ : JSON.stringify(stepSpec.ActionOutputMapping);
1094
1100
  }
1095
1101
  else {
1096
1102
  stepEntity.ActionOutputMapping = null;
@@ -1124,7 +1130,7 @@ class AgentSpecSync {
1124
1130
  return;
1125
1131
  }
1126
1132
  console.log(`🔶 saveStepPaths: Processing ${this.spec.Paths.length} path(s)...`);
1127
- const md = new global_1.Metadata();
1133
+ const md = new core_1.Metadata();
1128
1134
  // Create a map of step names to IDs for easy lookup
1129
1135
  const stepNameToId = new Map();
1130
1136
  if (this.spec.Steps) {
@@ -1189,7 +1195,7 @@ class AgentSpecSync {
1189
1195
  return JSON.parse(jsonString);
1190
1196
  }
1191
1197
  catch (error) {
1192
- (0, global_1.LogError)(`Failed to parse JSON field: ${error}`);
1198
+ (0, core_1.LogError)(`Failed to parse JSON field: ${error}`);
1193
1199
  return undefined;
1194
1200
  }
1195
1201
  }
@@ -1244,7 +1250,7 @@ class AgentSpecSync {
1244
1250
  Prompts: partial.Prompts || [],
1245
1251
  // Flow agent fields - critical for Flow agent support
1246
1252
  Steps: partial.Steps || [],
1247
- Paths: partial.Paths || [],
1253
+ Paths: partial.Paths || []
1248
1254
  };
1249
1255
  }
1250
1256
  /**
@@ -1333,40 +1339,41 @@ class AgentSpecSync {
1333
1339
  * @throws {Error} If any query fails
1334
1340
  */
1335
1341
  async loadCurrentDatabaseState(agentId) {
1336
- const rv = new global_1.RunView();
1342
+ const rv = new core_1.RunView();
1337
1343
  // Batch load all related records for this agent
1338
1344
  const [actions, prompts, relationships, steps, childAgents] = await rv.RunViews([
1339
1345
  {
1340
1346
  EntityName: 'AI Agent Actions',
1341
1347
  ExtraFilter: `AgentID='${agentId}'`,
1342
- ResultType: 'entity_object',
1348
+ ResultType: 'entity_object'
1343
1349
  },
1344
1350
  {
1345
1351
  EntityName: 'MJ: AI Agent Prompts',
1346
1352
  ExtraFilter: `AgentID='${agentId}'`,
1347
- ResultType: 'entity_object',
1353
+ ResultType: 'entity_object'
1348
1354
  },
1349
1355
  {
1350
1356
  EntityName: 'MJ: AI Agent Relationships',
1351
1357
  ExtraFilter: `AgentID='${agentId}'`,
1352
- ResultType: 'entity_object',
1358
+ ResultType: 'entity_object'
1353
1359
  },
1354
1360
  {
1355
1361
  EntityName: 'MJ: AI Agent Steps',
1356
1362
  ExtraFilter: `AgentID='${agentId}'`,
1357
- ResultType: 'entity_object',
1363
+ ResultType: 'entity_object'
1358
1364
  },
1359
1365
  {
1360
1366
  EntityName: 'AI Agents',
1361
1367
  ExtraFilter: `ParentID='${agentId}'`,
1362
- ResultType: 'entity_object',
1363
- },
1368
+ ResultType: 'entity_object'
1369
+ }
1364
1370
  ], this._contextUser);
1365
1371
  // Check for errors
1366
- if (!actions.Success || !prompts.Success || !relationships.Success || !steps.Success || !childAgents.Success) {
1372
+ if (!actions.Success || !prompts.Success || !relationships.Success ||
1373
+ !steps.Success || !childAgents.Success) {
1367
1374
  const errors = [actions, prompts, relationships, steps, childAgents]
1368
- .filter((r) => !r.Success)
1369
- .map((r) => r.ErrorMessage)
1375
+ .filter(r => !r.Success)
1376
+ .map(r => r.ErrorMessage)
1370
1377
  .join('; ');
1371
1378
  throw new Error(`Failed to load database state: ${errors}`);
1372
1379
  }
@@ -1378,7 +1385,7 @@ class AgentSpecSync {
1378
1385
  pathsResult = await rv.RunView({
1379
1386
  EntityName: 'MJ: AI Agent Step Paths',
1380
1387
  ExtraFilter: `OriginStepID IN (${stepIds})`,
1381
- ResultType: 'entity_object',
1388
+ ResultType: 'entity_object'
1382
1389
  }, this._contextUser);
1383
1390
  if (!pathsResult.Success) {
1384
1391
  throw new Error(`Failed to load step paths: ${pathsResult.ErrorMessage}`);
@@ -1394,7 +1401,7 @@ class AgentSpecSync {
1394
1401
  relationships: relationships.Results || [],
1395
1402
  steps: stepRecords,
1396
1403
  paths: pathsResult.Results || [],
1397
- childAgents: childAgents.Results || [],
1404
+ childAgents: childAgents.Results || []
1398
1405
  };
1399
1406
  }
1400
1407
  /**
@@ -1415,17 +1422,17 @@ class AgentSpecSync {
1415
1422
  identifyOrphans(dbState, spec) {
1416
1423
  return {
1417
1424
  // Orphaned actions: DB actions not in spec.Actions
1418
- actions: dbState.actions.filter((dbAction) => !spec.Actions?.some((specAction) => specAction.AgentActionID === dbAction.ID)),
1425
+ actions: dbState.actions.filter(dbAction => !spec.Actions?.some(specAction => specAction.AgentActionID === dbAction.ID)),
1419
1426
  // Orphaned prompt junctions: DB prompts not in spec.Prompts
1420
- prompts: dbState.prompts.filter((dbPrompt) => !spec.Prompts?.some((specPrompt) => specPrompt.ID === dbPrompt.ID)),
1427
+ prompts: dbState.prompts.filter(dbPrompt => !spec.Prompts?.some(specPrompt => specPrompt.ID === dbPrompt.ID)),
1421
1428
  // Orphaned relationships: DB relationships not in spec.SubAgents (related type)
1422
- relationships: dbState.relationships.filter((dbRel) => !spec.SubAgents?.some((specSub) => specSub.Type === 'related' && specSub.AgentRelationshipID === dbRel.ID)),
1429
+ relationships: dbState.relationships.filter(dbRel => !spec.SubAgents?.some(specSub => specSub.Type === 'related' && specSub.AgentRelationshipID === dbRel.ID)),
1423
1430
  // Orphaned steps: DB steps not in spec.Steps
1424
- steps: dbState.steps.filter((dbStep) => !spec.Steps?.some((specStep) => specStep.ID === dbStep.ID)),
1431
+ steps: dbState.steps.filter(dbStep => !spec.Steps?.some(specStep => specStep.ID === dbStep.ID)),
1425
1432
  // Orphaned paths: DB paths not in spec.Paths
1426
- paths: dbState.paths.filter((dbPath) => !spec.Paths?.some((specPath) => specPath.ID === dbPath.ID)),
1433
+ paths: dbState.paths.filter(dbPath => !spec.Paths?.some(specPath => specPath.ID === dbPath.ID)),
1427
1434
  // Orphaned child agents: DB children not in spec.SubAgents (child type)
1428
- childAgents: dbState.childAgents.filter((dbChild) => !spec.SubAgents?.some((specSub) => specSub.Type === 'child' && specSub.SubAgent.ID === dbChild.ID)),
1435
+ childAgents: dbState.childAgents.filter(dbChild => !spec.SubAgents?.some(specSub => specSub.Type === 'child' && specSub.SubAgent.ID === dbChild.ID))
1429
1436
  };
1430
1437
  }
1431
1438
  /**
@@ -1444,7 +1451,7 @@ class AgentSpecSync {
1444
1451
  * @throws {Error} If any delete operation fails
1445
1452
  */
1446
1453
  async deleteOrphans(orphans) {
1447
- const md = new global_1.Metadata();
1454
+ const md = new core_1.Metadata();
1448
1455
  // Phase 1: Leaf entities (Paths, Actions)
1449
1456
  console.log(`🗑️ Phase 1: Deleting ${orphans.paths.length} paths and ${orphans.actions.length} actions...`);
1450
1457
  for (const path of orphans.paths) {
@@ -1554,7 +1561,7 @@ class AgentSpecSync {
1554
1561
  */
1555
1562
  async orphanChildAgent(childAgentId) {
1556
1563
  console.log(`🔗 orphanChildAgent: Orphaning child agent ${childAgentId}...`);
1557
- const md = new global_1.Metadata();
1564
+ const md = new core_1.Metadata();
1558
1565
  const childAgent = await md.GetEntityObject('AI Agents', this._contextUser);
1559
1566
  const loaded = await childAgent.Load(childAgentId);
1560
1567
  if (!loaded) {