Skip to content

Commit 1d642fa

Browse files
authored
Add protocol-agnostic external chat relay infrastructure for real-time 3rd party communication (#383)
1 parent b955601 commit 1d642fa

File tree

55 files changed

+2678
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2678
-850
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace CrestApps.OrchardCore.AI;
2+
3+
/// <summary>
4+
/// Well-known notification action names used by built-in action handlers.
5+
/// </summary>
6+
public static class ChatNotificationActionNames
7+
{
8+
public const string CancelTransfer = "cancel-transfer";
9+
public const string EndSession = "end-session";
10+
}

src/Abstractions/CrestApps.OrchardCore.AI.Abstractions/ChatNotificationSenderExtensions.cs

Lines changed: 0 additions & 266 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace CrestApps.OrchardCore.AI;
2+
3+
/// <summary>
4+
/// Well-known notification types used by built-in chat notifications. Each type serves as
5+
/// both the unique identifier and the CSS styling class for the notification.
6+
/// </summary>
7+
public static class ChatNotificationTypes
8+
{
9+
public const string Typing = "typing";
10+
public const string Transfer = "transfer";
11+
public const string AgentConnected = "agent-connected";
12+
public const string AgentReconnecting = "agent-reconnecting";
13+
public const string ConnectionLost = "connection-lost";
14+
public const string ConversationEnded = "conversation-ended";
15+
public const string SessionEnded = "session-ended";
16+
}

src/Abstractions/CrestApps.OrchardCore.AI.Abstractions/IChatNotificationActionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace CrestApps.OrchardCore.AI;
44

55
/// <summary>
6-
/// Handles user-initiated actions on chat notification bubbles.
6+
/// Handles user-initiated actions on chat system messages.
77
/// When a user clicks an action button on a notification (e.g., "Cancel Transfer"),
88
/// the hub resolves a keyed service whose key matches the action name.
99
/// Register implementations using <c>services.AddKeyedScoped&lt;IChatNotificationActionHandler, YourHandler&gt;("your-action-name")</c>.

src/Abstractions/CrestApps.OrchardCore.AI.Abstractions/IChatNotificationSender.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace CrestApps.OrchardCore.AI;
44

55
/// <summary>
66
/// Sends transient UI notifications to chat clients via SignalR.
7-
/// Notifications appear as visual bubbles in the chat interface and are separate
7+
/// Notifications appear as system messages in the chat interface and are separate
88
/// from chat history. Use this service from webhooks, background tasks, or response
99
/// handlers to provide real-time feedback to users.
1010
/// </summary>
@@ -17,7 +17,7 @@ public interface IChatNotificationSender
1717
{
1818
/// <summary>
1919
/// Sends a notification to all clients connected to the specified session.
20-
/// If a notification with the same <see cref="ChatNotification.Id"/> already exists
20+
/// If a notification with the same <see cref="ChatNotification.Type"/> already exists
2121
/// on the client, it will be replaced.
2222
/// </summary>
2323
/// <param name="sessionId">The session or interaction identifier.</param>
@@ -27,7 +27,7 @@ public interface IChatNotificationSender
2727

2828
/// <summary>
2929
/// Updates an existing notification on all connected clients.
30-
/// Only replaces the notification if one with a matching <see cref="ChatNotification.Id"/> exists.
30+
/// Only replaces the notification if one with a matching <see cref="ChatNotification.Type"/> exists.
3131
/// </summary>
3232
/// <param name="sessionId">The session or interaction identifier.</param>
3333
/// <param name="chatType">The type of chat context.</param>
@@ -39,6 +39,6 @@ public interface IChatNotificationSender
3939
/// </summary>
4040
/// <param name="sessionId">The session or interaction identifier.</param>
4141
/// <param name="chatType">The type of chat context.</param>
42-
/// <param name="notificationId">The identifier of the notification to remove.</param>
43-
Task RemoveAsync(string sessionId, ChatContextType chatType, string notificationId);
42+
/// <param name="notificationType">The type of the notification to remove.</param>
43+
Task RemoveAsync(string sessionId, ChatContextType chatType, string notificationType);
4444
}

src/Abstractions/CrestApps.OrchardCore.AI.Abstractions/IChatNotificationTransport.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace CrestApps.OrchardCore.AI;
1111
/// </summary>
1212
/// <remarks>
1313
/// <para>
14-
/// Each hub that supports notification bubbles should provide its own implementation
14+
/// Each hub that supports notification system messages should provide its own implementation
1515
/// and register it as a keyed service:
1616
/// </para>
1717
/// <code>
@@ -22,7 +22,7 @@ public interface IChatNotificationTransport
2222
{
2323
/// <summary>
2424
/// Sends a notification to all clients in the session group. If a notification
25-
/// with the same <see cref="ChatNotification.Id"/> already exists on the client,
25+
/// with the same <see cref="ChatNotification.Type"/> already exists on the client,
2626
/// it is replaced.
2727
/// </summary>
2828
/// <param name="sessionId">The session or interaction identifier.</param>
@@ -31,7 +31,7 @@ public interface IChatNotificationTransport
3131

3232
/// <summary>
3333
/// Updates an existing notification on all connected clients in the session group.
34-
/// Only replaces the notification if one with a matching <see cref="ChatNotification.Id"/> exists.
34+
/// Only replaces the notification if one with a matching <see cref="ChatNotification.Type"/> exists.
3535
/// </summary>
3636
/// <param name="sessionId">The session or interaction identifier.</param>
3737
/// <param name="notification">The updated notification.</param>
@@ -41,6 +41,6 @@ public interface IChatNotificationTransport
4141
/// Removes a notification from all connected clients in the session group.
4242
/// </summary>
4343
/// <param name="sessionId">The session or interaction identifier.</param>
44-
/// <param name="notificationId">The identifier of the notification to remove.</param>
45-
Task RemoveNotificationAsync(string sessionId, string notificationId);
44+
/// <param name="notificationType">The type of the notification to remove.</param>
45+
Task RemoveNotificationAsync(string sessionId, string notificationType);
4646
}

0 commit comments

Comments
 (0)