mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 06:44:58 +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/list/__init__.py
Normal file
1
workflow/plugins/python/list/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""List manipulation plugins."""
|
||||
11
workflow/plugins/python/list/list_concat.py
Normal file
11
workflow/plugins/python/list/list_concat.py
Normal file
@@ -0,0 +1,11 @@
|
||||
"""Workflow plugin: concatenate lists."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Concatenate multiple lists."""
|
||||
lists = inputs.get("lists", [])
|
||||
result = []
|
||||
for lst in lists:
|
||||
if isinstance(lst, list):
|
||||
result.extend(lst)
|
||||
return {"result": result}
|
||||
18
workflow/plugins/python/list/list_every.py
Normal file
18
workflow/plugins/python/list/list_every.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""Workflow plugin: check if all items match condition."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Check if all items match condition."""
|
||||
items = inputs.get("items", [])
|
||||
key = inputs.get("key")
|
||||
value = inputs.get("value")
|
||||
|
||||
if not items:
|
||||
return {"result": True}
|
||||
|
||||
if key is not None and value is not None:
|
||||
result = all(isinstance(item, dict) and item.get(key) == value for item in items)
|
||||
else:
|
||||
result = all(items)
|
||||
|
||||
return {"result": result}
|
||||
14
workflow/plugins/python/list/list_find.py
Normal file
14
workflow/plugins/python/list/list_find.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Workflow plugin: find item in list."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Find first item matching condition."""
|
||||
items = inputs.get("items", [])
|
||||
key = inputs.get("key")
|
||||
value = inputs.get("value")
|
||||
|
||||
for item in items:
|
||||
if isinstance(item, dict) and item.get(key) == value:
|
||||
return {"result": item, "found": True}
|
||||
|
||||
return {"result": None, "found": False}
|
||||
7
workflow/plugins/python/list/list_length.py
Normal file
7
workflow/plugins/python/list/list_length.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Workflow plugin: get list length."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Get length of a list or string."""
|
||||
items = inputs.get("items", [])
|
||||
return {"result": len(items) if items is not None else 0}
|
||||
15
workflow/plugins/python/list/list_slice.py
Normal file
15
workflow/plugins/python/list/list_slice.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""Workflow plugin: slice a list."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Extract slice from list."""
|
||||
items = inputs.get("items", [])
|
||||
start = inputs.get("start", 0)
|
||||
end = inputs.get("end")
|
||||
|
||||
if end is None:
|
||||
result = items[start:]
|
||||
else:
|
||||
result = items[start:end]
|
||||
|
||||
return {"result": result}
|
||||
15
workflow/plugins/python/list/list_some.py
Normal file
15
workflow/plugins/python/list/list_some.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""Workflow plugin: check if some items match condition."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Check if at least one item matches condition."""
|
||||
items = inputs.get("items", [])
|
||||
key = inputs.get("key")
|
||||
value = inputs.get("value")
|
||||
|
||||
if key is not None and value is not None:
|
||||
result = any(isinstance(item, dict) and item.get(key) == value for item in items)
|
||||
else:
|
||||
result = any(items)
|
||||
|
||||
return {"result": result}
|
||||
17
workflow/plugins/python/list/list_sort.py
Normal file
17
workflow/plugins/python/list/list_sort.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""Workflow plugin: sort a list."""
|
||||
|
||||
|
||||
def run(_runtime, inputs):
|
||||
"""Sort list by key or naturally."""
|
||||
items = inputs.get("items", [])
|
||||
key = inputs.get("key")
|
||||
reverse = inputs.get("reverse", False)
|
||||
|
||||
try:
|
||||
if key:
|
||||
result = sorted(items, key=lambda x: x.get(key) if isinstance(x, dict) else x, reverse=reverse)
|
||||
else:
|
||||
result = sorted(items, reverse=reverse)
|
||||
return {"result": result}
|
||||
except (TypeError, AttributeError):
|
||||
return {"result": items, "error": "Cannot sort items"}
|
||||
Reference in New Issue
Block a user