// A stand-in harness turn for the session launch tests (row 269, #1774). // thread-adapter.mjs's turn, plus the run's cwd and the names in it, so a // test reads from the reply which workspace the session saw and at what // in-sandbox path. It keeps a history in $MOSAIC_SESSION_DIR, the session's // store. import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; const request = process.env.MOSAIC_REQUEST ?? ""; const body = request.match(/^Message [^\n]*:\n\n([\s\S]*)$/m)?.[1] ?? ""; const historyFile = join(process.env.MOSAIC_SESSION_DIR, "history"); const before = existsSync(historyFile) ? readFileSync(historyFile, "utf8").split("\n").filter(Boolean) : []; const cwd = process.cwd(); const entries = readdirSync(cwd).sort(); appendFileSync(historyFile, `${body}\n`); process.stdout.write(`THREAD ${JSON.stringify({ body, before, cwd, entries })}\n`); writeFileSync(process.env.MOSAIC_TURN_MARKER, "done\n");