@memberjunction/ng-core-entity-forms 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.
Files changed (152) hide show
  1. package/README.md +10 -10
  2. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-diagram.component.d.ts.map +1 -1
  3. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-diagram.component.js +45 -45
  4. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-diagram.component.js.map +1 -1
  5. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-form-section.component.d.ts.map +1 -1
  6. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-form-section.component.js +7 -6
  7. package/dist/lib/custom/AIAgents/FlowAgentType/flow-agent-form-section.component.js.map +1 -1
  8. package/dist/lib/custom/AIAgents/FlowAgentType/mj-integrated-flow-editor.component.d.ts.map +1 -1
  9. package/dist/lib/custom/AIAgents/FlowAgentType/mj-integrated-flow-editor.component.js +32 -17
  10. package/dist/lib/custom/AIAgents/FlowAgentType/mj-integrated-flow-editor.component.js.map +1 -1
  11. package/dist/lib/custom/AIAgents/add-action-dialog.component.d.ts.map +1 -1
  12. package/dist/lib/custom/AIAgents/add-action-dialog.component.js +36 -37
  13. package/dist/lib/custom/AIAgents/add-action-dialog.component.js.map +1 -1
  14. package/dist/lib/custom/AIAgents/agent-advanced-settings-dialog.component.js +2 -2
  15. package/dist/lib/custom/AIAgents/agent-advanced-settings-dialog.component.js.map +1 -1
  16. package/dist/lib/custom/AIAgents/agent-permissions-dialog.component.d.ts +1 -1
  17. package/dist/lib/custom/AIAgents/agent-permissions-dialog.component.d.ts.map +1 -1
  18. package/dist/lib/custom/AIAgents/agent-permissions-dialog.component.js +25 -18
  19. package/dist/lib/custom/AIAgents/agent-permissions-dialog.component.js.map +1 -1
  20. package/dist/lib/custom/AIAgents/agent-prompt-advanced-settings-dialog.component.d.ts.map +1 -1
  21. package/dist/lib/custom/AIAgents/agent-prompt-advanced-settings-dialog.component.js +11 -10
  22. package/dist/lib/custom/AIAgents/agent-prompt-advanced-settings-dialog.component.js.map +1 -1
  23. package/dist/lib/custom/AIAgents/ai-agent-form.component.d.ts.map +1 -1
  24. package/dist/lib/custom/AIAgents/ai-agent-form.component.js +147 -159
  25. package/dist/lib/custom/AIAgents/ai-agent-form.component.js.map +1 -1
  26. package/dist/lib/custom/AIAgents/create-prompt-dialog.component.d.ts.map +1 -1
  27. package/dist/lib/custom/AIAgents/create-prompt-dialog.component.js +10 -11
  28. package/dist/lib/custom/AIAgents/create-prompt-dialog.component.js.map +1 -1
  29. package/dist/lib/custom/AIAgents/create-sub-agent-dialog.component.d.ts.map +1 -1
  30. package/dist/lib/custom/AIAgents/create-sub-agent-dialog.component.js +32 -36
  31. package/dist/lib/custom/AIAgents/create-sub-agent-dialog.component.js.map +1 -1
  32. package/dist/lib/custom/AIAgents/new-agent-dialog.component.js +5 -5
  33. package/dist/lib/custom/AIAgents/new-agent-dialog.component.js.map +1 -1
  34. package/dist/lib/custom/AIAgents/prompt-selector-dialog.component.d.ts.map +1 -1
  35. package/dist/lib/custom/AIAgents/prompt-selector-dialog.component.js +13 -15
  36. package/dist/lib/custom/AIAgents/prompt-selector-dialog.component.js.map +1 -1
  37. package/dist/lib/custom/AIAgents/sub-agent-advanced-settings-dialog.component.d.ts.map +1 -1
  38. package/dist/lib/custom/AIAgents/sub-agent-advanced-settings-dialog.component.js +15 -13
  39. package/dist/lib/custom/AIAgents/sub-agent-advanced-settings-dialog.component.js.map +1 -1
  40. package/dist/lib/custom/AIAgents/sub-agent-selector-dialog.component.d.ts.map +1 -1
  41. package/dist/lib/custom/AIAgents/sub-agent-selector-dialog.component.js +23 -28
  42. package/dist/lib/custom/AIAgents/sub-agent-selector-dialog.component.js.map +1 -1
  43. package/dist/lib/custom/AIPromptRuns/ai-prompt-run-form.component.d.ts.map +1 -1
  44. package/dist/lib/custom/AIPromptRuns/ai-prompt-run-form.component.js +12 -15
  45. package/dist/lib/custom/AIPromptRuns/ai-prompt-run-form.component.js.map +1 -1
  46. package/dist/lib/custom/AIPrompts/ai-prompt-form.component.d.ts.map +1 -1
  47. package/dist/lib/custom/AIPrompts/ai-prompt-form.component.js +86 -105
  48. package/dist/lib/custom/AIPrompts/ai-prompt-form.component.js.map +1 -1
  49. package/dist/lib/custom/AIPrompts/template-selector-dialog.component.d.ts.map +1 -1
  50. package/dist/lib/custom/AIPrompts/template-selector-dialog.component.js +20 -13
  51. package/dist/lib/custom/AIPrompts/template-selector-dialog.component.js.map +1 -1
  52. package/dist/lib/custom/Actions/action-execution-log-form.component.d.ts.map +1 -1
  53. package/dist/lib/custom/Actions/action-execution-log-form.component.js +7 -4
  54. package/dist/lib/custom/Actions/action-execution-log-form.component.js.map +1 -1
  55. package/dist/lib/custom/Actions/action-form.component.d.ts.map +1 -1
  56. package/dist/lib/custom/Actions/action-form.component.js +80 -99
  57. package/dist/lib/custom/Actions/action-form.component.js.map +1 -1
  58. package/dist/lib/custom/Actions/action-test-harness.component.d.ts.map +1 -1
  59. package/dist/lib/custom/Actions/action-test-harness.component.js +17 -24
  60. package/dist/lib/custom/Actions/action-test-harness.component.js.map +1 -1
  61. package/dist/lib/custom/Queries/query-category-dialog.component.d.ts.map +1 -1
  62. package/dist/lib/custom/Queries/query-category-dialog.component.js +8 -8
  63. package/dist/lib/custom/Queries/query-category-dialog.component.js.map +1 -1
  64. package/dist/lib/custom/Queries/query-form.component.d.ts +2 -2
  65. package/dist/lib/custom/Queries/query-form.component.d.ts.map +1 -1
  66. package/dist/lib/custom/Queries/query-form.component.js +44 -32
  67. package/dist/lib/custom/Queries/query-form.component.js.map +1 -1
  68. package/dist/lib/custom/Queries/query-run-dialog.component.d.ts.map +1 -1
  69. package/dist/lib/custom/Queries/query-run-dialog.component.js +22 -24
  70. package/dist/lib/custom/Queries/query-run-dialog.component.js.map +1 -1
  71. package/dist/lib/custom/Templates/template-param-dialog.component.d.ts.map +1 -1
  72. package/dist/lib/custom/Templates/template-param-dialog.component.js +21 -15
  73. package/dist/lib/custom/Templates/template-param-dialog.component.js.map +1 -1
  74. package/dist/lib/custom/Templates/template-params-grid.component.d.ts.map +1 -1
  75. package/dist/lib/custom/Templates/template-params-grid.component.js +17 -29
  76. package/dist/lib/custom/Templates/template-params-grid.component.js.map +1 -1
  77. package/dist/lib/custom/Templates/templates-form.component.d.ts.map +1 -1
  78. package/dist/lib/custom/Templates/templates-form.component.js +26 -25
  79. package/dist/lib/custom/Templates/templates-form.component.js.map +1 -1
  80. package/dist/lib/custom/ai-agent-run/ai-agent-run-analytics.component.d.ts.map +1 -1
  81. package/dist/lib/custom/ai-agent-run/ai-agent-run-analytics.component.js +274 -335
  82. package/dist/lib/custom/ai-agent-run/ai-agent-run-analytics.component.js.map +1 -1
  83. package/dist/lib/custom/ai-agent-run/ai-agent-run-cost.service.d.ts.map +1 -1
  84. package/dist/lib/custom/ai-agent-run/ai-agent-run-cost.service.js +8 -8
  85. package/dist/lib/custom/ai-agent-run/ai-agent-run-cost.service.js.map +1 -1
  86. package/dist/lib/custom/ai-agent-run/ai-agent-run-data.service.d.ts.map +1 -1
  87. package/dist/lib/custom/ai-agent-run/ai-agent-run-data.service.js +28 -24
  88. package/dist/lib/custom/ai-agent-run/ai-agent-run-data.service.js.map +1 -1
  89. package/dist/lib/custom/ai-agent-run/ai-agent-run-timeline.component.d.ts.map +1 -1
  90. package/dist/lib/custom/ai-agent-run/ai-agent-run-timeline.component.js +30 -25
  91. package/dist/lib/custom/ai-agent-run/ai-agent-run-timeline.component.js.map +1 -1
  92. package/dist/lib/custom/ai-agent-run/ai-agent-run.component.d.ts.map +1 -1
  93. package/dist/lib/custom/ai-agent-run/ai-agent-run.component.js +21 -20
  94. package/dist/lib/custom/ai-agent-run/ai-agent-run.component.js.map +1 -1
  95. package/dist/lib/custom/shared/entity-selector-dialog.component.d.ts.map +1 -1
  96. package/dist/lib/custom/shared/entity-selector-dialog.component.js +7 -6
  97. package/dist/lib/custom/shared/entity-selector-dialog.component.js.map +1 -1
  98. package/dist/lib/generated/Entities/AIAgent/sections/aiagent-form-overview.component.d.ts.map +1 -1
  99. package/dist/lib/generated/Entities/AIAgent/sections/aiagent-form-overview.component.js +33 -47
  100. package/dist/lib/generated/Entities/AIAgent/sections/aiagent-form-overview.component.js.map +1 -1
  101. package/dist/lib/generated/Entities/AIAgent/sections/details.component.d.ts.map +1 -1
  102. package/dist/lib/generated/Entities/AIAgent/sections/details.component.js +31 -4
  103. package/dist/lib/generated/Entities/AIAgent/sections/details.component.js.map +1 -1
  104. package/dist/lib/generated/Entities/AIAgentExample/sections/details.component.d.ts.map +1 -1
  105. package/dist/lib/generated/Entities/AIAgentExample/sections/details.component.js +33 -4
  106. package/dist/lib/generated/Entities/AIAgentExample/sections/details.component.js.map +1 -1
  107. package/dist/lib/generated/Entities/AIAgentNote/sections/details.component.d.ts.map +1 -1
  108. package/dist/lib/generated/Entities/AIAgentNote/sections/details.component.js +33 -4
  109. package/dist/lib/generated/Entities/AIAgentNote/sections/details.component.js.map +1 -1
  110. package/dist/lib/generated/Entities/AIAgentRelationship/sections/details.component.d.ts.map +1 -1
  111. package/dist/lib/generated/Entities/AIAgentRelationship/sections/details.component.js +22 -4
  112. package/dist/lib/generated/Entities/AIAgentRelationship/sections/details.component.js.map +1 -1
  113. package/dist/lib/generated/Entities/AIAgentRun/aiagentrun.form.component.js +6 -6
  114. package/dist/lib/generated/Entities/AIAgentRun/aiagentrun.form.component.js.map +1 -1
  115. package/dist/lib/generated/Entities/AIConfiguration/aiconfiguration.form.component.js +8 -8
  116. package/dist/lib/generated/Entities/AIConfiguration/aiconfiguration.form.component.js.map +1 -1
  117. package/dist/lib/generated/Entities/AIModel/aimodel.form.component.js +34 -14
  118. package/dist/lib/generated/Entities/AIModel/aimodel.form.component.js.map +1 -1
  119. package/dist/lib/generated/Entities/ArtifactUse/artifactuse.form.component.d.ts +10 -0
  120. package/dist/lib/generated/Entities/ArtifactUse/artifactuse.form.component.d.ts.map +1 -0
  121. package/dist/lib/generated/Entities/ArtifactUse/artifactuse.form.component.js +59 -0
  122. package/dist/lib/generated/Entities/ArtifactUse/artifactuse.form.component.js.map +1 -0
  123. package/dist/lib/generated/Entities/ArtifactUse/sections/details.component.d.ts +11 -0
  124. package/dist/lib/generated/Entities/ArtifactUse/sections/details.component.d.ts.map +1 -0
  125. package/dist/lib/generated/Entities/ArtifactUse/sections/details.component.js +129 -0
  126. package/dist/lib/generated/Entities/ArtifactUse/sections/details.component.js.map +1 -0
  127. package/dist/lib/generated/Entities/ArtifactVersion/artifactversion.form.component.js +24 -4
  128. package/dist/lib/generated/Entities/ArtifactVersion/artifactversion.form.component.js.map +1 -1
  129. package/dist/lib/generated/Entities/CollectionArtifact/sections/details.component.js +10 -10
  130. package/dist/lib/generated/Entities/CollectionArtifact/sections/details.component.js.map +1 -1
  131. package/dist/lib/generated/Entities/ConversationArtifact/conversationartifact.form.component.js +6 -6
  132. package/dist/lib/generated/Entities/ConversationArtifact/conversationartifact.form.component.js.map +1 -1
  133. package/dist/lib/generated/Entities/ConversationDetail/conversationdetail.form.component.js +18 -8
  134. package/dist/lib/generated/Entities/ConversationDetail/conversationdetail.form.component.js.map +1 -1
  135. package/dist/lib/generated/Entities/ConversationDetailRating/conversationdetailrating.form.component.d.ts +10 -0
  136. package/dist/lib/generated/Entities/ConversationDetailRating/conversationdetailrating.form.component.d.ts.map +1 -0
  137. package/dist/lib/generated/Entities/ConversationDetailRating/conversationdetailrating.form.component.js +59 -0
  138. package/dist/lib/generated/Entities/ConversationDetailRating/conversationdetailrating.form.component.js.map +1 -0
  139. package/dist/lib/generated/Entities/ConversationDetailRating/sections/details.component.d.ts +11 -0
  140. package/dist/lib/generated/Entities/ConversationDetailRating/sections/details.component.d.ts.map +1 -0
  141. package/dist/lib/generated/Entities/ConversationDetailRating/sections/details.component.js +120 -0
  142. package/dist/lib/generated/Entities/ConversationDetailRating/sections/details.component.js.map +1 -0
  143. package/dist/lib/generated/Entities/User/user.form.component.js +49 -29
  144. package/dist/lib/generated/Entities/User/user.form.component.js.map +1 -1
  145. package/dist/lib/generated/generated-forms.module.d.ts +336 -327
  146. package/dist/lib/generated/generated-forms.module.d.ts.map +1 -1
  147. package/dist/lib/generated/generated-forms.module.js +199 -126
  148. package/dist/lib/generated/generated-forms.module.js.map +1 -1
  149. package/dist/lib/shared/components/template-editor.component.d.ts.map +1 -1
  150. package/dist/lib/shared/components/template-editor.component.js +27 -26
  151. package/dist/lib/shared/components/template-editor.component.js.map +1 -1
  152. package/package.json +17 -16
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Component, ViewContainerRef, ViewChild } from '@angular/core';
8
8
  import { RegisterClass, MJGlobal } from '@memberjunction/global';
