A port of AlanBBOS (20123) rewritten (quickly) in TypeScript