1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
//! Database models for the files table.
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use utoipa::ToSchema;
use uuid::Uuid;
/// TranscriptEntry stored in JSONB - matches frontend TranscriptEntry
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TranscriptEntry {
pub id: String,
pub speaker: String,
pub start: f32,
pub end: f32,
pub text: String,
pub is_final: bool,
}
/// Chart type for visualization elements
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum ChartType {
Line,
Bar,
Pie,
Area,
}
/// Body element types for structured file content
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum BodyElement {
/// Heading element (h1-h6)
Heading { level: u8, text: String },
/// Paragraph text
Paragraph { text: String },
/// Code block with optional language
Code {
language: Option<String>,
content: String,
},
/// List (ordered or unordered)
List {
ordered: bool,
items: Vec<String>,
},
/// Chart visualization
Chart {
#[serde(rename = "chartType")]
chart_type: ChartType,
title: Option<String>,
data: serde_json::Value,
config: Option<serde_json::Value>,
},
/// Image element (deferred for MVP)
Image {
src: String,
alt: Option<String>,
caption: Option<String>,
},
}
/// File record from the database.
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct File {
pub id: Uuid,
pub owner_id: Uuid,
pub name: String,
pub description: Option<String>,
#[sqlx(json)]
pub transcript: Vec<TranscriptEntry>,
pub location: Option<String>,
/// AI-generated summary of the transcript
pub summary: Option<String>,
/// Structured body content (headings, paragraphs, charts)
#[sqlx(json)]
pub body: Vec<BodyElement>,
/// Version number for optimistic locking
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
/// Request payload for creating a new file.
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct CreateFileRequest {
/// Name of the file (auto-generated if not provided)
pub name: Option<String>,
/// Optional description
pub description: Option<String>,
/// Transcript entries
pub transcript: Vec<TranscriptEntry>,
/// Storage location (e.g., s3://bucket/path) - not used yet
pub location: Option<String>,
}
/// Request payload for updating an existing file.
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateFileRequest {
/// New name (optional)
pub name: Option<String>,
/// New description (optional)
pub description: Option<String>,
/// New transcript (optional)
pub transcript: Option<Vec<TranscriptEntry>>,
/// AI-generated summary (optional)
pub summary: Option<String>,
/// Structured body content (optional)
pub body: Option<Vec<BodyElement>>,
/// Version for optimistic locking (required for updates from frontend)
pub version: Option<i32>,
}
/// Response for file list endpoint.
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FileListResponse {
pub files: Vec<FileSummary>,
pub total: i64,
}
/// Summary of a file for list views (excludes full transcript).
#[derive(Debug, Clone, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FileSummary {
pub id: Uuid,
pub name: String,
pub description: Option<String>,
pub transcript_count: usize,
/// Duration derived from last transcript end time
pub duration: Option<f32>,
/// Version number for optimistic locking
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
impl From<File> for FileSummary {
fn from(file: File) -> Self {
let duration = file
.transcript
.iter()
.map(|t| t.end)
.fold(0.0_f32, f32::max);
Self {
id: file.id,
name: file.name,
description: file.description,
transcript_count: file.transcript.len(),
duration: if duration > 0.0 { Some(duration) } else { None },
version: file.version,
created_at: file.created_at,
updated_at: file.updated_at,
}
}
}
// =============================================================================
// Version History Types
// =============================================================================
/// Source of a version change
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, sqlx::Type)]
#[sqlx(type_name = "varchar")]
#[serde(rename_all = "lowercase")]
pub enum VersionSource {
#[sqlx(rename = "user")]
User,
#[sqlx(rename = "llm")]
Llm,
#[sqlx(rename = "system")]
System,
}
impl std::fmt::Display for VersionSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
VersionSource::User => write!(f, "user"),
VersionSource::Llm => write!(f, "llm"),
VersionSource::System => write!(f, "system"),
}
}
}
impl std::str::FromStr for VersionSource {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"user" => Ok(VersionSource::User),
"llm" => Ok(VersionSource::Llm),
"system" => Ok(VersionSource::System),
_ => Err(format!("Unknown version source: {}", s)),
}
}
}
/// Full version record from the database
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FileVersion {
pub id: Uuid,
pub file_id: Uuid,
pub version: i32,
pub name: String,
pub description: Option<String>,
pub summary: Option<String>,
#[sqlx(json)]
pub body: Vec<BodyElement>,
pub source: String,
pub change_description: Option<String>,
pub created_at: DateTime<Utc>,
}
/// Summary of a version for list views
#[derive(Debug, Clone, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FileVersionSummary {
pub version: i32,
pub source: String,
pub created_at: DateTime<Utc>,
pub change_description: Option<String>,
}
impl From<FileVersion> for FileVersionSummary {
fn from(v: FileVersion) -> Self {
Self {
version: v.version,
source: v.source,
created_at: v.created_at,
change_description: v.change_description,
}
}
}
/// Response for version list endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct FileVersionListResponse {
pub versions: Vec<FileVersionSummary>,
pub total: i64,
}
/// Request to restore a file to a previous version
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct RestoreVersionRequest {
/// The version to restore to
pub target_version: i32,
/// The current version (for optimistic locking)
pub current_version: i32,
}
// =============================================================================
// Mesh/Task Types
// =============================================================================
/// Task status for orchestrating Claude Code instances
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum TaskStatus {
Pending,
Running,
Paused,
Blocked,
Done,
Failed,
Merged,
}
impl std::fmt::Display for TaskStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TaskStatus::Pending => write!(f, "pending"),
TaskStatus::Running => write!(f, "running"),
TaskStatus::Paused => write!(f, "paused"),
TaskStatus::Blocked => write!(f, "blocked"),
TaskStatus::Done => write!(f, "done"),
TaskStatus::Failed => write!(f, "failed"),
TaskStatus::Merged => write!(f, "merged"),
}
}
}
impl std::str::FromStr for TaskStatus {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"pending" => Ok(TaskStatus::Pending),
"running" => Ok(TaskStatus::Running),
"paused" => Ok(TaskStatus::Paused),
"blocked" => Ok(TaskStatus::Blocked),
"done" => Ok(TaskStatus::Done),
"failed" => Ok(TaskStatus::Failed),
"merged" => Ok(TaskStatus::Merged),
_ => Err(format!("Unknown task status: {}", s)),
}
}
}
/// Merge mode for task completion
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum MergeMode {
/// Create a PR for review
Pr,
/// Auto-merge to target branch
Auto,
/// Manual merge by user
Manual,
}
impl std::fmt::Display for MergeMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MergeMode::Pr => write!(f, "pr"),
MergeMode::Auto => write!(f, "auto"),
MergeMode::Manual => write!(f, "manual"),
}
}
}
impl std::str::FromStr for MergeMode {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"pr" => Ok(MergeMode::Pr),
"auto" => Ok(MergeMode::Auto),
"manual" => Ok(MergeMode::Manual),
_ => Err(format!("Unknown merge mode: {}", s)),
}
}
}
/// Task record from the database
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Task {
pub id: Uuid,
pub owner_id: Uuid,
pub parent_task_id: Option<Uuid>,
/// Depth in task hierarchy: 0=orchestrator (top-level), 1=subtask (max)
pub depth: i32,
pub name: String,
pub description: Option<String>,
pub status: String,
pub priority: i32,
pub plan: String,
// Daemon/container info
pub daemon_id: Option<Uuid>,
pub container_id: Option<String>,
pub overlay_path: Option<String>,
// Repository info
pub repository_url: Option<String>,
pub base_branch: Option<String>,
pub target_branch: Option<String>,
// Merge settings
pub merge_mode: Option<String>,
pub pr_url: Option<String>,
// Completion action settings
/// Path to user's local repository (outside ~/.makima)
pub target_repo_path: Option<String>,
/// Action on completion: "none", "branch", "merge", "pr"
pub completion_action: Option<String>,
// Progress tracking
pub progress_summary: Option<String>,
pub last_output: Option<String>,
pub error_message: Option<String>,
// Timestamps
pub started_at: Option<DateTime<Utc>>,
pub completed_at: Option<DateTime<Utc>>,
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
// Task continuation
/// Task ID to continue from (copy worktree from this task when starting).
/// Used for sequential subtask dependencies.
#[serde(skip_serializing_if = "Option::is_none")]
pub continue_from_task_id: Option<Uuid>,
/// Files to copy from parent task's worktree when starting.
#[serde(skip_serializing_if = "Option::is_none")]
pub copy_files: Option<serde_json::Value>,
}
impl Task {
/// Parse status string to TaskStatus enum
pub fn status_enum(&self) -> Result<TaskStatus, String> {
self.status.parse()
}
/// Parse merge_mode string to MergeMode enum
pub fn merge_mode_enum(&self) -> Option<Result<MergeMode, String>> {
self.merge_mode.as_ref().map(|s| s.parse())
}
}
/// Summary of a task for list views
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskSummary {
pub id: Uuid,
pub parent_task_id: Option<Uuid>,
/// Depth in task hierarchy: 0=orchestrator (top-level), 1=subtask (max)
pub depth: i32,
pub name: String,
pub status: String,
pub priority: i32,
pub progress_summary: Option<String>,
pub subtask_count: i64,
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
/// Response for task list endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskListResponse {
pub tasks: Vec<TaskSummary>,
pub total: i64,
}
/// Request payload for creating a new task
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct CreateTaskRequest {
/// Name of the task
pub name: String,
/// Optional description
pub description: Option<String>,
/// The plan/instructions for Claude Code
pub plan: String,
/// Parent task ID (for subtasks)
pub parent_task_id: Option<Uuid>,
/// Priority (higher = more urgent)
#[serde(default)]
pub priority: i32,
/// Repository URL
pub repository_url: Option<String>,
/// Base branch for overlay
pub base_branch: Option<String>,
/// Target branch to merge into
pub target_branch: Option<String>,
/// Merge mode (pr, auto, manual)
pub merge_mode: Option<String>,
/// Path to user's local repository (outside ~/.makima)
pub target_repo_path: Option<String>,
/// Action on completion: "none", "branch", "merge", "pr"
pub completion_action: Option<String>,
/// Task ID to continue from (copy worktree from this task when starting)
pub continue_from_task_id: Option<Uuid>,
/// Files to copy from parent task's worktree when starting
#[serde(skip_serializing_if = "Option::is_none")]
pub copy_files: Option<Vec<String>>,
}
/// Request payload for updating a task
#[derive(Debug, Default, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateTaskRequest {
pub name: Option<String>,
pub description: Option<String>,
pub plan: Option<String>,
pub status: Option<String>,
pub priority: Option<i32>,
pub progress_summary: Option<String>,
pub last_output: Option<String>,
pub error_message: Option<String>,
pub merge_mode: Option<String>,
pub pr_url: Option<String>,
/// Path to user's local repository (outside ~/.makima)
pub target_repo_path: Option<String>,
/// Action on completion: "none", "branch", "merge", "pr"
pub completion_action: Option<String>,
/// The daemon currently running this task
pub daemon_id: Option<Uuid>,
/// Explicitly clear daemon_id (set to NULL)
#[serde(default)]
pub clear_daemon_id: bool,
/// Version for optimistic locking
pub version: Option<i32>,
}
/// Task with its subtasks for detail view
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskWithSubtasks {
#[serde(flatten)]
pub task: Task,
pub subtasks: Vec<TaskSummary>,
}
/// Request to send a message to a running task's stdin.
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct SendMessageRequest {
/// The message to send to the task's stdin.
pub message: String,
}
// =============================================================================
// Daemon Types
// =============================================================================
/// Daemon status
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum DaemonStatus {
Connected,
Disconnected,
Unhealthy,
}
impl std::fmt::Display for DaemonStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DaemonStatus::Connected => write!(f, "connected"),
DaemonStatus::Disconnected => write!(f, "disconnected"),
DaemonStatus::Unhealthy => write!(f, "unhealthy"),
}
}
}
impl std::str::FromStr for DaemonStatus {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"connected" => Ok(DaemonStatus::Connected),
"disconnected" => Ok(DaemonStatus::Disconnected),
"unhealthy" => Ok(DaemonStatus::Unhealthy),
_ => Err(format!("Unknown daemon status: {}", s)),
}
}
}
/// Connected daemon record from the database
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Daemon {
pub id: Uuid,
pub owner_id: Uuid,
pub connection_id: String,
pub hostname: Option<String>,
pub machine_id: Option<String>,
pub max_concurrent_tasks: i32,
pub current_task_count: i32,
pub status: String,
pub last_heartbeat_at: DateTime<Utc>,
pub connected_at: DateTime<Utc>,
pub disconnected_at: Option<DateTime<Utc>>,
}
impl Daemon {
/// Parse status string to DaemonStatus enum
pub fn status_enum(&self) -> Result<DaemonStatus, String> {
self.status.parse()
}
}
/// Response for daemon list endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct DaemonListResponse {
pub daemons: Vec<Daemon>,
pub total: i64,
}
/// Response for daemon directories endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct DaemonDirectoriesResponse {
/// List of suggested directories from connected daemons
pub directories: Vec<DaemonDirectory>,
}
/// A suggested directory from a daemon
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct DaemonDirectory {
/// Path to the directory
pub path: String,
/// Display label for the directory
pub label: String,
/// Type of directory: "working", "makima", "worktrees"
pub directory_type: String,
/// Daemon hostname this directory is from
pub hostname: Option<String>,
/// Whether the directory already exists (for validation)
#[serde(skip_serializing_if = "Option::is_none")]
pub exists: Option<bool>,
}
// =============================================================================
// Task Event Types
// =============================================================================
/// Task event record from the database
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskEvent {
pub id: Uuid,
pub task_id: Uuid,
pub event_type: String,
pub previous_status: Option<String>,
pub new_status: Option<String>,
#[sqlx(json)]
pub event_data: Option<serde_json::Value>,
pub created_at: DateTime<Utc>,
}
/// Response for task events list endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskEventListResponse {
pub events: Vec<TaskEvent>,
pub total: i64,
}
/// A single output entry from a Claude Code task
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskOutputEntry {
pub id: Uuid,
pub task_id: Uuid,
/// Message type: "assistant", "tool_use", "tool_result", "result", "system", "error", "raw"
pub message_type: String,
/// Main text content
pub content: String,
/// Tool name if tool_use message
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_name: Option<String>,
/// Tool input JSON if tool_use message
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_input: Option<serde_json::Value>,
/// Whether tool result was an error
#[serde(skip_serializing_if = "Option::is_none")]
pub is_error: Option<bool>,
/// Cost in USD if result message
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_usd: Option<f64>,
/// Duration in ms if result message
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_ms: Option<u64>,
/// Timestamp when this output was recorded
pub created_at: DateTime<Utc>,
}
impl TaskOutputEntry {
/// Convert a TaskEvent with event_type='output' to a TaskOutputEntry
pub fn from_task_event(event: TaskEvent) -> Option<Self> {
if event.event_type != "output" {
return None;
}
let data = event.event_data?;
Some(Self {
id: event.id,
task_id: event.task_id,
message_type: data.get("messageType")?.as_str()?.to_string(),
content: data.get("content")?.as_str().unwrap_or("").to_string(),
tool_name: data.get("toolName").and_then(|v| v.as_str()).map(|s| s.to_string()),
tool_input: data.get("toolInput").cloned(),
is_error: data.get("isError").and_then(|v| v.as_bool()),
cost_usd: data.get("costUsd").and_then(|v| v.as_f64()),
duration_ms: data.get("durationMs").and_then(|v| v.as_u64()),
created_at: event.created_at,
})
}
}
/// Response for task output history endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TaskOutputResponse {
pub entries: Vec<TaskOutputEntry>,
pub total: usize,
pub task_id: Uuid,
}
// =============================================================================
// Mesh Chat History Types
// =============================================================================
/// Mesh chat conversation for persisting history
#[derive(Debug, Clone, FromRow, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MeshChatConversation {
pub id: Uuid,
pub owner_id: Uuid,
pub name: Option<String>,
pub is_active: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
/// Individual message in a mesh chat conversation
#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MeshChatMessageRecord {
pub id: Uuid,
pub conversation_id: Uuid,
pub role: String,
pub content: String,
pub context_type: String,
pub context_task_id: Option<Uuid>,
/// Tool calls made during this message (JSON, nullable)
pub tool_calls: Option<serde_json::Value>,
/// Pending questions requiring user response (JSON, nullable)
pub pending_questions: Option<serde_json::Value>,
pub created_at: DateTime<Utc>,
}
/// Response for chat history endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MeshChatHistoryResponse {
pub conversation_id: Uuid,
pub messages: Vec<MeshChatMessageRecord>,
}
// =============================================================================
// Merge API Types
// =============================================================================
/// Information about a task branch
#[derive(Debug, Clone, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct BranchInfo {
/// Full branch name
pub name: String,
/// Task ID extracted from branch name (if parseable)
pub task_id: Option<Uuid>,
/// Whether this branch has been merged
pub is_merged: bool,
/// Short SHA of the last commit
pub last_commit: String,
/// Subject line of the last commit
pub last_commit_message: String,
}
/// Response for branch list endpoint
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct BranchListResponse {
pub branches: Vec<BranchInfo>,
}
/// Request to start a merge
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeStartRequest {
/// Branch name to merge
pub source_branch: String,
}
/// Current merge state
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeStatusResponse {
/// Whether a merge is in progress
pub in_progress: bool,
/// Branch being merged (if in progress)
pub source_branch: Option<String>,
/// Files with unresolved conflicts
pub conflicted_files: Vec<String>,
}
/// Request to resolve a conflict
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeResolveRequest {
/// File path to resolve
pub file: String,
/// Resolution strategy: "ours" or "theirs"
pub strategy: String,
}
/// Request to commit a merge
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeCommitRequest {
/// Commit message
pub message: String,
}
/// Request to skip a subtask branch
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeSkipRequest {
/// Subtask ID to skip
pub subtask_id: Uuid,
/// Reason for skipping
pub reason: String,
}
/// Result of a merge operation
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeResultResponse {
/// Whether the operation succeeded
pub success: bool,
/// Human-readable message
pub message: String,
/// Commit SHA (if a commit was created)
pub commit_sha: Option<String>,
/// Conflicted files (if conflicts occurred)
pub conflicts: Option<Vec<String>>,
}
/// Response to check if all branches are merged
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MergeCompleteCheckResponse {
/// Whether the orchestrator can mark itself as complete
pub can_complete: bool,
/// Branches not yet merged or skipped
pub unmerged_branches: Vec<String>,
/// Count of merged branches
pub merged_count: u32,
/// Count of skipped branches
pub skipped_count: u32,
}
|