9
9
  import { BaseFormComponent, BaseFormSectionComponent } from '@memberjunction/ng-base-forms';
10
- import { CompositeKey, Metadata, RunView } from '@memberjunction/global';
10
+ import { CompositeKey, Metadata, RunView } from '@memberjunction/core';
11
11
  import { MJNotificationService } from '@memberjunction/ng-notifications';
12
12
  import { AIAgentFormComponent } from '../../generated/Entities/AIAgent/aiagent.form.component';
13
13
  import { firstValueFrom, Subject } from 'rxjs';
@@ -2035,11 +2035,11 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2035
2035
  }
2036
2036
  /** Number of child sub-agents (ParentID-based) */
2037
2037
  get childSubAgentCount() {
2038
- return this.allSubAgents.filter((s) => s.type === 'child').length;
2038
+ return this.allSubAgents.filter(s => s.type === 'child').length;
2039
2039
  }
2040
2040
  /** Number of related sub-agents (Relationship-based) */
2041
2041
  get relatedSubAgentCount() {
2042
- return this.allSubAgents.filter((s) => s.type === 'related').length;
2042
+ return this.allSubAgents.filter(s => s.type === 'related').length;
2043
2043
  }
2044
2044
  /** Total number of sub-agents across both types */
2045
2045
  get totalSubAgentCount() {
@@ -2069,9 +2069,9 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2069
2069
  get filteredSubAgents() {
2070
2070
  switch (this.subAgentFilter) {
2071
2071
  case 'child':
2072
- return this.allSubAgents.filter((s) => s.type === 'child');
2072
+ return this.allSubAgents.filter(s => s.type === 'child');
2073
2073
  case 'related':
2074
- return this.allSubAgents.filter((s) => s.type === 'related');
2074
+ return this.allSubAgents.filter(s => s.type === 'related');
2075
2075
  default:
2076
2076
  return this.allSubAgents;
2077
2077
  }
@@ -2092,7 +2092,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2092
2092
  this.selectedContextCompressionPrompt = null;
2093
2093
  return;
2094
2094
  }
2095
- this.selectedContextCompressionPrompt = AIEngineBase.Instance.Prompts.find((p) => p.ID === this.record.ContextCompressionPromptID);
2095
+ this.selectedContextCompressionPrompt = AIEngineBase.Instance.Prompts.find(p => p.ID === this.record.ContextCompressionPromptID);
2096
2096
  if (!this.selectedContextCompressionPrompt) {
2097
2097
  console.warn('Context compression prompt not found:', this.record.ContextCompressionPromptID);
2098
2098
  }
@@ -2106,7 +2106,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2106
2106
  title: 'Select Context Compression Prompt',
2107
2107
  content: PromptSelectorDialogComponent,
2108
2108
  width: 800,
2109
- height: 600,
2109
+ height: 600
2110
2110
  });
