import { clearChatConversationRoom, createChatConversationRoom, deleteChatConversationRequest, deleteChatConversationRoom, fetchChatConversationDetail, fetchChatConversations, fetchChatRuntimeJobDetail, fetchChatRuntimeSnapshot, markChatConversationResponsesRead, renameChatConversationRoom, updateChatConversationRoom, uploadChatComposerFile, } from '../../mainChatPanel'; import { dismissChatWebPushNotifications, markChatNotificationMessagesAsRead, } from '../../notificationApi'; import type { ChatComposerAttachment, ChatConversationDetailResponse, ChatConversationSummary, ChatRuntimeJobDetail, ChatRuntimeSnapshot, } from '../../mainChatPanel/types'; export type ChatGateway = { listConversations: () => Promise; getConversationDetail: ( sessionId: string, options?: { limit?: number; beforeMessageId?: number | null; }, ) => Promise; createConversation: (args: { sessionId: string; title: string; chatTypeId?: string | null; lastChatTypeId?: string | null; contextLabel?: string; contextDescription?: string; notifyOffline?: boolean; }) => Promise; renameConversation: (sessionId: string, title: string) => Promise; updateConversation: ( sessionId: string, payload: Partial< Pick< ChatConversationSummary, | 'title' | 'chatTypeId' | 'lastChatTypeId' | 'generalSectionName' | 'contextLabel' | 'contextDescription' | 'notifyOffline' > >, ) => Promise; clearConversation: (sessionId: string) => Promise; deleteConversation: (sessionId: string) => Promise; deleteConversationRequest: (sessionId: string, requestId: string) => Promise; markConversationRead: (sessionId: string) => Promise; fetchRuntimeSnapshot: () => Promise; fetchRuntimeJobDetail: (requestId: string) => Promise; uploadComposerFile: (sessionId: string, file: File) => Promise; dismissRoomNotifications: (sessionId: string) => Promise; markRoomNotificationMessagesRead: (sessionId: string) => Promise; }; export const chatGateway: ChatGateway = { listConversations: fetchChatConversations, getConversationDetail: fetchChatConversationDetail, createConversation: createChatConversationRoom, renameConversation: renameChatConversationRoom, updateConversation: updateChatConversationRoom, clearConversation: clearChatConversationRoom, deleteConversation: async (sessionId) => { await deleteChatConversationRoom(sessionId); }, deleteConversationRequest: async (sessionId, requestId) => { await deleteChatConversationRequest(sessionId, requestId); }, markConversationRead: async (sessionId) => { await markChatConversationResponsesRead(sessionId); }, fetchRuntimeSnapshot: fetchChatRuntimeSnapshot, fetchRuntimeJobDetail: fetchChatRuntimeJobDetail, uploadComposerFile: uploadChatComposerFile, dismissRoomNotifications: async (sessionId) => { await dismissChatWebPushNotifications(sessionId); }, markRoomNotificationMessagesRead: async (sessionId) => { await markChatNotificationMessagesAsRead(sessionId); }, };