/**
 * Chat Session Repository Port Interface
 *
 * Port for chat session and message persistence operations.
 */

import type { ChatSession, ChatMessage } from '../schema.js';

export interface CreateChatSessionData {
  targetType: 'phase' | 'task';
  targetId: string;
  initiativeId: string;
  agentId?: string | null;
}

export interface CreateChatMessageData {
  chatSessionId: string;
  role: 'user' | 'assistant' | 'system';
  content: string;
  changeSetId?: string | null;
}

export interface ChatSessionRepository {
  createSession(data: CreateChatSessionData): Promise<ChatSession>;
  findSessionById(id: string): Promise<ChatSession | null>;
  findActiveSession(targetType: 'phase' | 'task', targetId: string): Promise<ChatSession | null>;
  findActiveSessionByAgentId(agentId: string): Promise<ChatSession | null>;
  updateSession(id: string, data: { agentId?: string | null; status?: 'active' | 'closed' }): Promise<ChatSession>;
  createMessage(data: CreateChatMessageData): Promise<ChatMessage>;
  findMessagesBySessionId(sessionId: string): Promise<ChatMessage[]>;
}
