use crate::card::AgentCard;
use crate::lifecycle::AgentStatus;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
pub type AgentId = Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Agent {
pub id: AgentId,
pub card: AgentCard,
pub status: AgentStatus,
pub registered_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub last_heartbeat: Option<DateTime<Utc>>,
}
#[derive(Debug, Default)]
pub struct AgentFilter {
pub skill: Option<String>,
pub protocol: Option<String>,
pub status: Option<AgentStatus>,
}
#[async_trait]
pub trait AgentRegistry: Send + Sync {
async fn register(&self, card: AgentCard) -> Result<AgentId, String>;
async fn get(&self, id: AgentId) -> Result<Option<Agent>, String>;
async fn get_by_uri(&self, uri: &str) -> Result<Option<Agent>, String>;
async fn find(&self, filter: AgentFilter) -> Result<Vec<Agent>, String>;
async fn update_status(&self, id: AgentId, status: AgentStatus) -> Result<(), String>;
async fn heartbeat(&self, id: AgentId) -> Result<(), String>;
async fn discover_remote(&self, url: &str) -> Result<Agent, String>;
}