| | | 1 | | using CShells.Features; |
| | | 2 | | using Elsa.AI.Copilot.Options; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Platform.PackageManifest.Generator.Hints; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | |
| | | 8 | | namespace Elsa.AI.Copilot.ShellFeatures; |
| | | 9 | | |
| | | 10 | | [ManifestFeatureCategory("AI")] |
| | | 11 | | [ShellFeature( |
| | | 12 | | "CopilotAI", |
| | | 13 | | DisplayName = "Copilot AI Provider", |
| | | 14 | | Description = "Registers the Copilot adapter for Weaver AI")] |
| | | 15 | | [UsedImplicitly] |
| | | 16 | | public class CopilotAIFeature : IShellFeature |
| | | 17 | | { |
| | 0 | 18 | | private static readonly CopilotOptions DefaultOptions = new(); |
| | | 19 | | |
| | 0 | 20 | | public string? RuntimePath { get; set; } = DefaultOptions.RuntimePath; |
| | 0 | 21 | | public string? RuntimeUrl { get; set; } = DefaultOptions.RuntimeUrl; |
| | 0 | 22 | | public ICollection<string> RuntimeArguments { get; set; } = []; |
| | 0 | 23 | | public string? WorkingDirectory { get; set; } = DefaultOptions.WorkingDirectory; |
| | 0 | 24 | | public string? BaseDirectory { get; set; } = DefaultOptions.BaseDirectory; |
| | 0 | 25 | | public string? GitHubToken { get; set; } = DefaultOptions.GitHubToken; |
| | 0 | 26 | | public bool? UseLoggedInUser { get; set; } = DefaultOptions.UseLoggedInUser; |
| | 0 | 27 | | public string? Model { get; set; } = DefaultOptions.Model; |
| | 0 | 28 | | public string? ReasoningEffort { get; set; } = DefaultOptions.ReasoningEffort; |
| | 0 | 29 | | public string? ProviderName { get; set; } = DefaultOptions.ProviderName; |
| | | 30 | | |
| | | 31 | | public void ConfigureServices(IServiceCollection services) |
| | | 32 | | { |
| | 0 | 33 | | services.AddCopilotAIProvider(ConfigureOptions); |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | private void ConfigureOptions(CopilotOptions options) |
| | | 37 | | { |
| | 0 | 38 | | options.RuntimePath = RuntimePath; |
| | 0 | 39 | | options.RuntimeUrl = RuntimeUrl; |
| | 0 | 40 | | options.RuntimeArguments = RuntimeArguments; |
| | 0 | 41 | | options.WorkingDirectory = WorkingDirectory; |
| | 0 | 42 | | options.BaseDirectory = BaseDirectory; |
| | 0 | 43 | | options.GitHubToken = GitHubToken; |
| | 0 | 44 | | options.UseLoggedInUser = UseLoggedInUser; |
| | 0 | 45 | | options.Model = Model; |
| | 0 | 46 | | options.ReasoningEffort = ReasoningEffort; |
| | 0 | 47 | | options.ProviderName = ProviderName; |
| | 0 | 48 | | } |
| | | 49 | | } |