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,18 +1,27 @@
"""Workflow plugin: build tool map for function dispatch."""
from ...base import NodeExecutor
def run(runtime, inputs):
"""Build a map from tool names to their handlers.
This reads plugins from context and builds a dispatch map.
"""
plugins = runtime.context.get("plugins", {})
class BuildToolMap(NodeExecutor):
"""Build a map from tool names to their handlers."""
tool_map = {}
for plugin_type, plugin_info in plugins.items():
# Map plugin_type (e.g., "math.add") to handler info
tool_map[plugin_type] = plugin_info
node_type = "backend.build_tool_map"
category = "backend"
description = "Build tool map for function dispatch"
runtime.context["tool_map"] = tool_map
def execute(self, inputs, runtime=None):
"""Build a map from tool names to their handlers.
return {"success": True, "tool_count": len(tool_map)}
This reads plugins from context and builds a dispatch map.
"""
plugins = runtime.context.get("plugins", {})
tool_map = {}
for plugin_type, plugin_info in plugins.items():
# Map plugin_type (e.g., "math.add") to handler info
tool_map[plugin_type] = plugin_info
runtime.context["tool_map"] = tool_map
return {"success": True, "tool_count": len(tool_map)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "tools"],
"main": "backend_build_tool_map.py",
"files": ["backend_build_tool_map.py", "factory.py"],
"metadata": {
"plugin_type": "backend.build_tool_map",
"category": "backend"
"category": "backend",
"class": "BuildToolMap",
"entrypoint": "execute"
}
}

View File

@@ -1,35 +1,45 @@
"""Workflow plugin: configure logging."""
import logging
import sys
from ...base import NodeExecutor
def run(runtime, inputs):
"""Configure logging for the workflow runtime.
Inputs:
level: Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
format: Log format string
file: Optional file path for log output
"""
level_str = inputs.get("level", "INFO").upper()
log_format = inputs.get("format", "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
log_file = inputs.get("file")
class ConfigureLogging(NodeExecutor):
"""Configure logging for the workflow runtime."""
level = getattr(logging, level_str, logging.INFO)
node_type = "backend.configure_logging"
category = "backend"
description = "Configure logging for workflow runtime"
handlers = [logging.StreamHandler(sys.stdout)]
if log_file:
handlers.append(logging.FileHandler(log_file))
def execute(self, inputs, runtime=None):
"""Configure logging for the workflow runtime.
logging.basicConfig(
level=level,
format=log_format,
handlers=handlers
)
Inputs:
level: Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
format: Log format string
file: Optional file path for log output
"""
level_str = inputs.get("level", "INFO").upper()
log_format = inputs.get("format", "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
log_file = inputs.get("file")
logger = logging.getLogger("metabuilder")
logger.setLevel(level)
level = getattr(logging, level_str, logging.INFO)
runtime.context["logger"] = logger
handlers = [logging.StreamHandler(sys.stdout)]
if log_file:
handlers.append(logging.FileHandler(log_file))
return {"success": True, "level": level_str}
logging.basicConfig(
level=level,
format=log_format,
handlers=handlers
)
logger = logging.getLogger("metabuilder")
logger.setLevel(level)
runtime.context["logger"] = logger
return {"success": True, "level": level_str}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "logging"],
"main": "backend_configure_logging.py",
"files": ["backend_configure_logging.py", "factory.py"],
"metadata": {
"plugin_type": "backend.configure_logging",
"category": "backend"
"category": "backend",
"class": "ConfigureLogging",
"entrypoint": "execute"
}
}

View File

