Jido.Agent.Strategy.FSM.Machine (Jido v2.3.0)

Copy Markdown View Source

Generic FSM machine that uses configurable transitions.

Unlike the previous implementation that used Fsmx with hardcoded transitions, this module validates transitions dynamically based on the provided config.

Summary

Functions

Creates a new machine with the given initial state and transitions.

Attempts to transition to a new state.

Types

t()

@type t() :: %Jido.Agent.Strategy.FSM.Machine{
  error: nil | any(),
  last_result: nil | any(),
  processed_count: integer(),
  status: binary(),
  transitions: %{optional(binary()) => [binary()]}
}

Functions

new(initial_state, transitions)

@spec new(String.t(), map()) :: t()

Creates a new machine with the given initial state and transitions.

transition(machine, new_status)

@spec transition(t(), String.t()) :: {:ok, t()} | {:error, String.t()}

Attempts to transition to a new state.