/** * Rich-message promotion for stable non-editable Telegram text sends. * * When enabled, the daemon promotes eligible finalized `sendMessage` payloads * carrying raw markdown to Bot API `sendRichMessage`. Only an explicit * `{ ok: false }` response selects the unchanged HTML path; ambiguous transport * outcomes remain single-attempt and never fall back. */ import type { BotApi } from "./telegram-daemon"; import type { ThreadedSend } from "./threaded-render"; /** * Telegram's hard per-message character ceiling (4096). Final-answer promotion * uses this value to keep oversized Markdown on the existing chunked HTML path. * `/btw` eligibility has its own 32,768-scalar route guard; only a definite * rich rejection may select the correlated HTML path. */ export declare const RICH_MESSAGE_LIMIT = 4096; /** Wrap raw markdown in the `sendRichMessage` request payload shape. */ export declare function buildRichMessage(raw: string, extras?: { reply_markup?: unknown; }): { rich_message: { markdown: string; skip_entity_detection: true; }; reply_markup?: unknown; }; /** Whether `/btw` Markdown may use Bot API 10.1 rich delivery. */ export declare function isBtwRichEligible(markdown: string): boolean; /** * Whether a granted send should be promoted to `sendRichMessage`. Fail-closed * and class-aware: every clause must hold, otherwise the daemon keeps the HTML path. */ export declare function shouldPromoteRich(input: { enabled?: boolean; send: ThreadedSend; }): boolean; /** * Deliver the promoted rich message, falling back to `fallbackDeliver` only * after an explicit `{ ok: false }` response. Transport errors and malformed or * ambiguous responses are logged but never retried or sent again through HTML. */ export declare function deliverRichWithFallback(botApi: BotApi, base: { chat_id: string | number; message_thread_id?: number; disable_notification?: true; }, send: ThreadedSend, signal: AbortSignal, fallbackDeliver: () => Promise, log?: { warn(msg: string): void; }): Promise; /** * Deliver an action-needed (ask/idle) message via `sendRichMessage`, falling * back to the unchanged HTML chunk loop only after an explicit `{ ok:false }` * response. Other outcomes are ambiguous, are logged, and preserve the single * physical rich delivery. */ export declare function deliverRichActionWithFallback(botApi: BotApi, base: { chat_id: string | number; message_thread_id?: number; disable_notification?: true; }, opts: { markdown: string; replyMarkup?: unknown; }, signal: AbortSignal, htmlFallback: () => Promise, log?: { warn(msg: string): void; }): Promise<{ messageId?: number; usedRich: boolean; usedFallback: boolean; }>;