@@ -1,18 +1,28 @@
"""Workflow plugin: create Discord client."""
import os
from ...base import NodeExecutor
def run(runtime, inputs):
"""Create a Discord webhook client and store in runtime context.
Inputs:
webhook_url: Discord webhook URL (defaults to DISCORD_WEBHOOK_URL env var)
"""
webhook_url = inputs.get("webhook_url") or os.getenv("DISCORD_WEBHOOK_URL")
class CreateDiscord(NodeExecutor):
"""Create a Discord webhook client and store in runtime context."""
if not webhook_url:
return {"success": False, "error": "No webhook URL provided"}
node_type = "backend.create_discord"
category = "backend"
description = "Create Discord webhook client for notifications"
runtime.context["discord_webhook"] = webhook_url
def execute(self, inputs, runtime=None):
"""Create a Discord webhook client and store in runtime context.
return {"success": True}
Inputs:
webhook_url: Discord webhook URL (defaults to DISCORD_WEBHOOK_URL env var)
"""
webhook_url = inputs.get("webhook_url") or os.getenv("DISCORD_WEBHOOK_URL")
if not webhook_url:
return {"success": False, "error": "No webhook URL provided"}
runtime.context["discord_webhook"] = webhook_url
return {"success": True}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "discord"],
"main": "backend_create_discord.py",
"files": ["backend_create_discord.py", "factory.py"],
"metadata": {
"plugin_type": "backend.create_discord",
"category": "backend"
"category": "backend",
"class": "CreateDiscord",
"entrypoint": "execute"
}
}

View File

@@ -1,25 +1,35 @@
"""Workflow plugin: create GitHub client."""
import os
from ...base import NodeExecutor
def run(runtime, inputs):
"""Create a GitHub client and store in runtime context.
Inputs:
token: GitHub token (defaults to GITHUB_TOKEN env var)
"""
try:
from github import Github
except ImportError:
return {"success": False, "error": "PyGithub package not installed"}
class CreateGitHub(NodeExecutor):
"""Create a GitHub client and store in runtime context."""
token = inputs.get("token") or os.getenv("GITHUB_TOKEN")
node_type = "backend.create_github"
category = "backend"
description = "Create GitHub client for repository operations"
if not token:
return {"success": False, "error": "No token provided"}
def execute(self, inputs, runtime=None):
"""Create a GitHub client and store in runtime context.
client = Github(token)
Inputs:
token: GitHub token (defaults to GITHUB_TOKEN env var)
"""
try:
from github import Github
except ImportError:
return {"success": False, "error": "PyGithub package not installed"}
runtime.context["github"] = client
token = inputs.get("token") or os.getenv("GITHUB_TOKEN")
return {"success": True}
if not token:
return {"success": False, "error": "No token provided"}
client = Github(token)
runtime.context["github"] = client
return {"success": True}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "github"],
"main": "backend_create_github.py",
"files": ["backend_create_github.py", "factory.py"],
"metadata": {
"plugin_type": "backend.create_github",
"category": "backend"
"category": "backend",
"class": "CreateGitHub",
"entrypoint": "execute"
}
}

View File

@@ -1,28 +1,38 @@
"""Workflow plugin: create OpenAI client."""
import os
from ...base import NodeExecutor
def run(runtime, inputs):
"""Create an OpenAI client and store in runtime context.
Inputs:
api_key: OpenAI API key (defaults to OPENAI_API_KEY env var)
model: Model name (default: gpt-4)
"""
try:
from openai import OpenAI
except ImportError:
return {"success": False, "error": "openai package not installed"}
class CreateOpenAI(NodeExecutor):
"""Create an OpenAI client and store in runtime context."""
api_key = inputs.get("api_key") or os.getenv("OPENAI_API_KEY")
model = inputs.get("model", "gpt-4")
node_type = "backend.create_openai"
category = "backend"
description = "Create OpenAI client for AI operations"
if not api_key:
return {"success": False, "error": "No API key provided"}
def execute(self, inputs, runtime=None):
"""Create an OpenAI client and store in runtime context.
client = OpenAI(api_key=api_key)
Inputs:
api_key: OpenAI API key (defaults to OPENAI_API_KEY env var)
model: Model name (default: gpt-4)
"""
try:
from openai import OpenAI
except ImportError:
return {"success": False, "error": "openai package not installed"}
runtime.context["client"] = client
runtime.context["model_name"] = model
api_key = inputs.get("api_key") or os.getenv("OPENAI_API_KEY")
model = inputs.get("model", "gpt-4")
return {"success": True, "model": model}
if not api_key:
return {"success": False, "error": "No API key provided"}
client = OpenAI(api_key=api_key)
runtime.context["client"] = client
runtime.context["model_name"] = model
return {"success": True, "model": model}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "openai", "ai"],
"main": "backend_create_openai.py",
"files": ["backend_create_openai.py", "factory.py"],
"metadata": {
"plugin_type": "backend.create_openai",
"category": "backend"
"category": "backend",
"class": "CreateOpenAI",
"entrypoint": "execute"
}
}

