import type { JsonEnvFieldSpec, RedactedSecretValue, SettingsJson } from "@mono-agent/agent-contracts"; import type { TelegramTranscriptionConfig } from "./transcription.js"; export type TelegramGroupTriggerMode = "any" | "mention"; /** * A daily window during which proactive notifications (cron/webhook deliveries) * are posted silently (`disable_notification`). `start`/`end` are 24-hour `HH:MM` * clock times interpreted in `timezone` (an IANA zone); a window where `end` is * earlier than `start` wraps midnight (e.g. `22:00`–`07:00`). */ export interface TelegramQuietHours { readonly start: string; readonly end: string; readonly timezone: string; } /** * A custom bot command surfaced in Telegram's command menu (`setMyCommands`). * `command` is the bare name (no leading slash) of 1–32 lowercase letters, * digits, or underscores. When `prompt` is set, invoking the command runs that * prompt as a turn; a command with no `prompt` is a menu-only entry. */ export interface TelegramCommandConfig { readonly command: string; readonly description: string; readonly prompt?: string; } /** * Which lifecycle reactions are enabled. Resolved from `telegram.reactions`: * `true` enables all three; an object enables them individually (each key * defaults to `true`, so `{ done: false }` keeps πŸ‘€/πŸ‘Ž but drops πŸ‘). Resolves to * `undefined` when reactions are off entirely. */ export interface TelegramReactionsConfig { readonly working: boolean; readonly done: boolean; readonly error: boolean; } /** Attachment sizing knobs; names mirror the adapter's DownloadTelegramAttachmentsOptions. */ export interface TelegramAttachmentsConfig { /** Inbound download cap (bytes). Omit for the adapter default (20 MiB β€” the hosted API's hard limit). */ readonly maxBytes?: number; /** Per-file download timeout (ms) on the URL branch. Omit for the adapter default (30s). */ readonly downloadTimeoutMs?: number; /** Upload cap (bytes) for the TelegramSendFile tool. Omit for 20 MiB. */ readonly maxUploadBytes?: number; } /** Optional request-bound restrictions for app-owned Telegram send tools. */ export interface TelegramSendToolsConfig { readonly scope?: "producing-conversation"; readonly pathScope?: "run-output"; } export interface TelegramAdapterConfig { readonly enabled: boolean; readonly botToken: string; readonly allowedChatIds: readonly string[]; readonly allowAllChats: boolean; /** Group-message trigger rule. Omit for backward-compatible `any`. */ readonly groupMode?: TelegramGroupTriggerMode; /** Remove the bot's native @mention from responder text. Defaults to true. */ readonly stripMentionText?: boolean; /** * Base URL of a self-hosted Bot API server (e.g. `http://127.0.0.1:8081`). * Omit for the hosted `https://api.telegram.org`. A `--local` server returns * absolute file paths from getFile, which the adapter reads from disk. */ readonly apiRoot?: string; /** Attachment sizing (raise the 20 MiB defaults when running a self-hosted server). */ readonly attachments?: TelegramAttachmentsConfig; /** Pin the Bot API HTTP client to IPv4 (`4`) or IPv6 (`6`). Omit for dual-stack. */ readonly ipFamily?: 4 | 6; /** Poll-liveness watchdog window (ms). Omit to use the adapter default (120000). */ readonly pollWatchdogMs?: number; /** Window during which proactive notifications are delivered silently. Omit to always notify. */ readonly quietHours?: TelegramQuietHours; /** Custom command-menu entries. Omit (or empty) to leave only the built-in commands. */ readonly commands?: readonly TelegramCommandConfig[]; /** Per-state lifecycle reactions (πŸ‘€/πŸ‘/πŸ‘Ž). Omit (or all-off) to disable reactions. */ readonly reactions?: TelegramReactionsConfig; /** * Optional speech-to-text for inbound audio (voice / audio / video_note): the * full URL of an OpenAI-compatible `/v1/audio/transcriptions` route plus a * required model. Omit to leave audio as an on-disk file only. Not a secret. */ readonly transcription?: TelegramTranscriptionConfig; readonly sendTools?: TelegramSendToolsConfig; } export interface RedactedTelegramAdapterConfig { readonly enabled: boolean; readonly botToken: RedactedSecretValue; readonly allowedChatIds: { readonly count: number; }; readonly allowAllChats: boolean; readonly groupMode: TelegramGroupTriggerMode; readonly stripMentionText: boolean; readonly apiRoot?: string; readonly attachments?: TelegramAttachmentsConfig; readonly ipFamily?: 4 | 6; readonly pollWatchdogMs?: number; readonly quietHours?: TelegramQuietHours; readonly commands?: { readonly count: number; }; readonly reactions?: TelegramReactionsConfig; readonly transcription?: TelegramTranscriptionConfig; readonly sendTools?: TelegramSendToolsConfig; } export type TelegramAdapterConfigErrorCode = "missing_required_config" | "invalid_config"; export interface TelegramAdapterConfigErrorDetails { readonly code?: TelegramAdapterConfigErrorCode; readonly env?: string; readonly reason?: string; readonly [key: string]: unknown; } export declare class TelegramAdapterConfigError extends Error { readonly code: TelegramAdapterConfigErrorCode; readonly details: TelegramAdapterConfigErrorDetails; constructor(code: TelegramAdapterConfigErrorCode, message: string, details?: TelegramAdapterConfigErrorDetails); } export interface LoadTelegramAdapterConfigInput { readonly env: Record; readonly json?: SettingsJson; readonly jsonPath?: string; } export declare function loadTelegramAdapterConfig(input: LoadTelegramAdapterConfigInput): Promise; /** * True when `now` falls inside the configured quiet-hours window. Same-day * windows (`start < end`) are a simple range; an `end <= start` window wraps * midnight. A degenerate `start === end` window is never active (always notify). */ export declare function isWithinQuietHours(now: Date, quietHours: TelegramQuietHours): boolean; export declare function redactTelegramAdapterConfig(config: TelegramAdapterConfig): RedactedTelegramAdapterConfig; /** * The `telegram` section's field registry: the single source of truth both the * JSONβ†’env layering below and the app's config provenance view derive from. * Covers every env-mappable field (JSON-only structures like `commands`, * `quietHours`, and object-form `reactions` are read straight from JSON). */ export declare const TELEGRAM_CONFIG_FIELDS: readonly JsonEnvFieldSpec[]; //# sourceMappingURL=config.d.ts.map