namespace MarketAlly.AIPlugin.ClaudeCode;
///
/// Service for managing chat sessions and real-time communication
///
public interface IChatService
{
///
/// Starts a new chat session
///
/// Session start request
/// Cancellation token
/// Session information
Task> StartSessionAsync(StartSessionRequest request, CancellationToken cancellationToken = default);
///
/// Sends a message in an existing session
///
/// Session identifier
/// Message to send
/// Cancellation token
/// Claude's response
Task> SendMessageAsync(string sessionId, string message, CancellationToken cancellationToken = default);
///
/// Gets session history
///
/// Session identifier
/// Maximum messages to return
/// Cancellation token
/// Session history
Task>> GetSessionHistoryAsync(string sessionId, int maxMessages = 50, CancellationToken cancellationToken = default);
///
/// Gets all active sessions for the current user
///
/// Cancellation token
/// List of active sessions
Task>> GetActiveSessionsAsync(CancellationToken cancellationToken = default);
///
/// Ends a chat session
///
/// Session identifier
/// Cancellation token
/// Success response
Task> EndSessionAsync(string sessionId, CancellationToken cancellationToken = default);
///
/// Updates session context or settings
///
/// Session identifier
/// Context updates
/// Cancellation token
/// Updated session
Task> UpdateSessionContextAsync(string sessionId, SessionContextUpdate updates, CancellationToken cancellationToken = default);
///
/// Sets typing indicator for real-time chat
///
/// Session identifier
/// Whether user is typing
/// Cancellation token
/// Success response
Task> SetTypingIndicatorAsync(string sessionId, bool isTyping, CancellationToken cancellationToken = default);
///
/// Gets session statistics and analytics
///
/// Session identifier
/// Cancellation token
/// Session analytics
Task> GetSessionAnalyticsAsync(string sessionId, CancellationToken cancellationToken = default);
}
///
/// Start session request model
///
public class StartSessionRequest
{
public string? SessionName { get; set; }
public string? ProjectPath { get; set; }
public Dictionary? InitialContext { get; set; }
public ChatSessionSettings? Settings { get; set; }
}
///
/// Chat session model
///
public class ChatSession
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string? Name { get; set; }
public string? ProjectPath { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime LastActivity { get; set; } = DateTime.UtcNow;
public bool IsActive { get; set; } = true;
public int MessageCount { get; set; }
public Dictionary Context { get; set; } = new();
public ChatSessionSettings Settings { get; set; } = new();
public List Participants { get; set; } = new();
public SessionStatus Status { get; set; } = SessionStatus.Active;
}
///
/// Chat message model
///
public class ChatMessage
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string SessionId { get; set; } = string.Empty;
public string Role { get; set; } = string.Empty; // user, assistant, system
public string Content { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public MessageType Type { get; set; } = MessageType.Text;
public Dictionary Metadata { get; set; } = new();
public List? Attachments { get; set; }
public bool IsThinking { get; set; }
public double? ConfidenceScore { get; set; }
}
///
/// Chat session settings
///
public class ChatSessionSettings
{
public double Temperature { get; set; } = 0.7;
public int MaxTokens { get; set; } = 4096;
public bool IncludeProjectContext { get; set; } = true;
public bool IncludeConversationHistory { get; set; } = true;
public int MaxHistoryMessages { get; set; } = 20;
public string PersonalityMode { get; set; } = "helpful"; // helpful, creative, analytical, concise
public List EnabledFeatures { get; set; } = new();
public Dictionary CustomSettings { get; set; } = new();
}
///
/// Session context update model
///
public class SessionContextUpdate
{
public string? ProjectPath { get; set; }
public Dictionary? Context { get; set; }
public ChatSessionSettings? Settings { get; set; }
public string? Name { get; set; }
}
///
/// Session analytics model
///
public class SessionAnalytics
{
public string SessionId { get; set; } = string.Empty;
public int TotalMessages { get; set; }
public int UserMessages { get; set; }
public int AssistantMessages { get; set; }
public TimeSpan Duration { get; set; }
public DateTime FirstMessage { get; set; }
public DateTime LastMessage { get; set; }
public Dictionary TopicBreakdown { get; set; } = new();
public double AverageResponseTime { get; set; }
public List KeyInsights { get; set; } = new();
public int TokensUsed { get; set; }
public double EngagementScore { get; set; }
}
///
/// Message attachment model
///
public class MessageAttachment
{
public string Type { get; set; } = string.Empty; // file, image, code, link
public string Name { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public long Size { get; set; }
public string? MimeType { get; set; }
public Dictionary Metadata { get; set; } = new();
}
///
/// Message type enumeration
///
public enum MessageType
{
Text,
Code,
File,
Image,
System,
Error,
Command
}
///
/// Session status enumeration
///
public enum SessionStatus
{
Active,
Paused,
Ended,
Error
}