View File

@@ -1,25 +1,35 @@
"""Workflow plugin: create Slack client."""
import os
from ...base import NodeExecutor
def run(runtime, inputs):
"""Create a Slack client and store in runtime context.
Inputs:
token: Slack bot token (defaults to SLACK_BOT_TOKEN env var)
"""
try:
from slack_sdk import WebClient
except ImportError:
return {"success": False, "error": "slack_sdk package not installed"}
class CreateSlack(NodeExecutor):
"""Create a Slack client and store in runtime context."""
token = inputs.get("token") or os.getenv("SLACK_BOT_TOKEN")
node_type = "backend.create_slack"
category = "backend"
description = "Create Slack client for messaging"
if not token:
return {"success": False, "error": "No token provided"}
def execute(self, inputs, runtime=None):
"""Create a Slack client and store in runtime context.
client = WebClient(token=token)
Inputs:
token: Slack bot token (defaults to SLACK_BOT_TOKEN env var)
"""
try:
from slack_sdk import WebClient
except ImportError:
return {"success": False, "error": "slack_sdk package not installed"}
runtime.context["slack"] = client
token = inputs.get("token") or os.getenv("SLACK_BOT_TOKEN")
return {"success": True}
if not token:
return {"success": False, "error": "No token provided"}
client = WebClient(token=token)
runtime.context["slack"] = client
return {"success": True}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "slack"],
"main": "backend_create_slack.py",
"files": ["backend_create_slack.py", "factory.py"],
"metadata": {
"plugin_type": "backend.create_slack",
"category": "backend"
"category": "backend",
"class": "CreateSlack",
"entrypoint": "execute"
}
}

View File

@@ -1,20 +1,31 @@
"""Workflow plugin: load environment variables."""
import os
from dotenv import load_dotenv
from ...base import NodeExecutor
def run(_runtime, inputs):
"""Load environment variables from .env file.
Inputs:
path: Optional path to .env file (default: .env)
override: Whether to override existing env vars (default: False)
"""
path = inputs.get("path", ".env")
override = inputs.get("override", False)
class LoadEnv(NodeExecutor):
"""Load environment variables from .env file."""
if os.path.exists(path):
load_dotenv(path, override=override)
return {"success": True, "path": path}
node_type = "backend.load_env"
category = "backend"
description = "Load environment variables from .env file"
return {"success": False, "error": f"File not found: {path}"}
def execute(self, inputs, runtime=None):
"""Load environment variables from .env file.
Inputs:
path: Optional path to .env file (default: .env)
override: Whether to override existing env vars (default: False)
"""
path = inputs.get("path", ".env")
override = inputs.get("override", False)
if os.path.exists(path):
load_dotenv(path, override=override)
return {"success": True, "path": path}
return {"success": False, "error": f"File not found: {path}"}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "env"],
"main": "backend_load_env.py",
"files": ["backend_load_env.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_env",
"category": "backend"
"category": "backend",
"class": "LoadEnv",
"entrypoint": "execute"
}
}

View File

