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