Wires CrestApps.Core 2.0 into ASP.NET Core hosts (MVC, Razor Pages, Blazor, Minimal API, MAUI hybrid). Covers Program.cs ordering, middleware, chat hubs, WebRTC transport, document/knowledge endpoints, and MCP mapping.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are a CrestApps.Core expert. Register host services first, compose CrestApps through AddCrestAppsCore(...), then map only the hubs and endpoints for the features the host enables.
CrestApps.Core.Data.EntityCore or CrestApps.Core.Data.YesSql) when records must persist.AddCrestAppsStoreCommitterFilter() for MVC, .AddSignalR(addStoreCommitterFilter: true) for hubs, StoreCommitterEndpointFilter for Minimal API groups, and an explicit IStoreCommitter.CommitAsync() in background scopes.UseWebSockets() before UseRouting(). HTTP/2 WebSocket handshakes (extended CONNECT) are otherwise rejected with 405, which breaks the realtime WebSocket transport.UseAIAnonymousVisitorCookie() (from CrestApps.Core.AI.Chat) after routing and before authentication when anonymous visitors chat, so rate limiting and session reuse get a stable visitor key.ConfigureCrestAppsChatHubOptions<THub>() (or ConfigureChatHubOptions<THub>() on the Chat Interactions builder). HubOptions<THub> is per hub type; an unconfigured hub runs on SignalR defaults (one parallel invocation per client), which deadlocks the realtime WebRTC handshake.IAuthorizationService. Register IAuthorizationHandler implementations that grant the requirements, or every download and upload is forbidden.Add*Endpoint() returns its RouteHandlerBuilder, so call them one per statement and add filters or rate limiting to the result. Cookie-authenticated pages render the antiforgery token (<meta name="RequestVerificationToken" ...> or antiforgeryToken in the chat config) for the upload and remove endpoints.UseForwardedHeaders() with ForwardedHeadersOptions.KnownProxies/KnownNetworks. The visitor identity resolver never reads X-Forwarded-For itself, so without it every visitor shares the proxy's address for rate limiting.using CrestApps.Core;
using CrestApps.Core.AI;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Chat.AGUI;
using CrestApps.Core.AI.Documents;
using CrestApps.Core.AI.Documents.Endpoints;
using CrestApps.Core.AI.Documents.OpenXml;
using CrestApps.Core.AI.Documents.Pdf;
using CrestApps.Core.AI.OpenAI;
using CrestApps.Core.Data.EntityCore;
using CrestApps.Core.SignalR;
using MyApp.Hubs;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization();
builder.Services.AddControllersWithViews()
.AddCrestAppsStoreCommitterFilter();
builder.Services.AddHttpContextAccessor();
Directory.CreateDirectory(Path.Combine(builder.Environment.ContentRootPath, "App_Data"));
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddEntityCoreStores()
.AddOpenAI()
.AddChatInteractions(chat => chat
.AddEntityCoreStores()
.ConfigureChatHubOptions<ChatInteractionHub>())
.AddDocumentProcessing(documents => documents
.AddEntityCoreStores()
.AddOpenXml()
.AddPdf())
.AddSignalR(addStoreCommitterFilter: true))
.AddIndexingServices(indexing => indexing.AddEntityCoreStores())
.AddEntityCoreSqliteDataStore(
$"Data Source={Path.Combine(builder.Environment.ContentRootPath, "App_Data", "crestapps.db")}"));
builder.Services.ConfigureCrestAppsChatHubOptions<AIChatHub>();
var app = builder.Build();
await app.Services.InitializeEntityCoreSchemaAsync();
app.UseHttpsRedirection()
.UseStaticFiles()
.UseWebSockets()
.UseRouting()
.UseAIAnonymousVisitorCookie()
.UseAuthentication()
.UseAuthorization();
app.MapHub<AIChatHub>("/hubs/ai-chat");
app.MapHub<ChatInteractionHub>("/hubs/chat-interaction");
// Optional: other AG-UI clients over HTTP (see crestapps-core-ag-ui).
app.MapAGUIChat<AIChatHub>()
.RequireAuthorization();
app.AddDownloadAIDocumentEndpoint();
app.AddDownloadAIDocumentFigureEndpoint();
app.AddDownloadKnowledgeFigureEndpoint();
app.AddUploadChatInteractionDocumentEndpoint();
app.AddRemoveChatInteractionDocumentEndpoint();
app.AddUploadChatSessionDocumentEndpoint();
app.AddRemoveChatSessionDocumentEndpoint();
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
await app.RunAsync();
For YesSql, swap the store calls for .AddYesSqlStores() and .AddYesSqlDataStore(configuration => configuration.UseSqLite(...)), then create the index tables before serving requests (see crestapps-core-yessql-stores).
The packages ship hub base classes; the host owns the concrete hub, its route and its authorization.
using CrestApps.Core.AI.Chat.Hubs;
using CrestApps.Core.AI.Models;
using Microsoft.AspNetCore.Authorization;
namespace MyApp.Hubs;
[AllowAnonymous]
public sealed class AIChatHub : AIChatHubCore<IAIChatHubClient>
{
public AIChatHub(IServiceProvider services, TimeProvider timeProvider, ILogger<AIChatHub> logger)
: base(services, timeProvider, logger)
{
}
protected override Task<bool> AuthorizeProfileAsync(IServiceProvider services, AIProfile profile)
{
return Task.FromResult(Context.User?.Identity?.IsAuthenticated == true);
}
}
[Authorize]
public sealed class ChatInteractionHub : ChatInteractionHubBase
{
public ChatInteractionHub(IServiceProvider services, TimeProvider timeProvider, ILogger<ChatInteractionHub> logger)
: base(services, timeProvider, logger)
{
}
}
.AddSignalR(...) on the AI suite calls AddCoreSignalR(pathPrefix), which registers HubRouteManager, sets host-wide MaximumParallelInvocationsPerClient = 8 and StreamBufferCapacity = 64, and switches the JSON protocol to camelCase. Hub-level overrides and route management are covered in crestapps-core-signalr; realtime voice in crestapps-core-realtime-voice.
For speech-to-speech over WebRTC, also call builder.Services.AddWebRtcRealtimeTransport() (package CrestApps.Core.AI.WebRTC). It binds ICE servers from CrestApps:AI:RealtimeTransport; the browser falls back to WebSocket when WebRTC is unavailable.
| Endpoint extension | Route | Requirement and resource |
|---|---|---|
AddDownloadAIDocumentEndpoint() | GET ai/documents/{documentId}/download | AIChatDocumentOperations.ManageDocuments on ChatInteraction, AIProfile, or AIChatSessionDocumentAuthorizationContext |
AddDownloadAIDocumentFigureEndpoint() | GET ai/documents/{documentId}/figures/{figureId} | same as above |
AddDownloadKnowledgeFigureEndpoint() | GET ai/knowledge/{dataSourceId}/figures/{canonicalId} | AIKnowledgeOperations.ViewFigures on AIDataSource |
AddUploadChatInteractionDocumentEndpoint(), AddRemoveChatInteractionDocumentEndpoint() | POST ai/chat-interactions/upload-document, .../remove-document | ManageDocuments on ChatInteraction |
AddUploadChatSessionDocumentEndpoint(), AddRemoveChatSessionDocumentEndpoint() | POST ai/chat-sessions/upload-document, .../remove-document | ManageDocuments on AIChatSessionDocumentAuthorizationContext |
using CrestApps.Core.AI.Documents;
using CrestApps.Core.AI.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization.Infrastructure;
namespace MyApp.Security;
public sealed class ChatInteractionDocumentAuthorizationHandler
: AuthorizationHandler<OperationAuthorizationRequirement, ChatInteraction>
{
protected override Task HandleRequirementAsync(
AuthorizationHandlerContext context,
OperationAuthorizationRequirement requirement,
ChatInteraction resource)
{
if (resource is not null &&
requirement.Name == AIChatDocumentOperations.ManageDocuments.Name &&
context.User.IsInRole("Administrator"))
{
context.Succeed(requirement);
}
return Task.CompletedTask;
}
}
builder.Services.AddScoped<IAuthorizationHandler, ChatInteractionDocumentAuthorizationHandler>();
Write one handler per resource type the host serves, using whatever rule decides who may use that profile, interaction, session or data source.
AddRazorComponents().AddInteractiveServerComponents(), the same AddCrestAppsCore(...) block, then UseAntiforgery() after authorization and MapRazorComponents<App>().AddInteractiveServerRenderMode(). Inject IAICompletionService, IOrchestrator or IAIClientFactory into components.app.MapGroup("/api").AddEndpointFilter<StoreCommitterEndpointFilter>() around handlers that write through a staged store. Do not add it when the store persists each write immediately.services.AddMcpServer(...).WithHttpTransport(options => options.SessionMode = HttpServerSessionMode.StatefulForInitializeClients).WithCrestAppsHandlers() (the SDK default Stateless answers GET and DELETE /mcp with 405), keep .AddMcpServer(...) on the AI suite for CrestApps prompts and resources, and map app.MapMcp("mcp"). Authentication for /mcp is host middleware; match the endpoint path exactly so admin pages under /mcp/... keep the normal sign-in. See crestapps-core-mcp.The chat scripts and styles (ai-chat.js, ai-chat-widget.js, chat-interaction.js, chat-markers.js, realtime-audio.js, ai-chat.css, chat-widget.css, and others) ship in the npm package @crestapps/ai-chat-ui. The sample hosts serve the same files from the CrestApps.AI.Resources project as /_content/CrestApps.AI.Resources/scripts/... and /styles/...; that Razor class library is not published to NuGet, so a package-based host serves the npm build from its own wwwroot.
<script> tag and expose the same globals (coreAIChatManager, CoreAIChatMarkers, CoreAIRealtime).integrity hash, as the samples do with @microsoft/[email protected].When admin-managed settings feed options (for example DefaultAIDeploymentSettings, GeneralAIOptions, PromptSecurityOptions), consume IOptionsMonitor<TOptions> and register an IOptionsChangeTokenSource<TOptions> that fires when the settings store saves. The samples do this with SiteSettingsStore and SiteSettingsOptionsChangeTokenSource<TOptions>; copy the pattern rather than the sample types.
Do not tell users to call these from a package; they live in src/Startup and must be copied or rewritten: AddSharedSampleHostDefaults(), AddSharedSiteSettings(...), AddMvcSampleHostServices(...), AddBlazorSampleHostServices(...), AddSharedAIChatProtection(), UseSharedAIChatProtection(), AddA2AHost(), MapA2AHost(), AddChatApiEndpoints(), InitializeYesSqlSchemaAsync(), SeedArticlesAsync(), and SampleHostContentRootResolver. InitializeEntityCoreSchemaAsync(), ConfigureCrestAppsChatHubOptions<THub>(), UseAIAnonymousVisitorCookie(), AddWebRtcRealtimeTransport(), MapAGUIChat<THub>() and the Add*Endpoint() document extensions are package APIs. See crestapps-core-sample-hosts.
Add*Endpoint() methods return RouteHandlerBuilder instead of the route builder; split chained calls.AntiforgeryEndpointFilterOptions.NonCookieAuthenticationTypes if it is not Bearer, Api, ApiKey or OpenIddict.Validation.AspNetCore.DefaultAIVisitorIdentityResolver uses the connection's remote address only; configure forwarded headers behind a proxy.net10.0 and net11.0; a net11.0 host gets the 11.0 builds of the Microsoft.Extensions and EF Core packages.AddSharedTemplateProviders() is gone from the samples. AIProfileSystemPromptTemplateProvider moved into CrestApps.Core.AI and AddCoreAITemplating() registers it, so a package-based host renders saved system-prompt templates without extra code.ai/documents/{documentId}/download endpoint now also authorizes AI Profile documents; register a handler for AIProfile resources if profile documents should be downloadable.UseWebSockets() before UseRouting() and ConfigureCrestAppsChatHubOptions<THub>() for every mapped chat hub when the host offers realtime voice.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
crestapps-core, aspnet-core-hosting, signalr, webrtc, chat-hubs
/crestapps-core:crestapps-core-aspnet-hostingfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job