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    /// Make targeted edits to a file by replacing specific text
16    EditFile {
17        path: String,
18        old_string: String,
19        new_string: String,
20    },
21    /// Delete a file
22    DeleteFile {
23        path: String,
24    },
25    /// Create a directory
26    CreateDirectory {
27        path: String,
28    },
29    /// Execute a shell command
30    ExecuteCommand {
31        command: String,
32        working_dir: Option<String>,
33    },
34    /// Git diff for one or more paths (executor decides parallelization)
35    GitDiff {
36        paths: Vec<Option<String>>,
37    },
38    GitCommit {
39        message: String,
40        files: Vec<String>,
41    },
42    GitStatus,
43    /// Web search via Ollama Cloud API (executor decides parallelization)
44    WebSearch {
45        queries: Vec<(String, usize)>,
46    },
47    /// Fetch a URL's content via Ollama Cloud API
48    WebFetch {
49        url: String,
50    },
51}
52
53/// Result of an agent action
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub enum ActionResult {
56    Success { output: String },
57    Error { error: String },
58}
59
60/// Display representation of an action for UI rendering
61/// Used to show action results in Claude Code style
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct ActionDisplay {
64    /// Type of action (e.g., "Write", "Bash", "Read", "GitDiff", "ReadFiles")
65    pub action_type: String,
66    /// Target of the action (file path, command, etc.)
67    pub target: String,
68    /// Result of the action
69    pub result: ActionResult,
70    /// Preview of the output (truncated for display)
71    pub preview: Option<String>,
72    /// Line count for file operations
73    pub line_count: Option<usize>,
74    /// Full file content (for Write actions, to show preview)
75    pub file_content: Option<String>,
76    /// Duration of long-running actions in seconds (for display)
77    pub duration_seconds: Option<f64>,
78    /// Multiple targets for parallel operations (e.g., multiple files, searches)
79    pub targets: Option<Vec<String>>,
80    /// Number of items in parallel operation
81    pub item_count: Option<usize>,
82    /// Items that failed initially but were retried
83    pub failed_items: Option<Vec<String>>,
84}