@memberjunction/ng-core-entity-forms 2.111.0 → 2.112.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 (104) 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 +6 -7
  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 +17 -32
  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 +37 -36
  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 +18 -25
  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 +10 -11
  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 +159 -147
  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 +11 -10
  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 +36 -32
  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 +15 -13
  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 +13 -15
  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 +28 -23
  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 +15 -12
  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 +105 -86
  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 +13 -20
  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 +4 -7
  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 +99 -80
  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 +24 -17
  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 +32 -44
  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 +24 -22
  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 +15 -21
  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 +29 -17
  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 +25 -26
  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 +335 -274
  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 +24 -28
  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 +25 -30
  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 +20 -21
  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 +6 -7
  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 +47 -33
  100. package/dist/lib/generated/Entities/AIAgent/sections/aiagent-form-overview.component.js.map +1 -1
  101. package/dist/lib/shared/components/template-editor.component.d.ts.map +1 -1
  102. package/dist/lib/shared/components/template-editor.component.js +26 -27
  103. package/dist/lib/shared/components/template-editor.component.js.map +1 -1
  104. package/package.json +16 -17
@@ -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/core';
10
+ import { CompositeKey, Metadata, RunView } from '@memberjunction/global';
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,28 +2454,38 @@ 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
- "ID", "AgentID", "ParentRunID", "Status", "StartedAt", "CompletedAt",
2473
- "Success", "TotalTokensUsed", "TotalCost", "TotalCostRollUp", "TotalTokensUsedRollUp"
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',
2474
2484
  ],
2475
2485
  ExtraFilter: `AgentID='${this.record.ID}'`,
2476
2486
  OrderBy: '__mj_CreatedAt DESC',
2477
- MaxRows: 100
2478
- }
2487
+ MaxRows: 100,
2488
+ },
2479
2489
  ]);
2480
2490
  // Process results in the same order as queries
2481
2491
  if (results && results.length > 0) {
@@ -2500,7 +2510,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2500
2510
  prompts: false,
2501
2511
  actions: false,
2502
2512
  learningCycles: false,
2503
- notes: false
2513
+ notes: false,
2504
2514
  };
2505
2515
  this.cdr.detectChanges();
2506
2516
  }
@@ -2519,7 +2529,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2519
2529
  subAgentCount: this.subAgentCount,
2520
2530
  learningCycleCount: this.learningCycleCount,
2521
2531
  noteCount: this.noteCount,
2522
- executionHistoryCount: this.executionHistoryCount
2532
+ executionHistoryCount: this.executionHistoryCount,
2523
2533
  };
2524
2534
  }
2525
2535
  /**
@@ -2656,7 +2666,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2656
2666
  const dialogRef = this.dialogService.open({
2657
2667
  content: AgentPermissionsDialogComponent,
2658
2668
  width: 900,
2659
- height: 600
2669
+ height: 600,
2660
2670
  });
2661
2671
  const dialog = dialogRef.content.instance;
2662
2672
  dialog.agent = this.record;
@@ -2669,10 +2679,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2669
2679
  */
2670
2680
  getStatusBadgeColor() {
2671
2681
  switch (this.record?.Status) {
2672
- case 'Active': return '#28a745';
2673
- case 'Pending': return '#ffc107';
2674
- case 'Disabled': return '#6c757d';
2675
- default: return '#6c757d';
2682
+ case 'Active':
2683
+ return '#28a745';
2684
+ case 'Pending':
2685
+ return '#ffc107';
2686
+ case 'Disabled':
2687
+ return '#6c757d';
2688
+ default:
2689
+ return '#6c757d';
2676
2690
  }
2677
2691
  }
2678
2692
  /**
@@ -2757,13 +2771,16 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2757
2771
  */
