use std::sync::Arc;
use std::time::Duration;
use chrono::{DateTime, Utc};
use serde::Deserialize;
use tokio::sync::RwLock;
use crate::channel::ChannelProvider;
use crate::config::OutputConfig;
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum ChannelKind {
Telegram,
WhatsApp,
Slack,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct ChatId {
pub channel: ChannelKind,
pub platform_id: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(untagged)]
pub enum AllowedUser {
NumericId(i64),
Handle(String),
}
pub struct InboundMessage {
pub chat_id: ChatId,
pub user_id: String,
pub text: String,
pub context: MessageContext,
}
pub struct MessageContext {
pub workspace: Arc<RwLock<WorkspaceHandle>>,
pub provider: Arc<dyn ChannelProvider>,
pub output_config: Arc<OutputConfig>,
}
#[derive(Clone)]
pub struct WorkspaceHandle {
pub name: String,
pub directory: std::path::PathBuf,
pub backend: String,
pub timeout: Option<Duration>,
}
#[derive(Debug)]
pub struct CliResponse {
pub stdout: String,
pub stderr: String,
pub exit_code: i32,
#[allow(dead_code)] pub duration: Duration,
}
#[derive(Debug, Clone)]
pub struct SessionState {
pub is_active: bool,
pub last_activity: DateTime<Utc>,
}
impl SessionState {
pub fn new() -> Self {
Self {
is_active: false,
last_activity: Utc::now(),
}
}
}
impl Default for SessionState {
fn default() -> Self {
Self::new()
}
}
pub enum ResponseChunk {
Text(String),
File { name: String, content: Vec<u8> },
}
pub struct FormattedResponse {
pub chunks: Vec<ResponseChunk>,
}