plexus.cli.procedure.lua_dsl package

Lua DSL Runtime for Plexus Procedures.

This module provides a Lua-based domain-specific language for defining agentic workflows. It enables declarative orchestration through YAML configuration with Lua code for control flow.

Key components: - LuaDSLRuntime: Main execution engine - Primitives: Python implementations of Lua-callable operations - YAML Parser: Configuration validation and loading - Lua Sandbox: Safe, restricted Lua execution environment

class plexus.cli.procedure.lua_dsl.LuaDSLRuntime(procedure_id: str, client, mcp_server, openai_api_key: str | None = None)

Bases: object

Main execution engine for Lua-based procedure workflows.

Responsibilities: - Parse and validate YAML configuration - Setup sandboxed Lua environment - Create and inject primitives - Configure agents with LLMs and tools - Execute Lua workflow code - Return results

Initialize the Lua DSL runtime.

Args:

procedure_id: Unique procedure identifier client: PlexusDashboardClient instance mcp_server: MCP server providing tools openai_api_key: Optional OpenAI API key for LLMs

__init__(procedure_id: str, client, mcp_server, openai_api_key: str | None = None)

Initialize the Lua DSL runtime.

Args:

procedure_id: Unique procedure identifier client: PlexusDashboardClient instance mcp_server: MCP server providing tools openai_api_key: Optional OpenAI API key for LLMs

async execute(yaml_config: str, context: Dict[str, Any] | None = None) Dict[str, Any]

Execute a Lua-based procedure workflow.

Args:

yaml_config: YAML configuration string context: Optional context dict with pre-loaded data

Returns:
Execution results dict with:
  • success: bool

  • result: Any (return value from Lua workflow)

  • state: Final state

  • iterations: Number of iterations

  • tools_used: List of tool names called

  • error: Error message if failed

Raises:

LuaDSLRuntimeError: If execution fails

get_iteration_count() int

Get current iteration count.

get_state() Dict[str, Any]

Get current procedure state.

is_stopped() bool

Check if procedure was stopped.

Subpackages

Submodules