diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs index 613c17789..2a9508d77 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs @@ -19,7 +19,7 @@ public enum AgentField LlmConfig, Utility, KnowledgeBase, - EventRule, + Rule, MaxMessageCount } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentRuleHook.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentRuleHook.cs new file mode 100644 index 000000000..8a19a561a --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentRuleHook.cs @@ -0,0 +1,6 @@ +namespace BotSharp.Abstraction.Agents; + +public interface IAgentRuleHook +{ + void AddRules(List rules); +} diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs index 83927d9f0..96aa070c4 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs @@ -102,7 +102,7 @@ public class Agent /// /// Agent rules /// - public List EventRules { get; set; } = new(); + public List Rules { get; set; } = new(); /// /// Agent knowledge bases @@ -159,7 +159,7 @@ public static Agent Clone(Agent agent) MaxMessageCount = agent.MaxMessageCount, Profiles = agent.Profiles, RoutingRules = agent.RoutingRules, - EventRules = agent.EventRules, + Rules = agent.Rules, LlmConfig = agent.LlmConfig, KnowledgeBases = agent.KnowledgeBases, CreatedDateTime = agent.CreatedDateTime, @@ -275,9 +275,9 @@ public Agent SetRoutingRules(List rules) return this; } - public Agent SetEventRules(List rules) + public Agent SetRules(List rules) { - EventRules = rules ?? []; + Rules = rules ?? []; return this; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentEventRule.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs similarity index 91% rename from src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentEventRule.cs rename to src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs index 180c83a66..5c3a276e8 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentEventRule.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs @@ -1,6 +1,6 @@ namespace BotSharp.Abstraction.Agents.Models; -public class AgentEventRule +public class AgentRule { public string Name { get; set; } public bool Disabled { get; set; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Http/IHttpRequestHook.cs b/src/Infrastructure/BotSharp.Abstraction/Http/IHttpRequestHook.cs new file mode 100644 index 000000000..18b96e77c --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Http/IHttpRequestHook.cs @@ -0,0 +1,8 @@ +using System.Net.Http.Headers; + +namespace BotSharp.Abstraction.Http; + +public interface IHttpRequestHook +{ + void OnAddHttpHeaders(HttpHeaders headers); +} diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/IAuthenticationHook.cs b/src/Infrastructure/BotSharp.Abstraction/Users/IAuthenticationHook.cs index d953271f5..939d509e6 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Users/IAuthenticationHook.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Users/IAuthenticationHook.cs @@ -1,5 +1,4 @@ using BotSharp.Abstraction.Users.Models; -using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; namespace BotSharp.Abstraction.Users; diff --git a/src/Infrastructure/BotSharp.Core.Rules/Hooks/IEventRuleHook.cs b/src/Infrastructure/BotSharp.Core.Rules/Hooks/IEventRuleHook.cs deleted file mode 100644 index e65050b85..000000000 --- a/src/Infrastructure/BotSharp.Core.Rules/Hooks/IEventRuleHook.cs +++ /dev/null @@ -1,8 +0,0 @@ -using BotSharp.Abstraction.Agents.Models; - -namespace BotSharp.Core.Rules.Hooks; - -public interface IEventRuleHook -{ - void AddRules(List rules); -} diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs index ea95daa51..6889336a5 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs @@ -40,7 +40,7 @@ public async Task UpdateAgent(Agent agent, AgentField updateField) record.Samples = agent.Samples ?? []; record.Utilities = agent.Utilities ?? []; record.KnowledgeBases = agent.KnowledgeBases ?? []; - record.EventRules = agent.EventRules ?? []; + record.Rules = agent.Rules ?? []; if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit) { record.LlmConfig = agent.LlmConfig; @@ -105,7 +105,7 @@ public async Task UpdateAgentFromFile(string id) .SetSamples(foundAgent.Samples) .SetUtilities(foundAgent.Utilities) .SetKnowledgeBases(foundAgent.KnowledgeBases) - .SetEventRules(foundAgent.EventRules) + .SetRules(foundAgent.Rules) .SetLlmConfig(foundAgent.LlmConfig); _db.UpdateAgent(clonedAgent, AgentField.All); diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs index 3b8614f19..d38b2a89d 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs @@ -60,8 +60,8 @@ public void UpdateAgent(Agent agent, AgentField field) case AgentField.KnowledgeBase: UpdateAgentKnowledgeBases(agent.Id, agent.KnowledgeBases); break; - case AgentField.EventRule: - UpdateAgentEventRules(agent.Id, agent.EventRules); + case AgentField.Rule: + UpdateAgentRules(agent.Id, agent.Rules); break; case AgentField.MaxMessageCount: UpdateAgentMaxMessageCount(agent.Id, agent.MaxMessageCount); @@ -187,14 +187,14 @@ private void UpdateAgentKnowledgeBases(string agentId, List File.WriteAllText(agentFile, json); } - private void UpdateAgentEventRules(string agentId, List rules) + private void UpdateAgentRules(string agentId, List rules) { if (rules == null) return; var (agent, agentFile) = GetAgentFromFile(agentId); if (agent == null) return; - agent.EventRules = rules; + agent.Rules = rules; agent.UpdatedDateTime = DateTime.UtcNow; var json = JsonSerializer.Serialize(agent, _options); File.WriteAllText(agentFile, json); @@ -344,7 +344,7 @@ private void UpdateAgentAllFields(Agent inputAgent) agent.Utilities = inputAgent.Utilities; agent.KnowledgeBases = inputAgent.KnowledgeBases; agent.RoutingRules = inputAgent.RoutingRules; - agent.EventRules = inputAgent.EventRules; + agent.Rules = inputAgent.Rules; agent.LlmConfig = inputAgent.LlmConfig; agent.MaxMessageCount = inputAgent.MaxMessageCount; agent.UpdatedDateTime = DateTime.UtcNow; diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj index bacf34e90..28dde7557 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj +++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj @@ -48,7 +48,6 @@ - diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs index b4f1b3e6e..6efb7104e 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/AgentController.cs @@ -1,6 +1,4 @@ using BotSharp.Abstraction.Agents.Models; -using BotSharp.Core.Infrastructures; -using BotSharp.Core.Rules.Hooks; namespace BotSharp.OpenAPI.Controllers; @@ -163,11 +161,11 @@ public IEnumerable GetAgentUtilityOptions() return utilities.Where(x => !string.IsNullOrWhiteSpace(x.Name)).OrderBy(x => x.Name).ToList(); } - [HttpGet("/agent/event-rule/options")] - public IEnumerable GetAgentEventRuleOptions() + [HttpGet("/agent/rule/options")] + public IEnumerable GetAgentRuleOptions() { - var rules = new List(); - var hooks = _services.GetServices(); + var rules = new List(); + var hooks = _services.GetServices(); foreach (var hook in hooks) { hook.AddRules(rules); diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs index 9df167b7f..a0e8f7901 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs @@ -55,7 +55,7 @@ public class AgentCreationModel public List Utilities { get; set; } = new(); public List RoutingRules { get; set; } = new(); public List KnowledgeBases { get; set; } = new(); - public List EventRules { get; set; } = new(); + public List Rules { get; set; } = new(); public AgentLlmConfig? LlmConfig { get; set; } public Agent ToAgent() @@ -79,7 +79,7 @@ public Agent ToAgent() Profiles = Profiles, LlmConfig = LlmConfig, KnowledgeBases = KnowledgeBases, - EventRules = EventRules, + Rules = Rules, RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? [], }; } diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs index 2bfaa52f5..8e268b97b 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs @@ -75,8 +75,8 @@ public class AgentUpdateModel [JsonPropertyName("routing_rules")] public List? RoutingRules { get; set; } - [JsonPropertyName("event_rules")] - public List? EventRules { get; set; } + [JsonPropertyName("rules")] + public List? Rules { get; set; } [JsonPropertyName("llm_config")] public AgentLlmConfig? LlmConfig { get; set; } @@ -101,7 +101,7 @@ public Agent ToAgent() Responses = Responses ?? [], Utilities = Utilities ?? [], KnowledgeBases = KnowledgeBases ?? [], - EventRules = EventRules ?? [], + Rules = Rules ?? [], LlmConfig = LlmConfig }; diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs index d2a6f2cac..de4a13ba7 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs @@ -28,8 +28,8 @@ public class AgentViewModel [JsonPropertyName("knowledge_bases")] public List KnowledgeBases { get; set; } - [JsonPropertyName("event_rules")] - public List EventRules { get; set; } + [JsonPropertyName("rules")] + public List Rules { get; set; } [JsonPropertyName("is_public")] public bool IsPublic { get; set; } @@ -89,7 +89,7 @@ public static AgentViewModel FromAgent(Agent agent) MaxMessageCount = agent.MaxMessageCount, Profiles = agent.Profiles ?? [], RoutingRules = agent.RoutingRules ?? [], - EventRules = agent.EventRules ?? [], + Rules = agent.Rules ?? [], LlmConfig = agent.LlmConfig, Plugin = agent.Plugin, CreatedDateTime = agent.CreatedDateTime, diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs index d36aafba4..52f5075b3 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Functions/HandleHttpRequestFn.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Net.Mime; +using BotSharp.Abstraction.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -13,7 +14,6 @@ public class HandleHttpRequestFn : IFunctionCallback private readonly IServiceProvider _services; private readonly ILogger _logger; private readonly IHttpClientFactory _httpClientFactory; - private readonly IHttpContextAccessor _context; private readonly BotSharpOptions _options; public HandleHttpRequestFn(IServiceProvider services, @@ -25,7 +25,6 @@ public HandleHttpRequestFn(IServiceProvider services, _services = services; _logger = logger; _httpClientFactory = httpClientFactory; - _context = context; _options = options; } @@ -46,7 +45,7 @@ public async Task Execute(RoleDialogModel message) catch (Exception ex) { var msg = $"Fail when sending http request. Url: {url}, method: {method}, content: {content}"; - _logger.LogWarning($"{msg}\n(Error: {ex.Message})"); + _logger.LogError($"{msg}\n(Error: {ex.Message}\r\n{ex.InnerException})"); message.Content = msg; return false; } @@ -57,7 +56,7 @@ public async Task Execute(RoleDialogModel message) if (string.IsNullOrEmpty(url)) return null; using var client = _httpClientFactory.CreateClient(); - AddRequestHeaders(client); + PrepareRequestHeaders(client); var (uri, request) = BuildHttpRequest(url, method, content); var response = await client.SendAsync(request); @@ -69,15 +68,12 @@ public async Task Execute(RoleDialogModel message) return response; } - private void AddRequestHeaders(HttpClient client) + private void PrepareRequestHeaders(HttpClient client) { - client.DefaultRequestHeaders.Add("Authorization", $"{_context.HttpContext.Request.Headers["Authorization"]}"); - - var settings = _services.GetRequiredService(); - var origin = !string.IsNullOrEmpty(settings.Origin) ? settings.Origin : $"{_context.HttpContext.Request.Headers["Origin"]}"; - if (!string.IsNullOrEmpty(origin)) + var hooks = _services.GetServices(); + foreach (var hook in hooks) { - client.DefaultRequestHeaders.Add("Origin", origin); + hook.OnAddHttpHeaders(client.DefaultRequestHeaders); } } diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/BasicHttpRequestHook.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/BasicHttpRequestHook.cs new file mode 100644 index 000000000..5de858f2f --- /dev/null +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/Hooks/BasicHttpRequestHook.cs @@ -0,0 +1,40 @@ +using BotSharp.Abstraction.Http; +using Microsoft.AspNetCore.Http; +using System.Net.Http.Headers; + +namespace BotSharp.Plugin.HttpHandler.Hooks; + +public class BasicHttpRequestHook : IHttpRequestHook +{ + private readonly IServiceProvider _services; + private readonly IHttpContextAccessor _context; + + private const string AUTHORIZATION = "Authorization"; + private const string ORIGIN = "Origin"; + + public BasicHttpRequestHook( + IServiceProvider services, + IHttpContextAccessor context) + { + _services = services; + _context = context; + } + + public void OnAddHttpHeaders(HttpHeaders headers) + { + var settings = _services.GetRequiredService(); + + var auth = $"{_context.HttpContext.Request.Headers[AUTHORIZATION]}"; + if (!string.IsNullOrEmpty(auth)) + { + headers.Add(AUTHORIZATION, auth); + } + + var origin = $"{_context.HttpContext.Request.Headers[ORIGIN]}"; + origin = !string.IsNullOrEmpty(settings.Origin) ? settings.Origin : origin; + if (!string.IsNullOrEmpty(origin)) + { + headers.Add(ORIGIN, origin); + } + } +} diff --git a/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs b/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs index 9c8cab55f..a3c85c0b7 100644 --- a/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs +++ b/src/Plugins/BotSharp.Plugin.HttpHandler/HttpHandlerPlugin.cs @@ -1,4 +1,5 @@ using BotSharp.Abstraction.Agents; +using BotSharp.Abstraction.Http; using BotSharp.Abstraction.Settings; using Microsoft.Extensions.Configuration; @@ -21,5 +22,6 @@ public void RegisterDI(IServiceCollection services, IConfiguration config) }); services.AddScoped(); + services.AddScoped(); } } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs index 816e09049..54c9eae72 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs @@ -21,7 +21,7 @@ public class AgentDocument : MongoBase public List KnowledgeBases { get; set; } public List Profiles { get; set; } public List RoutingRules { get; set; } - public List EventRules { get; set; } + public List Rules { get; set; } public AgentLlmConfigMongoElement? LlmConfig { get; set; } public DateTime CreatedTime { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentEventRuleMongoElement.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs similarity index 68% rename from src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentEventRuleMongoElement.cs rename to src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs index cadb3c454..1b3467687 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentEventRuleMongoElement.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs @@ -2,16 +2,16 @@ namespace BotSharp.Plugin.MongoStorage.Models; -public class AgentEventRuleMongoElement +public class AgentRuleMongoElement { public string Name { get; set; } public bool Disabled { get; set; } public string EventName { get; set; } public string EntityType { get; set; } - public static AgentEventRuleMongoElement ToMongoElement(AgentEventRule rule) + public static AgentRuleMongoElement ToMongoElement(AgentRule rule) { - return new AgentEventRuleMongoElement + return new AgentRuleMongoElement { Name = rule.Name, Disabled = rule.Disabled, @@ -20,9 +20,9 @@ public static AgentEventRuleMongoElement ToMongoElement(AgentEventRule rule) }; } - public static AgentEventRule ToDomainElement(AgentEventRuleMongoElement rule) + public static AgentRule ToDomainElement(AgentRuleMongoElement rule) { - return new AgentEventRule + return new AgentRule { Name = rule.Name, Disabled = rule.Disabled, diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs index 92d9db607..af615298d 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs @@ -61,8 +61,8 @@ public void UpdateAgent(Agent agent, AgentField field) case AgentField.KnowledgeBase: UpdateAgentKnowledgeBases(agent.Id, agent.KnowledgeBases); break; - case AgentField.EventRule: - UpdateAgentEventRules(agent.Id, agent.EventRules); + case AgentField.Rule: + UpdateAgentRules(agent.Id, agent.Rules); break; case AgentField.MaxMessageCount: UpdateAgentMaxMessageCount(agent.Id, agent.MaxMessageCount); @@ -259,15 +259,15 @@ private void UpdateAgentKnowledgeBases(string agentId, List _dc.Agents.UpdateOne(filter, update); } - private void UpdateAgentEventRules(string agentId, List rules) + private void UpdateAgentRules(string agentId, List rules) { if (rules == null) return; - var elements = rules?.Select(x => AgentEventRuleMongoElement.ToMongoElement(x))?.ToList() ?? []; + var elements = rules?.Select(x => AgentRuleMongoElement.ToMongoElement(x))?.ToList() ?? []; var filter = Builders.Filter.Eq(x => x.Id, agentId); var update = Builders.Update - .Set(x => x.EventRules, elements) + .Set(x => x.Rules, elements) .Set(x => x.UpdatedTime, DateTime.UtcNow); _dc.Agents.UpdateOne(filter, update); @@ -314,7 +314,7 @@ private void UpdateAgentAllFields(Agent agent) .Set(x => x.Samples, agent.Samples) .Set(x => x.Utilities, agent.Utilities.Select(u => AgentUtilityMongoElement.ToMongoElement(u)).ToList()) .Set(x => x.KnowledgeBases, agent.KnowledgeBases.Select(u => AgentKnowledgeBaseMongoElement.ToMongoElement(u)).ToList()) - .Set(x => x.EventRules, agent.EventRules.Select(e => AgentEventRuleMongoElement.ToMongoElement(e)).ToList()) + .Set(x => x.Rules, agent.Rules.Select(e => AgentRuleMongoElement.ToMongoElement(e)).ToList()) .Set(x => x.LlmConfig, AgentLlmConfigMongoElement.ToMongoElement(agent.LlmConfig)) .Set(x => x.IsPublic, agent.IsPublic) .Set(x => x.UpdatedTime, DateTime.UtcNow); @@ -472,7 +472,7 @@ public void BulkInsertAgents(List agents) RoutingRules = x.RoutingRules?.Select(r => RoutingRuleMongoElement.ToMongoElement(r))?.ToList() ?? [], Utilities = x.Utilities?.Select(u => AgentUtilityMongoElement.ToMongoElement(u))?.ToList() ?? [], KnowledgeBases = x.KnowledgeBases?.Select(k => AgentKnowledgeBaseMongoElement.ToMongoElement(k))?.ToList() ?? [], - EventRules = x.EventRules?.Select(e => AgentEventRuleMongoElement.ToMongoElement(e))?.ToList() ?? [], + Rules = x.Rules?.Select(e => AgentRuleMongoElement.ToMongoElement(e))?.ToList() ?? [], CreatedTime = x.CreatedDateTime, UpdatedTime = x.UpdatedDateTime }).ToList(); @@ -565,7 +565,7 @@ private Agent TransformAgentDocument(AgentDocument? agentDoc) RoutingRules = agentDoc.RoutingRules?.Select(r => RoutingRuleMongoElement.ToDomainElement(agentDoc.Id, agentDoc.Name, r))?.ToList() ?? [], Utilities = agentDoc.Utilities?.Select(u => AgentUtilityMongoElement.ToDomainElement(u))?.ToList() ?? [], KnowledgeBases = agentDoc.KnowledgeBases?.Select(x => AgentKnowledgeBaseMongoElement.ToDomainElement(x))?.ToList() ?? [], - EventRules = agentDoc.EventRules?.Select(e => AgentEventRuleMongoElement.ToDomainElement(e))?.ToList() ?? [] + Rules = agentDoc.Rules?.Select(e => AgentRuleMongoElement.ToDomainElement(e))?.ToList() ?? [] }; } }