/** * Telegram ingress channel — drive Franklin from a Telegram chat. * * Why this exists: a persistent agent with a wallet is most useful when the * owner can reach it from anywhere, not just the laptop it runs on. This * module wraps Franklin's `interactiveSession` with a Telegram long-polling * loop: inbound text → agent turn → streamed text deltas delivered to the * originating chat, chunked to stay under Telegram's 4096-char limit. * * Security: hard owner lock. Only the Telegram user id listed in * `TELEGRAM_OWNER_ID` can talk to the bot. Anyone else gets a polite refusal * and their message is dropped — the agent's wallet is real money. * * Transport: long polling (`getUpdates` with `timeout=25`), not webhook. * Works behind NAT and through laptop sleep/wake without needing a public * HTTPS endpoint. `node fetch` is the only HTTP dep. */ import type { AgentConfig } from '../agent/types.js'; export interface TelegramOptions { /** Bot token from @BotFather. */ token: string; /** Numeric Telegram user id that's allowed to drive the bot. Required. */ ownerId: number; /** Extra numeric user ids allowed to drive the bot (e.g. other people in a * group). The owner is always allowed; this widens access without dropping * the lock. Empty/undefined → owner-only (original behaviour). */ allowedUsers?: Set; /** Called with each user-facing log line so the CLI can print them. */ log?: (line: string) => void; } /** * Split a long agent response into Telegram-sized chunks. Prefers newline * boundaries, falls back to hard character split for pathological inputs * (e.g. 10 KB of no-newline JSON). Short responses return a single chunk. */ export declare function splitForTelegram(text: string, max?: number): string[]; /** * Progressive flush: given a growing buffer, return `{flush, keep}` where * `flush` is ready-to-send text ending at a paragraph boundary and `keep` is * the trailing partial to hold until more arrives. Returns `{flush: '', * keep: buffer}` if the buffer isn't big enough or has no boundary yet. */ export declare function takeProgressiveChunk(buffer: string, threshold?: number, hardCap?: number): { flush: string; keep: string; }; /** * Start the bot. Resolves only on fatal error; the outer CLI handles SIGINT. */ export declare function runTelegramBot(agentConfig: AgentConfig, opts: TelegramOptions): Promise;