/** * Telegram Gateway for MAMA Standalone * * Production-hardened Telegram bot integration using grammY: * - Telegram message_id dedup without dropping repeated short replies * - Photo/document/caption ingestion through MAMA content blocks * - Group chat filtering (mention/command/reply-to-bot only) * - Sticker receive/send with emotion mapping * - Single-message streaming presenter (placeholder → final answer) * - Typing indicator, error handling */ import { BaseGateway } from './base-gateway.js'; import type { TurnProcessor } from './turn-contract.js'; import { type TelegramMediaDownloadRequest } from './telegram-media.js'; import type { TelegramReportDeliveryControl } from '../operator/report-delivery-coordinator.js'; /** * Telegram Gateway configuration */ export interface TelegramGatewayConfig { /** Enable Telegram gateway */ enabled: boolean; /** Telegram bot token from @BotFather */ token: string; /** Allowed chat IDs (empty = allow all) */ allowedChats?: string[]; /** Owner Telegram user IDs. Unset means owner resolution fails closed. */ ownerUserIds?: string[]; } /** * Telegram Gateway options */ export interface TelegramGatewayOptions { /** Telegram bot token */ token: string; /** Message router for processing messages */ turnProcessor: TurnProcessor; /** Gateway configuration */ config?: Partial; /** Polling interval in ms (unused with grammY, kept for interface compat) */ pollIntervalMs?: number; /** Internal test seam; production defaults to MAMA's private Telegram media directory. */ mediaRoot?: string; /** Internal test seam for the external Telegram file request. */ fetchImpl?: TelegramMediaDownloadRequest['fetchImpl']; /** Internal test/operations seam for restart-safe completed-message deduplication. */ messageLedgerPath?: string; /** Optional core-backed principal lookup; consumed by the identity overlay in Task 5. */ principalResolver?: (connector: string, namespace: string, externalId: string) => { principalId: string; kind: 'owner' | 'member'; status: string; } | null; } /** * Telegram Gateway class */ export declare class TelegramGateway extends BaseGateway { readonly source: "telegram"; readonly principalResolver: TelegramGatewayOptions['principalResolver']; private token; private config; private bot; private botId; private botUsername; private lastError; private lastMessageAt; private readonly mediaRoot; private readonly fetchImpl?; private readonly messageLedger; private readonly chatTails; private readonly activeChat; private recentMessageIds; private rejectedChatWarnAt; private dedupCleanupTimer; private stickerCache; private stickerSetLoaded; protected get mentionPattern(): RegExp | null; constructor(options: TelegramGatewayOptions); start(): Promise; stop(): Promise; private handleMessage; private runInChatQueue; private processMessage; sendMessage(chatId: string, text: string, idempotencyKey?: string): Promise; /** Detached system work must wait behind the normal per-chat delivery queue. */ sendSystemMessage(chatId: string, text: string, deliveryId?: string): Promise; /** * TG-05/TG-06: narrow owner-report delivery surface for the report * coordinator. Pins the delivery-ID-bound ledger entry before the first * send so a confirmed-send proof cannot be pruned while the report-context * SQLite row remains nonterminal, and classifies send failures with the * gateway's own definite-rejection test. */ createReportDeliveryControl(): TelegramReportDeliveryControl; sendMessageFromActiveTurn(chatId: string, text: string, idempotencyKey?: string): Promise; private sendMessageNow; sendFile(chatId: string, filePath: string, caption?: string, idempotencyKey?: string): Promise; sendFileFromActiveTurn(chatId: string, filePath: string, caption?: string, idempotencyKey?: string): Promise; sendImage(chatId: string, imagePath: string, caption?: string, idempotencyKey?: string): Promise; sendImageFromActiveTurn(chatId: string, imagePath: string, caption?: string, idempotencyKey?: string): Promise; private sendOutboundOnce; private recoverPendingInboundDeliveries; private createResponsePresenter; private outboundLedgerKey; sendSticker(chatId: string | number, emotion: string): Promise; sendStickerFromActiveTurn(chatId: string | number, emotion: string): Promise; private sendStickerNow; getLastError(): string | null; getLastMessageAt(): number | undefined; private loadStickerSet; } //# sourceMappingURL=telegram.d.ts.map