2111
2111
  const promptSelector = dialogRef.content.instance;
2112
2112
  // Configure the prompt selector for single selection
@@ -2114,7 +2114,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2114
2114
  title: 'Select Context Compression Prompt',
2115
2115
  multiSelect: false,
2116
2116
  selectedPromptIds: this.record.ContextCompressionPromptID ? [this.record.ContextCompressionPromptID] : [],
2117
- showCreateNew: false,
2117
+ showCreateNew: false
2118
2118
  };
2119
2119
  // Subscribe to the result
2120
2120
  promptSelector.result.subscribe({
@@ -2128,7 +2128,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2128
2128
  },
2129
2129
  error: (error) => {
2130
2130
  console.error('Error in prompt selector dialog:', error);
2131
- },
2131
+ }
2132
2132
  });
2133
2133
  }
2134
2134
  catch (error) {
@@ -2146,7 +2146,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2146
2146
  }
2147
2147
  // Main AI Agent permissions inherited from BaseFormComponent:
2148
2148
  // - UserCanEdit (Update permission)
2149
- // - UserCanRead (Read permission)
2149
+ // - UserCanRead (Read permission)
2150
2150
  // - UserCanCreate (Create permission)
2151
2151
  // - UserCanDelete (Delete permission)
2152
2152
  /** Check if user can create AI Agent Actions */
@@ -2226,7 +2226,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2226
2226
  }
2227
2227
  try {
2228
2228
  const md = new Metadata();
2229
- const entityInfo = md.Entities.find((e) => e.Name === entityName);
2229
+ const entityInfo = md.Entities.find(e => e.Name === entityName);
2230
2230
  if (!entityInfo) {
2231
2231
  console.warn(`Entity '${entityName}' not found for permission check`);
2232
2232
  this._permissionCache.set(cacheKey, false);
@@ -2313,19 +2313,19 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2313
2313
  prompts: true,
2314
2314
  actions: true,
2315
2315
  learningCycles: true,
2316
- notes: true,
2316
+ notes: true
2317
2317
  };
2318
2318
  // === Dropdown Data ===
2319
2319
  /** Model selection mode options for the dropdown */
2320
2320
  this.modelSelectionModes = [
2321
2321
  { text: 'Agent Type', value: 'Agent Type' },
2322
- { text: 'Agent', value: 'Agent' },
2322
+ { text: 'Agent', value: 'Agent' }
2323
2323
  ];
2324
2324
  /** Agent status options for the dropdown */
2325
2325
  this.statusOptions = [
2326
2326
  { text: 'Active', value: 'Active' },
2327
2327
  { text: 'Pending', value: 'Pending' },
2328
- { text: 'Disabled', value: 'Disabled' },
2328
+ { text: 'Disabled', value: 'Disabled' }
2329
2329
  ];
2330
2330
  /** Agent types loaded from the database */
2331
2331
  this.agentTypes = [];
@@ -2395,7 +2395,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2395
2395
  prompts: true,
2396
2396
  actions: true,
2397
2397
  learningCycles: true,
2398
- notes: true,
2398
+ notes: true
2399
2399
  };
2400
2400
  this.cdr.detectChanges(); // update UI
