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