import { notifyChatRunMilestones } from "./chat-run-milestone-notifications.js"; import { notifyChatConnectionConfiguration } from "./chat-channels/configuration-work-notifications.js"; import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js"; export async function notifyChatDeliveryWork(tx: object): Promise { await notifyDeliveryWork(tx, DELIVERY_QUEUES.chatInbound); } export async function notifyChatPublicationWork( tx: object, milestoneScope?: { companyId: string; issueId: string | null }, ): Promise { await notifyDeliveryWork(tx, DELIVERY_QUEUES.chatPublications); // Receipt recovery waits for the publication owner to release its claim. await notifyDeliveryWork(tx, DELIVERY_QUEUES.chatReceipts); // Published prompts and terminal delivery outcomes can change run lineage or // release its provider response slot. Callers supply the affected issue only // for those changes; transport claim/lease bookkeeping has no projection debt. if (milestoneScope?.issueId) { await notifyChatRunMilestones(tx, { companyId: milestoneScope.companyId, issueId: milestoneScope.issueId }); } } export const CHAT_ACTION_QUEUES = { provider_effect: DELIVERY_QUEUES.chatProviderEffects, github_webhook_ingress: DELIVERY_QUEUES.chatGitHubIngress, failed_run_retry: DELIVERY_QUEUES.chatFailedRunRetries, telegram_maintenance: DELIVERY_QUEUES.chatTelegramMaintenance, slack_session_sync: DELIVERY_QUEUES.chatSessionSyncs, slack_board_message: DELIVERY_QUEUES.chatBoardMessages, slash_task_start: DELIVERY_QUEUES.chatTaskStarts, receipt_reaction: DELIVERY_QUEUES.chatReceiptReactions, slack_session_stop: DELIVERY_QUEUES.chatSessionStops, } as const; export type ScheduledChatAction = keyof typeof CHAT_ACTION_QUEUES; export async function notifyChatActionWork(tx: object, kind: ScheduledChatAction): Promise { await notifyDeliveryWork(tx, CHAT_ACTION_QUEUES[kind]); } export async function notifyChatVerificationWork(tx: object): Promise { await notifyDeliveryWork(tx, DELIVERY_QUEUES.chatVerification); } export async function notifyChatEndpointWork(tx: object, connectionId: string, companyId: string): Promise { // Configuration/status transitions can restore post-control publication // authority. Ordinary health checks use the narrower configuration signals. await notifyChatRunMilestones(tx, { companyId }); await notifyChatDeliveryWork(tx); await notifyChatPublicationWork(tx); for (const queue of Object.values(CHAT_ACTION_QUEUES)) await notifyDeliveryWork(tx, queue); await notifyChatVerificationWork(tx); await notifyDeliveryWork(tx, DELIVERY_QUEUES.chatTelegramSubscriptions, connectionId); await notifyChatConnectionConfiguration(tx, connectionId); }