Skip to main content

minion_engine/plugins/
mod.rs

1pub mod loader;
2pub mod registry;
3
4use std::collections::HashMap;
5
6use async_trait::async_trait;
7
8use crate::config::StepConfig;
9use crate::engine::context::Context;
10use crate::error::StepError;
11use crate::steps::{StepOutput};
12use crate::workflow::schema::StepDef;
13
14/// Schema describing a plugin's configuration requirements
15#[derive(Debug, Clone, Default)]
16pub struct PluginConfigSchema {
17    /// Fields that must be present in the step config
18    pub required_fields: Vec<String>,
19    /// Optional fields with their default values
20    pub optional_fields: HashMap<String, serde_json::Value>,
21}
22
23/// Trait that all plugins must implement
24#[async_trait]
25pub trait PluginStep: Send + Sync {
26    /// Unique name identifying this plugin (used as step type in YAML)
27    fn name(&self) -> &str;
28
29    /// Execute the plugin step
30    async fn execute(
31        &self,
32        step_def: &StepDef,
33        config: &StepConfig,
34        context: &Context,
35    ) -> Result<StepOutput, StepError>;
36
37    /// Validate that the step config satisfies this plugin's requirements
38    fn validate(&self, config: &StepConfig) -> Result<(), StepError>;
39
40    /// Return the configuration schema for this plugin
41    fn config_schema(&self) -> PluginConfigSchema;
42}