bc25dc7b07
Implement the core application server as an ASP.NET web host with: - SignalR ChatHub for real-time client communication - Session management with token estimation for context windowing - Extensible tool system with attribute-based tool discovery - Chat stream update builder for streaming AI responses - App configuration with appsettings for development and production
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Luna.Agents.Extensions;
|
|
using Luna.Channels.Extensions;
|
|
using Luna.Configuration.Extensions;
|
|
using Luna.Core.Abstractions;
|
|
using Luna.Core.Hubs;
|
|
using Luna.Core.Services.Extensions;
|
|
using Luna.Core.Tools.Extensions;
|
|
using Luna.Memory.Extensions;
|
|
using Luna.Providers.Extensions;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Configuration
|
|
.AddLunaConfiguration();
|
|
|
|
builder.Services
|
|
.AddOpenApi()
|
|
.AddProviders()
|
|
.AddAgents()
|
|
.AddTools()
|
|
.AddMemoryStore()
|
|
.AddSessionManager()
|
|
.AddChannels();
|
|
|
|
builder.Services.AddSignalR()
|
|
.AddJsonProtocol(options =>
|
|
{
|
|
options.PayloadSerializerOptions.Converters.Add(
|
|
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
|
|
});
|
|
builder.Services.AddTransient<IChatHubContext, ChatHubContext>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.MapHub<ChatHub>("/chat");
|
|
app.Run();
|
|
|
|
// Expose Program type for WebApplicationFactory in integration tests
|
|
namespace Luna.Core
|
|
{
|
|
public partial class Program { }
|
|
}
|