mermaid_cli/agents/types.rs
1use serde::{Deserialize, Serialize};
2
3/// Represents an action that the AI wants to perform
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub enum AgentAction {
6 /// Read a file
7 ReadFile {
8 path: String,
9 },
10 /// Write or create a file
11 WriteFile {
12 path: String,
13 content: String,
14 },
15 /// Delete a file
16 DeleteFile {
17 path: String,
18 },
19 /// Create a directory
20 CreateDirectory {
21 path: String,
22 },
23 /// Execute a shell command
24 ExecuteCommand {
25 command: String,
26 working_dir: Option<String>,
27 },
28 /// Git operations
29 GitDiff {
30 path: Option<String>,
31 },
32 GitCommit {
33 message: String,
34 files: Vec<String>,
35 },
36 GitStatus,
37 /// Web search via local Searxng
38 WebSearch {
39 query: String,
40 result_count: usize,
41 },
42 /// Read multiple files in parallel
43 ParallelRead {
44 paths: Vec<String>,
45 },
46 /// Perform multiple web searches in parallel
47 ParallelWebSearch {
48 queries: Vec<(String, usize)>,
49 },
50 /// Perform multiple git diffs in parallel
51 ParallelGitDiff {
52 paths: Vec<Option<String>>,
53 },
54}
55
56/// Result of an agent action
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub enum ActionResult {
59 Success { output: String },
60 Error { error: String },
61}
62
63/// Display representation of an action for UI rendering
64/// Used to show action results in Claude Code style
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct ActionDisplay {
67 /// Type of action (e.g., "Write", "Bash", "Read", "GitDiff", "ReadFiles")
68 pub action_type: String,
69 /// Target of the action (file path, command, etc.)
70 pub target: String,
71 /// Result of the action
72 pub result: ActionResult,
73 /// Preview of the output (truncated for display)
74 pub preview: Option<String>,
75 /// Line count for file operations
76 pub line_count: Option<usize>,
77 /// Full file content (for Write actions, to show preview)
78 pub file_content: Option<String>,
79 /// Duration of long-running actions in seconds (for display)
80 pub duration_seconds: Option<f64>,
81 /// Multiple targets for parallel operations (e.g., multiple files, searches)
82 pub targets: Option<Vec<String>>,
83 /// Number of items in parallel operation
84 pub item_count: Option<usize>,
85 /// Items that failed initially but were retried
86 pub failed_items: Option<Vec<String>>,
87}