2025-10-10 20:19:30 +00:00
|
|
|
using BotSharp.Abstraction.Agents.Options;
|
2024-03-31 19:28:16 +00:00
|
|
|
using BotSharp.Abstraction.Functions.Models;
|
2024-01-13 21:17:40 +00:00
|
|
|
using BotSharp.Abstraction.Plugins.Models;
|
2023-12-28 15:20:18 +00:00
|
|
|
using BotSharp.Abstraction.Repositories.Filters;
|
|
|
|
|
|
2023-06-11 15:22:48 +00:00
|
|
|
namespace BotSharp.Abstraction.Agents;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Agent management service
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IAgentService
|
|
|
|
|
{
|
2023-06-12 13:28:49 +00:00
|
|
|
Task<Agent> CreateAgent(Agent agent);
|
2025-07-29 00:19:13 +00:00
|
|
|
Task<string> RefreshAgents(IEnumerable<string>? agentIds = null);
|
2024-01-23 05:04:06 +00:00
|
|
|
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
|
2025-04-20 23:24:13 +00:00
|
|
|
Task<List<IdName>> GetAgentOptions(List<string>? agentIds = null, bool byName = false);
|
2025-06-05 03:15:07 +00:00
|
|
|
Task<IEnumerable<AgentUtility>> GetAgentUtilityOptions();
|
2023-08-14 17:00:01 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-10-18 15:54:03 +00:00
|
|
|
/// Load agent configurations and trigger hooks
|
2023-08-14 17:00:01 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-12-22 22:36:18 +00:00
|
|
|
Task<Agent> LoadAgent(string id, bool loadUtility = true);
|
2023-08-14 17:00:01 +00:00
|
|
|
|
2024-08-13 21:36:12 +00:00
|
|
|
/// <summary>
|
2024-08-14 15:45:22 +00:00
|
|
|
/// Inherit from an agent
|
2024-08-13 21:36:12 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="agent"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
Task InheritAgent(Agent agent);
|
|
|
|
|
|
2025-09-25 20:31:54 +00:00
|
|
|
string RenderInstruction(Agent agent, Dictionary<string, object>? renderData = null);
|
2023-10-28 20:59:26 +00:00
|
|
|
|
2025-09-25 20:31:54 +00:00
|
|
|
string RenderTemplate(Agent agent, string templateName, Dictionary<string, object>? renderData = null);
|
2023-10-28 20:59:26 +00:00
|
|
|
|
2025-09-25 20:31:54 +00:00
|
|
|
bool RenderFunction(Agent agent, FunctionDef def, Dictionary<string, object>? renderData = null);
|
2024-03-31 19:28:16 +00:00
|
|
|
|
2025-09-25 20:31:54 +00:00
|
|
|
FunctionParametersDef? RenderFunctionProperty(Agent agent, FunctionDef def, Dictionary<string, object>? renderData = null);
|
2024-04-09 20:52:21 +00:00
|
|
|
|
2025-09-25 20:31:54 +00:00
|
|
|
(string, IEnumerable<FunctionDef>) PrepareInstructionAndFunctions(Agent agent, Dictionary<string, object>? renderData = null, StringComparer? comparer = null);
|
2025-08-13 18:54:14 +00:00
|
|
|
|
2025-05-28 21:16:48 +00:00
|
|
|
bool RenderVisibility(string? visibilityExpression, Dictionary<string, object> dict);
|
2025-09-25 20:31:54 +00:00
|
|
|
Dictionary<string, object> CollectRenderData(Agent agent);
|
2025-05-27 20:23:37 +00:00
|
|
|
|
2025-08-14 15:47:07 +00:00
|
|
|
|
2023-10-18 11:58:36 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Get agent detail without trigger any hook.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns>Original agent information</returns>
|
2023-06-27 18:31:13 +00:00
|
|
|
Task<Agent> GetAgent(string id);
|
2024-01-23 05:04:06 +00:00
|
|
|
|
2023-06-11 23:46:02 +00:00
|
|
|
Task<bool> DeleteAgent(string id);
|
2023-09-15 20:19:44 +00:00
|
|
|
Task UpdateAgent(Agent agent, AgentField updateField);
|
2024-05-09 22:06:03 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Path existing templates of agent, cannot create new or delete templates
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="agent"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
Task<string> PatchAgentTemplate(Agent agent);
|
2023-08-09 21:49:55 +00:00
|
|
|
string GetDataDir();
|
2023-06-27 18:31:13 +00:00
|
|
|
string GetAgentDataDir(string agentId);
|
2024-01-13 21:17:40 +00:00
|
|
|
|
2024-10-31 19:36:26 +00:00
|
|
|
Task<List<UserAgent>> GetUserAgents(string userId);
|
2024-05-15 22:30:45 +00:00
|
|
|
|
2024-01-13 21:17:40 +00:00
|
|
|
PluginDef GetPlugin(string agentId);
|
2025-10-10 20:19:30 +00:00
|
|
|
|
|
|
|
|
Task<List<AgentCodeScript>> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
|
|
|
|
|
=> Task.FromResult(new List<AgentCodeScript>());
|
|
|
|
|
|
|
|
|
|
Task<string?> GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
|
|
|
|
|
=> Task.FromResult(string.Empty);
|
|
|
|
|
|
|
|
|
|
Task<bool> UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> codeScripts, AgentCodeScriptUpdateOptions? options = null)
|
|
|
|
|
=> Task.FromResult(false);
|
2023-06-11 15:22:48 +00:00
|
|
|
}
|