using Health.Domain.Entities; using Health.Domain.Enums; namespace Health.Application.AI; public sealed record AiConversationDto( Guid Id, string AgentType, string? Title, string? Summary, int MessageCount, DateTime CreatedAt, DateTime UpdatedAt); public sealed record AiConversationMessageDto( Guid Id, string Role, string Content, string? Intent, string? MetadataJson, DateTime CreatedAt); public sealed record OpenConversationResult( bool Found, bool Created, Guid ConversationId); public interface IAiConversationService { Task OpenAsync(Guid userId, Guid? conversationId, AgentType agentType, string firstMessage, CancellationToken ct); Task AddUserMessageAsync(Guid conversationId, string content, string? metadataJson, CancellationToken ct); Task AddAssistantMessageAsync(Guid conversationId, string content, CancellationToken ct); Task AddAssistantMessageAsync(Guid conversationId, string content, string? metadataJson, CancellationToken ct); Task> GetRecentMessagesAsync(Guid conversationId, int limit, CancellationToken ct); Task> ListAsync(Guid userId, CancellationToken ct); Task> GetMessagesAsync(Guid userId, Guid conversationId, CancellationToken ct); Task UpdateSummaryAsync(Guid conversationId, string summary, CancellationToken ct); Task DeleteAsync(Guid userId, Guid conversationId, CancellationToken ct); Task DeleteAllAsync(Guid userId, CancellationToken ct); } public interface IAiConversationRepository { Task GetOwnedAsync(Guid userId, Guid conversationId, CancellationToken ct); Task GetAsync(Guid conversationId, CancellationToken ct); Task> ListAsync(Guid userId, CancellationToken ct); Task> GetMessagesAsync(Guid conversationId, CancellationToken ct); Task> GetRecentMessagesAsync(Guid conversationId, int limit, CancellationToken ct); Task AddConversationAsync(Conversation conversation, CancellationToken ct); Task AddMessageAsync(ConversationMessage message, CancellationToken ct); Task DeleteLegacyDietCommentaryArtifactsAsync(Guid userId, string promptPrefix, CancellationToken ct); void Delete(Conversation conversation); Task SaveChangesAsync(CancellationToken ct); } public interface IPatientContextService { Task BuildAsync(Guid userId, CancellationToken ct); } public sealed record AiConfirmedWriteResult(int Code, object? Data, string? Message); public interface IAiToolExecutionService { Task ExecuteAsync(string toolName, string arguments, Guid userId, CancellationToken ct); Task ConfirmAsync(Guid commandId, Guid userId, CancellationToken ct); }