Files
Codewalkers/apps/server/db/repositories/chat-session-repository.ts
Lukas May fcf822363c feat: Add persistent chat sessions for iterative phase/task refinement
Introduces a chat loop where users send instructions to an agent that
applies changes (create/update/delete phases, tasks, pages) and stays
alive for follow-up messages. Includes schema + migration, repository
layer, chat prompt, file-io action field extension, output handler chat
mode, revert support for deletes, tRPC procedures, events, frontend
slide-over UI with inline changeset display and revert, and docs.
2026-03-04 10:14:28 +01:00

32 lines
1.1 KiB
TypeScript

/**
* 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[]>;
}