Skip to main content

zeph_channels/
lib.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Channel implementations for the Zeph agent.
5//!
6//! This crate provides the concrete `Channel` implementations used by the
7//! Zeph agent loop.  Every implementation wraps a transport-specific I/O
8//! mechanism and exposes a uniform async interface that the agent core uses
9//! without knowing the underlying delivery medium.
10//!
11//! # Available channels
12//!
13//! | Type | Feature | Transport |
14//! |------|---------|-----------|
15//! | [`CliChannel`] | always | stdin / stdout |
16//! | [`telegram::TelegramChannel`] | always | Telegram Bot API via teloxide |
17//! | `DiscordChannel` | `discord` | Discord gateway |
18//! | `SlackChannel` | `slack` | Slack Events API |
19//!
20//! # Runtime dispatch
21//!
22//! [`AnyChannel`] is an enum that implements `Channel` by delegating to the
23//! active variant.  The binary selects the variant at startup and passes
24//! `AnyChannel` throughout; the agent core never needs to be generic over the
25//! channel type.
26//!
27//! # Shared timeouts
28//!
29//! [`CONFIRM_TIMEOUT`] and [`ELICITATION_TIMEOUT`] define the deny-on-timeout
30//! durations that all remote channel adapters must honour for interactive
31//! dialogs.  They are intentionally centralised here so that the behaviour is
32//! consistent across Telegram, Discord, and Slack.
33
34mod any;
35pub mod cli;
36#[cfg(feature = "discord")]
37pub mod discord;
38pub mod json_cli;
39mod line_editor;
40pub mod markdown;
41#[cfg(feature = "slack")]
42pub mod slack;
43pub mod telegram;
44
45pub use any::AnyChannel;
46pub use cli::CliChannel;
47pub use json_cli::JsonCliChannel;
48
49/// Shared timeout for interactive confirmation dialogs across all remote channels.
50///
51/// Used by Telegram, Discord, and Slack [`Channel::confirm`] implementations to
52/// ensure consistent deny-on-timeout behaviour.  When the timeout expires the
53/// implementation must return `Ok(false)` (deny), not an error.
54///
55/// [`Channel::confirm`]: zeph_core::channel::Channel::confirm
56pub const CONFIRM_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
57
58/// Per-field timeout for interactive elicitation dialogs on remote channels.
59///
60/// Used by Telegram, Discord, and Slack [`Channel::elicit`] implementations.
61/// Each individual field in the elicitation request resets the timer.  When the
62/// timeout expires the implementation must return
63/// [`ElicitationResponse::Cancelled`].
64///
65/// [`Channel::elicit`]: zeph_core::channel::Channel::elicit
66/// [`ElicitationResponse::Cancelled`]: zeph_core::channel::ElicitationResponse::Cancelled
67pub const ELICITATION_TIMEOUT: std::time::Duration = std::time::Duration::from_mins(2);