| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 3 | | |
| | | 4 | | using NexusLabs.Needlr.AgentFramework; |
| | | 5 | | using NexusLabs.Needlr.AgentFramework.Diagnostics; |
| | | 6 | | using NexusLabs.Needlr.AgentFramework.Iterative; |
| | | 7 | | |
| | | 8 | | namespace NexusLabs.Needlr.AgentFramework.Workflows; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Extension methods for registering graph workflow services in the DI container. |
| | | 12 | | /// </summary> |
| | | 13 | | public static class GraphWorkflowServiceExtensions |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Registers <see cref="IGraphWorkflowRunner"/> and its internal dependencies. |
| | | 17 | | /// Call after <c>UsingAgentFramework()</c>. |
| | | 18 | | /// </summary> |
| | | 19 | | public static IServiceCollection AddGraphWorkflowRunner(this IServiceCollection services) |
| | | 20 | | { |
| | 52 | 21 | | services.TryAddSingleton<GraphTopologyProvider>(); |
| | 52 | 22 | | services.TryAddSingleton<GraphEdgeRouter>(); |
| | 52 | 23 | | services.TryAddSingleton<IGraphWorkflowRunner>(sp => |
| | 92 | 24 | | new GraphWorkflowRunner( |
| | 92 | 25 | | sp.GetRequiredService<IWorkflowFactory>(), |
| | 92 | 26 | | sp.GetRequiredService<IAgentFactory>(), |
| | 92 | 27 | | sp.GetRequiredService<IChatClientAccessor>(), |
| | 92 | 28 | | sp.GetRequiredService<GraphTopologyProvider>(), |
| | 92 | 29 | | sp.GetRequiredService<GraphEdgeRouter>(), |
| | 92 | 30 | | sp.GetService<IAgentDiagnosticsAccessor>())); |
| | 52 | 31 | | return services; |
| | | 32 | | } |
| | | 33 | | } |