use uuid::Uuid;
#[derive(Debug, Clone)]
pub struct SessionContext {
pub session_id: Uuid,
pub agent_id: Uuid,
pub token: String,
pub role: String,
pub scopes: Vec<String>,
pub task_type: String,
pub expires_at: i64,
}
impl SessionContext {
pub fn system() -> Self {
Self {
session_id: Uuid::nil(),
agent_id: Uuid::nil(),
token: "system".to_string(),
role: "system".to_string(),
scopes: vec!["*".to_string()],
task_type: "system".to_string(),
expires_at: i64::MAX,
}
}
pub fn is_valid(&self) -> bool {
let now = chrono::Utc::now().timestamp();
self.expires_at > now
}
pub fn has_scope(&self, scope: &str) -> bool {
self.scopes.iter().any(|s| s == "*" || s == scope)
}
}