mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 22:34:56 +00:00
feat: Add Python plugins from AutoMetabuilder + restructure workflow folder
Restructure workflow/ for multi-language plugin support:
- Rename src/ to core/ (engine code: DAG executor, registry, types)
- Create executor/{cpp,python,ts}/ for language-specific runtimes
- Consolidate plugins to plugins/{ts,python}/ by language then category
Add 80+ Python plugins from AutoMetabuilder in 14 categories:
- control: bot control, switch logic, state management
- convert: type conversions (json, boolean, dict, list, number, string)
- core: AI requests, context management, tool calls
- dict: dictionary operations (get, set, keys, values, merge)
- list: list operations (concat, find, sort, slice, filter)
- logic: boolean logic (and, or, xor, equals, comparisons)
- math: arithmetic operations (add, subtract, multiply, power, etc.)
- string: string manipulation (concat, split, replace, format)
- notifications: Slack, Discord integrations
- test: assertion helpers and test suite runner
- tools: file operations, git, docker, testing utilities
- utils: filtering, mapping, reducing, condition branching
- var: variable store operations (get, set, delete, exists)
- web: Flask server, environment variables, JSON handling
Add language executor runtimes:
- TypeScript: direct import execution (default, fast startup)
- Python: child process with JSON stdin/stdout communication
- C++: placeholder for native FFI bindings (Phase 3)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1
workflow/plugins/python/convert/__init__.py
Normal file
1
workflow/plugins/python/convert/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Type conversion plugins."""
|
||||
13
workflow/plugins/python/convert/convert_parse_json.py
Normal file
13
workflow/plugins/python/convert/convert_parse_json.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""Workflow plugin: parse JSON string."""
|
||||
import json
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Parse JSON string to object."""
|
||||
text = inputs.get("text", "")
|
||||
|
||||
try:
|
||||
result = json.loads(text)
|
||||
return {"result": result}
|
||||
except json.JSONDecodeError as e:
|
||||
return {"result": None, "error": str(e)}
|
||||
11
workflow/plugins/python/convert/convert_to_boolean.py
Normal file
11
workflow/plugins/python/convert/convert_to_boolean.py
Normal file
@@ -0,0 +1,11 @@
|
||||
"""Workflow plugin: convert to boolean."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to boolean."""
|
||||
value = inputs.get("value")
|
||||
|
||||
if isinstance(value, str):
|
||||
return {"result": value.lower() not in ("false", "0", "", "none", "null")}
|
||||
|
||||
return {"result": bool(value)}
|
||||
17
workflow/plugins/python/convert/convert_to_dict.py
Normal file
17
workflow/plugins/python/convert/convert_to_dict.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""Workflow plugin: convert to dictionary."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to dictionary."""
|
||||
value = inputs.get("value")
|
||||
|
||||
if isinstance(value, dict):
|
||||
return {"result": value}
|
||||
elif isinstance(value, list):
|
||||
# Convert list of [key, value] pairs to dict
|
||||
try:
|
||||
return {"result": dict(value)}
|
||||
except (TypeError, ValueError):
|
||||
return {"result": {}, "error": "Cannot convert list to dict"}
|
||||
else:
|
||||
return {"result": {}}
|
||||
14
workflow/plugins/python/convert/convert_to_json.py
Normal file
14
workflow/plugins/python/convert/convert_to_json.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Workflow plugin: convert to JSON string."""
|
||||
import json
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to JSON string."""
|
||||
value = inputs.get("value")
|
||||
indent = inputs.get("indent")
|
||||
|
||||
try:
|
||||
result = json.dumps(value, indent=indent)
|
||||
return {"result": result}
|
||||
except (TypeError, ValueError) as e:
|
||||
return {"result": None, "error": str(e)}
|
||||
17
workflow/plugins/python/convert/convert_to_list.py
Normal file
17
workflow/plugins/python/convert/convert_to_list.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""Workflow plugin: convert to list."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to list."""
|
||||
value = inputs.get("value")
|
||||
|
||||
if isinstance(value, list):
|
||||
return {"result": value}
|
||||
elif isinstance(value, (tuple, set)):
|
||||
return {"result": list(value)}
|
||||
elif isinstance(value, dict):
|
||||
return {"result": list(value.items())}
|
||||
elif value is None:
|
||||
return {"result": []}
|
||||
else:
|
||||
return {"result": [value]}
|
||||
14
workflow/plugins/python/convert/convert_to_number.py
Normal file
14
workflow/plugins/python/convert/convert_to_number.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Workflow plugin: convert to number."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to number."""
|
||||
value = inputs.get("value")
|
||||
default = inputs.get("default", 0)
|
||||
|
||||
try:
|
||||
if isinstance(value, str) and "." in value:
|
||||
return {"result": float(value)}
|
||||
return {"result": int(value)}
|
||||
except (ValueError, TypeError):
|
||||
return {"result": default, "error": "Cannot convert to number"}
|
||||
7
workflow/plugins/python/convert/convert_to_string.py
Normal file
7
workflow/plugins/python/convert/convert_to_string.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Workflow plugin: convert to string."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Convert value to string."""
|
||||
value = inputs.get("value")
|
||||
return {"result": str(value) if value is not None else ""}
|
||||
Reference in New Issue
Block a user