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)]
16#[allow(dead_code)]
17pub struct PluginConfigSchema {
18    /// Fields that must be present in the step config
19    pub required_fields: Vec<String>,
20    /// Optional fields with their default values
21    pub optional_fields: HashMap<String, serde_json::Value>,
22}
23
24/// Trait that all plugins must implement
25#[allow(dead_code)]
26#[async_trait]
27pub trait PluginStep: Send + Sync {
28    /// Unique name identifying this plugin (used as step type in YAML)
29    fn name(&self) -> &str;
30
31    /// Execute the plugin step
32    async fn execute(
33        &self,
34        step_def: &StepDef,
35        config: &StepConfig,
36        context: &Context,
37    ) -> Result<StepOutput, StepError>;
38
39    /// Validate that the step config satisfies this plugin's requirements
40    fn validate(&self, config: &StepConfig) -> Result<(), StepError>;
41
42    /// Return the configuration schema for this plugin
43    fn config_schema(&self) -> PluginConfigSchema;
44}