Skip to content

NeedlrDevUIServiceCollectionExtensions

NexusLabs.Needlr.AgentFramework.DevUI

NeedlrDevUIServiceCollectionExtensions Class

Extension methods for bridging Needlr's NexusLabs.Needlr.AgentFramework.NeedlrAiAgentAttribute-declared agents into MAF DevUI's entity discovery.

public static class NeedlrDevUIServiceCollectionExtensions

Inheritance System.Object 🡒 NeedlrDevUIServiceCollectionExtensions

Remarks

MAF DevUI discovers agents via keyed AIAgent DI services. This bridge reads the source-generated agent registry and uses MAF's AddAIAgent hosting API to register each NexusLabs.Needlr.AgentFramework.NeedlrAiAgentAttribute-declared agent so DevUI's /v1/entities endpoint lists them.

This package deliberately isolates the preview-only DevUI and Hosting package dependencies from the stable NexusLabs.Needlr.AgentFramework package.

Methods

NeedlrDevUIServiceCollectionExtensions.AddNeedlrDevUI(this IServiceCollection) Method

Registers all NexusLabs.Needlr.AgentFramework.NeedlrAiAgentAttribute-declared agents with MAF's hosting infrastructure so they appear in DevUI's entity discovery at /v1/entities.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNeedlrDevUI(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The service collection to register agents into.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The service collection for chaining.

Example

var builder = WebApplication.CreateBuilder(args);

// Bridge Needlr agents -> DevUI
builder.Services.AddNeedlrDevUI();

// MAF hosting + DevUI
builder.Services.AddOpenAIResponses();
builder.Services.AddOpenAIConversations();

var app = builder.Build();
app.MapOpenAIResponses();
app.MapOpenAIConversations();
app.MapDevUI();
app.Run();

Remarks

The method reads agent types from the static NexusLabs.Needlr.AgentFramework.AgentFrameworkGeneratedBootstrap registry (populated by the source-generated [ModuleInitializer]) and registers each using MAF's AddAIAgent(name, instructions) hosting API. The agent's NexusLabs.Needlr.AgentFramework.NeedlrAiAgentAttribute.Instructions and NexusLabs.Needlr.AgentFramework.NeedlrAiAgentAttribute.Description are read from the attribute.

Agents are registered with instructions from the attribute. Their IChatClient is resolved from DI at runtime when DevUI invokes them — register an IChatClient in DI to enable interactive use.