2401
2401
  if (forceRefresh) {
@@ -2405,11 +2405,11 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2405
2405
  // Clear unified sub-agents array
2406
2406
  this.allSubAgents = [];
2407
2407
  // Load child sub-agents (ParentID-based)
2408
- const childAgents = AIEngineBase.Instance.Agents.filter((a) => a.ParentID === this.record.ID);
2408
+ const childAgents = AIEngineBase.Instance.Agents.filter(a => a.ParentID === this.record.ID);
2409
2409
  for (const agent of childAgents) {
2410
2410
  this.allSubAgents.push({
2411
2411
  agent,
2412
- type: 'child',
2412
+ type: 'child'
2413
2413
  });
2414
2414
  }
2415
2415
  // Also populate the deprecated subAgents array for backward compatibility
@@ -2419,16 +2419,16 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2419
2419
  const relationshipsResult = await rv.RunView({
2420
2420
  EntityName: 'MJ: AI Agent Relationships',
2421
2421
  ExtraFilter: `AgentID='${this.record.ID}' AND Status='Active'`,
2422
- ResultType: 'entity_object',
2422
+ ResultType: 'entity_object'
2423
2423
  });
2424
2424
  if (relationshipsResult.Success && relationshipsResult.Results) {
2425
2425
  for (const relationship of relationshipsResult.Results) {
2426
- const agent = AIEngineBase.Instance.Agents.find((a) => a.ID === relationship.SubAgentID);
2426
+ const agent = AIEngineBase.Instance.Agents.find(a => a.ID === relationship.SubAgentID);
2427
2427
  if (agent) {
2428
2428
  this.allSubAgents.push({
2429
2429
  agent,
2430
2430
  type: 'related',
2431
- relationship,
2431
+ relationship
2432
2432
  });
2433
2433
  }
2434
2434
  }
@@ -2440,13 +2440,13 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2440
2440
  }
2441
2441
  return (a.agent.Name || '').localeCompare(b.agent.Name || '');
2442
2442
  });
2443
- this.agentPrompts = AIEngineBase.Instance.Prompts.filter((p) => {
2444
- const filteredAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter((ap) => ap.AgentID === this.record.ID);
2445
- return filteredAgentPrompts.some((ap) => ap.PromptID === p.ID);
2443
+ this.agentPrompts = AIEngineBase.Instance.Prompts.filter(p => {
2444
+ const filteredAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter(ap => ap.AgentID === this.record.ID);
2445
+ return filteredAgentPrompts.some(ap => ap.PromptID === p.ID);
2446
2446
  });
2447
- this.agentActions = ActionEngineBase.Instance.Actions.filter((a) => {
2448
- const filteredAgentActions = AIEngineBase.Instance.AgentActions.filter((aa) => aa.AgentID === this.record.ID);
2449
- return filteredAgentActions.some((aa) => aa.ActionID === a.ID);
2447
+ this.agentActions = ActionEngineBase.Instance.Actions.filter(a => {
2448
+ const filteredAgentActions = AIEngineBase.Instance.AgentActions.filter(aa => aa.AgentID === this.record.ID);
2449
+ return filteredAgentActions.some(aa => aa.ActionID === a.ID);
2450
2450
  });
2451
2451
  // Execute all queries in a single batch for better performance
2452
2452
  const results = await rv.RunViews([
@@ -2454,38 +2454,28 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2454
2454
  {
2455
2455
  EntityName: 'AI Agent Learning Cycles',
2456
2456
  // limit fields
2457
- Fields: ['ID', 'Name', 'StartedAt', 'EndedAt', 'Status', 'AgentID'],
2457
+ Fields: ["ID", "Name", "StartedAt", "EndedAt", "Status", "AgentID"],
2458
2458
  ExtraFilter: `AgentID='${this.record.ID}'`,
2459
- OrderBy: 'StartedAt DESC',
2459
+ OrderBy: 'StartedAt DESC'
2460
2460
  },
2461
2461
  // Notes
2462
2462
  {
2463
2463
  EntityName: 'AI Agent Notes',
2464
2464
  // limit fields
2465
- Fields: ['ID', 'Name', 'AgentID', 'AgentNoteType', 'AgentNoteTypeID', 'UserID'],
2466
- ExtraFilter: `AgentID='${this.record.ID}'`,
2465
+ Fields: ["ID", "Name", "AgentID", "AgentNoteType", "AgentNoteTypeID", "UserID"],
2466
+ ExtraFilter: `AgentID='${this.record.ID}'`
2467
2467
  },
2468
2468
  // Execution history
2469
2469
  {
2470
2470
  EntityName: 'MJ: AI Agent Runs',
2471
2471
  Fields: [
2472
- // limit what we take from runs as this is where we can have a LOT come down if we include JSON fields
2473
- 'ID',
2474
- 'AgentID',
2475
- 'ParentRunID',
2476
- 'Status',
2477
- 'StartedAt',
2478
- 'CompletedAt',
2479
- 'Success',
2480
- 'TotalTokensUsed',
2481
- 'TotalCost',
2482
- 'TotalCostRollUp',
2483
- 'TotalTokensUsedRollUp',
2472
+ "ID", "AgentID", "ParentRunID", "Status", "StartedAt", "CompletedAt",
2473
+ "Success", "TotalTokensUsed", "TotalCost", "TotalCostRollUp", "TotalTokensUsedRollUp"
2484
2474
  ],
2485
2475
  ExtraFilter: `AgentID='${this.record.ID}'`,
2486
2476
  OrderBy: '__mj_CreatedAt DESC',
2487
- MaxRows: 100,
2488
- },
2477
+ MaxRows: 100
2478
+ }
2489
2479
  ]);
2490
2480
  // Process results in the same order as queries
2491
2481
  if (results && results.length > 0) {
@@ -2510,7 +2500,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2510
2500
  prompts: false,
2511
2501
  actions: false,
2512
2502
  learningCycles: false,
2513
- notes: false,
2503
+ notes: false
2514
2504
  };
2515
2505
  this.cdr.detectChanges();
2516
2506
  }
@@ -2529,7 +2519,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2529
2519
  subAgentCount: this.subAgentCount,
2530
2520
  learningCycleCount: this.learningCycleCount,
2531
2521
  noteCount: this.noteCount,
2532
- executionHistoryCount: this.executionHistoryCount,
2522
+ executionHistoryCount: this.executionHistoryCount
2533
2523
  };
2534
2524
  }
2535
2525
  /**
@@ -2666,7 +2656,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2666
2656
  const dialogRef = this.dialogService.open({
2667
2657
  content: AgentPermissionsDialogComponent,
2668
2658
  width: 900,
2669
- height: 600,
2659
+ height: 600
2670
2660
  });
2671
2661
  const dialog = dialogRef.content.instance;
2672
2662
  dialog.agent = this.record;
@@ -2679,14 +2669,10 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2679
2669
  */
2680
2670
  getStatusBadgeColor() {
2681
2671
  switch (this.record?.Status) {
2682
- case 'Active':
2683
- return '#28a745';
2684
- case 'Pending':
2685
- return '#ffc107';
2686
- case 'Disabled':
2687
- return '#6c757d';
2688
- default:
2689
- return '#6c757d';
2672
+ case 'Active': return '#28a745';
2673
+ case 'Pending': return '#ffc107';
2674
+ case 'Disabled': return '#6c757d';
2675
+ default: return '#6c757d';
2690
2676
  }
2691
2677
  }
2692
2678
  /**
@@ -2771,16 +2757,13 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2771
2757
  */