@@ -1,29 +1,39 @@
"""Workflow plugin: load UI/CLI messages."""
import os
import json
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load UI/CLI messages for localization.
Inputs:
path: Path to messages file
locale: Locale code (default: en)
"""
path = inputs.get("path", "config/messages")
locale = inputs.get("locale", "en")
class LoadMessages(NodeExecutor):
"""Load UI/CLI messages for localization."""
messages_file = os.path.join(path, f"{locale}.json")
node_type = "backend.load_messages"
category = "backend"
description = "Load UI/CLI messages for localization"
if not os.path.exists(messages_file):
messages_file = os.path.join(path, "en.json") # Fallback
def execute(self, inputs, runtime=None):
"""Load UI/CLI messages for localization.
if not os.path.exists(messages_file):
return {"success": False, "error": "No messages file found"}
Inputs:
path: Path to messages file
locale: Locale code (default: en)
"""
path = inputs.get("path", "config/messages")
locale = inputs.get("locale", "en")
with open(messages_file) as f:
messages = json.load(f)
messages_file = os.path.join(path, f"{locale}.json")
runtime.context["msgs"] = messages
if not os.path.exists(messages_file):
messages_file = os.path.join(path, "en.json") # Fallback
return {"success": True, "locale": locale, "message_count": len(messages)}
if not os.path.exists(messages_file):
return {"success": False, "error": "No messages file found"}
with open(messages_file) as f:
messages = json.load(f)
runtime.context["msgs"] = messages
return {"success": True, "locale": locale, "message_count": len(messages)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "messages", "i18n"],
"main": "backend_load_messages.py",
"files": ["backend_load_messages.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_messages",
"category": "backend"
"category": "backend",
"class": "LoadMessages",
"entrypoint": "execute"
}
}

View File

@@ -1,26 +1,36 @@
"""Workflow plugin: load workflow metadata."""
import os
import json
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load workflow metadata from package.json or config.
Inputs:
path: Path to metadata file
"""
path = inputs.get("path", "package.json")
class LoadMetadata(NodeExecutor):
"""Load workflow metadata from package.json or config."""
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
node_type = "backend.load_metadata"
category = "backend"
description = "Load workflow metadata from config"
with open(path) as f:
metadata = json.load(f)
def execute(self, inputs, runtime=None):
"""Load workflow metadata from package.json or config.
runtime.context["metadata"] = metadata
Inputs:
path: Path to metadata file
"""
path = inputs.get("path", "package.json")
return {
"success": True,
"name": metadata.get("name"),
"version": metadata.get("version")
}
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
with open(path) as f:
metadata = json.load(f)
runtime.context["metadata"] = metadata
return {
"success": True,
"name": metadata.get("name"),
"version": metadata.get("version")
}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "metadata"],
"main": "backend_load_metadata.py",
"files": ["backend_load_metadata.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_metadata",
"category": "backend"
"category": "backend",
"class": "LoadMetadata",
"entrypoint": "execute"
}
}

View File

@@ -1,50 +1,59 @@
"""Workflow plugin: load workflow plugins."""
import os
import json
import importlib.util
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load workflow plugins from directory.
class LoadPlugins(NodeExecutor):
"""Load workflow plugins from directory."""
Inputs:
path: Path to plugins directory
"""
path = inputs.get("path", "workflow/plugins/python")
node_type = "backend.load_plugins"
category = "backend"
description = "Load workflow plugins from directory"
if not os.path.exists(path):
return {"success": False, "error": f"Path not found: {path}"}
def execute(self, inputs, runtime=None):
"""Load workflow plugins from directory.
plugins = {}
categories = []
Inputs:
path: Path to plugins directory
"""
path = inputs.get("path", "workflow/plugins/python")
for category in os.listdir(path):
category_path = os.path.join(path, category)
if not os.path.isdir(category_path) or category.startswith("_"):
continue
if not os.path.exists(path):
return {"success": False, "error": f"Path not found: {path}"}
categories.append(category)
plugins = {}
categories = []
for plugin_name in os.listdir(category_path):
plugin_path = os.path.join(category_path, plugin_name)
if not os.path.isdir(plugin_path):
for category in os.listdir(path):
category_path = os.path.join(path, category)
if not os.path.isdir(category_path) or category.startswith("_"):
continue
package_json = os.path.join(plugin_path, "package.json")
if os.path.exists(package_json):
with open(package_json) as f:
metadata = json.load(f)
plugin_type = metadata.get("metadata", {}).get("plugin_type")
if plugin_type:
plugins[plugin_type] = {
"path": plugin_path,
"metadata": metadata
}
categories.append(category)
runtime.context["plugins"] = plugins
for plugin_name in os.listdir(category_path):
plugin_path = os.path.join(category_path, plugin_name)
if not os.path.isdir(plugin_path):
continue
return {
"success": True,
"categories": categories,
"plugin_count": len(plugins)
}
package_json = os.path.join(plugin_path, "package.json")
if os.path.exists(package_json):
with open(package_json) as f:
metadata = json.load(f)
plugin_type = metadata.get("metadata", {}).get("plugin_type")
if plugin_type:
plugins[plugin_type] = {
"path": plugin_path,
"metadata": metadata
}
runtime.context["plugins"] = plugins
return {
"success": True,
"categories": categories,
"plugin_count": len(plugins)
}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "loader"],
"main": "backend_load_plugins.py",
"files": ["backend_load_plugins.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_plugins",
"category": "backend"
"category": "backend",
"class": "LoadPlugins",
"entrypoint": "execute"
}
}

View File

@@ -1,21 +1,31 @@
"""Workflow plugin: load system prompt."""
import os
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load system prompt from file.
Inputs:
path: Path to prompt file
"""
path = inputs.get("path", "config/system_prompt.txt")
class LoadPrompt(NodeExecutor):
"""Load system prompt from file."""
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
node_type = "backend.load_prompt"
category = "backend"
description = "Load system prompt from file"
with open(path) as f:
prompt = f.read()
def execute(self, inputs, runtime=None):
"""Load system prompt from file.
runtime.context["system_prompt"] = prompt
Inputs:
path: Path to prompt file
"""
path = inputs.get("path", "config/system_prompt.txt")
return {"success": True, "length": len(prompt)}
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
with open(path) as f:
prompt = f.read()
runtime.context["system_prompt"] = prompt
return {"success": True, "length": len(prompt)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "prompt", "ai"],
"main": "backend_load_prompt.py",
"files": ["backend_load_prompt.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_prompt",
"category": "backend"
"category": "backend",
"class": "LoadPrompt",
"entrypoint": "execute"
}
}

