Implements CrestApps chat response handlers in Orchard Core 3.0, covering IChatResponseHandler, streaming/deferred results, external relay contracts, and handler registration.
Ships in crestapps-orchardcore. 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.
IChatResponseHandler is a shared CrestApps.Core contract used by Orchard chat
sessions and chat interactions. A handler either returns response updates now or
defers the assistant response until an external system supplies it.
using CrestApps.Core.AI.ResponseHandling;
namespace MyCompany.OrchardCore.Chat;
public sealed class LiveAgentResponseHandler : IChatResponseHandler
{
public string Name => "LiveAgent";
public async Task<ChatResponseHandlerResult> HandleAsync(
ChatResponseHandlerContext context,
CancellationToken cancellationToken = default)
{
await SendToAgentSystemAsync(context.Prompt, cancellationToken);
return ChatResponseHandlerResult.Deferred();
}
private static Task SendToAgentSystemAsync(
string prompt,
CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
Register a custom handler as an enumerable scoped service:
using CrestApps.Core.AI.ResponseHandling;
using Microsoft.Extensions.DependencyInjection;
services.TryAddEnumerable(
ServiceDescriptor.Scoped<IChatResponseHandler, LiveAgentResponseHandler>());
The active handler is selected by IChatResponseHandlerResolver.Resolve(handlerName, chatMode) from
AIChatSession.ResponseHandlerName or ChatInteraction.ResponseHandlerName. An empty or unknown name
falls back to the built-in AI handler (ChatResponseHandlerNames.AI, "AI"), and so does every request in
ChatMode.Conversation: spoken conversations always run through the AI handler, and a custom name is
logged and ignored.
ChatResponseHandlerContext gives the handler Prompt, ConnectionId, SessionId, ChatType,
ConversationHistory, Services, and the Profile, ChatSession or Interaction it serves. A handler can
set AssistantAppearance (Label, Icon, CssClass, DisableStreamingAnimation) to change how its
replies are labelled in the chat UI, for example to show a live agent's name.
A profile can route new chat sessions to a handler from the first message. The setting is stored on
profile.Settings as ResponseHandlerProfileSettings.InitialResponseHandlerName and edited as
Initial response handler on the profile's General card (registered by the AI Chat Services
feature, CrestApps.OrchardCore.AI.Chat.Core, and useful only once a non-AI handler is registered).
{
"steps": [
{
"name": "AIProfile",
"Profiles": [
{
"Name": "live-support",
"DisplayText": "Live Support",
"Type": "Chat",
"Settings": {
"ResponseHandlerProfileSettings": { "InitialResponseHandlerName": "LiveAgent" }
}
}
]
}
]
}
Profile templates carry the same value as ProfileTemplateMetadata.InitialResponseHandlerName. A tool or
an external event can switch an active session later by updating the session's or interaction's
ResponseHandlerName.
Use Deferred() only when the handler has handed work to an external process
that will deliver the reply later. The hub persists the user prompt and does
not wait for an assistant response.
For immediate output, return an async sequence of ChatResponseUpdate values:
using CrestApps.Core.AI.ResponseHandling;
using Microsoft.Extensions.AI;
return ChatResponseHandlerResult.Streaming(StreamUpdatesAsync(cancellationToken));
static async IAsyncEnumerable<ChatResponseUpdate> StreamUpdatesAsync(
[System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
{
yield return new ChatResponseUpdate(ChatRole.Assistant, "Connecting you to an agent.");
await Task.CompletedTask;
}
The factory is ChatResponseHandlerResult.Streaming(...), not Stream(...).
Use a deferred handler only with an authenticated, idempotent callback or relay
strategy; a successful handoff does not make an arbitrary anonymous webhook
safe.
IChatNotificationSender sends UI-only notifications to the appropriate
SignalR clients. A notification is identified by its required Type; there is
no ChatNotification.Id property.
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Models;
await notifications.SendAsync(
sessionId,
ChatContextType.AIChatSession,
new ChatNotification(ChatNotificationTypes.Transfer)
{
Content = "Transferring you to a live agent.",
Icon = "fa-solid fa-headset",
Dismissible = true,
});
await notifications.RemoveAsync(
sessionId,
ChatContextType.AIChatSession,
ChatNotificationTypes.Transfer);
SendAsync replaces an active notification with the same type.
UpdateAsync updates only an existing matching type, and RemoveAsync accepts
the notification type string. Use ChatNotificationTypes and
ChatNotificationActionNames for built-in values. Register a custom action
handler as a keyed IChatNotificationActionHandler.
For persistent WebSocket, SSE, gRPC, or queue-based handoff, implement
IExternalChatRelay. It is protocol agnostic, but its signatures are fixed:
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Models;
namespace MyCompany.OrchardCore.Chat;
public sealed class LiveAgentRelay : IExternalChatRelay
{
public Task<bool> IsConnectedAsync(CancellationToken cancellationToken = default)
=> Task.FromResult(true);
public Task ConnectAsync(
ExternalChatRelayContext context,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public Task SendPromptAsync(string text, CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public Task SendSignalAsync(
string signalName,
IDictionary<string, string> data = null,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public Task DisconnectAsync(CancellationToken cancellationToken = default)
=> Task.CompletedTask;
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
}
The singleton IExternalChatRelayManager owns connection lifetime. Create or
reuse a relay with:
var relay = await relayManager.GetOrCreateAsync(
context.SessionId,
new ExternalChatRelayContext
{
SessionId = context.SessionId,
ChatType = context.ChatType,
},
() => new LiveAgentRelay(),
cancellationToken);
await relay.SendPromptAsync(context.Prompt, cancellationToken);
The relay event callback is also identifier-based, not context-based:
await relayEventHandler.HandleEventAsync(
sessionId,
ChatContextType.AIChatSession,
relayEvent,
cancellationToken);
Register keyed IExternalChatRelayNotificationBuilder services for custom
event types. The default event handler selects the builder by
ExternalChatRelayEvent.EventType.
When an AI tool changes the response-handler selection, implement a real
AITool and register it with the current Core API:
services.AddCoreAITool<TransferToLiveAgentTool>("transfer_to_live_agent");
Do not use the removed AddAITool registration name. Keep the tool's
authorization, input validation, and response-handler mutation in the same
tenant scope as the session or interaction being changed.
ChatResponseHandlerResult.Streaming updates ordered and cancellation
aware.IExternalChatRelayManager.CloseAsync when a session
ends; it disconnects and disposes the registered relay.crestapps-core-response-handlers for the underlying CrestApps.Core IChatResponseHandler contract outside Orchard Core.crestapps-core-external-relays for the underlying CrestApps.Core IExternalChatRelay and relay-manager contracts.orchardcore-ai-tools for Orchard-aware tool registration, selection,
and authorization.orchardcore-ai-workflows for AI completion workflow activities.orchardcore-ai-chat-interactions for the interaction UI and its
capability configuration.orchardcore-ai-chat-notifications for the notification UI and action handlers.orchardcore-ai-realtime-voice for spoken conversations, which always use the AI handler.What SKILL.md sets; muted values are Claude Code's defaults
137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts./crestapps-orchardcore:orchardcore-ai-response-handlersfrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcoreOther plugins' skills for the same job