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,8 @@
"""Factory for ToolsRunDocker plugin."""
from .tools_run_docker import ToolsRunDocker
def create():
"""Create and return a ToolsRunDocker instance."""
return ToolsRunDocker()

View File

@@ -1,13 +1,16 @@
{
"name": "@metabuilder/tools_run_docker",
"version": "1.0.0",
"description": "tools_run_docker plugin",
"description": "Run a command inside a Docker container with optional volumes and working directory",
"author": "MetaBuilder",
"license": "MIT",
"keywords": ["tools", "workflow", "plugin"],
"keywords": ["tools", "workflow", "plugin", "docker"],
"main": "tools_run_docker.py",
"files": ["tools_run_docker.py", "factory.py"],
"metadata": {
"plugin_type": "tools.run_docker",
"category": "tools"
"category": "tools",
"class": "ToolsRunDocker",
"entrypoint": "execute"
}
}

View File

@@ -1,59 +1,68 @@
"""Workflow plugin: run command in Docker container."""
import subprocess
import os
import logging
from ...base import NodeExecutor
logger = logging.getLogger("metabuilder.docker")
def _run_command_in_docker(image: str, command: str, volumes: dict = None, workdir: str = None):
"""Run a command inside a Docker container.
class ToolsRunDocker(NodeExecutor):
"""Run a command inside a Docker container."""
:param image: Docker image to use.
:param command: Command to execute.
:param volumes: Dictionary of volume mappings {host_path: container_path}.
:param workdir: Working directory inside the container.
:return: Standard output of the command.
"""
docker_command = ["docker", "run", "--rm"]
node_type = "tools.run_docker"
category = "tools"
description = "Run a command inside a Docker container with optional volumes and working directory"
if volumes:
for host_path, container_path in volumes.items():
docker_command.extend(["-v", f"{os.path.abspath(host_path)}:{container_path}"])
def execute(self, inputs, runtime=None):
"""Run a command inside a Docker container.
if workdir:
docker_command.extend(["-w", workdir])
Inputs:
- image: Docker image to use
- command: Command to execute
- volumes: Optional dict of volume mappings {host_path: container_path}
- workdir: Optional working directory inside the container
"""
image = inputs.get("image")
command = inputs.get("command")
volumes = inputs.get("volumes")
workdir = inputs.get("workdir")
docker_command.append(image)
docker_command.extend(["sh", "-c", command])
if not image or not command:
return {"error": "Both 'image' and 'command' are required"}
logger.info(f"Executing in Docker ({image}): {command}")
result = subprocess.run(docker_command, capture_output=True, text=True, check=False)
output = self._run_command_in_docker(image, command, volumes, workdir)
return {"output": output}
output = result.stdout
if result.stderr:
output += "\n" + result.stderr
def _run_command_in_docker(self, image: str, command: str, volumes: dict = None, workdir: str = None):
"""Run a command inside a Docker container.
logger.info(output)
return output
:param image: Docker image to use.
:param command: Command to execute.
:param volumes: Dictionary of volume mappings {host_path: container_path}.
:param workdir: Working directory inside the container.
:return: Standard output of the command.
"""
docker_command = ["docker", "run", "--rm"]
if volumes:
for host_path, container_path in volumes.items():
docker_command.extend(["-v", f"{os.path.abspath(host_path)}:{container_path}"])
def run(_runtime, inputs):
"""Run a command inside a Docker container.
if workdir:
docker_command.extend(["-w", workdir])
Inputs:
- image: Docker image to use
- command: Command to execute
- volumes: Optional dict of volume mappings {host_path: container_path}
- workdir: Optional working directory inside the container
"""
image = inputs.get("image")
command = inputs.get("command")
volumes = inputs.get("volumes")
workdir = inputs.get("workdir")
docker_command.append(image)
docker_command.extend(["sh", "-c", command])
if not image or not command:
return {"error": "Both 'image' and 'command' are required"}
logger.info(f"Executing in Docker ({image}): {command}")
result = subprocess.run(docker_command, capture_output=True, text=True, check=False)
output = _run_command_in_docker(image, command, volumes, workdir)
return {"output": output}
output = result.stdout
if result.stderr:
output += "\n" + result.stderr
logger.info(output)
return output