View File

@@ -1,24 +1,34 @@
"""Workflow plugin: load tool policies."""
import os
import json
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load tool policies for access control.
Inputs:
path: Path to tool policies file
"""
path = inputs.get("path", "config/tool_policies.json")
class LoadToolPolicies(NodeExecutor):
"""Load tool policies for access control."""
if not os.path.exists(path):
# Default to permissive if no policies file
runtime.context["tool_policies"] = {}
return {"success": True, "policy_count": 0}
node_type = "backend.load_tool_policies"
category = "backend"
description = "Load tool policies for access control"
with open(path) as f:
policies = json.load(f)
def execute(self, inputs, runtime=None):
"""Load tool policies for access control.
runtime.context["tool_policies"] = policies
Inputs:
path: Path to tool policies file
"""
path = inputs.get("path", "config/tool_policies.json")
return {"success": True, "policy_count": len(policies)}
if not os.path.exists(path):
# Default to permissive if no policies file
runtime.context["tool_policies"] = {}
return {"success": True, "policy_count": 0}
with open(path) as f:
policies = json.load(f)
runtime.context["tool_policies"] = policies
return {"success": True, "policy_count": len(policies)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "tools", "policy"],
"main": "backend_load_tool_policies.py",
"files": ["backend_load_tool_policies.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_tool_policies",
"category": "backend"
"category": "backend",
"class": "LoadToolPolicies",
"entrypoint": "execute"
}
}

View File

@@ -1,22 +1,32 @@
"""Workflow plugin: load tool registry."""
import os
import json
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load tool registry defining available AI tools.
Inputs:
path: Path to tool registry file
"""
path = inputs.get("path", "config/tool_registry.json")
class LoadToolRegistry(NodeExecutor):
"""Load tool registry defining available AI tools."""
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
node_type = "backend.load_tool_registry"
category = "backend"
description = "Load tool registry for AI function calling"
with open(path) as f:
registry = json.load(f)
def execute(self, inputs, runtime=None):
"""Load tool registry defining available AI tools.
runtime.context["tool_registry"] = registry
Inputs:
path: Path to tool registry file
"""
path = inputs.get("path", "config/tool_registry.json")
return {"success": True, "tool_count": len(registry)}
if not os.path.exists(path):
return {"success": False, "error": f"File not found: {path}"}
with open(path) as f:
registry = json.load(f)
runtime.context["tool_registry"] = registry
return {"success": True, "tool_count": len(registry)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "tools", "registry"],
"main": "backend_load_tool_registry.py",
"files": ["backend_load_tool_registry.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_tool_registry",
"category": "backend"
"category": "backend",
"class": "LoadToolRegistry",
"entrypoint": "execute"
}
}