2758
2772
  async createSubAgent() {
2759
2773
  try {
2760
- this.agentManagementService.openCreateSubAgentDialog({
2774
+ this.agentManagementService
2775
+ .openCreateSubAgentDialog({
2761
2776
  title: `Create Sub-Agent for ${this.record.Name || 'Agent'}`,
2762
2777
  initialName: '',
2763
2778
  parentAgentId: this.record.ID,
2764
2779
  parentAgentName: this.record.Name || 'Agent',
2765
- viewContainerRef: this.viewContainerRef
2766
- }).pipe(takeUntil(this.destroy$)).subscribe({
2780
+ viewContainerRef: this.viewContainerRef,
2781
+ })
2782
+ .pipe(takeUntil(this.destroy$))
2783
+ .subscribe({
2767
2784
  next: async (result) => {
2768
2785
  if (result && result.subAgent) {
2769
2786
  try {
@@ -2775,14 +2792,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2775
2792
  // Add the sub-agent to pending records
2776
2793
  this.PendingRecords.push({
2777
2794
  entityObject: result.subAgent,
2778
- action: 'save'
2795
+ action: 'save',
2779
2796
  });
2780
2797
  // Add any newly created prompts to pending records
2781
2798
  if (result.newPrompts) {
2782
2799
  for (const prompt of result.newPrompts) {
2783
2800
  this.PendingRecords.push({
2784
2801
  entityObject: prompt,
2785
- action: 'save'
2802
+ action: 'save',
2786
2803
  });
2787
2804
  }
2788
2805
  }
@@ -2791,7 +2808,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2791
2808
  for (const template of result.newPromptTemplates) {
2792
2809
  this.PendingRecords.push({
2793
2810
  entityObject: template,
2794
- action: 'save'
2811
+ action: 'save',
2795
2812
  });
2796
2813
  }
2797
2814
  }
@@ -2800,7 +2817,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2800
2817
  for (const content of result.newTemplateContents) {
2801
2818
  this.PendingRecords.push({
2802
2819
  entityObject: content,
2803
- action: 'save'
2820
+ action: 'save',
2804
2821
  });
2805
2822
  }
2806
2823
  }
@@ -2809,7 +2826,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2809
2826
  for (const agentPrompt of result.agentPrompts) {
2810
2827
  this.PendingRecords.push({
2811
2828
  entityObject: agentPrompt,
2812
- action: 'save'
2829
+ action: 'save',
2813
2830
  });
2814
2831
  }
2815
2832
  }
@@ -2818,7 +2835,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2818
2835
  for (const agentAction of result.agentActions) {
2819
2836
  this.PendingRecords.push({
2820
2837
  entityObject: agentAction,
2821
- action: 'save'
2838
+ action: 'save',
2822
2839
  });
2823
2840
  }
2824
2841
  }
@@ -2838,7 +2855,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2838
2855
  error: (error) => {
2839
2856
  console.error('Error in create sub-agent dialog:', error);
2840
2857
  MJNotificationService.Instance.CreateSimpleNotification('Error opening sub-agent creation dialog. Please try again.', 'error', 3000);
2841
- }
2858
+ },
2842
2859
  });
2843
2860
  }
2844
2861
  catch (error) {
@@ -2851,24 +2868,25 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2851
2868
  */
2852
2869
  async addPrompt() {
2853
2870
  // Get currently linked and pending prompt IDs for pre-selection
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'));
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'));
2858
2873
  const allLinkedIds = [...currentPromptIds, ...pendingAddIds];
2859
2874
  try {
2860
- this.agentManagementService.openPromptSelectorDialog({
2875
+ this.agentManagementService
2876
+ .openPromptSelectorDialog({
2861
2877
  title: 'Add Prompts to Agent',
2862
2878
  multiSelect: true,
2863
2879
  selectedPromptIds: [],
2864
2880
  showCreateNew: true,
2865
2881
  linkedPromptIds: allLinkedIds,
2866
- viewContainerRef: this.viewContainerRef
2867
- }).pipe(takeUntil(this.destroy$)).subscribe({
2882
+ viewContainerRef: this.viewContainerRef,
2883
+ })
2884
+ .pipe(takeUntil(this.destroy$))
2885
+ .subscribe({
2868
2886
  next: async (result) => {
2869
2887
  if (result && result.selectedPrompts.length > 0) {
2870
2888
  // Filter out already linked or pending prompts
2871
- const newPrompts = result.selectedPrompts.filter(prompt => !allLinkedIds.includes(prompt.ID));
2889
+ const newPrompts = result.selectedPrompts.filter((prompt) => !allLinkedIds.includes(prompt.ID));
2872
2890
  if (newPrompts.length === 0) {
2873
2891
  MJNotificationService.Instance.CreateSimpleNotification('All selected prompts are already linked to this agent', 'info', 3000);
2874
2892
  return;
@@ -2884,7 +2902,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2884
2902
  agentPrompt.ExecutionOrder = 1;
2885
2903
  this.PendingRecords.push({
2886
2904
  entityObject: agentPrompt,
2887
- action: 'save'
2905
+ action: 'save',
2888
2906
  });
2889
2907
  }
2890
2908
  this.hasUnsavedChanges = true;
@@ -2903,7 +2921,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2903
2921
  error: (error) => {
2904
2922
  console.error('Error opening prompt selector:', error);
2905
2923
  MJNotificationService.Instance.CreateSimpleNotification('Error opening prompt selector. Please try again.', 'error', 3000);
2906
- }
2924
+ },
2907
2925
  });
2908
2926
  }
2909
2927
  catch (error) {
@@ -2930,21 +2948,22 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2930
2948
  */
2931
2949
  async configureActions() {
2932
2950
  // Get currently linked and pending action IDs for pre-selection
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'));
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'));
2937
2953
  const allLinkedIds = [...currentActionIds, ...pendingAddIds];
2938
- this.agentManagementService.openAddActionDialog({
2954
+ this.agentManagementService
2955
+ .openAddActionDialog({
2939
2956
  agentId: this.record.ID,
2940
2957
  agentName: this.record.Name || 'Agent',
2941
2958
  existingActionIds: allLinkedIds,
2942
- viewContainerRef: this.viewContainerRef
2943
- }).pipe(takeUntil(this.destroy$)).subscribe({
2959
+ viewContainerRef: this.viewContainerRef,
2960
+ })
2961
+ .pipe(takeUntil(this.destroy$))
2962
+ .subscribe({
2944
2963
  next: async (selectedActions) => {
2945
2964
  if (selectedActions && selectedActions.length > 0) {
2946
2965
  // Filter out already linked or pending actions
2947
- const newActions = selectedActions.filter(action => !allLinkedIds.includes(action.ID));
2966
+ const newActions = selectedActions.filter((action) => !allLinkedIds.includes(action.ID));
2948
2967
  if (newActions.length === 0) {
2949
2968
  MJNotificationService.Instance.CreateSimpleNotification('All selected actions are already linked to this agent', 'info', 3000);
2950
2969
  return;
@@ -2959,7 +2978,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2959
2978
  agentAction.Status = 'Active';
2960
2979
  this.PendingRecords.push({
2961
2980
  entityObject: agentAction,
2962
- action: 'save'
2981
+ action: 'save',
2963
2982
  });
2964
2983
  }
2965
2984
  this.hasUnsavedChanges = true;
@@ -2974,7 +2993,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
2974
2993
  error: (error) => {
2975
2994
  console.error('Error in add action dialog:', error);
2976
2995
  MJNotificationService.Instance.CreateSimpleNotification('Error opening action selection dialog. Please try again.', 'error', 3000);
2977
- }
2996
+ },
2978
2997
  });
2979
2998
  }
2980
2999
  /**
@@ -3125,7 +3144,8 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3125
3144
  // Force cache refresh by clearing old entries
3126
3145
  const now = Date.now();
3127
3146
  for (const [key, cached] of this._runningTimeCache.entries()) {
3128
- if (now - cached.timestamp > 500) { // Refresh every 500ms
3147
+ if (now - cached.timestamp > 500) {
3148
+ // Refresh every 500ms
3129
3149
  this._runningTimeCache.delete(key);
3130
3150
  }
3131
3151
  }
@@ -3263,11 +3283,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3263
3283
  */
3264
3284
  async createNewPrompt() {
3265
3285
  try {
3266
- this.agentManagementService.openCreatePromptDialog({
3286
+ this.agentManagementService
3287
+ .openCreatePromptDialog({
3267
3288
  title: `Create New Prompt for ${this.record.Name || 'Agent'}`,
3268
3289
  initialName: '',
3269
- viewContainerRef: this.viewContainerRef
3270
- }).pipe(takeUntil(this.destroy$)).subscribe({
3290
+ viewContainerRef: this.viewContainerRef,
3291
+ })
3292
+ .pipe(takeUntil(this.destroy$))
3293
+ .subscribe({
3271
3294
  next: async (result) => {
3272
3295
  if (result && result.prompt) {
3273
3296
  try {
@@ -3277,7 +3300,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3277
3300
  // Add the prompt to PendingRecords (will be saved with agent)
3278
3301
  this.PendingRecords.push({
3279
3302
  entityObject: result.prompt,
3280
- action: 'save'
3303
+ action: 'save',
3281
3304
  });
3282
3305
  // Add template to PendingRecords if created
3283
3306
  if (result.template) {
@@ -3285,7 +3308,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3285
3308
  result.template.UserID = currentUserId;
3286
3309
  this.PendingRecords.push({
3287
3310
  entityObject: result.template,
3288
- action: 'save'
3311
+ action: 'save',
3289
3312
  });
3290
3313
  }
3291
3314
  // Add template contents to PendingRecords if created
@@ -3294,7 +3317,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3294
3317
  // Template content does not have UserID field, no manual user assignment needed
3295
3318
  this.PendingRecords.push({
3296
3319
  entityObject: content,
3297
- action: 'save'
3320
+ action: 'save',
3298
3321
  });
3299
3322
  }
3300
3323
  }
@@ -3308,7 +3331,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3308
3331
  // AI Agent Prompt does not have UserID field, no manual user assignment needed
3309
3332
  this.PendingRecords.push({
3310
3333
  entityObject: agentPrompt,
3311
- action: 'save'
3334
+ action: 'save',
3312
3335
  });
3313
3336
  this.hasUnsavedChanges = true;
3314
3337
  // Update UI to show the new prompt
@@ -3326,7 +3349,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3326
3349
  error: (error) => {
3327
3350
  console.error('Error in create prompt dialog:', error);
3328
3351
  MJNotificationService.Instance.CreateSimpleNotification('Error opening prompt creation dialog. Please try again.', 'error', 3000);
3329
- }
3352
+ },
3330
3353
  });
3331
3354
  }
3332
3355
  catch (error) {
@@ -3342,19 +3365,16 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3342
3365
  const confirmDialog = this.dialogService.open({
3343
3366
  title: 'Remove Prompt',
3344
3367
  content: `Are you sure you want to remove the prompt "${prompt.Name}" from this agent?`,
3345
- actions: [
3346
- { text: 'Cancel' },
3347
- { text: 'Remove', themeColor: 'error' }
3348
- ],
3368
+ actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3349
3369
  width: 450,
3350
- height: 200
3370
+ height: 200,
3351
3371
  });
3352
3372
  try {
3353
3373
  const result = await firstValueFrom(confirmDialog.result);
3354
3374
  if (result && result.text === 'Remove') {
3355
3375
  try {
3356
3376
  // Check if this is a pending add (not yet in database)
3357
- const pendingAddIndex = this.PendingRecords.findIndex(p => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' &&
3377
+ const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'MJ: AI Agent Prompts' &&
3358
3378
  p.action === 'save' &&
3359
3379
  p.entityObject.Get('PromptID') === prompt.ID);
3360
3380
  if (pendingAddIndex >= 0) {
@@ -3367,14 +3387,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3367
3387
  const linkResult = await rv.RunView({
3368
3388
  EntityName: 'MJ: AI Agent Prompts',
3369
3389
  ExtraFilter: `AgentID='${this.record.ID}' AND PromptID='${prompt.ID}'`,
3370
- ResultType: 'entity_object'
3390
+ ResultType: 'entity_object',
3371
3391
  });
3372
3392
  if (linkResult.Success && linkResult.Results && linkResult.Results.length > 0) {
3373
3393
  const agentPromptToDelete = linkResult.Results[0];
3374
3394
  // Add to pending deletions
3375
3395
  this.PendingRecords.push({
3376
3396
  entityObject: agentPromptToDelete,
3377
- action: 'delete'
3397
+ action: 'delete',
3378
3398
  });
3379
3399
  }
3380
3400
  else {
@@ -3382,7 +3402,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3382
3402
  }
3383
3403
  }
3384
3404
  // Remove from UI immediately
3385
- const promptIndex = this.agentPrompts.findIndex(p => p.ID === prompt.ID);
3405
+ const promptIndex = this.agentPrompts.findIndex((p) => p.ID === prompt.ID);
3386
3406
  if (promptIndex >= 0) {
3387
3407
  this.agentPrompts.splice(promptIndex, 1);
3388
3408
  }
@@ -3417,24 +3437,23 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3417
3437
  async addSubAgents() {
3418
3438
  try {
3419
3439
  // Get list of already pending sub-agent IDs to filter duplicates
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);
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);
3426
3442
  const allLinkedIds = [...pendingSubAgentIds, ...existingSubAgentIds];
3427
- this.agentManagementService.openSubAgentSelectorDialog({
3443
+ this.agentManagementService
3444
+ .openSubAgentSelectorDialog({
3428
3445
  title: 'Add Sub-Agents',
3429
3446
  multiSelect: true,
3430
3447
  parentAgentId: this.record.ID,
3431
3448
  showCreateNew: true,
3432
- viewContainerRef: this.viewContainerRef
3433
- }).pipe(takeUntil(this.destroy$)).subscribe({
3449
+ viewContainerRef: this.viewContainerRef,
3450
+ })
3451
+ .pipe(takeUntil(this.destroy$))
3452
+ .subscribe({
3434
3453
  next: async (result) => {
3435
3454
  if (result && result.selectedAgents && result.selectedAgents.length > 0) {
3436
3455
  // Filter out already linked or pending agents
3437
- const newAgents = result.selectedAgents.filter(agent => !allLinkedIds.includes(agent.ID));
3456
+ const newAgents = result.selectedAgents.filter((agent) => !allLinkedIds.includes(agent.ID));
3438
3457
  if (newAgents.length === 0) {
3439
3458
  MJNotificationService.Instance.CreateSimpleNotification('All selected agents are already linked to this agent', 'info', 3000);
3440
3459
  return;
@@ -3449,7 +3468,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3449
3468
  subAgentToUpdate.ExposeAsAction = false;
3450
3469
  this.PendingRecords.push({
3451
3470
  entityObject: subAgentToUpdate,
3452
- action: 'save'
3471
+ action: 'save',
3453
3472
  });
3454
3473
  }
3455
3474
  this.hasUnsavedChanges = true;
@@ -3468,7 +3487,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3468
3487
  error: (error) => {
3469
3488
  console.error('Error opening sub-agent selector:', error);
3470
3489
  MJNotificationService.Instance.CreateSimpleNotification('Error opening sub-agent selector. Please try again.', 'error', 3000);
3471
- }
3490
+ },
3472
3491
  });
3473
3492
  }
3474
3493
  catch (error) {
@@ -3484,19 +3503,16 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3484
3503
  const confirmDialog = this.dialogService.open({
3485
3504
  title: 'Remove Sub-Agent',
3486
3505
  content: `Are you sure you want to remove "${subAgent.Name}" as a sub-agent? This will make it an independent root agent.`,
3487
- actions: [
3488
- { text: 'Cancel' },
3489
- { text: 'Remove', themeColor: 'error' }
3490
- ],
3506
+ actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3491
3507
  width: 450,
3492
- height: 200
3508
+ height: 200,
3493
3509
  });
3494
3510
  try {
3495
3511
  const result = await firstValueFrom(confirmDialog.result);
3496
3512
  if (result && result.text === 'Remove') {
3497
3513
  try {
3498
3514
  // Check if this is a pending add (not yet in database)
3499
- const pendingAddIndex = this.PendingRecords.findIndex(p => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3515
+ const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'AI Agents' &&
3500
3516
  p.action === 'save' &&
3501
3517
  p.entityObject.Get('ID') === subAgent.ID &&
3502
3518
  p.entityObject.Get('ParentID') === this.record.ID);
@@ -3512,11 +3528,11 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3512
3528
  subAgentToUpdate.ParentID = null; // Will become a root agent
3513
3529
  this.PendingRecords.push({
3514
3530
  entityObject: subAgentToUpdate,
3515
- action: 'save'
3531
+ action: 'save',
3516
3532
  });
3517
3533
  }
3518
3534
  // Remove from UI immediately
3519
- const subAgentIndex = this.subAgents.findIndex(sa => sa.ID === subAgent.ID);
3535
+ const subAgentIndex = this.subAgents.findIndex((sa) => sa.ID === subAgent.ID);
3520
3536
  if (subAgentIndex >= 0) {
3521
3537
  this.subAgents.splice(subAgentIndex, 1);
3522
3538
  }
@@ -3601,12 +3617,9 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3601
3617
  const confirmDialog = this.dialogService.open({
3602
3618
  title: 'Unlink Related Sub-Agent',
3603
3619
  content: `Are you sure you want to unlink "${item.agent.Name}"? This will remove the relationship but keep the agent itself.`,
3604
- actions: [
3605
- { text: 'Cancel' },
3606
- { text: 'Unlink', themeColor: 'error' }
3607
- ],
3620
+ actions: [{ text: 'Cancel' }, { text: 'Unlink', themeColor: 'error' }],
3608
3621
  width: 450,
3609
- height: 200
3622
+ height: 200,
3610
3623
  });
3611
3624
  try {
3612
3625
  const result = await firstValueFrom(confirmDialog.result);
@@ -3615,7 +3628,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3615
3628
  const success = await item.relationship.Delete();
3616
3629
  if (success) {
3617
3630
  // Remove from unified list
3618
- const index = this.allSubAgents.findIndex(s => s.type === 'related' && s.relationship?.ID === item.relationship.ID);
3631
+ const index = this.allSubAgents.findIndex((s) => s.type === 'related' && s.relationship?.ID === item.relationship.ID);
3619
3632
  if (index >= 0) {
3620
3633
  this.allSubAgents.splice(index, 1);
3621
3634
  }
@@ -3664,21 +3677,16 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3664
3677
  const confirmDialog = this.dialogService.open({
3665
3678
  title: 'Remove Action',
3666
3679
  content: `Are you sure you want to remove the action "${action.Name}" from this agent?`,
3667
- actions: [
3668
- { text: 'Cancel' },
3669
- { text: 'Remove', themeColor: 'error' }
3670
- ],
3680
+ actions: [{ text: 'Cancel' }, { text: 'Remove', themeColor: 'error' }],
3671
3681
  width: 450,
3672
- height: 200
3682
+ height: 200,
3673
3683
  });
3674
3684
  try {
3675
3685
  const result = await firstValueFrom(confirmDialog.result);
3676
3686
  if (result && result.text === 'Remove') {
3677
3687
  try {
3678
3688
  // Check if this is a pending add (not yet in database)
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);
3689
+ const pendingAddIndex = this.PendingRecords.findIndex((p) => p.entityObject.EntityInfo.Name === 'AI Agent Actions' && p.action === 'save' && p.entityObject.Get('ActionID') === action.ID);
3682
3690
  if (pendingAddIndex >= 0) {
3683
3691
  // Remove from pending adds
3684
3692
  this.PendingRecords.splice(pendingAddIndex, 1);
@@ -3689,14 +3697,14 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3689
3697
  const linkResult = await rv.RunView({
3690
3698
  EntityName: 'AI Agent Actions',
3691
3699
  ExtraFilter: `AgentID='${this.record.ID}' AND ActionID='${action.ID}'`,
3692
- ResultType: 'entity_object'
3700
+ ResultType: 'entity_object',
3693
3701
  });
3694
3702
  if (linkResult.Success && linkResult.Results && linkResult.Results.length > 0) {
3695
3703
  const agentActionToDelete = linkResult.Results[0];
3696
3704
  // Add to pending deletions
3697
3705
  this.PendingRecords.push({
3698
3706
  entityObject: agentActionToDelete,
3699
- action: 'delete'
3707
+ action: 'delete',
3700
3708
  });
3701
3709
  }
3702
3710
  else {
@@ -3704,7 +3712,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3704
3712
  }
3705
3713
  }
3706
3714
  // Remove from UI immediately
3707
- const actionIndex = this.agentActions.findIndex(a => a.ID === action.ID);
3715
+ const actionIndex = this.agentActions.findIndex((a) => a.ID === action.ID);
3708
3716
  if (actionIndex >= 0) {
3709
3717
  this.agentActions.splice(actionIndex, 1);
3710
3718
  }
@@ -3731,17 +3739,20 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3731
3739
  try {
3732
3740
  // Find the corresponding AIAgentPromptEntity for this prompt
3733
3741
  // Get all agent prompts for validation
3734
- const allAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter(ap => ap.AgentID === this.record.ID);
3735
- const agentPrompt = allAgentPrompts.find(ap => ap.PromptID === prompt.ID);
3742
+ const allAgentPrompts = AIEngineBase.Instance.AgentPrompts.filter((ap) => ap.AgentID === this.record.ID);
3743
+ const agentPrompt = allAgentPrompts.find((ap) => ap.PromptID === prompt.ID);
3736
3744
  if (!agentPrompt) {
3737
3745
  MJNotificationService.Instance.CreateSimpleNotification('Unable to find prompt configuration for advanced settings', 'error', 3000);
3738
3746
  return;
3739
3747
  }
3740
- this.agentManagementService.openAgentPromptAdvancedSettingsDialog({
3748
+ this.agentManagementService
3749
+ .openAgentPromptAdvancedSettingsDialog({
3741
3750
  agentPrompt: agentPrompt,
3742
3751
  allAgentPrompts: allAgentPrompts,
3743
- viewContainerRef: this.viewContainerRef
3744
- }).pipe(takeUntil(this.destroy$)).subscribe({
3752
+ viewContainerRef: this.viewContainerRef,
3753
+ })
3754
+ .pipe(takeUntil(this.destroy$))
3755
+ .subscribe({
3745
3756
  next: async (formData) => {
3746
3757
  if (formData) {
3747
3758
  try {
@@ -3772,7 +3783,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3772
3783
  error: (error) => {
3773
3784
  console.error('Error opening prompt advanced settings dialog:', error);
3774
3785
  MJNotificationService.Instance.CreateSimpleNotification('Error opening advanced settings. Please try again.', 'error', 3000);
3775
- }
3786
+ },
3776
3787
  });
3777
3788
  }
3778
3789
  catch (error) {
@@ -3787,12 +3798,15 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3787
3798
  event.stopPropagation(); // Prevent navigation
3788
3799
  try {
3789
3800
  // Get all sub-agents under the same parent for validation
3790
- const allSubAgents = AIEngineBase.Instance.Agents.filter(sa => sa.ParentID === subAgentEntity.ParentID);
3791
- this.agentManagementService.openSubAgentAdvancedSettingsDialog({
3801
+ const allSubAgents = AIEngineBase.Instance.Agents.filter((sa) => sa.ParentID === subAgentEntity.ParentID);
3802
+ this.agentManagementService
3803
+ .openSubAgentAdvancedSettingsDialog({
3792
3804
  subAgent: subAgentEntity,
3793
3805
  allSubAgents: allSubAgents,
3794
- viewContainerRef: this.viewContainerRef
3795
- }).pipe(takeUntil(this.destroy$)).subscribe({
3806
+ viewContainerRef: this.viewContainerRef,
3807
+ })
3808
+ .pipe(takeUntil(this.destroy$))
3809
+ .subscribe({
3796
3810
  next: async (formData) => {
3797
3811
  if (formData) {
3798
3812
  try {
@@ -3807,7 +3821,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3807
3821
  if (saveResult) {
3808
3822
  MJNotificationService.Instance.CreateSimpleNotification('Sub-agent settings updated successfully', 'success', 3000);
3809
3823
  // Update the local sub-agent data to reflect changes
3810
- const localSubAgent = this.subAgents.find(sa => sa.ID === subAgentEntity.ID);
3824
+ const localSubAgent = this.subAgents.find((sa) => sa.ID === subAgentEntity.ID);
3811
3825
  if (localSubAgent) {
3812
3826
  localSubAgent.ExecutionOrder = formData.executionOrder;
3813
3827
  localSubAgent.ExecutionMode = formData.executionMode;
@@ -3831,7 +3845,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3831
3845
  error: (error) => {
3832
3846
  console.error('Error opening sub-agent advanced settings dialog:', error);
3833
3847
  MJNotificationService.Instance.CreateSimpleNotification('Error opening advanced settings. Please try again.', 'error', 3000);
3834
- }
3848
+ },
3835
3849
  });
3836
3850
  }
3837
3851
  catch (error) {
@@ -3888,7 +3902,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3888
3902
  // We need to save Templates and Template Contents BEFORE the main AI Agent
3889
3903
  // since AI Prompts depend on Templates, and AI Agent Prompts depend on AI Agents
3890
3904
  // 1. First save Templates (they have no dependencies)
3891
- const templateRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'Templates');
3905
+ const templateRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'Templates');
3892
3906
  for (const templateRecord of templateRecords) {
3893
3907
  templateRecord.entityObject.TransactionGroup = transactionGroup;
3894
3908
  if (templateRecord.action === 'save') {
@@ -3903,7 +3917,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3903
3917
  }
3904
3918
  }
3905
3919
  // 2. Save Template Contents (depend on Templates)
3906
- const templateContentRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'Template Contents');
3920
+ const templateContentRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'Template Contents');
3907
3921
  for (const contentRecord of templateContentRecords) {
3908
3922
  contentRecord.entityObject.TransactionGroup = transactionGroup;
3909
3923
  if (contentRecord.action === 'save') {
@@ -3918,7 +3932,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3918
3932
  }
3919
3933
  }
3920
3934
  // 3. Save AI Prompts (depend on Templates)
3921
- const promptRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name === 'AI Prompts');
3935
+ const promptRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Prompts');
3922
3936
  for (const promptRecord of promptRecords) {
3923
3937
  promptRecord.entityObject.TransactionGroup = transactionGroup;
3924
3938
  if (promptRecord.action === 'save') {
@@ -3940,9 +3954,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3940
3954
  return false;
3941
3955
  }
3942
3956
  // 4.1. Handle deferred sub-agent creation - set ParentID on any sub-agents created before parent was saved
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);
3957
+ const subAgentRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name === 'AI Agents' && p.action === 'save' && p.entityObject.Get('_tempParentId') === this.record.ID);
3946
3958
  for (const subAgentRecord of subAgentRecords) {
3947
3959
  // Cast to AIAgentEntityExtended to access ParentID property
3948
3960
  const subAgent = subAgentRecord.entityObject;
@@ -3952,7 +3964,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
3952
3964
  subAgent.Set('_tempParentId', null);
3953
3965
  }
3954
3966
  // 5. Save all other pending records (AI Agent Actions, AI Agent Prompts, etc.)
3955
- const otherRecords = this.PendingRecords.filter(p => p.entityObject.EntityInfo.Name !== 'Templates' &&
3967
+ const otherRecords = this.PendingRecords.filter((p) => p.entityObject.EntityInfo.Name !== 'Templates' &&
3956
3968
  p.entityObject.EntityInfo.Name !== 'Template Contents' &&
3957
3969
  p.entityObject.EntityInfo.Name !== 'AI Prompts');
3958
3970
  for (const record of otherRecords) {
@@ -4006,7 +4018,7 @@ let AIAgentFormComponentExtended = class AIAgentFormComponentExtended extends AI
4006
4018
  this.destroy$.next();
4007
4019
  this.destroy$.complete();
4008
4020
  // Clear all active timeouts
4009
- this.activeTimeouts.forEach(timeoutId => {
4021
+ this.activeTimeouts.forEach((timeoutId) => {
4010
4022
  clearTimeout(timeoutId);
4011
4023
  });
4012
4024
  this.activeTimeouts.length = 0;
@@ -4062,7 +4074,7 @@ export { AIAgentFormComponentExtended };
4062
4074
  type: ViewChild,
4063
4075
  args: ['customSectionContainer', { read: ViewContainerRef }]
4064
4076
  }] }); })();
4065
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AIAgentFormComponentExtended, { className: "AIAgentFormComponentExtended", filePath: "src/lib/custom/AIAgents/ai-agent-form.component.ts", lineNumber: 73 }); })();
4077
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AIAgentFormComponentExtended, { className: "AIAgentFormComponentExtended", filePath: "src/lib/custom/AIAgents/ai-agent-form.component.ts", lineNumber: 82 }); })();
4066
4078
  export function LoadAIAgentFormComponentExtended() {
4067
4079
  // This function is called to ensure the component is loaded and registered
4068
4080
  }