refactor(workflow): convert all plugins to class/struct + factory pattern

- 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>
This commit is contained in:
2026-01-22 14:53:04 +00:00
parent 2562c2f55b
commit 7ce8b4ae8a
653 changed files with 13243 additions and 3034 deletions

View File

@@ -0,0 +1,7 @@
"""Factory for MathAbs plugin."""
from .math_abs import MathAbs
def create():
return MathAbs()

View File

@@ -1,7 +1,18 @@
"""Workflow plugin: absolute value."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Calculate absolute value."""
value = inputs.get("value", 0)
return {"result": abs(value)}
class MathAbs(NodeExecutor):
"""Get absolute value."""
node_type = "math.abs"
category = "math"
description = "Get absolute value"
def execute(self, inputs, runtime=None):
try:
value = float(inputs.get("value", 0))
return {"result": abs(value)}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_abs",
"version": "1.0.0",
"description": "math_abs plugin",
"description": "Get absolute value",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_abs.py",
"files": ["math_abs.py", "factory.py"],
"metadata": {
"plugin_type": "math.abs",
"category": "math"
"category": "math",
"class": "MathAbs",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathAdd plugin."""
from .math_add import MathAdd
def create():
return MathAdd()

View File

@@ -1,7 +1,19 @@
"""Workflow plugin: add numbers."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Add two or more numbers."""
numbers = inputs.get("numbers", [])
return {"result": sum(numbers)}
class MathAdd(NodeExecutor):
"""Add numbers together."""
node_type = "math.add"
category = "math"
description = "Add numbers together"
def execute(self, inputs, runtime=None):
numbers = inputs.get("numbers", inputs.get("values", []))
try:
result = sum(float(n) for n in numbers)
return {"result": result}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_add",
"version": "1.0.0",
"description": "math_add plugin",
"description": "Add numbers together",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_add.py",
"files": ["math_add.py", "factory.py"],
"metadata": {
"plugin_type": "math.add",
"category": "math"
"category": "math",
"class": "MathAdd",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathDivide plugin."""
from .math_divide import MathDivide
def create():
return MathDivide()

View File

@@ -1,12 +1,21 @@
"""Workflow plugin: divide numbers."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class MathDivide(NodeExecutor):
"""Divide a by b."""
a = inputs.get("a", 0)
b = inputs.get("b", 1)
if b == 0:
return {"result": None, "error": "Division by zero"}
node_type = "math.divide"
category = "math"
description = "Divide a by b"
return {"result": a / b}
def execute(self, inputs, runtime=None):
try:
a = float(inputs.get("a", 0))
b = float(inputs.get("b", 0))
if b == 0:
return {"error": "Division by zero"}
return {"result": a / b}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_divide",
"version": "1.0.0",
"description": "math_divide plugin",
"description": "Divide a by b",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_divide.py",
"files": ["math_divide.py", "factory.py"],
"metadata": {
"plugin_type": "math.divide",
"category": "math"
"category": "math",
"class": "MathDivide",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathMax plugin."""
from .math_max import MathMax
def create():
return MathMax()

View File

@@ -1,11 +1,19 @@
"""Workflow plugin: maximum value."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Find maximum value in numbers."""
numbers = inputs.get("numbers", [])
if not numbers:
return {"result": None}
class MathMax(NodeExecutor):
"""Get maximum of values."""
return {"result": max(numbers)}
node_type = "math.max"
category = "math"
description = "Get maximum of values"
def execute(self, inputs, runtime=None):
numbers = inputs.get("numbers", inputs.get("values", []))
try:
result = max(float(n) for n in numbers)
return {"result": result}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_max",
"version": "1.0.0",
"description": "math_max plugin",
"description": "Get maximum of values",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_max.py",
"files": ["math_max.py", "factory.py"],
"metadata": {
"plugin_type": "math.max",
"category": "math"
"category": "math",
"class": "MathMax",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathMin plugin."""
from .math_min import MathMin
def create():
return MathMin()

View File

@@ -1,11 +1,19 @@
"""Workflow plugin: minimum value."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Find minimum value in numbers."""
numbers = inputs.get("numbers", [])
if not numbers:
return {"result": None}
class MathMin(NodeExecutor):
"""Get minimum of values."""
return {"result": min(numbers)}
node_type = "math.min"
category = "math"
description = "Get minimum of values"
def execute(self, inputs, runtime=None):
numbers = inputs.get("numbers", inputs.get("values", []))
try:
result = min(float(n) for n in numbers)
return {"result": result}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_min",
"version": "1.0.0",
"description": "math_min plugin",
"description": "Get minimum of values",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_min.py",
"files": ["math_min.py", "factory.py"],
"metadata": {
"plugin_type": "math.min",
"category": "math"
"category": "math",
"class": "MathMin",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathModulo plugin."""
from .math_modulo import MathModulo
def create():
return MathModulo()

View File

@@ -1,12 +1,21 @@
"""Workflow plugin: modulo operation."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class MathModulo(NodeExecutor):
"""Calculate a modulo b."""
a = inputs.get("a", 0)
b = inputs.get("b", 1)
if b == 0:
return {"result": None, "error": "Modulo by zero"}
node_type = "math.modulo"
category = "math"
description = "Calculate a modulo b"
return {"result": a % b}
def execute(self, inputs, runtime=None):
try:
a = float(inputs.get("a", 0))
b = float(inputs.get("b", 0))
if b == 0:
return {"error": "Modulo by zero"}
return {"result": a % b}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_modulo",
"version": "1.0.0",
"description": "math_modulo plugin",
"description": "Calculate a modulo b",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_modulo.py",
"files": ["math_modulo.py", "factory.py"],
"metadata": {
"plugin_type": "math.modulo",
"category": "math"
"category": "math",
"class": "MathModulo",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathMultiply plugin."""
from .math_multiply import MathMultiply
def create():
return MathMultiply()

View File

@@ -1,10 +1,22 @@
"""Workflow plugin: multiply numbers."""
from functools import reduce
from operator import mul
def run(_runtime, inputs):
"""Multiply two or more numbers."""
numbers = inputs.get("numbers", [])
result = 1
for num in numbers:
result *= num
return {"result": result}
from ...base import NodeExecutor
class MathMultiply(NodeExecutor):
"""Multiply numbers together."""
node_type = "math.multiply"
category = "math"
description = "Multiply numbers together"
def execute(self, inputs, runtime=None):
numbers = inputs.get("numbers", inputs.get("values", []))
try:
result = reduce(mul, (float(n) for n in numbers), 1)
return {"result": result}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_multiply",
"version": "1.0.0",
"description": "math_multiply plugin",
"description": "Multiply numbers together",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_multiply.py",
"files": ["math_multiply.py", "factory.py"],
"metadata": {
"plugin_type": "math.multiply",
"category": "math"
"category": "math",
"class": "MathMultiply",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathPower plugin."""
from .math_power import MathPower
def create():
return MathPower()

View File

@@ -1,8 +1,19 @@
"""Workflow plugin: power operation."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Calculate a to the power of b."""
a = inputs.get("a", 0)
b = inputs.get("b", 1)
return {"result": a ** b}
class MathPower(NodeExecutor):
"""Raise base to exponent power."""
node_type = "math.power"
category = "math"
description = "Raise base to exponent power"
def execute(self, inputs, runtime=None):
try:
a = float(inputs.get("a", inputs.get("base", 0)))
b = float(inputs.get("b", inputs.get("exponent", 0)))
return {"result": a**b}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_power",
"version": "1.0.0",
"description": "math_power plugin",
"description": "Raise base to exponent power",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_power.py",
"files": ["math_power.py", "factory.py"],
"metadata": {
"plugin_type": "math.power",
"category": "math"
"category": "math",
"class": "MathPower",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathRound plugin."""
from .math_round import MathRound
def create():
return MathRound()

View File

@@ -1,8 +1,19 @@
"""Workflow plugin: round number."""
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Round number to specified precision."""
value = inputs.get("value", 0)
precision = inputs.get("precision", 0)
return {"result": round(value, precision)}
class MathRound(NodeExecutor):
"""Round to specified decimals."""
node_type = "math.round"
category = "math"
description = "Round to specified decimals"
def execute(self, inputs, runtime=None):
try:
value = float(inputs.get("value", 0))
decimals = int(inputs.get("decimals", inputs.get("precision", 0)))
return {"result": round(value, decimals)}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_round",
"version": "1.0.0",
"description": "math_round plugin",
"description": "Round to specified decimals",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_round.py",
"files": ["math_round.py", "factory.py"],
"metadata": {
"plugin_type": "math.round",
"category": "math"
"category": "math",
"class": "MathRound",
"entrypoint": "execute"
}
}

View File

@@ -0,0 +1,7 @@
"""Factory for MathSubtract plugin."""
from .math_subtract import MathSubtract
def create():
return MathSubtract()

View File

@@ -1,8 +1,19 @@
"""Workflow plugin: subtract numbers."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class MathSubtract(NodeExecutor):
"""Subtract b from a."""
a = inputs.get("a", 0)
b = inputs.get("b", 0)
return {"result": a - b}
node_type = "math.subtract"
category = "math"
description = "Subtract b from a"
def execute(self, inputs, runtime=None):
try:
a = float(inputs.get("a", 0))
b = float(inputs.get("b", 0))
return {"result": a - b}
except (ValueError, TypeError) as e:
return {"error": str(e)}

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/math_subtract",
"version": "1.0.0",
"description": "math_subtract plugin",
"description": "Subtract b from a",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["math", "workflow", "plugin"],
"main": "math_subtract.py",
"files": ["math_subtract.py", "factory.py"],
"metadata": {
"plugin_type": "math.subtract",
"category": "math"
"category": "math",
"class": "MathSubtract",
"entrypoint": "execute"
}
}