View File

@@ -1,27 +1,37 @@
"""Workflow plugin: load tools for AI function calling."""
import os
import json
from ...base import NodeExecutor
def run(runtime, inputs):
"""Load tool definitions for AI function calling.
Inputs:
path: Path to tools definition file or directory
"""
path = inputs.get("path", "config/tools.json")
class LoadTools(NodeExecutor):
"""Load tool definitions for AI function calling."""
tools = []
node_type = "backend.load_tools"
category = "backend"
description = "Load tool definitions for AI function calling"
if os.path.isfile(path):
with open(path) as f:
tools = json.load(f)
elif os.path.isdir(path):
for filename in os.listdir(path):
if filename.endswith(".json"):
with open(os.path.join(path, filename)) as f:
tools.extend(json.load(f))
def execute(self, inputs, runtime=None):
"""Load tool definitions for AI function calling.
runtime.context["tools"] = tools
Inputs:
path: Path to tools definition file or directory
"""
path = inputs.get("path", "config/tools.json")
return {"success": True, "tool_count": len(tools)}
tools = []
if os.path.isfile(path):
with open(path) as f:
tools = json.load(f)
elif os.path.isdir(path):
for filename in os.listdir(path):
if filename.endswith(".json"):
with open(os.path.join(path, filename)) as f:
tools.extend(json.load(f))
runtime.context["tools"] = tools
return {"success": True, "tool_count": len(tools)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "tools", "ai"],
"main": "backend_load_tools.py",
"files": ["backend_load_tools.py", "factory.py"],
"metadata": {
"plugin_type": "backend.load_tools",
"category": "backend"
"category": "backend",
"class": "LoadTools",
"entrypoint": "execute"
}
}

View File

@@ -1,27 +1,37 @@
"""Workflow plugin: parse CLI arguments."""
import argparse
from ...base import NodeExecutor
def run(runtime, inputs):
"""Parse command line arguments.
Inputs:
args: Optional list of arguments (defaults to sys.argv)
"""
parser = argparse.ArgumentParser(description="MetaBuilder Workflow")
class ParseCliArgs(NodeExecutor):
"""Parse command line arguments."""
parser.add_argument("--config", "-c", default="config.json",
help="Path to configuration file")
parser.add_argument("--workflow", "-w",
help="Path to workflow file")
parser.add_argument("--verbose", "-v", action="store_true",
help="Enable verbose output")
parser.add_argument("--dry-run", action="store_true",
help="Simulate workflow execution")
node_type = "backend.parse_cli_args"
category = "backend"
description = "Parse command line arguments"
args_list = inputs.get("args")
parsed = parser.parse_args(args_list)
def execute(self, inputs, runtime=None):
"""Parse command line arguments.
runtime.context["cli_args"] = vars(parsed)
Inputs:
args: Optional list of arguments (defaults to sys.argv)
"""
parser = argparse.ArgumentParser(description="MetaBuilder Workflow")
return {"success": True, "args": vars(parsed)}
parser.add_argument("--config", "-c", default="config.json",
help="Path to configuration file")
parser.add_argument("--workflow", "-w",
help="Path to workflow file")
parser.add_argument("--verbose", "-v", action="store_true",
help="Enable verbose output")
parser.add_argument("--dry-run", action="store_true",
help="Simulate workflow execution")
args_list = inputs.get("args")
parsed = parser.parse_args(args_list)
runtime.context["cli_args"] = vars(parsed)
return {"success": True, "args": vars(parsed)}

View File

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

View File

@@ -6,8 +6,11 @@
"license": "MIT",
"keywords": ["backend", "workflow", "plugin", "cli", "args"],
"main": "backend_parse_cli_args.py",
"files": ["backend_parse_cli_args.py", "factory.py"],
"metadata": {
"plugin_type": "backend.parse_cli_args",
"category": "backend"
"category": "backend",
"class": "ParseCliArgs",
"entrypoint": "execute"
}
}