Building Deterministic Multi-Agent State Machines in TypeScript