runtara-workflows
Workflow compilation library for Runtara. Compiles JSON DSL scenarios into optimized native Rust binaries.
Overview
This crate provides:
- JSON DSL Parsing: Load workflow definitions from JSON
- Code Generation: Generate Rust code from workflow specifications
- Native Compilation: Compile generated code to optimized binaries
- Incremental Builds: Cache compiled dependencies for fast subsequent compilations
Installation
Add to your Cargo.toml:
[]
= "1.0"
Usage
Compiling a Scenario
use ;
use fs;
Workflow JSON Format
Workflows are defined as JSON scenarios:
Step Types
| Type | Description |
|---|---|
Agent |
Execute an agent capability |
Finish |
Complete the workflow with output |
StartScenario |
Invoke a child workflow |
Value Mappings
| Type | Description | Example |
|---|---|---|
immediate |
Hardcoded value | "value": "https://api.example.com" |
reference |
Reference to data | "value": "data.order_id" |
reference |
Reference to step output | "value": "steps.fetch.outputs.body" |
Child Workflows
Workflows can invoke other workflows:
let input = CompilationInput ;
Using the CLI
The crate provides runtara-compile for command-line compilation:
# Compile a scenario
# Copy to specific location
# With debug mode (emits step telemetry events)
Debug Mode
When compiling with debug_mode: true (or --debug CLI flag), the compiled workflow emits telemetry events for each step execution. These events are stored as custom events in runtara-core and can be used for:
- Step-level tracing: See exactly which steps executed and in what order
- Performance analysis: Measure step execution duration
- Input/output inspection: Capture step inputs and outputs (truncated to 10KB)
- Debugging failures: Understand workflow state at each step
Debug mode emits two event types per step:
| Event Subtype | Timing | Payload |
|---|---|---|
step_debug_start |
Before step execution | step_id, step_name, step_type, inputs, input_mapping, timestamp_ms |
step_debug_end |
After step execution | step_id, step_name, step_type, outputs, duration_ms, timestamp_ms |
Example payload for step_debug_start:
Example payload for step_debug_end:
Query debug events from the database:
SELECT subtype, payload, created_at
FROM instance_events
WHERE instance_id = $1 AND event_type = 'custom'
ORDER BY created_at;
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
RUNTARA_NATIVE_LIBRARY_DIR |
No | (auto-detected) | Directory containing pre-compiled stdlib and dependencies |
RUNTARA_STDLIB_NAME |
No | runtara_workflow_stdlib |
Stdlib crate name for custom product stdlibs |
DATA_DIR |
No | .data |
Data directory for compiled artifacts |
Custom Workflow Stdlib
Products can extend the standard library with custom agents:
-
Create a crate that re-exports
runtara-workflow-stdlib:// my-product-stdlib/src/lib.rs pub use *; // Add product-specific agents -
Compile to
.rliband place in your native library directory -
Set environment variables:
Compilation Output
The compile_scenario function returns:
Integration with Management SDK
After compilation, register the binary with runtara-environment:
use ;
use ;
use fs;
// Compile the workflow
let result = compile_scenario?;
// Read the compiled binary
let binary = read?;
// Register with runtara-environment
let sdk = new?;
sdk.connect.await?;
let registration = sdk.register_image.await?;
// Start instances using the image_id
sdk.start_instance.await?;
Related Crates
runtara-dsl- DSL type definitionsruntara-workflow-stdlib- Standard library for compiled workflowsruntara-agents- Built-in agent implementationsruntara-management-sdk- Register and run compiled workflows
License
This project is licensed under AGPL-3.0-or-later.