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

@@ -1,5 +1,7 @@
"""Workflow plugin: get current bot execution status."""
from ...base import NodeExecutor
# Global state for bot process
_bot_process = None
_mock_running = False
@@ -27,13 +29,20 @@ def reset_bot_state():
_mock_running = False
def run(_runtime, _inputs):
"""Get current bot execution status.
class ControlGetBotStatus(NodeExecutor):
"""Get current bot execution status."""
Returns:
Dictionary with:
- is_running: bool - Whether the bot is currently running
- config: dict - Current run configuration (empty if not running)
- process: object - Bot process object (or None if not running)
"""
return get_bot_state()
node_type = "control.get_bot_status"
category = "control"
description = "Get current bot execution status"
def execute(self, inputs, runtime=None):
"""Get current bot execution status.
Returns:
Dictionary with:
- is_running: bool - Whether the bot is currently running
- config: dict - Current run configuration (empty if not running)
- process: object - Bot process object (or None if not running)
"""
return get_bot_state()

View File

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

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/control_get_bot_status",
"version": "1.0.0",
"description": "control_get_bot_status plugin",
"description": "Get current bot execution status",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["control", "workflow", "plugin"],
"main": "control_get_bot_status.py",
"files": ["control_get_bot_status.py", "factory.py"],
"metadata": {
"plugin_type": "control.get_bot_status",
"category": "control"
"category": "control",
"class": "ControlGetBotStatus",
"entrypoint": "execute"
}
}

View File

@@ -1,13 +1,22 @@
"""Workflow plugin: reset bot execution state."""
from .control_get_bot_status import reset_bot_state
from ...base import NodeExecutor
from ..control_get_bot_status.control_get_bot_status import reset_bot_state
def run(_runtime, _inputs):
"""Reset bot execution state.
class ControlResetBotState(NodeExecutor):
"""Reset bot execution state."""
Returns:
Dictionary with:
- reset: bool - Always True to indicate state was reset
"""
reset_bot_state()
return {"reset": True}
node_type = "control.reset_bot_state"
category = "control"
description = "Reset bot execution state"
def execute(self, inputs, runtime=None):
"""Reset bot execution state.
Returns:
Dictionary with:
- reset: bool - Always True to indicate state was reset
"""
reset_bot_state()
return {"reset": True}

View File

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

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/control_reset_bot_state",
"version": "1.0.0",
"description": "control_reset_bot_state plugin",
"description": "Reset bot execution state",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["control", "workflow", "plugin"],
"main": "control_reset_bot_state.py",
"files": ["control_reset_bot_state.py", "factory.py"],
"metadata": {
"plugin_type": "control.reset_bot_state",
"category": "control"
"category": "control",
"class": "ControlResetBotState",
"entrypoint": "execute"
}
}

View File

@@ -1,20 +1,19 @@
"""Workflow plugin: start bot execution in background thread."""
import os
import subprocess
import sys
import threading
import time
from .control_get_bot_status import (
from ...base import NodeExecutor
from ..control_get_bot_status.control_get_bot_status import (
get_bot_state,
reset_bot_state,
_bot_process,
_mock_running,
_current_run_config
)
# Import global state
import workflow.plugins.python.control.control_get_bot_status as bot_status
import workflow.plugins.python.control.control_get_bot_status.control_get_bot_status as bot_status
def _run_bot_task(mode: str, iterations: int, yolo: bool, stop_at_mvp: bool) -> None:
@@ -61,37 +60,44 @@ def _run_bot_task(mode: str, iterations: int, yolo: bool, stop_at_mvp: bool) ->
reset_bot_state()
def run(_runtime, inputs):
"""Start bot execution in background thread.
class ControlStartBot(NodeExecutor):
"""Start bot execution in background thread."""
Args:
inputs: Dictionary with keys:
- mode: str (default: "once") - Execution mode ("once", "iterations", etc.)
- iterations: int (default: 1) - Number of iterations for "iterations" mode
- yolo: bool (default: True) - Run in YOLO mode
- stop_at_mvp: bool (default: False) - Stop when MVP is reached
node_type = "control.start_bot"
category = "control"
description = "Start bot execution in background thread"
Returns:
Dictionary with:
- started: bool - Whether the bot was started successfully
- error: str (optional) - Error message if bot is already running
"""
mode = inputs.get("mode", "once")
iterations = inputs.get("iterations", 1)
yolo = inputs.get("yolo", True)
stop_at_mvp = inputs.get("stop_at_mvp", False)
def execute(self, inputs, runtime=None):
"""Start bot execution in background thread.
# Check if bot is already running
state = get_bot_state()
if state["is_running"]:
return {"started": False, "error": "Bot already running"}
Args:
inputs: Dictionary with keys:
- mode: str (default: "once") - Execution mode ("once", "iterations", etc.)
- iterations: int (default: 1) - Number of iterations for "iterations" mode
- yolo: bool (default: True) - Run in YOLO mode
- stop_at_mvp: bool (default: False) - Stop when MVP is reached
# Start bot in background thread
thread = threading.Thread(
target=_run_bot_task,
args=(mode, iterations, yolo, stop_at_mvp),
daemon=True
)
thread.start()
Returns:
Dictionary with:
- started: bool - Whether the bot was started successfully
- error: str (optional) - Error message if bot is already running
"""
mode = inputs.get("mode", "once")
iterations = inputs.get("iterations", 1)
yolo = inputs.get("yolo", True)
stop_at_mvp = inputs.get("stop_at_mvp", False)
return {"started": True}
# Check if bot is already running
state = get_bot_state()
if state["is_running"]:
return {"started": False, "error": "Bot already running"}
# Start bot in background thread
thread = threading.Thread(
target=_run_bot_task,
args=(mode, iterations, yolo, stop_at_mvp),
daemon=True
)
thread.start()
return {"started": True}

View File

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

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/control_start_bot",
"version": "1.0.0",
"description": "control_start_bot plugin",
"description": "Start bot execution in background thread",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["control", "workflow", "plugin"],
"main": "control_start_bot.py",
"files": ["control_start_bot.py", "factory.py"],
"metadata": {
"plugin_type": "control.start_bot",
"category": "control"
"category": "control",
"class": "ControlStartBot",
"entrypoint": "execute"
}
}

View File

@@ -1,11 +1,32 @@
"""Workflow plugin: switch/case control flow."""
from ...base import NodeExecutor
def run(_runtime, inputs):
class ControlSwitch(NodeExecutor):
"""Switch on value and return matching case."""
value = inputs.get("value")
cases = inputs.get("cases", {})
default = inputs.get("default")
result = cases.get(str(value), default)
return {"result": result, "matched": str(value) in cases}
node_type = "control.switch"
category = "control"
description = "Switch/case control flow"
def execute(self, inputs, runtime=None):
"""Switch on value and return matching case.
Args:
inputs: Dictionary with keys:
- value: The value to switch on
- cases: dict - Map of case values to results
- default: Default value if no case matches
Returns:
Dictionary with:
- result: The matched case value or default
- matched: bool - Whether a case was matched
"""
value = inputs.get("value")
cases = inputs.get("cases", {})
default = inputs.get("default")
result = cases.get(str(value), default)
return {"result": result, "matched": str(value) in cases}

View File

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

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/control_switch",
"version": "1.0.0",
"description": "control_switch plugin",
"description": "Switch/case control flow",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["control", "workflow", "plugin"],
"main": "control_switch.py",
"files": ["control_switch.py", "factory.py"],
"metadata": {
"plugin_type": "control.switch",
"category": "control"
"category": "control",
"class": "ControlSwitch",
"entrypoint": "execute"
}
}