#!/usr/bin/env -S bun --no-env-file --config=/dev/null /** * gstack-aside-repl — run one `aside repl` script and keep the files it saves. * * A one-shot `aside repl` deletes its session directory when the script ends, * and the sandbox refuses every path outside that directory ("escapes the * session directory"), so a screenshot saved there is gone before bash can * copy it (#4784; verified on Aside CLI 1.26.1107). The bytes leave the only * way that survives: stdout. This wrapper prepends * * saveArtifact(name, data) // data: Buffer/Uint8Array, or a string saved as UTF-8 * * to the script, which prints one line behind a per-run random marker: the * name, the byte count and the base64 data. A name that is not one plain file * name throws in the script, and a line whose data decodes to another byte * count (a truncated line) is an error, never a short file. * The wrapper decodes each such line into --out/, prints * `SAVED= bytes=` in its place, and passes every other line through, * so image data never reaches the caller. Page content the script prints * cannot forge an artifact: it never sees the marker. * * Usage: gstack-aside-repl --out [--] '