plexus.cli.procedure.lua_dsl.primitives.state module
State Primitive - Mutable state management for procedures.
Provides: - State.get(key, default) - Get state value - State.set(key, value) - Set state value - State.increment(key, amount) - Increment numeric value - State.append(key, value) - Append to list - State.all() - Get all state as table
- class plexus.cli.procedure.lua_dsl.primitives.state.StatePrimitive
Bases:
objectManages mutable state for procedure execution.
State is preserved across agent turns and can be used to track progress, accumulate results, and coordinate between agents.
Initialize state storage.
- __init__()
Initialize state storage.
- all() Dict[str, Any]
Get all state as a dictionary.
- Returns:
Complete state dictionary
- Example (Lua):
local state = State.all() for k, v in pairs(state) do
print(k, v)
end
- append(key: str, value: Any) None
Append a value to a list in state.
- Args:
key: State key (will be created as list if doesn’t exist) value: Value to append
- Example (Lua):
State.append(“nodes_created”, node_id)
- clear() None
Clear all state (mainly for testing).
- get(key: str, default: Any = None) Any
Get a value from state.
- Args:
key: State key to retrieve default: Default value if key not found
- Returns:
Stored value or default
- Example (Lua):
local count = State.get(“hypothesis_count”, 0)
- increment(key: str, amount: float = 1) float
Increment a numeric value in state.
- Args:
key: State key to increment amount: Amount to increment by (default 1)
- Returns:
New value after increment
- Example (Lua):
State.increment(“hypotheses_filed”) State.increment(“score”, 10)
- set(key: str, value: Any) None
Set a value in state.
- Args:
key: State key to set value: Value to store
- Example (Lua):
State.set(“current_phase”, “exploration”)