State interface represents a state in the workflow’s state machine. It defines the behavior, transitions, and actions associated with a particular state in the workflow.
The State interface in Solmyr’s workflow system is based on XState’s state node configuration. It provides a streamlined subset of XState’s features, optimized for AI-driven workflows. Developers familiar with XState will find many similarities, though some advanced XState features may not be directly exposed in our API.
Structure
Properties
Provides guidance for the AI on how to handle this state. This description is used by the AI to understand the context and make decisions.
Defines transitions to other states based on events. Keys are event types, values are Transition objects.
Defines immediate transitions that are checked as soon as the state is entered. Useful for conditional branching without waiting for an event.
Defines an action to be executed when entering this state. Typically used to invoke tools or perform side effects.
src: Always “callTool” for invoking a tool.input.name: The name of the tool to be called.onDone: Transition to be taken when the tool execution completes successfully.onError: Transition to be taken if the tool execution fails.
Defines nested states for hierarchical state machines. Follows the same structure as the top-level
states property.Controls AI interaction within this state.
ai: If true, the workflow will pause here and allow the AI to respond or decide on the next event. If false or not present, the state machine will proceed without AI intervention.
Indicates the initial state for nested state machines. Only applicable if the
states property is present.