ec78c0cdf5
Introduce Luna.Identity project with user identity service, pairing code generation, and channel linking. Channels (Telegram, CLI) now verify link status before routing messages and prompt users to pair via the web interface. WebChannel handles /link <channel-type> <code> commands to complete the pairing flow. Fix inverted expiration check in IsPairingCodeExpired that caused codes to be treated as expired immediately after creation.
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Luna.Shared;
|
|
|
|
namespace Luna.Channels.Abstractions;
|
|
|
|
public delegate Task ChannelMessageReceivedEventHandler(object? sender, ChannelMessageReceivedEventArgs args);
|
|
public delegate Task ChannelConnectionChangedEventHandler(object? sender, ChannelConnectionEventArgs args);
|
|
|
|
/// <summary>
|
|
/// Represents a communication channel for the Luna AI Assistant.
|
|
/// Channels handle sending and receiving messages via different platforms
|
|
/// (e.g., CLI, Telegram, Discord, Email).
|
|
/// </summary>
|
|
public interface IChannel : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Unique identifier for this channel instance
|
|
/// </summary>
|
|
string ChannelId { get; }
|
|
|
|
/// <summary>
|
|
/// Type of channel (e.g., "cli", "telegram", "discord")
|
|
/// </summary>
|
|
string ChannelType { get; }
|
|
|
|
/// <summary>
|
|
/// Display name for the channel
|
|
/// </summary>
|
|
string DisplayName { get; }
|
|
|
|
/// <summary>
|
|
/// Indicates whether the channel is currently connected and ready
|
|
/// </summary>
|
|
bool IsConnected { get; }
|
|
|
|
/// <summary>
|
|
/// Event raised when a message is received from the channel
|
|
/// </summary>
|
|
event ChannelMessageReceivedEventHandler? MessageReceived;
|
|
|
|
/// <summary>
|
|
/// Event raised when the channel connection state changes
|
|
/// </summary>
|
|
event ChannelConnectionChangedEventHandler? ConnectionStateChanged;
|
|
|
|
Task<bool> VerifyChannelLinkAsync();
|
|
|
|
/// <summary>
|
|
/// Send a message to the channel
|
|
/// </summary>
|
|
/// <param name="message">The message to send</param>
|
|
/// <param name="cancellationToken">Cancellation token</param>
|
|
/// <returns>Task representing the send operation</returns>
|
|
Task SendMessageAsync(ChannelMessage message, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Send a streaming response to the channel
|
|
/// </summary>
|
|
/// <param name="messageStream">Async enumerable of response updates</param>
|
|
/// <param name="cancellationToken">Cancellation token</param>
|
|
/// <returns>Task representing the send operation</returns>
|
|
Task SendStreamingMessageAsync(IAsyncEnumerable<ChatStreamUpdate> messageStream, CancellationToken cancellationToken = default);
|
|
} |