1use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8use vigil_audit::{
9 EventHit, ReplayEvent, SecretRefEntry, ServerOnboardingData, StoredServerProfile,
10 ToolApprovalCard, ToolSecretBinding,
11};
12use vigil_runner_types::SandboxProfile;
13use vigil_types::{ApprovalRequest, ApprovalScope, ApprovalStatus};
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
17#[serde(tag = "kind", content = "data")]
18#[non_exhaustive]
19pub enum UiResponse {
20 Ack,
22 EventList(Vec<EventSummary>),
24 EventDetail(EventDetail),
26 SearchHits(Vec<EventHit>),
28 ApprovalList(Vec<ApprovalSummary>),
30 ApprovalDetail(ApprovalDetailDto),
32 SessionList(Vec<SessionSummary>),
34 ReplayDump(SessionReplay),
36 ChainVerification(ChainVerifyReport),
38 ServerList(Vec<StoredServerProfile>),
40 ServerOnboarding(ServerOnboardingData),
42 ToolApprovalList(Vec<ToolApprovalCard>),
44 DriftedServerList(Vec<ServerOnboardingData>),
46 SandboxProfileList(Vec<SandboxProfile>),
48 SandboxProfileOpt(Option<SandboxProfile>),
50 ApprovalResolution(ApprovalResolutionDto),
52 SandboxProfileUpserted(SandboxProfileUpsertDto),
54 SecretBinding(SecretBindingSummary),
56 PrivacyFindings(PrivacyFindingsDto),
58 SessionExport(SessionExportDto),
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct EventSummary {
67 pub event_id: i64,
69 pub session_id: String,
71 pub event_type: String,
73 pub redacted_text: Option<String>,
75 pub created_at: i64,
77}
78
79impl From<ReplayEvent> for EventSummary {
80 fn from(e: ReplayEvent) -> Self {
81 Self {
82 event_id: e.event_id,
83 session_id: e.session_id,
84 event_type: e.event_type,
85 redacted_text: e.redacted_text,
86 created_at: e.created_at,
87 }
88 }
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct EventDetail {
94 pub event_id: i64,
96 pub session_id: String,
98 pub event_type: String,
100 pub payload: Value,
102 pub redacted_text: Option<String>,
104 pub prev_hash: String,
106 pub event_hash: String,
108 pub created_at: i64,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct ApprovalSummary {
115 pub approval_id: String,
117 pub session_id: String,
119 pub title: String,
121 pub summary: String,
123 pub status: ApprovalStatus,
125 pub expires_at: i64,
127}
128
129impl From<&ApprovalRequest> for ApprovalSummary {
130 fn from(r: &ApprovalRequest) -> Self {
131 Self {
132 approval_id: r.approval_id.clone(),
133 session_id: r.session_id.clone(),
134 title: r.title.clone(),
135 summary: r.summary.clone(),
136 status: r.status,
137 expires_at: r.expires_at,
138 }
139 }
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
147pub struct PrivacyFindingDto {
148 pub label: String,
150 pub count: i64,
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
163pub struct SessionExportDto {
164 pub session_id: String,
166 pub format: crate::ExportFormat,
168 pub content: String,
170 pub byte_len: usize,
172 pub event_count: usize,
174 pub generated_at: i64,
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
183pub struct RedactionScanSummaryDto {
184 pub scan_id: String,
186 pub session_id: String,
188 pub ts: i64,
190 pub source: String,
192 pub text_length_bucket: i64,
194 pub fingerprint: String,
196 pub finding_count: i64,
198}
199
200#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
206pub struct PrivacyFindingsDto {
207 pub by_label_total: Vec<PrivacyFindingDto>,
209 pub recent_scans: Vec<RedactionScanSummaryDto>,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct ApprovalDetailDto {
216 pub request: ApprovalRequest,
218 pub invocation_id: String,
220 pub decision_id: String,
222 #[serde(default)]
228 pub privacy_findings: Vec<PrivacyFindingDto>,
229}
230
231#[derive(Debug, Clone, Serialize, Deserialize)]
233pub struct SessionSummary {
234 pub session_id: String,
236 pub source: String,
238 pub app_name: Option<String>,
240 pub started_at: i64,
242 pub ended_at: Option<i64>,
244 pub risk_score: i64,
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize)]
250pub struct SessionReplay {
251 pub session_id: String,
253 pub event_count: usize,
255 pub events: Vec<EventDetail>,
257 pub chain_verified: Option<ChainVerifyReport>,
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize)]
263pub struct ChainVerifyReport {
264 pub ok: bool,
266 pub broken_at_event_id: Option<i64>,
268 pub message: Option<String>,
270}
271
272#[derive(Debug, Clone, Serialize, Deserialize)]
274pub struct ApprovalResolutionDto {
275 pub approval_id: String,
277 pub status: ApprovalStatus,
279 pub scope: Option<ApprovalScope>,
281 pub resolved_by: Option<String>,
283}
284
285#[derive(Debug, Clone, Serialize, Deserialize)]
287pub struct SandboxProfileUpsertDto {
288 pub profile_id: String,
290 pub profile_hash: String,
292 pub inserted: bool,
294}
295
296#[derive(Debug, Clone, Serialize, Deserialize)]
298pub struct SecretBindingSummary {
299 pub server_id: String,
301 pub refs: Vec<SecretRefEntry>,
303 pub bindings: Vec<ToolSecretBinding>,
305}