Lines 278-318javascript
278 // parse top-level await or return. Those programs retain the prior async
279 // block behavior; a syntax failure occurs before any user code executes.
280 if (!statementList || !(error instanceof SyntaxError)) throw error;
281 program = new Function('"use strict"; return (async () => {' + code + "\n})();");
282 value = await program();
284 const output = render(value);
285 return logs.length === 0 ? output : value === undefined ? logs.join("\n") : logs.join("\n") + "
287 function install(name, value) { Object.defineProperty(globalThis, name, { value, configurable: false, enumerable: false, writable: false }); }
288 install("browser", browser); install("context", context); install("page", page);
289 install("state", state); install("browserState", state);
290 install("a11y", a11y); install("view", view); install("routeFulfill", routeFulfill); install("console", replConsole);
291 install("__araHandsRepl", Object.freeze({ version, evaluate }));
293`.trim(),os=String.raw`
295 const bridge = globalThis.__araHandsRepl;
296 if (!bridge || typeof bridge.evaluate !== "function") throw new Error("Reason Hands browser bridge is not installed");
297 return await bridge.evaluate(typeof input === "string" ? input : input && input.code);
299`.trim();import{Buffer as wt}from"buffer";import{randomUUID as Ea}from"crypto";class cs extends Error{code;constructor(e){super(e==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":e);this.code=e;this.name="HandsReplBrowserDispatcherError"}}var ds=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),ss=/^hands_[A-Za-z0-9_-]{8,128}$/,Ra=2048,ls=32,us=1e4,Oa=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder ...
300`):J;w({status:M.statusCode??502,headers:T,body:Buffer.concat(G)})})}),x=setTimeout(()=>W.destroy(Error("hands_browser_fetch_timeout")),yc);W.once("close",()
301`)}function tn(e){try{ic(e)}catch{}}async function Ps(e){if(e.managedBrowser&&e.driverModuleDirectory!==void 0)throw Error("hands_browser_ambiguous_driver_configuration");let l=e.launch||e.targetContext?null:e.managedBrowser?await zn(e.managedBrowser,{executablePath:e.browserExecutablePath}):await Mt({executablePath:e.browserExecutablePath,driverModuleDirectory:e.driverModuleDirectory});if(l?.status==="unavailable")throw Error(`hands_browser_${l.reason}`);let f=l?.status==="resolved"?l.executablePath:e.browserExecutablePath;if(!f||!jt(f))throw Error("hands_browser_unavailable");let g=e.launch? ...
302Viewing ${Lr} (${Mr.sourceWidth}x${Mr.sourceHeight} source, sent at ${Mr.width}x${Mr.height}, ${Math.round(ft.length/1024)}KB).`}if(Gr>640
303${sr}`}catch{return`${or}
304Screen capture unavailable.`}}return or})(),We,nr=new Promise((or,Pr)=>{We=setTimeout(()=>Pr(Error("REPL evaluation timed out after 105 seconds")),hc)});try{return await Promise.race([Ee,nr])}catch(or){if(or instanceof Error&&or.message.includes("timed out"))Ee.catch(()=>{return}),await Ve.resetEvaluator(he).catch(()=>{return});throw or}finally{if(We)clearTimeout(We)}},ye=Promise.resolve(),ze=new Set,Xe=new Set;tn(e.socketPath);let Te=dt.createServer((le)=>{ze.add(le),le.once("close",()=>{ze.delete(le),Xe.delete(le)}),le.setEncoding("utf8");let he="",xe=!1;le.on("data",(Ve)=>{if(xe)return;if(h ...
305`);if(Le===-1)return;xe=!0;let Be=he.slice(0,Le);if(e.onControl)try{let Ee=JSON.parse(Be);if(typeof Ee.action===
306`}catch{return!1}}var Ac=/^(\/.+)-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;function Ts(e){let l=Ac.exec(e.replace(/\/+$/,""));return l?`${l[1]}/repo`:null}import{randomUUID as yd}from"crypto";import{spawn as vd,spawnSync as kd}from"child_process";import{accessSync as Sd,chmodSync as zt,closeSync as Ed,constants as Dt,fchmodSync as Rd,fstatSync as Od,openSync as xd,copyFileSync as Pd,existsSync as co,lstatSync as vr,statSync as lt,mkdtempSync as Id,mkdirSync as Ct,realpathSync as tr,renameSync as cn,rmSync as Ad,writeFileSync as ln}from"fs";import{homedir as Td, ...
307const { writeSync } = require("node:fs");
308const { createRequire } = require("node:module");
309const { join } = require("node:path");
310const { createInterface } = require("node:readline");
311const { formatWithOptions, inspect } = require("node:util");
312const vm = require("node:vm");
314const timeoutMs = ${to};
315const maxLogChars = 524288;
316let activeOutput = [];
317let activeOutputChars = 0;
318function appendOutput(value) {
Long lines were clipped for display.