Skip to main content

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 one or more files (executor decides parallelization)
7    ReadFile {
8        paths: Vec<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 diff for one or more paths (executor decides parallelization)
29    GitDiff {
30        paths: Vec<Option<String>>,
31    },
32    GitCommit {
33        message: String,
34        files: Vec<String>,
35    },
36    GitStatus,
37    /// Web search via local Searxng (executor decides parallelization)
38    WebSearch {
39        queries: Vec<(String, usize)>,
40    },
41}
42
43/// Result of an agent action
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub enum ActionResult {
46    Success { output: String },
47    Error { error: String },
48}
49
50/// Display representation of an action for UI rendering
51/// Used to show action results in Claude Code style
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct ActionDisplay {
54    /// Type of action (e.g., "Write", "Bash", "Read", "GitDiff", "ReadFiles")
55    pub action_type: String,
56    /// Target of the action (file path, command, etc.)
57    pub target: String,
58    /// Result of the action
59    pub result: ActionResult,
60    /// Preview of the output (truncated for display)
61    pub preview: Option<String>,
62    /// Line count for file operations
63    pub line_count: Option<usize>,
64    /// Full file content (for Write actions, to show preview)
65    pub file_content: Option<String>,
66    /// Duration of long-running actions in seconds (for display)
67    pub duration_seconds: Option<f64>,
68    /// Multiple targets for parallel operations (e.g., multiple files, searches)
69    pub targets: Option<Vec<String>>,
70    /// Number of items in parallel operation
71    pub item_count: Option<usize>,
72    /// Items that failed initially but were retried
73    pub failed_items: Option<Vec<String>>,
74}