1#!/usr/bin/env node2// Record a video of an Instance AI thread in the n8n UI while the run continues.3//4// node record_iai.mjs <out-dir> [--live]5//6// --live also saves the screen to <out-dir>/live.png every few seconds, for the live page.7//8// Protocol on stdin and stdout, one line each:9// prints "ready" after sign-in10// reads "open <thread-url>" and opens the thread11// reads "stop", or stdin closes: keeps the last screen for a moment, then saves <out-dir>/screen.webm12// and the last screen as <out-dir>/screen-poster.png13// The sign-in happens in a separate context, so the video starts at the thread.14import