1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use serde::{Deserialize, Serialize};
use crate::ids::{AgentId, ThreadId};
use crate::message::{AgentContent, Role};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ActionType {
NewAgent,
IngestFile,
NewThread,
AddMessage,
RunThread,
CheckThread,
Shutdown,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct NewAgentAction {
pub agent_id: Option<AgentId>,
pub agent_name: String,
pub agent_instructions: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IngestFileAction {
pub agent_id: AgentId,
pub file_path: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct NewThreadAction {
pub agent_id: AgentId,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CheckThreadAction {
pub agent_id: AgentId,
pub thread_id: ThreadId,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AddMessageAction {
pub agent_id: AgentId,
pub thread_id: ThreadId,
pub message_role: Role,
pub message_content: AgentContent,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RunThreadAction {
pub agent_id: AgentId,
pub thread_id: ThreadId,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(
tag = "action_type",
content = "action_data",
rename_all = "snake_case"
)]
pub enum AgiAction {
NewAgent(NewAgentAction),
IngestFile(IngestFileAction),
NewThread(NewThreadAction),
AddMessage(AddMessageAction),
RunThread(RunThreadAction),
CheckThread(CheckThreadAction),
Shutdown,
}
impl AgiAction {
pub fn action_type(&self) -> ActionType {
match self {
Self::NewAgent(_) => ActionType::NewAgent,
Self::IngestFile(_) => ActionType::IngestFile,
Self::NewThread(_) => ActionType::NewThread,
Self::AddMessage(_) => ActionType::AddMessage,
Self::RunThread(_) => ActionType::RunThread,
Self::CheckThread(_) => ActionType::CheckThread,
Self::Shutdown => ActionType::Shutdown,
}
}
}