2772
2758
  async createSubAgent() {
2773
2759
  try {
2774
- this.agentManagementService
2775
- .openCreateSubAgentDialog({
2760
+ this.agentManagementService.openCreateSubAgentDialog({
2776
2761
  title: `Create Sub-Agent for ${this.record.Name || 'Agent'}`,
2777
2762
  initialName: '',
2778
2763
  parentAgentId: this.record.ID,
2779
2764
  parentAgentName: this.record.Name || 'Agent',
2780
- viewContainerRef: this.viewContainerRef,
2781
- })
2782
- .pipe(takeUntil(this.destroy$))
2783
- .subscribe({
2765
+ viewContainerRef: this.viewContainerRef
2766
+ }).pipe(takeUntil(this.destroy$)).subscribe({
2784
2767
  next: async (result) => {
2785
2768
  if (result && result.subAgent) {
2786
2769
  try {
@@ -2792,14 +2775,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2792
2775
  // Add the sub-agent to pending records
2793
2776
  this.PendingRecords.push({
2794
2777
  entityObject: result.subAgent,
2795
- action: 'save',
2778
+ action: 'save'
2796
2779
  });
2797
2780
  // Add any newly created prompts to pending records
2798
2781
  if (result.newPrompts) {
2799
2782
  for (const prompt of result.newPrompts) {
2800
2783
  this.PendingRecords.push({
2801
2784
  entityObject: prompt,
2802
- action: 'save',
2785
+ action: 'save'
2803
2786
  });
2804
2787
  }
2805
2788
  }
@@ -2808,7 +2791,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2808
2791
  for (const template of result.newPromptTemplates) {
2809
2792
  this.PendingRecords.push({
2810
2793
  entityObject: template,
2811
- action: 'save',
2794
+ action: 'save'
2812
2795
  });
2813
2796
  }
2814
2797
  }
@@ -2817,7 +2800,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2817
2800
  for (const content of result.newTemplateContents) {
2818
2801
  this.PendingRecords.push({
2819
2802
  entityObject: content,
2820
- action: 'save',
2803
+ action: 'save'
2821
2804
  });
2822
2805
  }
2823
2806
  }
@@ -2826,7 +2809,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2826
2809
  for (const agentPrompt of result.agentPrompts) {
2827
2810
  this.PendingRecords.push({
2828
2811
  entityObject: agentPrompt,
2829
- action: 'save',
2812
+ action: 'save'
2830
2813
  });
2831
2814
  }
2832
2815
  }
@@ -2835,7 +2818,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2835
2818
  for (const agentAction of result.agentActions) {
2836
2819
  this.PendingRecords.push({
2837
2820
  entityObject: agentAction,
2838
- action: 'save',
2821
+ action: 'save'
2839
2822
  });
2840
2823
  }
2841
2824
  }
@@ -2855,7 +2838,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2855
2838
  error: (error) => {
2856
2839
  console.error('Error in create sub-agent dialog:', error);
2857
2840
  MJNotificationService.Instance.CreateSimpleNotification('Error opening sub-agent creation dialog. Please try again.', 'error', 3000);
2858
- },
2841
+ }
2859
2842
  });
2860
2843
  }
2861
2844
  catch (error) {
@@ -2868,25 +2851,24 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2868
2851
  */
2869
2852
  async addPrompt() {
2870
2853
  // Get currently linked and pending prompt IDs for pre-selection
2871
- const currentPromptIds = this.agentPrompts.map((ap) => ap.ID);
2872
- const pendingAddIds = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' && p.action === 'save').map((p) => p.entityObject.Get('PromptID'));
2854
+ const currentPromptIds = this.agentPrompts.map(ap => ap.ID);
2855
+ const pendingAddIds = this.PendingRecords
2856
+ .filter(p => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' && p.action === 'save')
2857
+ .map(p => p.entityObject.Get('PromptID'));
2873
2858
  const allLinkedIds = [...currentPromptIds, ...pendingAddIds];
2874
2859
  try {
2875
- this.agentManagementService
2876
- .openPromptSelectorDialog({
2860
+ this.agentManagementService.openPromptSelectorDialog({
2877
2861
  title: 'Add Prompts to Agent',
2878
2862
  multiSelect: true,
2879
2863
  selectedPromptIds: [],
2880
2864
  showCreateNew: true,
2881
2865
  linkedPromptIds: allLinkedIds,
2882
- viewContainerRef: this.viewContainerRef,
2883
- })
2884
- .pipe(takeUntil(this.destroy$))
2885
- .subscribe({
2866
+ viewContainerRef: this.viewContainerRef
2867
+ }).pipe(takeUntil(this.destroy$)).subscribe({
2886
2868
  next: async (result) => {
2887
2869
  if (result && result.selectedPrompts.length > 0) {
2888
2870
  // Filter out already linked or pending prompts
2889
- const newPrompts = result.selectedPrompts.filter((prompt) => !allLinkedIds.includes(prompt.ID));
2871
+ const newPrompts = result.selectedPrompts.filter(prompt => !allLinkedIds.includes(prompt.ID));
2890
2872
  if (newPrompts.length === 0) {
2891
2873
  MJNotificationService.Instance.CreateSimpleNotification('All selected prompts are already linked to this agent', 'info', 3000);
2892
2874
  return;
@@ -2902,7 +2884,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2902
2884
  agentPrompt.ExecutionOrder = 1;
2903
2885
  this.PendingRecords.push({
2904
2886
  entityObject: agentPrompt,
2905
- action: 'save',
2887
+ action: 'save'
2906
2888
  });
2907
2889
  }
2908
2890
  this.hasUnsavedChanges = true;
@@ -2921,7 +2903,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2921
2903
  error: (error) => {
2922
2904
  console.error('Error opening prompt selector:', error);
2923
2905
  MJNotificationService.Instance.CreateSimpleNotification('Error opening prompt selector. Please try again.', 'error', 3000);
2924
- },
2906
+ }
2925
2907
  });
2926
2908
  }
2927
2909
  catch (error) {
@@ -2948,22 +2930,21 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2948
2930
  */
2949
2931
  async configureActions() {
2950
2932
  // Get currently linked and pending action IDs for pre-selection
2951
- const currentActionIds = this.agentActions.map((aa) => aa.ID);
2952
- const pendingAddIds = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Agent Actions' && p.action === 'save').map((p) => p.entityObject.Get('ActionID'));
2933
+ const currentActionIds = this.agentActions.map(aa => aa.ID);
2934
+ const pendingAddIds = this.PendingRecords
2935
+ .filter(p => p.entityObject.EntityInfo.Name === 'AI Agent Actions' && p.action === 'save')
2936
+ .map(p => p.entityObject.Get('ActionID'));
2953
2937
  const allLinkedIds = [...currentActionIds, ...pendingAddIds];
2954
- this.agentManagementService
2955
- .openAddActionDialog({
2938
+ this.agentManagementService.openAddActionDialog({
2956
2939
  agentId: this.record.ID,
2957
2940
  agentName: this.record.Name || 'Agent',
2958
2941
  existingActionIds: allLinkedIds,
2959
- viewContainerRef: this.viewContainerRef,
2960
- })
2961
- .pipe(takeUntil(this.destroy$))
2962
- .subscribe({
2942
+ viewContainerRef: this.viewContainerRef
2943
+ }).pipe(takeUntil(this.destroy$)).subscribe({
2963
2944
  next: async (selectedActions) => {
2964
2945
  if (selectedActions && selectedActions.length > 0) {
2965
2946
  // Filter out already linked or pending actions
2966
- const newActions = selectedActions.filter((action) => !allLinkedIds.includes(action.ID));
2947
+ const newActions = selectedActions.filter(action => !allLinkedIds.includes(action.ID));
2967
2948
  if (newActions.length === 0) {
2968
2949
  MJNotificationService.Instance.CreateSimpleNotification('All selected actions are already linked to this agent', 'info', 3000);
2969
2950
  return;
@@ -2978,7 +2959,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2978
2959
  agentAction.Status = 'Active';
2979
2960
  this.PendingRecords.push({
2980
2961
  entityObject: agentAction,
2981
- action: 'save',
2962
+ action: 'save'
2982
2963
  });
2983
2964
  }
2984
2965
  this.hasUnsavedChanges = true;
@@ -2993,7 +2974,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2993
2974
  error: (error) => {
2994
2975
  console.error('Error in add action dialog:', error);
2995
2976
  MJNotificationService.Instance.CreateSimpleNotification('Error opening action selection dialog. Please try again.', 'error', 3000);
2996
- },
2977
+ }
2997
2978
  });
2998
2979
  }
2999
2980
  /**
@@ -3144,8 +3125,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3144
3125
  // Force cache refresh by clearing old entries
3145
3126
  const now = Date.now();
3146
3127
  for (const [key, cached] of this._runningTimeCache.entries()) {
3147
- if (now - cached.timestamp > 500) {
3148
- // Refresh every 500ms
3128
+ if (now - cached.timestamp > 500) { // Refresh every 500ms
3149
3129
  this._runningTimeCache.delete(key);
3150
3130
  }
3151
3131
  }
@@ -3283,14 +3263,11 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3283
3263
  */
3284
3264
  async createNewPrompt() {
3285
3265
  try {
3286
- this.agentManagementService
3287
- .openCreatePromptDialog({
3266
+ this.agentManagementService.openCreatePromptDialog({
3288
3267
  title: `Create New Prompt for ${this.record.Name || 'Agent'}`,
3289
3268
  initialName: '',
3290
- viewContainerRef: this.viewContainerRef,
3291
- })
3292
- .pipe(takeUntil(this.destroy$))
3293
- .subscribe({
3269
+ viewContainerRef: this.viewContainerRef
3270
+ }).pipe(takeUntil(this.destroy$)).subscribe({
3294
3271
  next: async (result) => {
3295
3272
  if (result && result.prompt) {
3296
3273
  try {
@@ -3300,7 +3277,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3300
3277
  // Add the prompt to PendingRecords (will be saved with agent)
3301
3278
  this.PendingRecords.push({
3302
3279
  entityObject: result.prompt,
3303
- action: 'save',
3280
+ action: 'save'
3304
3281
  });
3305
3282
  // Add template to PendingRecords if created
3306
3283
  if (result.template) {
@@ -3308,7 +3285,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3308
3285
  result.template.UserID = currentUserId;
3309
3286
  this.PendingRecords.push({
3310
3287
  entityObject: result.template,
3311
- action: 'save',
3288
+ action: 'save'
3312
3289
  });
3313
3290
  }
3314
3291
  // Add template contents to PendingRecords if created
@@ -3317,7 +3294,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3317
3294
  // Template content does not have UserID field, no manual user assignment needed
3318
3295
  this.PendingRecords.push({
3319
3296
  entityObject: content,
3320
- action: 'save',
3297
+ action: 'save'
3321
3298
  });
3322
3299
  }
3323
3300
  }
@@ -3331,7 +3308,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3331
3308
  // AI Agent Prompt does not have UserID field, no manual user assignment needed
3332
3309
  this.PendingRecords.push({
3333
3310
  entityObject: agentPrompt,
3334
- action: 'save',
3311
+ action: 'save'
3335
3312
  });
3336
3313
  this.hasUnsavedChanges = true;
3337
3314
  // Update UI to show the new prompt
@@ -3349,7 +3326,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3349
3326
  error: (error) => {
3350
3327
  console.error('Error in create prompt dialog:', error);
3351
3328
  MJNotificationService.Instance.CreateSimpleNotification('Error opening prompt creation dialog. Please try again.', 'error', 3000);
3352
- },
3329
+ }
3353
3330
  });
3354
3331
  }
3355
3332
  catch (error) {
@@ -3365,16 +3342,19 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3365
3342
  const confirmDialog = this.dialogService.open({
3366
3343
  title: 'Remove Prompt',
3367
3344
  content: `Are you sure you want to remove the prompt "${prompt.Name}" from this agent?`,
3368
- actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3345
+ actions: [
3346
+ { text: 'Cancel' },
3347
+ { text: 'Remove', themeColor: 'error' }
3348
+ ],
3369
3349
  width: 450,
3370
- height: 200,
3350
+ height: 200
3371
3351
  });
3372
3352
  try {
3373
3353
  const result = await firstValueFrom(confirmDialog.result);
3374
3354
  if (result && result.text === 'Remove') {
3375
3355
  try {
3376
3356
  // Check if this is a pending add (not yet in database)
3377
- const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' &&
3357
+ const pendingAddIndex = this.PendingRecords.findIndex(p => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' &&
3378
3358
  p.action === 'save' &&
3379
3359
  p.entityObject.Get('PromptID') === prompt.ID);
3380
3360
  if (pendingAddIndex >= 0) {
@@ -3387,14 +3367,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3387
3367
  const linkResult = await rv.RunView({
3388
3368
  EntityName: 'MJ: AI Agent Prompts',
3389
3369
  ExtraFilter: `AgentID='${this.record.ID}' AND PromptID='${prompt.ID}'`,
3390
- ResultType: 'entity_object',
3370
+ ResultType: 'entity_object'
3391
3371
  });
3392
3372
  if (linkResult.Success && linkResult.Results && linkResult.Results.length > 0) {
3393
3373
  const agentPromptToDelete = linkResult.Results[0];
3394
3374
  // Add to pending deletions
3395
3375
  this.PendingRecords.push({
3396
3376
  entityObject: agentPromptToDelete,
3397
- action: 'delete',
3377
+ action: 'delete'
3398
3378
  });
3399
3379
  }
3400
3380
  else {
@@ -3402,7 +3382,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3402
3382
  }
3403
3383
  }
3404
3384
  // Remove from UI immediately
3405
- const promptIndex = this.agentPrompts.findIndex((p) => p.ID === prompt.ID);
3385
+ const promptIndex = this.agentPrompts.findIndex(p => p.ID === prompt.ID);
3406
3386
  if (promptIndex >= 0) {
3407
3387
  this.agentPrompts.splice(promptIndex, 1);
3408
3388
  }
@@ -3437,23 +3417,24 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3437
3417
  async addSubAgents() {
3438
3418
  try {
3439
3419
  // Get list of already pending sub-agent IDs to filter duplicates
3440
- const pendingSubAgentIds = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Agents' && p.action === 'save' && p.entityObject.Get('ParentID') === this.record.ID).map((p) => p.entityObject.Get('ID'));
3441
- const existingSubAgentIds = this.subAgents.map((agent) => agent.ID);
3420
+ const pendingSubAgentIds = this.PendingRecords
3421
+ .filter(p => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3422
+ p.action === 'save' &&
3423
+ p.entityObject.Get('ParentID') === this.record.ID)
3424
+ .map(p => p.entityObject.Get('ID'));
3425
+ const existingSubAgentIds = this.subAgents.map(agent => agent.ID);
3442
3426
  const allLinkedIds = [...pendingSubAgentIds, ...existingSubAgentIds];
3443
- this.agentManagementService
3444
- .openSubAgentSelectorDialog({
3427
+ this.agentManagementService.openSubAgentSelectorDialog({
3445
3428
  title: 'Add Sub-Agents',
3446
3429
  multiSelect: true,
3447
3430
  parentAgentId: this.record.ID,
3448
3431
  showCreateNew: true,
3449
- viewContainerRef: this.viewContainerRef,
3450
- })
3451
- .pipe(takeUntil(this.destroy$))
3452
- .subscribe({
3432
+ viewContainerRef: this.viewContainerRef
3433
+ }).pipe(takeUntil(this.destroy$)).subscribe({
3453
3434
  next: async (result) => {
3454
3435
  if (result && result.selectedAgents && result.selectedAgents.length > 0) {
3455
3436
  // Filter out already linked or pending agents
3456
- const newAgents = result.selectedAgents.filter((agent) => !allLinkedIds.includes(agent.ID));
3437
+ const newAgents = result.selectedAgents.filter(agent => !allLinkedIds.includes(agent.ID));
3457
3438
  if (newAgents.length === 0) {
3458
3439
  MJNotificationService.Instance.CreateSimpleNotification('All selected agents are already linked to this agent', 'info', 3000);
3459
3440
  return;
@@ -3468,7 +3449,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3468
3449
  subAgentToUpdate.ExposeAsAction = false;
3469
3450
  this.PendingRecords.push({
3470
3451
  entityObject: subAgentToUpdate,
3471
- action: 'save',
3452
+ action: 'save'
3472
3453
  });
3473
3454
  }
3474
3455
  this.hasUnsavedChanges = true;
@@ -3487,7 +3468,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3487
3468
  error: (error) => {
3488
3469
  console.error('Error opening sub-agent selector:', error);
3489
3470
  MJNotificationService.Instance.CreateSimpleNotification('Error opening sub-agent selector. Please try again.', 'error', 3000);
3490
- },
3471
+ }
3491
3472
  });
3492
3473
  }
3493
3474
  catch (error) {
@@ -3503,16 +3484,19 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3503
3484
  const confirmDialog = this.dialogService.open({
3504
3485
  title: 'Remove Sub-Agent',
3505
3486
  content: `Are you sure you want to remove "${subAgent.Name}" as a sub-agent? This will make it an independent root agent.`,
3506
- actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3487
+ actions: [
3488
+ { text: 'Cancel' },
3489
+ { text: 'Remove', themeColor: 'error' }
3490
+ ],
3507
3491
  width: 450,
3508
- height: 200,
3492
+ height: 200
3509
3493
  });
3510
3494
  try {
3511
3495
  const result = await firstValueFrom(confirmDialog.result);
3512
3496
  if (result && result.text === 'Remove') {
3513
3497
  try {
3514
3498
  // Check if this is a pending add (not yet in database)
3515
- const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3499
+ const pendingAddIndex = this.PendingRecords.findIndex(p => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3516
3500
  p.action === 'save' &&
3517
3501
  p.entityObject.Get('ID') === subAgent.ID &&
3518
3502
  p.entityObject.Get('ParentID') === this.record.ID);
@@ -3528,11 +3512,11 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3528
3512
  subAgentToUpdate.ParentID = null; // Will become a root agent
3529
3513
  this.PendingRecords.push({
3530
3514
  entityObject: subAgentToUpdate,
3531
- action: 'save',
3515
+ action: 'save'
3532
3516
  });
3533
3517
  }
3534
3518
  // Remove from UI immediately
3535
- const subAgentIndex = this.subAgents.findIndex((sa) => sa.ID === subAgent.ID);
3519
+ const subAgentIndex = this.subAgents.findIndex(sa => sa.ID === subAgent.ID);
3536
3520
  if (subAgentIndex >= 0) {
3537
3521
  this.subAgents.splice(subAgentIndex, 1);
3538
3522
  }
@@ -3617,9 +3601,12 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3617
3601
  const confirmDialog = this.dialogService.open({
3618
3602
  title: 'Unlink Related Sub-Agent',
3619
3603
  content: `Are you sure you want to unlink "${item.agent.Name}"? This will remove the relationship but keep the agent itself.`,
3620
- actions: [{ text: 'Cancel' }, { text: 'Unlink', themeColor: 'error' }],
3604
+ actions: [
3605
+ { text: 'Cancel' },
3606
+ { text: 'Unlink', themeColor: 'error' }
3607
+ ],
3621
3608
  width: 450,
3622
- height: 200,
3609
+ height: 200
3623
3610
  });
3624
3611
  try {
3625
3612
  const result = await firstValueFrom(confirmDialog.result);
@@ -3628,7 +3615,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3628
3615
  const success = await item.relationship.Delete();
3629
3616
  if (success) {
3630
3617
  // Remove from unified list
3631
- const index = this.allSubAgents.findIndex((s) => s.type === 'related' && s.relationship?.ID === item.relationship.ID);
3618
+ const index = this.allSubAgents.findIndex(s => s.type === 'related' && s.relationship?.ID === item.relationship.ID);
3632
3619
  if (index >= 0) {
3633
3620
  this.allSubAgents.splice(index, 1);
3634
3621
  }
@@ -3677,16 +3664,21 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3677
3664
  const confirmDialog = this.dialogService.open({
3678
3665
  title: 'Remove Action',
3679
3666
  content: `Are you sure you want to remove the action "${action.Name}" from this agent?`,
3680
- actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3667
+ actions: [
3668
+ { text: 'Cancel' },
3669
+ { text: 'Remove', themeColor: 'error' }
3670
+ ],
3681
3671
  width: 450,
3682
- height: 200,
3672
+ height: 200
3683
3673
  });
3684
3674
  try {
3685
3675
  const result = await firstValueFrom(confirmDialog.result);
3686
3676
  if (result && result.text === 'Remove') {
3687
3677
  try {
3688
3678
  // Check if this is a pending add (not yet in database)
3689
- const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'AI Agent Actions' && p.action === 'save' && p.entityObject.Get('ActionID') === action.ID);
3679
+ const pendingAddIndex = this.PendingRecords.findIndex(p => p.entityObject.EntityInfo.Name === 'AI Agent Actions' &&
3680
+ p.action === 'save' &&
3681
+ p.entityObject.Get('ActionID') === action.ID);
3690
3682
  if (pendingAddIndex >= 0) {
3691
3683
  // Remove from pending adds
3692
3684
  this.PendingRecords.splice(pendingAddIndex, 1);
@@ -3697,14 +3689,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3697
3689
  const linkResult = await rv.RunView({
3698
3690
  EntityName: 'AI Agent Actions',
3699
3691
  ExtraFilter: `AgentID='${this.record.ID}' AND ActionID='${action.ID}'`,
3700
- ResultType: 'entity_object',
3692
+ ResultType: 'entity_object'
3701
3693
  });
3702
3694
  if (linkResult.Success && linkResult.Results && linkResult.Results.length > 0) {
3703
3695
  const agentActionToDelete = linkResult.Results[0];
3704
3696
  // Add to pending deletions
3705
3697
  this.PendingRecords.push({
3706
3698
  entityObject: agentActionToDelete,
3707
- action: 'delete',
3699
+ action: 'delete'
3708
3700
  });
3709
3701
  }
3710
3702
  else {
@@ -3712,7 +3704,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3712
3704
  }
3713
3705
  }
3714
3706
  // Remove from UI immediately
3715
- const actionIndex = this.agentActions.findIndex((a) => a.ID === action.ID);
3707
+ const actionIndex = this.agentActions.findIndex(a => a.ID === action.ID);
3716
3708
  if (actionIndex >= 0) {
3717
3709
  this.agentActions.splice(actionIndex, 1);
3718
3710
  }
@@ -3739,20 +3731,17 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3739
3731
  try {
3740
3732
  // Find the corresponding AIAgentPromptEntity for this prompt
3741
3733
  // Get all agent prompts for validation
3742
- const allAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter((ap) => ap.AgentID === this.record.ID);
3743
- const agentPrompt = allAgentPrompts.find((ap) => ap.PromptID === prompt.ID);
3734
+ const allAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter(ap => ap.AgentID === this.record.ID);
3735
+ const agentPrompt = allAgentPrompts.find(ap => ap.PromptID === prompt.ID);
3744
3736
  if (!agentPrompt) {
3745
3737
  MJNotificationService.Instance.CreateSimpleNotification('Unable to find prompt configuration for advanced settings', 'error', 3000);
3746
3738
  return;
3747
3739
  }
3748
- this.agentManagementService
3749
- .openAgentPromptAdvancedSettingsDialog({
3740
+ this.agentManagementService.openAgentPromptAdvancedSettingsDialog({
3750
3741
  agentPrompt: agentPrompt,
3751
3742
  allAgentPrompts: allAgentPrompts,
3752
- viewContainerRef: this.viewContainerRef,
3753
- })
3754
- .pipe(takeUntil(this.destroy$))
3755
- .subscribe({
3743
+ viewContainerRef: this.viewContainerRef
3744
+ }).pipe(takeUntil(this.destroy$)).subscribe({
3756
3745
  next: async (formData) => {
3757
3746
  if (formData) {
3758
3747
  try {
@@ -3783,7 +3772,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3783
3772
  error: (error) => {
3784
3773
  console.error('Error opening prompt advanced settings dialog:', error);
3785
3774
  MJNotificationService.Instance.CreateSimpleNotification('Error opening advanced settings. Please try again.', 'error', 3000);
3786
- },
3775
+ }
3787
3776
  });
3788
3777
  }
3789
3778
  catch (error) {
@@ -3798,15 +3787,12 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3798
3787
  event.stopPropagation(); // Prevent navigation
3799
3788
  try {
3800
3789
  // Get all sub-agents under the same parent for validation
3801
- const allSubAgents = AIEngineBase.Instance.Agents.filter((sa) => sa.ParentID === subAgentEntity.ParentID);
3802
- this.agentManagementService
3803
- .openSubAgentAdvancedSettingsDialog({
3790
+ const allSubAgents = AIEngineBase.Instance.Agents.filter(sa => sa.ParentID === subAgentEntity.ParentID);
3791
+ this.agentManagementService.openSubAgentAdvancedSettingsDialog({
3804
3792
  subAgent: subAgentEntity,
3805
3793
  allSubAgents: allSubAgents,
3806
- viewContainerRef: this.viewContainerRef,
3807
- })
3808
- .pipe(takeUntil(this.destroy$))
3809
- .subscribe({
3794
+ viewContainerRef: this.viewContainerRef
3795
+ }).pipe(takeUntil(this.destroy$)).subscribe({
3810
3796
  next: async (formData) => {
3811
3797
  if (formData) {
3812
3798
  try {
@@ -3821,7 +3807,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3821
3807
  if (saveResult) {
3822
3808
  MJNotificationService.Instance.CreateSimpleNotification('Sub-agent settings updated successfully', 'success', 3000);
3823
3809
  // Update the local sub-agent data to reflect changes
3824
- const localSubAgent = this.subAgents.find((sa) => sa.ID === subAgentEntity.ID);
3810
+ const localSubAgent = this.subAgents.find(sa => sa.ID === subAgentEntity.ID);
3825
3811
  if (localSubAgent) {
3826
3812
  localSubAgent.ExecutionOrder = formData.executionOrder;
3827
3813
  localSubAgent.ExecutionMode = formData.executionMode;
@@ -3845,7 +3831,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3845
3831
  error: (error) => {
3846
3832
  console.error('Error opening sub-agent advanced settings dialog:', error);
3847
3833
  MJNotificationService.Instance.CreateSimpleNotification('Error opening advanced settings. Please try again.', 'error', 3000);
3848
- },
3834
+ }
3849
3835
  });
3850
3836
  }
3851
3837
  catch (error) {
@@ -3902,7 +3888,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3902
3888
  // We need to save Templates and Template Contents BEFORE the main AI Agent
3903
3889
  // since AI Prompts depend on Templates, and AI Agent Prompts depend on AI Agents
3904
3890
  // 1. First save Templates (they have no dependencies)
3905
- const templateRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'Templates');
3891
+ const templateRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'Templates');
3906
3892
  for (const templateRecord of templateRecords) {
3907
3893
  templateRecord.entityObject.TransactionGroup = transactionGroup;
3908
3894
  if (templateRecord.action === 'save') {
@@ -3917,7 +3903,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3917
3903
  }
3918
3904
  }
3919
3905
  // 2. Save Template Contents (depend on Templates)
3920
- const templateContentRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'Template Contents');
3906
+ const templateContentRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'Template Contents');
3921
3907
  for (const contentRecord of templateContentRecords) {
3922
3908
  contentRecord.entityObject.TransactionGroup = transactionGroup;
3923
3909
  if (contentRecord.action === 'save') {
@@ -3932,7 +3918,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3932
3918
  }
3933
3919
  }
3934
3920
  // 3. Save AI Prompts (depend on Templates)
3935
- const promptRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Prompts');
3921
+ const promptRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'AI Prompts');
3936
3922
  for (const promptRecord of promptRecords) {
3937
3923
  promptRecord.entityObject.TransactionGroup = transactionGroup;
3938
3924
  if (promptRecord.action === 'save') {
@@ -3954,7 +3940,9 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3954
3940
  return false;
3955
3941
  }
3956
3942
  // 4.1. Handle deferred sub-agent creation - set ParentID on any sub-agents created before parent was saved
3957
- const subAgentRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Agents' && p.action === 'save' && p.entityObject.Get('_tempParentId') === this.record.ID);
3943
+ const subAgentRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3944
+ p.action === 'save' &&
3945
+ p.entityObject.Get('_tempParentId') === this.record.ID);
3958
3946
  for (const subAgentRecord of subAgentRecords) {
3959
3947
  // Cast to AIAgentEntityExtended to access ParentID property
3960
3948
  const subAgent = subAgentRecord.entityObject;
@@ -3964,7 +3952,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3964
3952
  subAgent.Set('_tempParentId', null);
3965
3953
  }
3966
3954
  // 5. Save all other pending records (AI Agent Actions, AI Agent Prompts, etc.)
3967
- const otherRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name !== 'Templates' &&
3955
+ const otherRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name !== 'Templates' &&
3968
3956
  p.entityObject.EntityInfo.Name !== 'Template Contents' &&
3969
3957
  p.entityObject.EntityInfo.Name !== 'AI Prompts');
3970
3958
  for (const record of otherRecords) {
@@ -4018,7 +4006,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
4018
4006
  this.destroy$.next();
4019
4007
  this.destroy$.complete();
4020
4008
  // Clear all active timeouts
4021
- this.activeTimeouts.forEach((timeoutId) => {
4009
+ this.activeTimeouts.forEach(timeoutId => {
4022
4010
  clearTimeout(timeoutId);
4023
4011
  });
4024
4012
  this.activeTimeouts.length = 0;
@@ -4074,7 +4062,7 @@ export { AIAgentFormComponentExtended };
4074
4062
  type: ViewChild,
4075
4063
  args: ['customSectionContainer', { read: ViewContainerRef }]
4076
4064
  }] }); })();
4077
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AIAgentFormComponentExtended, { className: "AIAgentFormComponentExtended", filePath: "src/lib/custom/AIAgents/ai-agent-form.component.ts", lineNumber: 82 }); })();
4065
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AIAgentFormComponentExtended, { className: "AIAgentFormComponentExtended", filePath: "src/lib/custom/AIAgents/ai-agent-form.component.ts", lineNumber: 73 }); })();
4078
4066
  export function LoadAIAgentFormComponentExtended() {
4079
4067
  // This function is called to ensure the component is loaded and registered
4080
4068
  }