mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
- Python: class extending NodeExecutor + factory.py (80+ plugins) - TypeScript: class implements NodeExecutor + factory.ts (7 groups, 116 classes) - Go: struct with methods + factory.go (36 plugins) - Rust: struct impl NodeExecutor trait + factory.rs (54 plugins) - Mojo: struct + factory.mojo (11 plugins) All package.json files now include: - files array listing source files - metadata.class/struct field - metadata.entrypoint field This enables a unified plugin loading system across all languages with no import side effects (Spring-style DI pattern). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Mojo Workflow Plugins
This directory contains workflow plugins implemented in Mojo, a Python superset with systems programming capabilities.
Overview
Mojo plugins provide high-performance implementations for workflow operations while maintaining Python interoperability. This allows seamless integration with the existing Python-based workflow system while enabling performance-critical optimizations.
Directory Structure
mojo/
├── plugin.mojo # Base types and traits for all plugins
├── README.md # This file
├── math/ # Mathematical operation plugins
│ ├── package.json # Category manifest
│ ├── math_add.mojo
│ ├── math_subtract.mojo
│ ├── math_multiply.mojo
│ └── math_divide.mojo
├── string/ # String manipulation plugins
│ ├── package.json # Category manifest
│ ├── string_concat.mojo
│ ├── string_upper.mojo
│ ├── string_lower.mojo
│ └── string_length.mojo
└── list/ # List operation plugins
├── package.json # Category manifest
├── list_concat.mojo
├── list_length.mojo
└── list_reverse.mojo
Plugin Pattern
Each plugin follows a standard pattern:
# Workflow plugin: <description>
from collections import Dict
from python import PythonObject
fn run(inputs: Dict[String, PythonObject]) -> Dict[String, PythonObject]:
"""<Plugin description>."""
# Extract inputs
var value = inputs.get("key", default_value)
# Perform operation
var result = compute(value)
# Return result
return Dict[String, PythonObject]{"result": result}
Categories
Math Plugins
Mathematical operations on numbers:
| Plugin | Type | Description |
|---|---|---|
math_add.mojo |
math.add |
Add two or more numbers |
math_subtract.mojo |
math.subtract |
Subtract numbers sequentially |
math_multiply.mojo |
math.multiply |
Multiply two or more numbers |
math_divide.mojo |
math.divide |
Divide numbers sequentially |
String Plugins
String manipulation operations:
| Plugin | Type | Description |
|---|---|---|
string_concat.mojo |
string.concat |
Concatenate strings |
string_upper.mojo |
string.upper |
Convert string to uppercase |
string_lower.mojo |
string.lower |
Convert string to lowercase |
string_length.mojo |
string.length |
Get string length |
List Plugins
List/array operations:
| Plugin | Type | Description |
|---|---|---|
list_concat.mojo |
list.concat |
Concatenate multiple lists |
list_length.mojo |
list.length |
Get list length |
list_reverse.mojo |
list.reverse |
Reverse a list |
Package Manifest
Each category has a package.json manifest:
{
"name": "category_name",
"version": "1.0.0",
"description": "Category description",
"metadata": {
"plugin_type": "category.operation",
"language": "mojo"
},
"plugins": [
{
"name": "plugin_name",
"file": "plugin_file.mojo",
"type": "category.operation",
"description": "Plugin description"
}
]
}
Mojo Advantages
Mojo provides several advantages for workflow plugins:
- Performance: Systems-level performance with SIMD and parallel processing
- Python Interop: Seamless integration with Python objects and libraries
- Type Safety: Strong typing with compile-time checks
- Memory Safety: Ownership and borrowing model for safe memory management
- Hardware Access: Direct access to hardware features when needed
Usage
Plugins can be loaded and executed by the workflow runtime:
# Python integration example
from workflow.loader import load_mojo_plugin
plugin = load_mojo_plugin("math/math_add.mojo")
result = plugin.run({"numbers": [1, 2, 3, 4, 5]})
print(result["result"]) # Output: 15.0
Building Plugins
To compile Mojo plugins:
# Compile a single plugin
mojo build math/math_add.mojo
# Compile all plugins in a category
for f in math/*.mojo; do mojo build "$f"; done
Testing
Each plugin can be tested independently:
# Run plugin tests
mojo test math/math_add.mojo
Contributing
When adding new plugins:
- Follow the standard plugin pattern
- Implement the
runfunction with proper input/output handling - Add the plugin to the category's
package.json - Update this README with the new plugin information
- Add appropriate tests