Ananke.AspNetCore 0.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ananke.AspNetCore --version 0.6.0
                    
NuGet\Install-Package Ananke.AspNetCore -Version 0.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ananke.AspNetCore" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ananke.AspNetCore" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Ananke.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ananke.AspNetCore --version 0.6.0
                    
#r "nuget: Ananke.AspNetCore, 0.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ananke.AspNetCore@0.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ananke.AspNetCore&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Ananke.AspNetCore&version=0.6.0
                    
Install as a Cake Tool

Ananke.AspNetCore

NuGet License

ASP.NET Core integration helpers for Ananke — SSE streaming, ChatSessionEvent-to-SSE bridging, state-machine endpoint utilities, provider configuration, and session management.

Install

dotnet add package Ananke.AspNetCore

Quick start

SSE streaming

using Ananke.AspNetCore.Sse;

app.MapPost("/api/chat", async (ChatRequest request, HttpContext context, CancellationToken ct) =>
{
    // One call sets Content-Type + Cache-Control headers
    context.Response.EnableSse();

    // Write named SSE events with JSON data
    await context.Response.WriteSseAsync("session", new { sessionId = "abc" });
    await context.Response.WriteSseAsync("delta", new { text = "Hello!" });
    await context.Response.WriteSseAsync("done", new { text = "Hello!" });
});

ChatSessionEvent → SSE bridge

Pipe a StreamingChatWorkflow event stream directly to an HTTP response:

using Ananke.AspNetCore.Sse;

var events = StreamingChatWorkflow.Create("chat", model)
    .WithSystemPrompt("You are helpful.")
    .BuildStream(messages, ct);

await events.WriteSseAsync(context.Response);

Or via a delegate (useful for session-based scenarios where the writer is re-bound per request):

await events.WriteSseAsync(
    writeSse: myWriteDelegate,
    onError: msg => logger.LogError("Error: {Msg}", msg));

Event mapping:

ChatSessionEvent SSE event name
TextDeltaEvent delta
AudioDeltaEvent audio_delta
ToolCallEvent tool_call
ToolResultEvent tool_result
InterruptedEvent interrupted
ResumedEvent resumed
ErrorEvent error
CompletedEvent (silently consumed)

State-machine SSE loop

Await a state machine's CurrentWork through phase transitions, surviving interrupt-induced cancellation races:

using Ananke.AspNetCore.Sse;

await machine.FireAsync(MyAction.Start);
var reachedDone = await machine.RunSseLoopAsync(MyPhase.Done);

if (reachedDone)
    await context.Response.WriteSseAsync("done", new { });

Provider configuration

Register LLM providers at startup and read settings from IConfiguration:

using Ananke.AspNetCore.Configuration;

// Register providers (typically in Program.cs)
AgentModelFactory.RegisterProvider("OpenAI",
    defaultModel: "gpt-4.1-mini",
    agentFactory: (key, model) => OpenAIChatAgentModel.Create(key, model),
    embeddingFactory: (key, model) => OpenAIEmbeddingModel.Create(key, model));

AgentModelFactory.RegisterProvider("Google",
    defaultModel: "gemini-2.5-flash",
    agentFactory: (key, model) => GeminiAgentModel.Create(key, model));

// Read from configuration (secrets.json / appsettings.json)
// { "Provider": "OpenAI", "OpenAI": { "ApiKey": "sk-...", "Model": "gpt-4.1-mini" } }
var profile = AgentModelFactory.FromConfiguration(builder.Configuration);
var agentModel = profile.CreateAgentModel();
var embedder = profile.CreateEmbeddingModel(); // null if not configured

Session store

Thread-safe in-memory session management:

using Ananke.AspNetCore.Sessions;

var sessions = new InMemorySessionStore<MySession>();

// Atomic get-or-create
var session = sessions.GetOrCreate(sessionId, () => new MySession());

// Lookup
var existing = sessions.Get(sessionId);          // null if missing
sessions.TryGet(sessionId, out var s);           // bool pattern

// Cleanup
sessions.Remove(sessionId);
var removed = sessions.RemoveAndGet(sessionId);  // remove + return

Features

  • EnableSse() — one-liner SSE response header setup
  • WriteSseAsync(name, data) — JSON-serialized SSE event writing with flush
  • ChatSessionEvent → SSE bridge — maps all workflow event types to named SSE events
  • RunSseLoopAsync(terminalState) — reusable state-machine await loop with interrupt-race handling
  • AgentModelFactory — registry-based provider configuration from IConfiguration
  • ProviderProfile — immutable settings record with CreateAgentModel() / CreateEmbeddingModel()
  • InMemorySessionStore<T>ConcurrentDictionary-backed thread-safe session store
Package What it adds
Ananke.Orchestration Workflow builder, agents, ChatSessionEvent, StreamingChatWorkflow
Ananke.StateMachine State machine engine with OnEnter work and interrupt support
Ananke.Orchestration.OpenAI OpenAI IStreamingAgentModel + IEmbeddingModel provider
Ananke.Orchestration.Google Google Gemini IStreamingAgentModel + IEmbeddingModel provider
Ananke.Orchestration.Anthropic Anthropic / Claude IStreamingAgentModel provider

Documentation

Full docs, demos, and architecture: github.com/sevensamurai/Ananke

License

Apache 2.0

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.2 80 4/12/2026
0.7.1 77 4/11/2026
0.7.0 89 4/11/2026
0.6.0 88 4/10/2026
0.5.0 85 4/5/2026
0.4.0 80 4/3/2026
0.3.0 111 3/15/2026
0.2.0 100 3/15/2026