1use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
13#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
14pub enum AutomationMode {
15 AutomationModeUnspecified,
17 AutoCreatePr,
19}
20
21#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
23#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
24pub enum SessionState {
25 StateUnspecified,
27 Queued,
29 Planning,
31 AwaitingPlanApproval,
33 AwaitingUserFeedback,
35 InProgress,
37 Paused,
39 Failed,
41 Completed,
43}
44
45#[derive(Debug, Serialize, Deserialize, Clone)]
51#[serde(rename_all = "camelCase")]
52pub struct Session {
53 #[serde(skip_serializing_if = "Option::is_none")]
55 pub name: Option<String>,
56 #[serde(skip_serializing_if = "Option::is_none")]
58 pub id: Option<String>,
59 pub prompt: String,
61 pub source_context: SourceContext,
63 #[serde(skip_serializing_if = "Option::is_none")]
65 pub title: Option<String>,
66 #[serde(skip_serializing_if = "Option::is_none")]
68 pub require_plan_approval: Option<bool>,
69 #[serde(skip_serializing_if = "Option::is_none")]
71 pub automation_mode: Option<AutomationMode>,
72 #[serde(skip_serializing)]
74 pub create_time: Option<DateTime<Utc>>,
75 #[serde(skip_serializing)]
77 pub update_time: Option<DateTime<Utc>>,
78 #[serde(skip_serializing)]
80 pub state: Option<SessionState>,
81 #[serde(skip_serializing)]
83 pub url: Option<String>,
84 #[serde(skip_serializing)]
86 pub outputs: Option<Vec<SessionOutput>>,
87}
88
89#[derive(Debug, Serialize, Deserialize, Clone)]
91#[serde(rename_all = "camelCase")]
92pub struct SourceContext {
93 #[serde(skip_serializing_if = "Option::is_none")]
95 pub github_repo_context: Option<GitHubRepoContext>,
96 pub source: String,
98}
99
100#[derive(Debug, Serialize, Deserialize, Clone)]
102#[serde(rename_all = "camelCase")]
103pub struct GitHubRepoContext {
104 pub starting_branch: String,
106}
107
108#[derive(Debug, Serialize, Deserialize, Clone)]
110#[serde(rename_all = "camelCase")]
111pub struct SessionOutput {
112 pub pull_request: Option<PullRequest>,
114}
115
116#[derive(Debug, Serialize, Deserialize, Clone)]
118#[serde(rename_all = "camelCase")]
119pub struct PullRequest {
120 pub url: String,
122 pub title: String,
124 pub description: String,
126}
127
128#[derive(Debug, Serialize, Deserialize, Clone)]
133#[serde(rename_all = "camelCase")]
134pub struct Activity {
135 pub name: String,
137 pub id: String,
139 pub description: Option<String>,
141 pub create_time: DateTime<Utc>,
143 pub originator: String,
145 pub agent_messaged: Option<AgentMessaged>,
147 pub user_messaged: Option<UserMessaged>,
149 pub plan_generated: Option<PlanGenerated>,
151 pub plan_approved: Option<PlanApproved>,
153 pub progress_updated: Option<ProgressUpdated>,
155 pub session_completed: Option<serde_json::Value>,
157 pub session_failed: Option<SessionFailed>,
159 pub artifacts: Option<Vec<Artifact>>,
161}
162
163#[derive(Debug, Serialize, Deserialize, Clone)]
165#[serde(rename_all = "camelCase")]
166pub struct AgentMessaged {
167 pub agent_message: String,
169}
170
171#[derive(Debug, Serialize, Deserialize, Clone)]
173#[serde(rename_all = "camelCase")]
174pub struct UserMessaged {
175 pub user_message: String,
177}
178
179#[derive(Debug, Serialize, Deserialize, Clone)]
181#[serde(rename_all = "camelCase")]
182pub struct PlanGenerated {
183 pub plan: Plan,
185}
186
187#[derive(Debug, Serialize, Deserialize, Clone)]
189#[serde(rename_all = "camelCase")]
190pub struct Plan {
191 pub id: String,
193 pub steps: Vec<PlanStep>,
195 pub create_time: DateTime<Utc>,
197}
198
199#[derive(Debug, Serialize, Deserialize, Clone)]
201#[serde(rename_all = "camelCase")]
202pub struct PlanStep {
203 pub id: String,
205 pub title: String,
207 pub description: String,
209 pub index: i32,
211}
212
213#[derive(Debug, Serialize, Deserialize, Clone)]
215#[serde(rename_all = "camelCase")]
216pub struct PlanApproved {
217 pub plan_id: String,
219}
220
221#[derive(Debug, Serialize, Deserialize, Clone)]
223#[serde(rename_all = "camelCase")]
224pub struct ProgressUpdated {
225 pub title: String,
227 pub description: String,
229}
230
231#[derive(Debug, Serialize, Deserialize, Clone)]
233#[serde(rename_all = "camelCase")]
234pub struct SessionFailed {
235 pub reason: String,
237}
238
239#[derive(Debug, Serialize, Deserialize, Clone)]
241#[serde(rename_all = "camelCase")]
242pub struct Artifact {
243 pub change_set: Option<ChangeSet>,
245 pub media: Option<Media>,
247 pub bash_output: Option<BashOutput>,
249}
250
251#[derive(Debug, Serialize, Deserialize, Clone)]
253#[serde(rename_all = "camelCase")]
254pub struct ChangeSet {
255 pub git_patch: Option<GitPatch>,
257 pub source: String,
259}
260
261#[derive(Debug, Serialize, Deserialize, Clone)]
263#[serde(rename_all = "camelCase")]
264pub struct GitPatch {
265 pub unidiff_patch: String,
267 pub base_commit_id: String,
269 pub suggested_commit_message: Option<String>,
271}
272
273#[derive(Debug, Serialize, Deserialize, Clone)]
275#[serde(rename_all = "camelCase")]
276pub struct Media {
277 pub data: String,
279 pub mime_type: String,
281}
282
283#[derive(Debug, Serialize, Deserialize, Clone)]
285#[serde(rename_all = "camelCase")]
286pub struct BashOutput {
287 pub command: String,
289 pub output: String,
291 pub exit_code: i32,
293}
294
295#[derive(Debug, Serialize, Deserialize, Clone)]
297#[serde(rename_all = "camelCase")]
298pub struct Source {
299 pub name: String,
301 pub id: String,
303 pub github_repo: Option<GitHubRepo>,
305}
306
307#[derive(Debug, Serialize, Deserialize, Clone)]
309#[serde(rename_all = "camelCase")]
310pub struct GitHubRepo {
311 pub owner: String,
313 pub repo: String,
315 pub is_private: bool,
317 pub default_branch: GitHubBranch,
319 pub branches: Vec<GitHubBranch>,
321}
322
323#[derive(Debug, Serialize, Deserialize, Clone)]
325#[serde(rename_all = "camelCase")]
326pub struct GitHubBranch {
327 pub display_name: String,
329}
330
331#[derive(Debug, Serialize, Deserialize, Clone)]
333#[serde(rename_all = "camelCase")]
334pub struct ListSessionsResponse {
335 pub sessions: Vec<Session>,
337 pub next_page_token: Option<String>,
339}
340
341#[derive(Debug, Serialize, Deserialize, Clone)]
343#[serde(rename_all = "camelCase")]
344pub struct ListActivitiesResponse {
345 pub activities: Vec<Activity>,
347 pub next_page_token: Option<String>,
349}
350
351#[derive(Debug, Serialize, Deserialize, Clone)]
353#[serde(rename_all = "camelCase")]
354pub struct ListSourcesResponse {
355 pub sources: Vec<Source>,
357 pub next_page_token: Option<String>,
359}
360
361#[derive(Debug, Serialize, Deserialize, Clone)]
363pub struct SendMessageRequest {
364 pub prompt: String,
366}
367
368#[derive(Debug, Serialize, Deserialize, Clone)]
370pub struct ApprovePlanRequest {}
371
372#[derive(Debug, Serialize, Deserialize, Clone)]
374pub struct Empty {}