1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value};
3
4use crate::DaemonError;
5
6#[derive(Clone, Debug, Serialize)]
8pub struct DaemonRequest<'a> {
9 pub v: u32,
10 pub op: &'a str,
11 pub args: &'a Map<String, Value>,
12}
13
14#[derive(Clone, Debug, Deserialize)]
16pub struct DaemonResponse {
17 pub v: u32,
18 pub ok: bool,
19 #[serde(default)]
20 pub result: Map<String, Value>,
21 #[serde(default)]
22 pub error: Option<DaemonError>,
23}
24
25#[derive(Clone, Debug, Deserialize)]
28pub struct PingResult {
29 #[serde(default)]
30 pub version: String,
31 #[serde(default)]
32 pub pid: u64,
33 #[serde(default)]
34 pub ts: String,
35 #[serde(default)]
36 pub ipc_v: u32,
37 #[serde(default)]
38 pub capabilities: Map<String, Value>,
39 pub implementation: String,
40 #[serde(default)]
41 pub compatibility: Option<String>,
42}
43
44#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
46#[serde(rename_all = "snake_case")]
47pub enum MessageMode {
48 Send,
49 RequestReply,
50 Mail,
51}
52
53#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
55#[serde(rename_all = "snake_case")]
56pub enum ReplyMessageMode {
57 Send,
58 Mail,
59}
60
61impl ReplyMessageMode {
62 pub const fn as_str(self) -> &'static str {
63 match self {
64 Self::Send => "send",
65 Self::Mail => "mail",
66 }
67 }
68}
69
70#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
72#[serde(rename_all = "snake_case")]
73pub enum ContextDetail {
74 Overview,
75 Summary,
76 Full,
77}
78
79impl ContextDetail {
80 pub const fn as_str(self) -> &'static str {
81 match self {
82 Self::Overview => "overview",
83 Self::Summary => "summary",
84 Self::Full => "full",
85 }
86 }
87}
88
89#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
91#[serde(rename_all = "snake_case")]
92pub enum MessageHistoryMode {
93 All,
94 Send,
95 RequestReply,
96 Mail,
97}
98
99impl MessageHistoryMode {
100 pub const fn as_str(self) -> &'static str {
101 match self {
102 Self::All => "all",
103 Self::Send => "send",
104 Self::RequestReply => "request_reply",
105 Self::Mail => "mail",
106 }
107 }
108}
109
110impl MessageMode {
111 pub const fn as_str(self) -> &'static str {
112 match self {
113 Self::Send => "send",
114 Self::RequestReply => "request_reply",
115 Self::Mail => "mail",
116 }
117 }
118}
119
120#[derive(Clone, Debug, Default)]
122pub struct TerminalHistoryOptions {
123 pub render_before: Option<u64>,
124 pub before: Option<u64>,
125 pub limit_bytes: Option<u64>,
126 pub strip_ansi: Option<bool>,
127 pub compact: Option<bool>,
128 pub by: Option<String>,
129}
130
131#[derive(Clone, Debug, Default)]
133pub struct TerminalSinceOptions {
134 pub limit_bytes: Option<u64>,
135 pub by: Option<String>,
136}
137
138#[derive(Clone, Debug, Default)]
140pub struct TerminalSnapshotOptions {
141 pub limit_bytes: Option<u64>,
142 pub by: Option<String>,
143}
144
145#[derive(Clone, Debug, Deserialize)]
146pub struct TerminalSnapshotResult {
147 pub data: String,
148 pub start_cursor: u64,
149 pub end_cursor: u64,
150}
151
152#[derive(Clone, Debug, Deserialize)]
153pub struct TerminalHistoryResult {
154 pub group_id: String,
155 pub actor_id: String,
156 pub warning: String,
157 pub hint: String,
158 pub text: String,
159 pub start_cursor: u64,
160 pub end_cursor: u64,
161 pub has_more: bool,
162 pub cursor_expired: bool,
163}
164
165#[derive(Clone, Debug, Deserialize)]
166pub struct TerminalSinceHistory {
167 pub data: String,
168 pub start_cursor: u64,
169 pub end_cursor: u64,
170 pub has_more: bool,
171 pub cursor_expired: bool,
172}
173
174#[derive(Clone, Debug, Deserialize)]
175pub struct TerminalSinceResult {
176 pub history: TerminalSinceHistory,
177}
178
179#[derive(Clone, Debug, Deserialize)]
180pub struct TerminalResizeResult {
181 pub group_id: String,
182 pub actor_id: String,
183 pub cols: u32,
184 pub rows: u32,
185}
186
187#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
188#[serde(rename_all = "snake_case")]
189pub enum WebModelDeliveryMode {
190 Standard,
191 ImageCompat,
192}
193
194#[derive(Clone, Debug, Deserialize)]
195pub struct WebModelDeliveryPreference {
196 pub mode: WebModelDeliveryMode,
197 pub updated_at: String,
198 pub updated_by: String,
199}
200
201#[derive(Clone, Debug, Deserialize)]
202pub struct WebModelDeliveryPreferencesResult {
203 pub group_id: String,
204 pub actor_id: String,
205 pub preference: WebModelDeliveryPreference,
206}
207
208#[derive(Clone, Debug, Deserialize)]
209pub struct WebModelRecoveredTurnDelivery {
210 pub mode: String,
211 pub cursor_committed: bool,
212 pub web_model_mode: WebModelDeliveryMode,
213}
214
215#[derive(Clone, Debug, Deserialize)]
216pub struct WebModelRecoveredTurn {
217 pub turn_id: String,
218 pub group_id: String,
219 pub actor_id: String,
220 pub event_ids: Vec<String>,
221 pub latest_event_id: String,
222 pub latest_ts: String,
223 pub messages: Vec<Value>,
224 pub coalesced_text: String,
225 pub system_prompt: String,
226 pub delivery: WebModelRecoveredTurnDelivery,
227}
228
229#[derive(Clone, Debug, Deserialize)]
230pub struct WebModelRuntimeRecoverTurnResult {
231 pub status: String,
232 pub turn: WebModelRecoveredTurn,
233}