Procedure API Reference
Complete reference for all Lua primitives available in workflows.
Procedure Primitives
Control and monitor other procedures.
Procedure.run(name, params)
Invoke a procedure synchronously and wait for result.
Returns: Table containing procedure outputs
local result = Procedure.run("researcher", {
topic = "quantum computing"
})
Log.info("Findings: " .. result.findings)Procedure.spawn(name, params)
Spawn a procedure asynchronously and return handle.
Returns: Handle for monitoring
local handle = Procedure.spawn("researcher", {
topic = "quantum computing"
})
-- Do other work
local result = Procedure.wait(handle)Procedure.status(handle)
Get current status of an async procedure.
Returns: Table with stage, waiting_for_human, iterations, message
local status = Procedure.status(handle)
if status.waiting_for_human then
notify_slack("Waiting for approval")
endProcedure.wait(handle, options)
Wait for async procedure to complete.
local result = Procedure.wait(handle, {timeout = 300})Agent Primitives
Execute agent turns. Agent name determines primitive name (e.g., worker → Worker.turn()).
Agent.turn(options)
Execute one agent turn.
Returns: Table with content and tool_calls
-- Basic turn
Worker.turn()
-- With injection
Worker.turn({inject = "Focus on security"})
-- Capture response
local response = Worker.turn()
Log.info(response.content)Human Primitives
Human-in-the-loop interaction.
Human.approve(options)
Request yes/no approval (blocking).
Returns: Boolean
local approved = Human.approve({
message = "Deploy?",
context = {version = "2.1.0"},
timeout = 3600,
default = false
})Human.input(options)
Request text input (blocking).
Returns: String or nil
local topic = Human.input({
message = "What topic?",
placeholder = "Enter topic..."
})Human.notify(options)
Send notification (non-blocking).
Human.notify({
message = "Processing phase 2",
level = "info",
context = {progress = "40%"}
})State Primitives
Mutable state management.
State.get(key, default)
Get state value.
local count = State.get("count", 0)State.set(key, value)
Set state value.
State.set("count", 10)
State.set("config", {mode = "fast"})State.increment(key, amount)
Increment numeric value.
State.increment("count") -- +1
State.increment("count", 5) -- +5State.append(key, value)
Append to array.
State.set("items", {})
State.append("items", "first")
State.append("items", "second")Stage Primitives
Workflow stage management.
Stage.set(name)
Set current stage.
Stage.set("processing")Stage.current()
Get current stage name.
Returns: String
Stage.is(name)
Check if in specific stage.
Returns: Boolean
Utility Primitives
Logging, file operations, and utilities.
Log.info / warn / error(message, context)
Log message at specified level.
Log.info("Processing item", {id = item_id})
Log.error("Failed", {error = err})Sleep(seconds)
Sleep for specified duration.
Sleep(5) -- Wait 5 secondsJson.encode / decode
JSON serialization.
local json = Json.encode({key = "value"})
local data = Json.decode(json_string)File.read / write / exists
File system operations.
if File.exists("/path/to/file") then
local content = File.read("/path/to/file")
endComplete Reference
Full API documentation with all primitives is available in:
/plexus/procedures/docs/api-reference.html/plexus/procedures/AGENTS.md
Includes detailed documentation for: Tool, Session, Control, GraphNode primitives and more.