xls-rs 0.1.2

A powerful CLI tool and library for spreadsheet manipulation with pandas-style operations. Supports CSV, Excel (XLSX, XLS, ODS), Parquet, and Avro formats with formula evaluation, data transformation, and comprehensive analytics capabilities.
Documentation
//! Workflow capability

use crate::capabilities::{Capability, CapabilityMetadata};
use crate::workflow::{WorkflowConfig, WorkflowExecutor};
use anyhow::{Context, Result};
use serde_json::{json, Value};
use std::sync::Arc;

pub struct WorkflowCapability {
    executor: Arc<WorkflowExecutor>,
}

impl WorkflowCapability {
    pub fn new() -> Self {
        Self {
            executor: Arc::new(WorkflowExecutor::new()),
        }
    }
}

impl Capability for WorkflowCapability {
    fn metadata(&self) -> CapabilityMetadata {
        CapabilityMetadata {
            name: "execute_workflow".to_string(),
            description: "Execute a data processing workflow from a JSON plan".to_string(),
            parameters: json!({
                "type": "object",
                "properties": {
                    "workflow": { 
                        "type": "object", 
                        "description": "Workflow configuration object (JSON)",
                        "properties": {
                            "name": { "type": "string" },
                            "description": { "type": "string" },
                            "steps": { 
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "operation": { "type": "string" },
                                        "input": { "type": "string" },
                                        "output": { "type": "string" },
                                        "args": { "type": "object" }
                                    },
                                    "required": ["operation"]
                                }
                            }
                        },
                        "required": ["name", "steps"]
                    }
                },
                "required": ["workflow"]
            }),
        }
    }

    fn execute(&self, args: Value) -> Result<Value> {
        let workflow_json = args.get("workflow").context("Missing workflow object")?;
        
        // Validate workflow structure
        let config: WorkflowConfig = serde_json::from_value(workflow_json.clone())
            .context("Invalid workflow configuration format")?;

        self.executor.execute_config(&config)?;
        
        Ok(json!({
            "status": "success",
            "message": format!("Executed workflow '{}' with {} steps", config.name, config.steps.len())
        }))
    }
}