/** * Conversation Repository Port Interface * * Port for inter-agent conversation persistence operations. */ import type { Conversation } from '../schema.js'; export interface CreateConversationData { fromAgentId: string; toAgentId: string; initiativeId?: string | null; phaseId?: string | null; taskId?: string | null; question: string; } export interface ConversationRepository { create(data: CreateConversationData): Promise; findById(id: string): Promise; findPendingForAgent(toAgentId: string): Promise; answer(id: string, answer: string): Promise; /** * Count conversations grouped by fromAgentId for a batch of agent IDs. * Returns only agents that have at least one conversation (count > 0). * Used by listForRadar to compute messagesCount without N+1 queries. */ countByFromAgentIds(agentIds: string[]): Promise<{ agentId: string; count: number }[]>; /** * Find all conversations initiated by a given agent, ordered by createdAt ascending. * Used by conversation.getByFromAgent drilldown procedure. * Cap at 200 results. */ findByFromAgentId(agentId: string): Promise; }