main
John Lauer Record temperature shutdown replay and screen an offset passive cooling alternative c7a3cd8
import fs from 'node:fs';import http from 'node:http';import path from 'node:path';
const {default:puppeteer}=await import('/home/adom/project/adom-video-brand/node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js');
const out='videos/temperature-safety',root=path.resolve('demos/temperature-safety');
const server=http.createServer((req,res)=>{const file=req.url==='/'?'index.html':req.url==='/trace.json'?'trace.json':null;if(!file){res.writeHead(404);return res.end();}res.setHeader('Content-Type',file.endsWith('json')?'application/json':'text/html');res.end(fs.readFileSync(path.join(root,file)));});await new Promise(r=>server.listen(0,'127.0.0.1',r));
const b=await puppeteer.launch({executablePath:'/home/adom/.cache/ms-playwright/chromium-1243/chrome-linux64/chrome',headless:true,args:['--no-sandbox']});let recording;
try{const p=await b.newPage();p.on('pageerror',e=>process.stderr.write(e.stack+'\n'));await p.setViewport({width:1920,height:1080});await p.goto(`http://127.0.0.1:${server.address().port}`,{waitUntil:'networkidle2'});if(fs.existsSync(out+'/replay.webm'))throw Error('Preserve existing take');recording=await p.screencast({path:out+'/replay.webm',format:'webm',fps:30,ffmpegPath:'/usr/bin/ffmpeg'});await new Promise(r=>setTimeout(r,1000));await p.evaluate(()=>window.startReplay());await p.waitForFunction(()=>window.replayDone,{timeout:15000});await p.screenshot({path:out+'/final.png'});await new Promise(r=>setTimeout(r,1800));await recording.stop();recording=null;fs.writeFileSync(out+'/capture.json',JSON.stringify({method:'Actual headless browser recording of saved compiled-C policy trace with synthetic inputs; replay at 1x, not hardware footage',nativeTake:false,humanApproval:'pending',review:'pending'},null,2)+'\n');}finally{if(recording)await recording.stop();await b.close();await new Promise(r=>server.close(r));}