| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Permissions; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | |
| | | 5 | | namespace Elsa.AI.Host.Permissions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stable resource names for AI. Endpoints reference these constants rather than string |
| | | 9 | | /// literals, and the descriptors below are declared alongside them so the two cannot drift. |
| | | 10 | | /// </summary> |
| | | 11 | | public static class AIResourcePermissions |
| | | 12 | | { |
| | | 13 | | /// <summary>Converse with the AI assistant.</summary> |
| | | 14 | | public const string Chat = "ai/chat"; |
| | | 15 | | /// <summary>Browse available AI tools.</summary> |
| | | 16 | | public const string Tools = "ai/tools"; |
| | | 17 | | /// <summary>Inspect AI capabilities.</summary> |
| | | 18 | | public const string Capabilities = "ai/capabilities"; |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary>Contributes the AI resources to the permission catalog.</summary> |
| | | 22 | | [UsedImplicitly] |
| | | 23 | | public sealed class AIResourcePermissionsDescriptorProvider : IPermissionDescriptorProvider |
| | | 24 | | { |
| | | 25 | | /// <inheritdoc /> |
| | | 26 | | public IEnumerable<PermissionDescriptor> GetDescriptors() => |
| | 0 | 27 | | [ |
| | 0 | 28 | | new(AIResourcePermissions.Chat, [CoreVerbs.Execute], "AI chat", "Converse with the AI assistant.", "AI"), |
| | 0 | 29 | | new(AIResourcePermissions.Tools, [CoreVerbs.View], "AI tools", "Browse available AI tools.", "AI"), |
| | 0 | 30 | | new(AIResourcePermissions.Capabilities, [CoreVerbs.View], "AI capabilities", "Inspect AI capabilities.", "AI"), |
| | 0 | 31 | | ]; |
| | | 32 | | } |