mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-30 16:54:57 +00:00
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:
7
workflow/plugins/python/logic/logic_and/factory.py
Normal file
7
workflow/plugins/python/logic/logic_and/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicAnd plugin."""
|
||||
|
||||
from .logic_and import LogicAnd
|
||||
|
||||
|
||||
def create():
|
||||
return LogicAnd()
|
||||
@@ -1,7 +1,15 @@
|
||||
"""Workflow plugin: logical AND."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicAnd(NodeExecutor):
|
||||
"""Perform logical AND on values."""
|
||||
values = inputs.get("values", [])
|
||||
return {"result": all(values)}
|
||||
|
||||
node_type = "logic.and"
|
||||
category = "logic"
|
||||
description = "Perform logical AND on values"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
values = inputs.get("values", [])
|
||||
return {"result": all(values)}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_and",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_and plugin",
|
||||
"description": "Perform logical AND on values",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_and.py",
|
||||
"files": ["logic_and.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.and",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicAnd",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_equals/factory.py
Normal file
7
workflow/plugins/python/logic/logic_equals/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicEquals plugin."""
|
||||
|
||||
from .logic_equals import LogicEquals
|
||||
|
||||
|
||||
def create():
|
||||
return LogicEquals()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: equality comparison."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicEquals(NodeExecutor):
|
||||
"""Check if two values are equal."""
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a == b}
|
||||
|
||||
node_type = "logic.equals"
|
||||
category = "logic"
|
||||
description = "Check if two values are equal"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a == b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_equals",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_equals plugin",
|
||||
"description": "Check if two values are equal",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_equals.py",
|
||||
"files": ["logic_equals.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.equals",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicEquals",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_gt/factory.py
Normal file
7
workflow/plugins/python/logic/logic_gt/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicGt plugin."""
|
||||
|
||||
from .logic_gt import LogicGt
|
||||
|
||||
|
||||
def create():
|
||||
return LogicGt()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: greater than comparison."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicGt(NodeExecutor):
|
||||
"""Check if a > b."""
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a > b}
|
||||
|
||||
node_type = "logic.gt"
|
||||
category = "logic"
|
||||
description = "Check if a > b"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a > b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_gt",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_gt plugin",
|
||||
"description": "Check if a > b",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_gt.py",
|
||||
"files": ["logic_gt.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.gt",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicGt",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_gte/factory.py
Normal file
7
workflow/plugins/python/logic/logic_gte/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicGte plugin."""
|
||||
|
||||
from .logic_gte import LogicGte
|
||||
|
||||
|
||||
def create():
|
||||
return LogicGte()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: greater than or equal comparison."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicGte(NodeExecutor):
|
||||
"""Check if a >= b."""
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a >= b}
|
||||
|
||||
node_type = "logic.gte"
|
||||
category = "logic"
|
||||
description = "Check if a >= b"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a >= b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_gte",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_gte plugin",
|
||||
"description": "Check if a >= b",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_gte.py",
|
||||
"files": ["logic_gte.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.gte",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicGte",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_in/factory.py
Normal file
7
workflow/plugins/python/logic/logic_in/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicIn plugin."""
|
||||
|
||||
from .logic_in import LogicIn
|
||||
|
||||
|
||||
def create():
|
||||
return LogicIn()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: membership test."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicIn(NodeExecutor):
|
||||
"""Check if value is in collection."""
|
||||
value = inputs.get("value")
|
||||
collection = inputs.get("collection", [])
|
||||
return {"result": value in collection}
|
||||
|
||||
node_type = "logic.in"
|
||||
category = "logic"
|
||||
description = "Check if value is in collection"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
value = inputs.get("value")
|
||||
collection = inputs.get("collection", inputs.get("array", []))
|
||||
return {"result": value in collection}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_in",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_in plugin",
|
||||
"description": "Check if value is in collection",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_in.py",
|
||||
"files": ["logic_in.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.in",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicIn",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_lt/factory.py
Normal file
7
workflow/plugins/python/logic/logic_lt/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicLt plugin."""
|
||||
|
||||
from .logic_lt import LogicLt
|
||||
|
||||
|
||||
def create():
|
||||
return LogicLt()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: less than comparison."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicLt(NodeExecutor):
|
||||
"""Check if a < b."""
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a < b}
|
||||
|
||||
node_type = "logic.lt"
|
||||
category = "logic"
|
||||
description = "Check if a < b"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a < b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_lt",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_lt plugin",
|
||||
"description": "Check if a < b",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_lt.py",
|
||||
"files": ["logic_lt.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.lt",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicLt",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_lte/factory.py
Normal file
7
workflow/plugins/python/logic/logic_lte/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicLte plugin."""
|
||||
|
||||
from .logic_lte import LogicLte
|
||||
|
||||
|
||||
def create():
|
||||
return LogicLte()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: less than or equal comparison."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicLte(NodeExecutor):
|
||||
"""Check if a <= b."""
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a <= b}
|
||||
|
||||
node_type = "logic.lte"
|
||||
category = "logic"
|
||||
description = "Check if a <= b"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = inputs.get("a")
|
||||
b = inputs.get("b")
|
||||
return {"result": a <= b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_lte",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_lte plugin",
|
||||
"description": "Check if a <= b",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_lte.py",
|
||||
"files": ["logic_lte.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.lte",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicLte",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_or/factory.py
Normal file
7
workflow/plugins/python/logic/logic_or/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicOr plugin."""
|
||||
|
||||
from .logic_or import LogicOr
|
||||
|
||||
|
||||
def create():
|
||||
return LogicOr()
|
||||
@@ -1,7 +1,15 @@
|
||||
"""Workflow plugin: logical OR."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicOr(NodeExecutor):
|
||||
"""Perform logical OR on values."""
|
||||
values = inputs.get("values", [])
|
||||
return {"result": any(values)}
|
||||
|
||||
node_type = "logic.or"
|
||||
category = "logic"
|
||||
description = "Perform logical OR on values"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
values = inputs.get("values", [])
|
||||
return {"result": any(values)}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_or",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_or plugin",
|
||||
"description": "Perform logical OR on values",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_or.py",
|
||||
"files": ["logic_or.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.or",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicOr",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
7
workflow/plugins/python/logic/logic_xor/factory.py
Normal file
7
workflow/plugins/python/logic/logic_xor/factory.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Factory for LogicXor plugin."""
|
||||
|
||||
from .logic_xor import LogicXor
|
||||
|
||||
|
||||
def create():
|
||||
return LogicXor()
|
||||
@@ -1,8 +1,16 @@
|
||||
"""Workflow plugin: logical XOR."""
|
||||
|
||||
from ...base import NodeExecutor
|
||||
|
||||
def run(_runtime, inputs):
|
||||
|
||||
class LogicXor(NodeExecutor):
|
||||
"""Perform logical XOR on two values."""
|
||||
a = inputs.get("a", False)
|
||||
b = inputs.get("b", False)
|
||||
return {"result": bool(a) != bool(b)}
|
||||
|
||||
node_type = "logic.xor"
|
||||
category = "logic"
|
||||
description = "Perform logical XOR on two values"
|
||||
|
||||
def execute(self, inputs, runtime=None):
|
||||
a = bool(inputs.get("a", False))
|
||||
b = bool(inputs.get("b", False))
|
||||
return {"result": a != b}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
{
|
||||
"name": "@metabuilder/logic_xor",
|
||||
"version": "1.0.0",
|
||||
"description": "logic_xor plugin",
|
||||
"description": "Perform logical XOR on two values",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["logic", "workflow", "plugin"],
|
||||
"main": "logic_xor.py",
|
||||
"files": ["logic_xor.py", "factory.py"],
|
||||
"metadata": {
|
||||
"plugin_type": "logic.xor",
|
||||
"category": "logic"
|
||||
"category": "logic",
|
||||
"class": "LogicXor",
|
||||
"entrypoint": "execute"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user