use std::path::PathBuf;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct OpenclawCredentialCleanupSummary {
pub dot_env_entries_removed: usize,
pub auth_profile_files_updated: usize,
pub auth_profile_entries_removed: usize,
pub oauth_entries_removed: usize,
pub backup_files_created: usize,
}
impl OpenclawCredentialCleanupSummary {
pub fn has_changes(&self) -> bool {
self.dot_env_entries_removed > 0
|| self.auth_profile_files_updated > 0
|| self.auth_profile_entries_removed > 0
|| self.oauth_entries_removed > 0
|| self.backup_files_created > 0
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct OpenclawCredentialCleanupPreview {
pub state_dir: PathBuf,
pub state_dir_exists: bool,
pub dot_env: Option<OpenclawFileRemovalPreview>,
pub auth_profiles: Vec<OpenclawFileRemovalPreview>,
pub oauth: Option<OpenclawFileRemovalPreview>,
}
impl OpenclawCredentialCleanupPreview {
pub fn has_changes(&self) -> bool {
self.dot_env.is_some() || !self.auth_profiles.is_empty() || self.oauth.is_some()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OpenclawFileRemovalPreview {
pub path: PathBuf,
pub backup_path: PathBuf,
pub removals: Vec<String>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub enum OnboardAuthMethod {
#[default]
StaticKey,
OAuth {
provider_id: String,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OnboardTarget {
Openclaw {
config_path: PathBuf,
},
Hermes,
}
impl OnboardTarget {
pub fn as_str(&self) -> &'static str {
match self {
OnboardTarget::Openclaw { .. } => "openclaw",
OnboardTarget::Hermes => "hermes",
}
}
}
#[derive(Debug, Clone)]
pub struct OnboardConfig {
pub provider: String,
pub model: String,
pub auth_method: OnboardAuthMethod,
pub real_api_key: String,
pub virtual_api_key: String,
pub target: OnboardTarget,
pub server_host: String,
pub server_port: u16,
pub email: Option<OnboardEmailConfig>,
}
#[derive(Debug, Clone)]
pub struct OnboardEmailConfig {
pub mode: OnboardEmailMode,
pub sender_rules: Vec<String>,
pub account_virtual_key: String,
pub email: String,
pub app_password: String,
pub imap_host: String,
pub imap_port: u16,
}
#[derive(Debug, Clone)]
pub struct OnboardSkillFile {
pub relative_path: &'static str,
pub content: String,
}
#[derive(Debug, Clone)]
pub struct OnboardSkillBundle {
pub name: &'static str,
pub files: Vec<OnboardSkillFile>,
}
pub const EMAIL_MESSAGES_SKILL_NAME: &str = "get-email-messages";
pub const ADMIN_STATS_SKILL_NAME: &str = "get-clawshell-stats";
pub const STATS_CRON_JOB_NAME: &str = "clawshell-weekly-stats";
pub const STATS_CRON_PROMPT: &str = "\
Use the get-clawshell-stats skill to fetch ClawShell runtime statistics \
from the /admin/stats endpoint, then present a short summary: total \
requests served, token usage (prompt, completion, total), and \
email-filter activity (total filtered count plus the top filtered \
senders). If the endpoint returns an error or is unreachable, report \
that instead.";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OnboardEmailMode {
Allowlist,
Denylist,
}
impl OnboardEmailMode {
pub(crate) fn as_toml_value(self) -> &'static str {
match self {
OnboardEmailMode::Allowlist => "allowlist",
OnboardEmailMode::Denylist => "denylist",
}
}
}