I have not played with this problem, so I don't know what
is out there. However given the kinds of problems that
you want to solve, I would suggest taking a close look
and its documentation.
Not because it solves the problem you want (it doesn't),
but because the entire "state machine" philosophy it
uses is (at a guess) going to be a good fit for your
problem and is similar to the direction you are heading.
Therefore seeing a mature implementation of those ideas
in another context is likely to shorten the path between
you and some key design ideas you will find helpful.
Remember that the most interesting innovations tend to
happen when someone finds a way of taking person A's
well-developed theories and apply them to person B's