1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8pub enum AgentType {
9 ClaudeCode,
11 Aider,
13 Codex,
15 Custom,
17 Shell,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct AgentConfig {
24 pub agent_type: AgentType,
26 pub startup_command: Option<String>,
28 pub prompt_prefix: Option<String>,
30 pub prompt_suffix: Option<String>,
32 pub response_pattern: Option<String>,
34 pub response_timeout_ms: u64,
36 pub streaming: bool,
38 pub custom_settings: HashMap<String, serde_json::Value>,
40}
41
42impl Default for AgentConfig {
43 fn default() -> Self {
44 Self {
45 agent_type: AgentType::Shell,
46 startup_command: None,
47 prompt_prefix: None,
48 prompt_suffix: None,
49 response_pattern: None,
50 response_timeout_ms: 30000,
51 streaming: false,
52 custom_settings: HashMap::new(),
53 }
54 }
55}
56
57impl AgentConfig {
58 pub fn claude_code() -> Self {
60 Self {
61 agent_type: AgentType::ClaudeCode,
62 startup_command: Some("claude".to_string()),
63 prompt_prefix: None,
64 prompt_suffix: Some("\n".to_string()),
65 response_pattern: Some(r"(?s).*\n\n(.+)$".to_string()),
66 response_timeout_ms: 60000,
67 streaming: true,
68 custom_settings: HashMap::new(),
69 }
70 }
71
72 pub fn aider() -> Self {
74 Self {
75 agent_type: AgentType::Aider,
76 startup_command: Some("aider".to_string()),
77 prompt_prefix: None,
78 prompt_suffix: Some("\n".to_string()),
79 response_pattern: Some(r"(?s).*\n\n(.+)$".to_string()),
80 response_timeout_ms: 60000,
81 streaming: true,
82 custom_settings: HashMap::new(),
83 }
84 }
85}
86
87pub struct AgentSession {
89 pub session_id: String,
91 pub config: AgentConfig,
93 pub history: Vec<ConversationTurn>,
95 pub context_tokens: usize,
97 pub current_task: Option<AgentTask>,
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct ConversationTurn {
104 pub timestamp: chrono::DateTime<chrono::Utc>,
106 pub input: String,
108 pub response: String,
110 pub tokens: usize,
112 pub execution_time_ms: u64,
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct AgentTask {
119 pub id: String,
121 pub task_type: TaskType,
123 pub description: String,
125 pub parameters: HashMap<String, serde_json::Value>,
127 pub status: TaskStatus,
129 pub parent_task_id: Option<String>,
131 pub depends_on: Vec<String>,
133}
134
135#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
137pub enum TaskType {
138 CodeGeneration,
140 CodeReview,
142 Debugging,
144 Documentation,
146 Testing,
148 Refactoring,
150 Research,
152 Custom,
154}
155
156#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
158pub enum TaskStatus {
159 Pending,
161 InProgress,
163 Completed,
165 Failed,
167 Cancelled,
169 Blocked,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175pub struct AgentMessage {
176 pub id: String,
178 pub from: String,
180 pub to: String,
182 pub message_type: MessageType,
184 pub content: serde_json::Value,
186 pub timestamp: chrono::DateTime<chrono::Utc>,
188 pub priority: MessagePriority,
190}
191
192#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
194pub enum MessageType {
195 TaskAssignment,
197 TaskResult,
199 Information,
201 Query,
203 Response,
205 Error,
207 StatusUpdate,
209}
210
211#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
213pub enum MessagePriority {
214 Low,
215 Normal,
216 High,
217 Critical,
218}
219
220#[derive(Debug, Clone, Serialize, Deserialize)]
222pub struct Workflow {
223 pub id: String,
225 pub name: String,
227 pub steps: Vec<WorkflowStep>,
229 pub current_step: usize,
231 pub status: WorkflowStatus,
233 pub context: HashMap<String, serde_json::Value>,
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize)]
239pub struct WorkflowStep {
240 pub name: String,
242 pub agent: String,
244 pub task: AgentTask,
246 pub success_condition: Option<String>,
248 pub retry_policy: RetryPolicy,
250 pub next_steps: HashMap<String, usize>,
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize)]
256pub struct RetryPolicy {
257 pub max_attempts: u32,
259 pub retry_delay_ms: u64,
261 pub exponential_backoff: bool,
263}
264
265#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
267pub enum WorkflowStatus {
268 NotStarted,
270 Running,
272 Paused,
274 Completed,
276 Failed,
278 Cancelled,
280}