Skip to main content

agentctl/workflow/steps/
automation.rs

1use super::{fzf_cli, image_processing, macos_agent, screen_record};
2use crate::workflow::schema::{AutomationStep, AutomationTool};
3use serde::Serialize;
4
5#[derive(Debug, Clone, Serialize)]
6pub struct AutomationCommandProvenance {
7    pub tool: String,
8    pub command: String,
9    pub args: Vec<String>,
10}
11
12#[derive(Debug, Clone)]
13pub struct AutomationInvocation {
14    pub command: String,
15    pub args: Vec<String>,
16    pub env: Vec<(String, String)>,
17    pub provenance: AutomationCommandProvenance,
18}
19
20impl AutomationInvocation {
21    pub fn new(
22        tool: AutomationTool,
23        command: impl Into<String>,
24        args: Vec<String>,
25        env: Vec<(String, String)>,
26    ) -> Self {
27        let command = command.into();
28        let provenance = AutomationCommandProvenance {
29            tool: tool.as_id().to_string(),
30            command: command.clone(),
31            args: args.clone(),
32        };
33
34        Self {
35            command,
36            args,
37            env,
38            provenance,
39        }
40    }
41}
42
43pub fn resolve_automation_invocation(step: &AutomationStep) -> AutomationInvocation {
44    match step.tool {
45        AutomationTool::MacosAgent => macos_agent::build(step),
46        AutomationTool::ScreenRecord => screen_record::build(step),
47        AutomationTool::ImageProcessing => image_processing::build(step),
48        AutomationTool::FzfCli => fzf_cli::build(step),
49    }
50}