Skip to main content

systemprompt_analytics/models/cli/
agent.rs

1//! CLI-facing agent analytics rows.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8use sqlx::FromRow;
9use systemprompt_identifiers::{ContextId, SessionId};
10
11#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
12pub struct AgentListRow {
13    pub agent_name: String,
14    pub task_count: i64,
15    pub completed_count: i64,
16    pub avg_execution_time_ms: i64,
17    pub total_cost_microdollars: i64,
18    pub last_active: DateTime<Utc>,
19}
20
21#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
22pub struct AgentStatsRow {
23    pub total_agents: i64,
24    pub total_tasks: i64,
25    pub completed_tasks: i64,
26    pub failed_tasks: i64,
27    pub avg_execution_time_ms: f64,
28}
29
30#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
31pub struct AgentAiStatsRow {
32    pub total_ai_requests: i64,
33    pub total_cost_microdollars: i64,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
37pub struct AgentTaskRow {
38    pub started_at: DateTime<Utc>,
39    pub status: Option<String>,
40    pub execution_time_ms: Option<i32>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
44pub struct AgentStatusBreakdownRow {
45    pub status: String,
46    pub status_count: i64,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
50pub struct AgentErrorRow {
51    pub error_type: Option<String>,
52    pub error_count: i64,
53}
54
55#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
56pub struct AgentHourlyRow {
57    pub task_hour: i32,
58    pub task_count: i64,
59}
60
61#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
62pub struct AgentSummaryRow {
63    pub total_tasks: i64,
64    pub completed: i64,
65    pub failed: i64,
66    pub avg_time: f64,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
70pub struct ConversationListRow {
71    pub context_id: ContextId,
72    pub name: Option<String>,
73    pub task_count: i64,
74    pub message_count: i64,
75    pub created_at: DateTime<Utc>,
76    pub updated_at: DateTime<Utc>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
80pub struct GatewaySessionListRow {
81    pub session_id: SessionId,
82    pub message_count: i64,
83    pub created_at: DateTime<Utc>,
84    pub updated_at: DateTime<Utc>,
85}
86
87#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
88pub struct TimestampRow {
89    pub timestamp: DateTime<Utc>,
90}