1use std::time::Duration;
10
11#[derive(Debug, Clone)]
17#[non_exhaustive]
18pub enum ClientFrame {
19 Prompt { content: Vec<Content> },
21
22 AskUserAnswer { ask_id: String, value: serde_json::Value },
24
25 PermissionResponse { req_id: String, decision: PermissionDecision },
27
28 Cancel,
30}
31
32#[derive(Debug, Clone)]
34#[non_exhaustive]
35pub enum Content {
36 Text(String),
37 Image { mime: String, data: Vec<u8> },
38 }
40
41#[derive(Debug, Clone)]
47#[non_exhaustive]
48pub enum AgentEvent {
49 Ready { session_id: String, model: Option<String> },
51
52 TextChunk { msg_id: String, text: String, channel: TextChannel },
54
55 Thought { msg_id: String, text: String },
57
58 ToolCallStart { call_id: String, name: String, input: serde_json::Value },
60
61 ToolCallEnd { call_id: String, output: String, is_error: bool },
63
64 Plan { entries: Vec<PlanEntry> },
66
67 AskUser { ask_id: String, prompt: String, kind: AskKind, options: Vec<AskOption> },
69
70 PermissionRequest {
72 req_id: String,
73 tool: String,
74 intent: serde_json::Value,
75 scope: PermissionScope,
76 },
77
78 Done { stop_reason: StopReason, usage: Usage },
80
81 Error { code: String, message: String },
83}
84
85#[derive(Debug, Clone, Copy, PartialEq, Eq)]
87#[non_exhaustive]
88pub enum TextChannel {
89 Assistant,
90 System,
91}
92
93#[derive(Debug, Clone)]
95pub struct PlanEntry {
96 pub id: String,
97 pub content: String,
98 pub status: PlanStatus,
99 pub priority: PlanPriority,
100}
101
102#[derive(Debug, Clone, Copy, PartialEq, Eq)]
103#[non_exhaustive]
104pub enum PlanStatus { Pending, InProgress, Completed, Cancelled, Blocked }
105
106#[derive(Debug, Clone, Copy, PartialEq, Eq)]
107#[non_exhaustive]
108pub enum PlanPriority { High, Medium, Low }
109
110#[derive(Debug, Clone, Copy, PartialEq, Eq)]
111#[non_exhaustive]
112pub enum AskKind { YesNo, Options, FreeText }
113
114#[derive(Debug, Clone)]
115pub struct AskOption {
116 pub id: String,
117 pub label: String,
118}
119
120#[derive(Debug, Clone, Copy, PartialEq, Eq)]
121#[non_exhaustive]
122pub enum PermissionScope { Read, Write, Execute, Network }
123
124#[derive(Debug, Clone, Copy, PartialEq, Eq)]
125#[non_exhaustive]
126pub enum PermissionDecision { AllowOnce, AllowAlways, Deny }
127
128#[derive(Debug, Clone, Copy, PartialEq, Eq)]
129#[non_exhaustive]
130pub enum StopReason {
131 EndTurn,
132 MaxTokens,
133 ToolUse,
134 StopSequence,
135 Cancelled,
136 Error,
137}
138
139#[derive(Debug, Clone, Default)]
141pub struct Usage {
142 pub input_tokens: u64,
143 pub output_tokens: u64,
144 pub cache_read_tokens: u64,
145 pub cache_creation_tokens: u64,
146 pub cost_usd_estimate: Option<f64>,
147 pub duration: Option<Duration>,
148 pub model_id: Option<String>,
149}