Skip to main content

ralph_telegram/
lib.rs

1//! # ralph-telegram
2//!
3//! Telegram integration for human-in-the-loop orchestration in Ralph.
4//!
5//! This crate provides bidirectional communication between AI agents and humans
6//! during orchestration loops via Telegram:
7//!
8//! - **AI → Human**: Agents emit `human.interact` events; the bot sends questions to Telegram
9//! - **Human → AI**: Humans reply or send proactive guidance via Telegram messages
10//!
11//! ## Key Components
12//!
13//! - [`StateManager`] — Persists chat ID, pending questions, and reply routing
14//! - [`MessageHandler`] — Processes incoming messages and writes events to JSONL
15//! - [`TelegramService`] — Lifecycle management for the bot within the event loop
16//! - [`error`] — Error types for startup, send, and receive failures
17
18mod bot;
19pub mod commands;
20pub mod daemon;
21mod error;
22mod handler;
23mod loop_lock;
24mod service;
25mod state;
26
27pub use bot::{BotApi, TelegramBot, escape_html, markdown_to_telegram_html};
28pub use daemon::TelegramDaemon;
29pub use error::{TelegramError, TelegramResult};
30pub use handler::MessageHandler;
31pub use service::{
32    BASE_RETRY_DELAY, CheckinContext, MAX_SEND_RETRIES, TelegramService, retry_with_backoff,
33};
34pub use state::{PendingQuestion, StateManager, TelegramState};