Skip to content

reactive-fsmState-scoped tool availability for TypeScript AI agents

Decide which tools an LLM can see in each conversation state, with a small state machine and a per-step tool budget.

Install ​

bash
npm install reactive-fsm

Requires Node 20+.

Minimal example ​

ts
import { createFSM } from 'reactive-fsm'

const fsm = createFSM({
  initialState: 'IDENTITY',
  states: ['IDENTITY', 'BOOKING'] as const,
  tools: {
    IDENTITY: ['validate_dni'],
    BOOKING: ['check_availability'],
  },
  loopShield: { enabled: true, maxConsecutiveTools: 3 },
})

fsm.transitionTo('BOOKING')
fsm.allowedTools // ['check_availability']

Where to go next ​

MIT licensed