Skip to main content

claw10_domain/
model.rs

1use serde::{Deserialize, Serialize};
2
3use crate::agent::AgentId;
4use crate::identity::IdentityId;
5use crate::mission::MissionId;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ModelProfile {
9    pub id: String,
10    pub provider: String,
11    pub model_name: String,
12    pub context_window: u32,
13    pub max_output_tokens: u32,
14    pub cost_per_1k_input: f64,
15    pub cost_per_1k_output: f64,
16    pub suitable_for: Vec<String>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct ModelProvider {
21    pub id: String,
22    pub name: String,
23    pub base_url: String,
24    pub api_key_ref: String,
25    pub is_active: bool,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct RiskLevel(pub String);
30
31impl RiskLevel {
32    pub const LOW: &'static str = "low";
33    pub const MEDIUM: &'static str = "medium";
34    pub const HIGH: &'static str = "high";
35    pub const CRITICAL: &'static str = "critical";
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Incident {
40    pub id: String,
41    pub mission_id: MissionId,
42    pub agent_id: AgentId,
43    pub severity: String,
44    pub description: String,
45    pub state: IncidentState,
46    pub created_at: chrono::DateTime<chrono::Utc>,
47    pub resolved_at: Option<chrono::DateTime<chrono::Utc>>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
51pub enum IncidentState {
52    Open,
53    Investigating,
54    Mitigating,
55    Resolved,
56    Closed,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct Reputation {
61    pub agent_id: AgentId,
62    pub score: f64,
63    pub total_tasks_completed: u64,
64    pub total_tasks_accepted: u64,
65    pub total_revisions: u64,
66    pub average_confidence: f64,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct Channel {
71    pub id: String,
72    pub channel_type: ChannelType,
73    pub config: serde_json::Value,
74    pub is_active: bool,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct IncomingMessage {
79    pub id: String,
80    pub channel_id: String,
81    pub sender_id: String,
82    pub text: String,
83    pub raw_payload: serde_json::Value,
84    pub received_at: chrono::DateTime<chrono::Utc>,
85}
86
87#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88pub enum ChannelType {
89    Terminal,
90    Rest,
91    Webhook,
92    Telegram,
93    WhatsApp,
94    Slack,
95    Discord,
96    Mobile,
97    InternalBus,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
101pub struct Session {
102    pub id: String,
103    pub identity_id: IdentityId,
104    pub channel_id: String,
105    pub state: SessionState,
106    pub created_at: chrono::DateTime<chrono::Utc>,
107    pub expires_at: chrono::DateTime<chrono::Utc>,
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
111pub enum SessionState {
112    Active,
113    Idle,
114    Expired,
115    Terminated,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct SwarmLimitsConfig {
120    pub max_spawn_depth: u32,
121    pub max_children_per_agent: u32,
122    pub max_agents_per_mission: u32,
123    pub max_concurrent_agents: u32,
124    pub max_persistent_children_per_agent: u32,
125    pub max_turns_per_ephemeral_agent: u32,
126    pub max_idle_seconds_ephemeral: u64,
127}
128
129impl Default for SwarmLimitsConfig {
130    fn default() -> Self {
131        Self {
132            max_spawn_depth: 3,
133            max_children_per_agent: 5,
134            max_agents_per_mission: 30,
135            max_concurrent_agents: 12,
136            max_persistent_children_per_agent: 3,
137            max_turns_per_ephemeral_agent: 40,
138            max_idle_seconds_ephemeral: 600,
139        }
140    }
141}
142