| | | 1 | | using NexusLabs.Needlr.AgentFramework.Progress; |
| | | 2 | | |
| | | 3 | | namespace NexusLabs.Needlr.AgentFramework; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Declares which <see cref="IProgressSink"/> types should receive progress events when |
| | | 7 | | /// this agent runs. The source generator discovers this attribute and emits a companion |
| | | 8 | | /// method that returns the sink types for use by orchestrators when creating reporters. |
| | | 9 | | /// </summary> |
| | | 10 | | /// <remarks> |
| | | 11 | | /// <para> |
| | | 12 | | /// Apply alongside <see cref="NeedlrAiAgentAttribute"/> on agent classes: |
| | | 13 | | /// </para> |
| | | 14 | | /// <code> |
| | | 15 | | /// [NeedlrAiAgent(Instructions = "...")] |
| | | 16 | | /// [ProgressSinks(typeof(CostTrackingSink), typeof(AuditSink))] |
| | | 17 | | /// public partial class WriterAgent { } |
| | | 18 | | /// </code> |
| | | 19 | | /// <para> |
| | | 20 | | /// The generator emits a <c>GetWriterAgentProgressSinkTypes()</c> extension method |
| | | 21 | | /// on <c>IAgentFactory</c> that returns the declared types. Orchestrators use this |
| | | 22 | | /// to create reporters with the correct sinks for each agent. |
| | | 23 | | /// </para> |
| | | 24 | | /// </remarks> |
| | | 25 | | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] |
| | | 26 | | public sealed class ProgressSinksAttribute : Attribute |
| | | 27 | | { |
| | | 28 | | /// <summary>Gets the sink types declared for this agent.</summary> |
| | 0 | 29 | | public Type[] SinkTypes { get; } |
| | | 30 | | |
| | | 31 | | /// <param name="sinkTypes"> |
| | | 32 | | /// The <see cref="IProgressSink"/> types to use for this agent's progress reporting. |
| | | 33 | | /// </param> |
| | 0 | 34 | | public ProgressSinksAttribute(params Type[] sinkTypes) |
| | | 35 | | { |
| | 0 | 36 | | ArgumentNullException.ThrowIfNull(sinkTypes); |
| | 0 | 37 | | SinkTypes = sinkTypes; |
| | 0 | 38 | | } |
| | | 39 | | } |