Expand description
§Atento Core - Chain Execution Engine
Atento Core is a powerful Rust library for defining and executing sequential chained scripts with multi-interpreter support, robust error handling, and advanced variable passing capabilities.
§Key Features
- Multi-Interpreter Support: Execute scripts in Bash, Batch,
PowerShell, Pwsh, and Python - Sequential Execution: Guaranteed step order with dependency management
- Variable Passing: Global parameters and step-to-step output chaining
- Type Safety: Strongly typed parameters (string, int, float, bool, datetime)
- Cross-Platform: Works reliably on Linux, macOS, and Windows
- Secure Execution: Temporary file isolation and proper permission handling
- Embedded Logging: Captures stdout, stderr, and errors inline in JSON results
- No Telemetry: Never collects usage stats or requires licensing checks
§Quick Start
use atento_core;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Run a chain from a YAML file
atento_core::run("chain.yaml")?;
Ok(())
}§Chain Structure
Chains are defined in YAML format with the following structure:
name: "Example Chain"
timeout: 300 # Global timeout in seconds
parameters:
project_name:
type: string
value: "my-project"
build_number:
type: int
value: 42
steps:
setup:
name: "Setup Environment"
type: bash # Interpreter: bash, batch, powershell, pwsh, python
timeout: 60
script: |
echo "Setting up {{ inputs.project }}"
echo "BUILD_DIR=/tmp/build-{{ inputs.build_num }}"
inputs:
project:
ref: parameters.project_name
build_num:
ref: parameters.build_number
outputs:
build_directory:
pattern: "BUILD_DIR=(.*)"
build:
name: "Build Project"
type: python
script: |
import os
build_dir = "{{ inputs.build_dir }}"
print(f"Building in {build_dir}")
print("BUILD_SUCCESS=true")
inputs:
build_dir:
ref: steps.setup.outputs.build_directory
outputs:
status:
pattern: "BUILD_SUCCESS=(.*)"
results:
build_status:
ref: steps.build.outputs.status
workspace:
ref: steps.setup.outputs.build_directory§Supported Interpreters
| Type | Description | Platform |
|---|---|---|
bash | Bash shell scripts | Unix/Linux/macOS |
batch | Windows batch files | Windows |
powershell | PowerShell (Windows) | Windows |
pwsh | PowerShell Core | Cross-platform |
python | Python scripts | Cross-platform |
python3 | Python3 scripts | Cross-platform |
§Variable Substitution
Use {{ inputs.variable_name }} syntax in scripts to substitute input values:
script: |
echo "Processing {{ inputs.filename }} in {{ inputs.directory }}"
cp "{{ inputs.source }}" "{{ inputs.destination }}"§Output Extraction
Capture values from command output using regex patterns with capture groups:
outputs:
version:
pattern: "Version: ([0-9]+\.[0-9]+\.[0-9]+)"
status:
pattern: "Status: (SUCCESS|FAILED)"§Error Handling
The library provides comprehensive error handling for:
- File I/O operations
- YAML parsing errors
- Chain validation failures
- Script execution timeouts
- Type conversion errors
- Unresolved variable references
§Example Usage
// Load and validate a chain
let yaml_content = std::fs::read_to_string("chain.yaml")?;
let chain: Chain = serde_yaml::from_str(&yaml_content)?;
// Validate the chain structure
chain.validate()?;
// Execute the chain
let result = chain.run();
// Serialize results to JSON
let json_output = serde_json::to_string_pretty(&result)?;
println!("{}", json_output);Structs§
- Chain
- Chain
Result - Interpreter
- Interpreter configuration with command, arguments, and file extension
- Step
- Step
Result
Enums§
- Atento
Error - The main error type for the Atento chain engine.
- Data
Type - Represents the data type of a parameter, input, or output value.
Functions§
- default_
interpreters - Returns the default interpreter configurations as (key, Interpreter) pairs
- run
- Runs a chain from a YAML file.
Type Aliases§
- Result
- Type alias for Results using
AtentoError