jamjet_agents/
registry.rs1use crate::card::AgentCard;
2use crate::lifecycle::AgentStatus;
3use async_trait::async_trait;
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6use uuid::Uuid;
7
8pub type AgentId = Uuid;
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Agent {
13 pub id: AgentId,
14 pub card: AgentCard,
15 pub status: AgentStatus,
16 pub registered_at: DateTime<Utc>,
17 pub updated_at: DateTime<Utc>,
18 pub last_heartbeat: Option<DateTime<Utc>>,
19}
20
21#[derive(Debug, Default)]
23pub struct AgentFilter {
24 pub skill: Option<String>,
25 pub protocol: Option<String>,
26 pub status: Option<AgentStatus>,
27}
28
29#[async_trait]
30pub trait AgentRegistry: Send + Sync {
31 async fn register(&self, card: AgentCard) -> Result<AgentId, String>;
33
34 async fn get(&self, id: AgentId) -> Result<Option<Agent>, String>;
36
37 async fn get_by_uri(&self, uri: &str) -> Result<Option<Agent>, String>;
39
40 async fn find(&self, filter: AgentFilter) -> Result<Vec<Agent>, String>;
42
43 async fn update_status(&self, id: AgentId, status: AgentStatus) -> Result<(), String>;
45
46 async fn heartbeat(&self, id: AgentId) -> Result<(), String>;
48
49 async fn discover_remote(&self, url: &str) -> Result<Agent, String>;
52}