/** * Response Router Service * * Routes orchestrator responses back to the correct source. * - Web chat: no-op (existing TerminalGateway -> ChatGateway -> WebSocket pipeline handles it) * - Slack: resolves the blocking promise via the slackResolve callback * * @module services/messaging/response-router */ import type { QueuedMessage } from '../../types/messaging.types.js'; import type { ReplyStatus } from '../../types/thread-status.types.js'; import type { ThreadStatusQueueService } from './thread-status-queue.service.js'; /** * ResponseRouterService routes orchestrator responses to the appropriate * destination based on the message source. * * @example * ```typescript * const router = new ResponseRouterService(); * router.routeResponse(completedMessage, 'Here is the response'); * ``` */ export declare class ResponseRouterService { private logger; /** Thread status queue for tracking reply outcomes */ private threadStatusQueue; constructor(); /** * Set the thread status queue service for tracking reply outcomes. * * @param service - The ThreadStatusQueueService instance */ setThreadStatusQueue(service: ThreadStatusQueueService): void; /** * Determine the reply status based on orchestrator response content. * Checks for delegation markers and follow-up question patterns. * * @param response - The orchestrator's reply text * @returns The appropriate ReplyStatus for this response */ detectReplyStatus(response: string): ReplyStatus; /** * Route a response to the appropriate destination based on message source. * * @param message - The completed/failed QueuedMessage * @param response - The response content from the orchestrator */ routeResponse(message: QueuedMessage, response: string): void; /** * Route response to web chat. * This is a no-op because the existing TerminalGateway -> ChatGateway -> * WebSocket pipeline already broadcasts responses to connected clients. * * @param message - The completed QueuedMessage * @param response - The response content */ private routeToWebChat; /** * Route response to Slack by calling the slackResolve callback. * This unblocks the Slack bridge's promise that is waiting for a response. * * @param message - The completed QueuedMessage * @param response - The response content */ private routeToSlack; /** * Route response to Google Chat by calling the googleChatResolve callback. * This unblocks the promise that sends the reply back to the Chat thread. * * @param message - The completed QueuedMessage * @param response - The response content */ private routeToGoogleChat; /** * Route response to Telegram by calling the telegramResolve callback. * This unblocks the promise that sends the reply back to the Telegram chat. * * @param message - The completed QueuedMessage * @param response - The response content */ private routeToTelegram; /** * Resolve a source-specific callback stored in the message's sourceMetadata. * * Shared helper used by routeToSlack, routeToGoogleChat, and routeError * to avoid duplicating the resolve-callback pattern. * * @param message - The QueuedMessage containing the callback in sourceMetadata * @param response - The response string to pass to the callback * @param callbackKey - The key in sourceMetadata that holds the resolve function * @param label - Human-readable label for log messages (e.g. "Slack", "Google Chat") */ private resolveCallback; /** * Route an error to the appropriate destination. * * @param message - The failed QueuedMessage * @param error - The error message */ routeError(message: QueuedMessage, error: string): void; /** * Route a response back to a remote device via CloudSync. * * Cross-machine messages are fire-and-forget on the response side — * the orchestrator uses reply-remote skill for explicit replies. * This handler is mainly for logging and future auto-reply support. */ private routeToRemoteDevice; } //# sourceMappingURL=response-router.service.d.ts.map