use crate::knowledge::Knowledge;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::Mutex;
pub struct AppState {
pub openai_api_key: String,
pub model: String,
pub system_prompt: String,
pub knowledge_base: Arc<Knowledge>,
pub pack_jobs: Mutex<HashMap<String, PackJob>>,
pub wizard_jobs: Mutex<HashMap<String, WizardJob>>,
}
#[derive(Debug, Clone)]
pub struct PackJob {
pub lines: Vec<PackLogLine>,
pub progress: u8,
pub step: String,
pub status: PackJobStatus,
pub pack_path: Option<String>,
pub workspace_path: Option<String>,
pub download_url: Option<String>,
pub filename: Option<String>,
pub error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PackJobStatus {
Running,
Done,
Failed,
}
impl PackJobStatus {
pub fn as_str(&self) -> &'static str {
match self {
Self::Running => "running",
Self::Done => "done",
Self::Failed => "failed",
}
}
}
#[derive(Debug, Clone)]
pub struct PackLogLine {
pub text: String,
pub kind: LogKind,
}
#[derive(Debug, Clone)]
pub enum LogKind {
Info,
Progress,
Warning,
Error,
Done,
}
impl LogKind {
pub fn as_str(&self) -> &'static str {
match self {
Self::Info => "info",
Self::Progress => "progress",
Self::Warning => "warning",
Self::Error => "error",
Self::Done => "done",
}
}
}
#[derive(Debug, Clone)]
pub struct WizardJob {
pub mode: WizardMode,
pub lines: Vec<PackLogLine>,
pub progress: u8,
pub step: String,
pub status: WizardJobStatus,
pub download_url: Option<String>,
pub filename: Option<String>,
pub deploy_url: Option<String>,
pub error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WizardMode {
Deploy,
Develop,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WizardJobStatus {
Building,
Deploying,
Done,
Failed,
}
impl WizardJobStatus {
pub fn as_str(&self) -> &'static str {
match self {
Self::Building => "building",
Self::Deploying => "deploying",
Self::Done => "done",
Self::Failed => "failed",
}
}
}