agent_hub_runtime/core/
audit_log.rs1use serde::Serialize;
11
12pub const MAX_ENTRIES: i64 = 10_000;
14
15#[derive(Debug, Clone, Serialize)]
17pub struct AuditEntry {
18 pub id: i64,
19 pub ts: i64,
21 pub action: String,
23 pub skill_id: Option<String>,
24 pub skill_name: Option<String>,
25 pub tool: Option<String>,
27 pub success: bool,
28 pub detail: Option<String>,
30}
31
32#[derive(Debug, Default, Clone)]
34pub struct AuditDraft {
35 pub action: String,
36 pub skill_id: Option<String>,
37 pub skill_name: Option<String>,
38 pub tool: Option<String>,
39 pub success: bool,
40 pub detail: Option<String>,
41}
42
43impl AuditDraft {
44 pub fn new(action: impl Into<String>) -> Self {
45 Self {
46 action: action.into(),
47 ..Default::default()
48 }
49 }
50
51 pub fn ok(mut self) -> Self {
52 self.success = true;
53 self
54 }
55
56 pub fn fail(mut self, error: impl Into<String>) -> Self {
57 self.success = false;
58 self.detail = Some(error.into());
59 self
60 }
61
62 pub fn skill(mut self, id: impl Into<String>, name: impl Into<String>) -> Self {
63 self.skill_id = Some(id.into());
64 self.skill_name = Some(name.into());
65 self
66 }
67
68 pub fn tool(mut self, tool: impl Into<String>) -> Self {
69 self.tool = Some(tool.into());
70 self
71 }
72
73 pub fn detail(mut self, detail: impl Into<String>) -> Self {
74 self.detail = Some(detail.into());
75 self
76 }
77}