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>
55 lines
1.5 KiB
Mojo
55 lines
1.5 KiB
Mojo
"""Workflow plugin: add numbers.
|
|
|
|
Adds two or more numbers together and returns the sum.
|
|
Input: {"numbers": [1, 2, 3, ...]}
|
|
Output: {"result": 6.0}
|
|
"""
|
|
|
|
from collections import Dict
|
|
from python import PythonObject
|
|
|
|
|
|
struct MathAdd:
|
|
"""Plugin that adds two or more numbers together."""
|
|
|
|
var node_type: String
|
|
var category: String
|
|
var description: String
|
|
|
|
fn __init__(inout self):
|
|
"""Initialize the MathAdd plugin."""
|
|
self.node_type = "math.add"
|
|
self.category = "math"
|
|
self.description = "Add two or more numbers together"
|
|
|
|
fn execute(self, inputs: Dict[String, PythonObject], runtime: PythonObject = PythonObject(None)) -> Dict[String, PythonObject]:
|
|
"""Add two or more numbers.
|
|
|
|
Args:
|
|
inputs: Dictionary containing "numbers" key with a list of numbers.
|
|
runtime: Optional runtime context (unused).
|
|
|
|
Returns:
|
|
Dictionary with "result" key containing the sum as Float64.
|
|
"""
|
|
var numbers = inputs.get("numbers", PythonObject([]))
|
|
var result: Float64 = 0.0
|
|
|
|
for i in range(len(numbers)):
|
|
result += Float64(numbers[i])
|
|
|
|
var output = Dict[String, PythonObject]()
|
|
output["result"] = PythonObject(result)
|
|
return output
|
|
|
|
|
|
fn main():
|
|
"""Test the add plugin."""
|
|
var plugin = MathAdd()
|
|
|
|
var inputs = Dict[String, PythonObject]()
|
|
inputs["numbers"] = PythonObject([1, 2, 3, 4, 5])
|
|
|
|
var result = plugin.execute(inputs)
|
|
print("Sum:", result["result"]) # Expected: 15.0
|