import { spawn } from "node:child_process"; export interface ScriptResult { code: number | null; /** Why the script's process group could not be killed after the timeout, when that failed. */ killFailure?: string; stderr: string; stdout: string; } /** Sends `signal` to `pid`, as `process.kill` does: a negative `pid` names a process group. */ type Kill = (pid: number, signal: NodeJS.Signals) => void; const EMPTY_BLOCK_REASON = "clipboard-copy: the clipboard check blocked the command without a reason."; /** A gate script that neither allowed (exit 0) nor blocked (exit 2) the call still blocks it, with a `failure` that says what went wrong in place of the script's `reason`. */ export type GateResult = { block: false } | { block: true; failure: string } | { block: true; reason: string }; /** Runs `bash