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.
32 lines
1.1 KiB
TypeScript
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[]>;
|
|
}
|