@reason-machines/cli-linux-arm64-musl 0.2.330 → 0.2.332

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/bin/ara +1 -1
  2. package/bin/vm-hands/api-36ywgdp3.js +2 -0
  3. package/bin/vm-hands/api-credentials-41xjt55r.js +2 -0
  4. package/bin/vm-hands/ask-relay-76k5tqcx.js +8 -0
  5. package/bin/vm-hands/connect-cli-asw6s1nn.js +2 -0
  6. package/bin/vm-hands/{custom-endpoint-device-8yqvpsd7.js → custom-endpoint-device-dt74zv7m.js} +1 -1
  7. package/bin/vm-hands/desktop-account-a16gh9sj.js +2 -0
  8. package/bin/vm-hands/{device-workspace-pacdp5tv.js → device-workspace-nqxczwd3.js} +1 -1
  9. package/bin/vm-hands/hands-worker-source-tc1snvve.js +2 -0
  10. package/bin/vm-hands/{index-wx03jedr.js → index-g4t2q0ep.js} +1 -1
  11. package/bin/vm-hands/local-automation-pps1ej8x.js +2 -0
  12. package/bin/vm-hands/local-capabilities-nasxgqd8.js +2 -0
  13. package/bin/vm-hands/local-desktop-users-qej2mfhx.js +2 -0
  14. package/bin/vm-hands/local-display-mac-4pddah9q.js +2 -0
  15. package/bin/vm-hands/local-display-session-mhheere8.js +2 -0
  16. package/bin/vm-hands/local-pty-session-kq8bd4pm.js +2 -0
  17. package/bin/vm-hands/{network-contract-gb6gk8fg.js → network-contract-qxn4pg15.js} +1 -1
  18. package/bin/vm-hands/package-s8sef5wh.js +2 -0
  19. package/bin/vm-hands/permissions-g6sk0rv1.js +2 -0
  20. package/bin/vm-hands/{reason-hands-protocol-469gmb0h.js → reason-hands-protocol-n14gyf7k.js} +1 -1
  21. package/bin/vm-hands/{status-wdwrnxja.js → status-b7h8djyg.js} +2 -2
  22. package/bin/vm-hands/version-gp19vrz1.js +2 -0
  23. package/bin/vm-hands/{vm-hands-entry-lite-40t7d4p5.js → vm-hands-entry-lite-070nd0vy.js} +1 -1
  24. package/bin/vm-hands/{vm-hands-entry-lite-ht03kzr3.js → vm-hands-entry-lite-2yf0rw8q.js} +3 -3
  25. package/bin/vm-hands/{vm-hands-entry-lite-6g65w75z.js → vm-hands-entry-lite-3dx1yqhd.js} +2 -2
  26. package/bin/vm-hands/{vm-hands-entry-lite-abrbc7gf.js → vm-hands-entry-lite-4b8f37q4.js} +2 -2
  27. package/bin/vm-hands/{vm-hands-entry-lite-ydjye6jz.js → vm-hands-entry-lite-4r3s0ppn.js} +23 -23
  28. package/bin/vm-hands/{vm-hands-entry-lite-nj8bmc9y.js → vm-hands-entry-lite-5n6vc7je.js} +2 -2
  29. package/bin/vm-hands/{vm-hands-entry-lite-j7ee0rr6.js → vm-hands-entry-lite-5xm2vftq.js} +2 -2
  30. package/bin/vm-hands/{vm-hands-entry-lite-g5w3cema.js → vm-hands-entry-lite-6h3vb0mz.js} +3 -3
  31. package/bin/vm-hands/{vm-hands-entry-lite-rd9vsaew.js → vm-hands-entry-lite-7kzy7rxj.js} +2 -2
  32. package/bin/vm-hands/{vm-hands-entry-lite-dyqeaqzb.js → vm-hands-entry-lite-983czfdb.js} +2 -2
  33. package/bin/vm-hands/{vm-hands-entry-lite-rnwjp0tk.js → vm-hands-entry-lite-9k57wmkv.js} +2 -2
  34. package/bin/vm-hands/{vm-hands-entry-lite-n5ec0fjy.js → vm-hands-entry-lite-9rr6gh58.js} +1 -1
  35. package/bin/vm-hands/{vm-hands-entry-lite-tav4dt92.js → vm-hands-entry-lite-awwev9zg.js} +2 -2
  36. package/bin/vm-hands/{vm-hands-entry-lite-0yghpjef.js → vm-hands-entry-lite-c64behya.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-8afzattm.js → vm-hands-entry-lite-cnmd8nft.js} +2 -2
  38. package/bin/vm-hands/vm-hands-entry-lite-dhzcvvt2.js +5 -0
  39. package/bin/vm-hands/vm-hands-entry-lite-dtcpbbkc.js +3 -0
  40. package/bin/vm-hands/{vm-hands-entry-lite-ekp1wmw5.js → vm-hands-entry-lite-dw2jf6dx.js} +2 -2
  41. package/bin/vm-hands/vm-hands-entry-lite-feaxcj0x.js +5 -0
  42. package/bin/vm-hands/vm-hands-entry-lite-ffgjezmx.js +3 -0
  43. package/bin/vm-hands/{vm-hands-entry-lite-ngtfq7a3.js → vm-hands-entry-lite-gmwz37w0.js} +2 -2
  44. package/bin/vm-hands/{vm-hands-entry-lite-n8gsyjq7.js → vm-hands-entry-lite-h01d2fbm.js} +2 -2
  45. package/bin/vm-hands/{vm-hands-entry-lite-pbnx8z9g.js → vm-hands-entry-lite-hj6jjk24.js} +1 -1
  46. package/bin/vm-hands/{vm-hands-entry-lite-jz24p4jj.js → vm-hands-entry-lite-jzms4xs2.js} +2 -2
  47. package/bin/vm-hands/vm-hands-entry-lite-m4vkk8n3.js +343 -0
  48. package/bin/vm-hands/vm-hands-entry-lite-mm72ht4e.js +3 -0
  49. package/bin/vm-hands/{vm-hands-entry-lite-669hk342.js → vm-hands-entry-lite-mtp2h66e.js} +2 -2
  50. package/bin/vm-hands/{vm-hands-entry-lite-5a0kyaxa.js → vm-hands-entry-lite-px64jhhn.js} +1 -1
  51. package/bin/vm-hands/{vm-hands-entry-lite-kbz9zfha.js → vm-hands-entry-lite-s64raarx.js} +2 -2
  52. package/bin/vm-hands/{vm-hands-entry-lite-9y8v419y.js → vm-hands-entry-lite-t5h3g60g.js} +1 -1
  53. package/bin/vm-hands/{vm-hands-entry-lite-djy0ww6h.js → vm-hands-entry-lite-tf5mepq5.js} +2 -2
  54. package/bin/vm-hands/{vm-hands-entry-lite-dj69r683.js → vm-hands-entry-lite-wv11sawh.js} +2 -2
  55. package/bin/vm-hands/{vm-hands-entry-lite-e5fatvff.js → vm-hands-entry-lite-y9psseqc.js} +2 -2
  56. package/bin/vm-hands/vm-hands-entry-lite-zgs6j8wj.js +3 -0
  57. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  58. package/bin/vm-hands/{vm-hands-executor-rt8r46bt.js → vm-hands-executor-x9zpbtp9.js} +1 -1
  59. package/bin/vm-hands/vm-hands-op-runner-346cxpn5.js +2 -0
  60. package/bin/vm-hands/{vm-hands-runtime-h7s6zcvq.js → vm-hands-runtime-twndxmvd.js} +3 -3
  61. package/bin/vm-hands/worker-sandbox-1m0s1vnq.js +2 -0
  62. package/package.json +1 -1
  63. package/bin/vm-hands/connect-cli-4gee1bxs.js +0 -2
  64. package/bin/vm-hands/desktop-account-s4629ksd.js +0 -2
  65. package/bin/vm-hands/hands-worker-source-fprvxtp8.js +0 -2
  66. package/bin/vm-hands/local-automation-5gkaj1mg.js +0 -2
  67. package/bin/vm-hands/local-capabilities-px6n9wdf.js +0 -2
  68. package/bin/vm-hands/local-desktop-users-ktbva6me.js +0 -2
  69. package/bin/vm-hands/local-display-mac-kbbrwa0y.js +0 -2
  70. package/bin/vm-hands/local-display-session-qqgjsa3g.js +0 -2
  71. package/bin/vm-hands/local-pty-session-bnhx083p.js +0 -2
  72. package/bin/vm-hands/package-bzy9agdv.js +0 -2
  73. package/bin/vm-hands/permissions-tj216d4z.js +0 -2
  74. package/bin/vm-hands/version-5crmvxxa.js +0 -2
  75. package/bin/vm-hands/vm-hands-entry-lite-qq1091m3.js +0 -344
  76. package/bin/vm-hands/vm-hands-entry-lite-sggk0bqc.js +0 -5
  77. package/bin/vm-hands/vm-hands-op-runner-m45mtphf.js +0 -2
  78. package/bin/vm-hands/worker-sandbox-bqwkytj2.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$b as y,Yb as i,Zb as l,_b as g}from"./vm-hands-entry-lite-9y8v419y.js";import{Ag as S,Bg as _,Dg as P,Eg as C,Fg as I,Hg as O,Kg as A,kg as Q,lg as J,mg as z,ng as Z,og as K,pg as $,qg as k,sg as G,ug as X,vg as M,wg as Y,xg as H,yg as V}from"./vm-hands-entry-lite-8afzattm.js";import{Gh as L,Hh as W,Ih as F,Jh as j}from"./vm-hands-entry-lite-n5ec0fjy.js";var d=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var a=String.raw`(function(fs, path) {
2
+ import{kc as i,lc as l,mc as g,nc as y}from"./vm-hands-entry-lite-t5h3g60g.js";import{Ag as H,Bg as V,Dg as S,Eg as _,Gg as P,Hg as C,Ig as I,Kg as O,Ng as A,ng as Q,og as J,pg as z,qg as Z,rg as K,sg as $,tg as k,vg as G,xg as X,yg as M,zg as Y}from"./vm-hands-entry-lite-cnmd8nft.js";import{Wh as L,Xh as W,Yh as F,Zh as j}from"./vm-hands-entry-lite-9rr6gh58.js";var d=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var a=String.raw`(function(fs, path) {
3
3
  const fail = (message, reasonCode) => { throw Object.assign(Error(message), {reasonCode}); };
4
4
  const read = (p, reasonCode, trim=true) => { try { const text=fs.readFileSync(p, "utf8"); return trim?text.trim():text; }
5
5
  catch { fail("memory_read", reasonCode); } };
@@ -4080,4 +4080,4 @@ void startJobControl().then(() => {
4080
4080
  if (validPrivateJob) markReady(); else connect();
4081
4081
  }, () => process.exit(45));
4082
4082
  `.trimStart(),vt=ut("sha256").update(xt,"utf8").digest("hex");
4083
- export{n as wb,h as xb,bt as yb,o as zb,Gt as Ab,b as Bb,m as Cb,ct as Db,ft as Eb,dt as Fb,at as Gb,Rt as Hb,gt as Ib,yt as Jb,xt as Kb,vt as Lb};
4083
+ export{n as Wb,h as Xb,bt as Yb,o as Zb,Gt as _b,b as $b,m as ac,ct as bc,ft as cc,dt as dc,at as ec,Rt as fc,gt as gc,yt as hc,xt as ic,vt as jc};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fe as Aq}from"./vm-hands-entry-lite-ht03kzr3.js";import{ef as H,hf as L0,kf as y0,lf as T8,mf as sq,of as $8,rf as iq,tf as nq}from"./vm-hands-entry-lite-jz24p4jj.js";import{Cf as j0}from"./vm-hands-entry-lite-tav4dt92.js";import{hg as U0}from"./vm-hands-entry-lite-sggk0bqc.js";import{oh as Zq}from"./vm-hands-entry-lite-djy0ww6h.js";import{ph as d}from"./vm-hands-entry-lite-kbz9zfha.js";import{Ph as W0}from"./vm-hands-entry-lite-dyqeaqzb.js";import{Wh as M}from"./vm-hands-entry-lite-40t7d4p5.js";import{execFile as tx,spawn as T0}from"child_process";import{randomBytes as ex}from"crypto";import{chmodSync as q1,existsSync as B0,lstatSync as x1,mkdirSync as X1,readFileSync as Q1,rmSync as P1,writeFileSync as o8}from"fs";import{connect as b1}from"net";import{join as _}from"path";var Uq="./desktop-wallpaper-0pjhgyfk.jpg";var Lq="./dock-browser-afp005mt.png";var yq="./dock-files-rywdm96b.png";var jq="./dock-terminal-s41cj1jp.png";var Tq=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
2
+ import{We as Zq}from"./vm-hands-entry-lite-tf5mepq5.js";import{Ze as Aq}from"./vm-hands-entry-lite-2yf0rw8q.js";import{Bf as L0,Ef as y0,Ff as T8,Gf as sq,If as $8,Lf as iq,Nf as nq,yf as H}from"./vm-hands-entry-lite-jzms4xs2.js";import{Wf as j0}from"./vm-hands-entry-lite-awwev9zg.js";import{kg as U0}from"./vm-hands-entry-lite-dhzcvvt2.js";import{Fh as d}from"./vm-hands-entry-lite-s64raarx.js";import{di as W0}from"./vm-hands-entry-lite-983czfdb.js";import{ki as M}from"./vm-hands-entry-lite-070nd0vy.js";import{execFile as tx,spawn as T0}from"child_process";import{randomBytes as ex}from"crypto";import{chmodSync as q1,existsSync as B0,lstatSync as x1,mkdirSync as X1,readFileSync as Q1,rmSync as P1,writeFileSync as o8}from"fs";import{connect as b1}from"net";import{join as _}from"path";var Uq="./desktop-wallpaper-0pjhgyfk.jpg";var Lq="./dock-browser-afp005mt.png";var yq="./dock-files-rywdm96b.png";var jq="./dock-terminal-s41cj1jp.png";var Tq=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
3
3
  # The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
4
4
  # python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
5
5
  # Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
@@ -178,4 +178,4 @@ Gtk.main()
178
178
  `).flatMap((Q)=>{let P=Q.indexOf("=");return P>0?[[Q.slice(0,P),Q.slice(P+1)]]:[]})))}catch{return{}}}var N0=new Set;async function C1(q,x,X){let Q=await R1(),P=/^:(\d+)(?:\.\d+)?$/.exec(Q.DISPLAY??"")?.[1];if(!P||`:${P}`===B8||Q.WAYLAND_DISPLAY||Q.XDG_SESSION_TYPE==="wayland")return null;let b={display:`:${P}`,xauthority:Q.XAUTHORITY??_(q,".Xauthority"),rfbSocket:_(x,`rfb-${P}.sock`)},J=`${b.display} ${b.xauthority}`;if(N0.has(J)||!await s({path:`/tmp/.X11-unix/X${P}`},!1))return null;let y={HOME:q,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:b.display,XAUTHORITY:b.xauthority};if(await R0(X,b,x,`x11vnc-${P}.log`,y))return{...b,sound:null};return N0.add(J),process.stderr.write(`Reason worker: your screen ${b.display} could not be served; using the virtual desktop
179
179
  `),null}function S1(q,x){let X=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,Q=[["terminal","xterm"],["files","pcmanfm"]].filter(([,b])=>!B0(`/usr/bin/${b}`)).map(([b])=>b),P=Rq({root:q,display:x,screen:t8,browserExec:X,absent:Q});for(let b of["","openbox","tint2","picom"])D8(_(q,b));for(let[b,J]of Object.entries(P.files))o8(_(q,b),J,{mode:384});for(let[b,J]of Object.entries(Dq))o8(_(q,`ara-${b}`),Q1(J),{mode:384});return{root:q,openboxConfig:_(q,"openbox","rc.xml"),start:P.start}}async function Z1(q,x){let X=[`ROOT=${JSON.stringify(q.root)}`,...q.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
180
180
  `);await new Promise((Q)=>{let P=T0("/bin/sh",["-c",X],{stdio:"ignore",env:{...x,PATH:"/usr/bin:/bin"}}),b=setTimeout(()=>{P.kill(),Q()},R8);P.once("error",()=>{clearTimeout(b),Q()}),P.once("exit",()=>{clearTimeout(b),Q()})})}async function oX(q,x={}){let X=x.now??Date.now,Q=y1(q.payload,X());if(q.signal.throwIfAborted(),!Q.video)throw new M("display_video_required","Reason desktops stream as video now; this request came without it.");let P=x.platform??process.platform;if(P!=="linux"&&P!=="darwin")throw new M("display_video_unsupported","This machine does not serve desktop video.");let b=Q.video,J=(x.video?.desktop??(P==="darwin"?async()=>oq:B1))();return await A1(q.signal,Q,x,X,(y)=>Q0(y,{request:b,desktop:J,...Q.viewer?{viewer:Q.viewer}:{},viewerSameNetwork:Q.viewer_same_network===!0},x.video),(y)=>T8({type:"error",code:y}))}function A1(q,x,X,Q,P,b){let J=Q();return new Promise((y,C)=>{let W=null,j=!1,R=!1,Z,B,Y,w=!1,N=null,D=(A)=>{if(R)return;if(N)A=N;R=!0,clearTimeout(Z),clearTimeout(B),q.removeEventListener("abort",F),Y?.close();try{W?.close(1000,"display_session_over")}catch{}if("error"in A){C(A.error);return}y({reason:A.reason,...Y?.summary(),duration_ms:Math.max(0,Q()-J)})},G=()=>D({error:new M("display_relay_unavailable","Reason could not reach the desktop relay.")}),F=()=>{let A=q.reason;D({error:A instanceof M?A:new M("cancelled","Reason closed the desktop session.")})},O=()=>{if(!N||!W)return;let A=N.error;try{W.send(b(A instanceof M?A.code:"display_unavailable"))}catch{}D(N)};if(Y=P({get done(){return R||N!==null},get open(){return j&&!R&&N===null},get bufferedAmount(){return W?.bufferedAmount??0},send(A){if(R||N||!j||!W)return;try{W.send(A)}catch{D({reason:"relay_closed"})}},end:(A)=>{if(R||N)return;if(!("error"in A)){D(A);return}if(N=A,w&&j)O()}}),R){Y.close();return}if(q.aborted){F();return}q.addEventListener("abort",F,{once:!0}),Z=setTimeout(()=>D({reason:"session_expired"}),Math.max(1,Date.parse(x.expires_at)-Q())),B=setTimeout(()=>D({reason:"viewer_absent"}),X.viewerWaitMs??N1);try{W=(X.connect??j0)(x.relay_url,(X.loadProxy??U0)()?.url)}catch{G();return}W.binaryType="arraybuffer",W.onopen=()=>{if(R||!W)return;j=!0,Y?.opened()},W.onmessage=(A)=>{if(R)return;let f=A.data,I=f instanceof ArrayBuffer?new Uint8Array(f):ArrayBuffer.isView(f)?new Uint8Array(f.buffer,f.byteOffset,f.byteLength):null;if(!I||I.byteLength===0)return;if(clearTimeout(B),w=!0,N){O();return}Y?.received(I)},W.onclose=()=>{if(R)return;if(!j){G();return}D({reason:"relay_closed"})},W.onerror=()=>{if(R||j)return;G()}})}
181
- export{_8 as ie,f1 as je,p1 as ke,r as le,j8 as me,HX as ne,J0 as oe,Cq as pe,zq as qe,k as re,UX as se,LX as te,yX as ue,J1 as ve,B8 as we,y1 as xe,j1 as ye,nX as ze,D8 as Ae,B1 as Be,oX as Ce};
181
+ export{_8 as xe,f1 as ye,p1 as ze,r as Ae,j8 as Be,HX as Ce,J0 as De,Cq as Ee,zq as Fe,k as Ge,UX as He,LX as Ie,yX as Je,J1 as Ke,B8 as Le,y1 as Me,j1 as Ne,nX as Oe,D8 as Pe,B1 as Qe,oX as Re};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ab as Y8,Bb as s9,Cb as _0,Db as L9,Eb as n0,Lb as K0,zb as NQ}from"./vm-hands-entry-lite-nj8bmc9y.js";import{Tb as bQ,Ub as kQ,Vb as G4,Wb as z4,Xb as V8}from"./vm-hands-entry-lite-n8gsyjq7.js";import{ac as b0}from"./vm-hands-entry-lite-9y8v419y.js";import{Bd as w9,Cd as o0,Dd as W8,Ed as g0,Id as C0,Vc as e$,Yc as $Q}from"./vm-hands-entry-lite-rnwjp0tk.js";import{he as x}from"./vm-hands-entry-lite-669hk342.js";import{$e as HZ}from"./vm-hands-entry-lite-ngtfq7a3.js";import{Nf as vQ,Of as y8,ag as yQ,gg as i9,hg as f8}from"./vm-hands-entry-lite-sggk0bqc.js";import{$g as i$,Ag as d9,Bg as s$,Cg as n$,Dg as R8,Gg as p9,Pg as I8,Qg as S0,Rg as O0,Sg as l9,Zg as w8,_g as JQ,jg as TZ,mg as B9,vg as QQ,wg as ZQ,yg as XQ}from"./vm-hands-entry-lite-8afzattm.js";import{nh as J4}from"./vm-hands-entry-lite-djy0ww6h.js";import{ph as N8,qh as u9,th as X4}from"./vm-hands-entry-lite-kbz9zfha.js";import{Ah as e8,Bh as s0,Ch as p0,Dh as u$,Oh as W$,uh as B8,vh as i0,wh as L8,xh as a0,yh as H9,zh as J8}from"./vm-hands-entry-lite-n5ec0fjy.js";import{Uh as Y4}from"./vm-hands-entry-lite-dyqeaqzb.js";import{Wh as C}from"./vm-hands-entry-lite-40t7d4p5.js";import{Xh as P1,ai as KZ}from"./vm-hands-entry-lite-5a0kyaxa.js";var v={chunk:32768,upload:1048576,total:536870912,streams:16,queued:512,buffered:262144,relayBuffered:8388608,requestMs:30000,lifetimeMs:600000,authorizationMs:2000,window:8};function h9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function P0($,Q,Z=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Q&&$<=Z}function E$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function S$($,Q){let Z=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Z.length]),Z,Q])}function I0($){if(!h9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(E$)||!P0($.attachmentRevision,0)||!P0($.grantRevision,1)||!P0($.generation,1)||!P0($.port,1024,65535)||!P0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function c0($,Q){return Object.keys($).every((Z)=>$[Z]===Q[Z])}function q9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Q=decodeURIComponent($);if(Q.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Q))throw Error("preview_path_invalid");return $}function R$($){return Array.isArray($)&&$.length<=64&&$.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Q[0])&&typeof Q[1]==="string"&&Q[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Q[1]))}function C9($,Q=v.chunk){if($.length>Math.ceil(Q/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Z=Buffer.from($,"base64");if(Z.length>Q)throw Error("preview_data_too_large");return Z}function w$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function b$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Q=JSON.parse($);if(!h9(Q))throw Error("preview_frame_invalid");if(Q.type==="hello")return{type:"hello",binding:I0(Q.binding),...P0(Q.messages,v.chunk,v.upload)?{messages:Q.messages}:{},...P0(Q.window,1,v.window)?{window:Q.window}:{},...Q.bytes===!0?{bytes:!0}:{}};if(Q.type==="refused"&&typeof Q.reason==="string"&&/^[a-z_]{1,32}$/.test(Q.reason))return{type:"refused",binding:I0(Q.binding),reason:Q.reason};if(!E$(Q.id))throw Error("preview_frame_invalid");if(Q.type==="end"||Q.type==="cancel"||Q.type==="credit")return{type:Q.type,id:Q.id};if(Q.type==="ws"&&typeof Q.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Q.protocol))return{type:"ws",id:Q.id,protocol:Q.protocol};if(Q.type==="data"&&typeof Q.data==="string"&&typeof Q.binary==="boolean")return C9(Q.data,v.upload),{type:"data",id:Q.id,data:Q.data,binary:Q.binary};if(Q.type==="head"&&P0(Q.status,200,599)&&R$(Q.headers))return{type:"head",id:Q.id,status:Q.status,headers:Q.headers};if(Q.type==="request"&&typeof Q.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Q.method)&&typeof Q.path==="string"&&R$(Q.headers)&&typeof Q.body==="string"&&typeof Q.upgrade==="boolean")return C9(Q.body,v.upload),{type:"request",id:Q.id,method:Q.method,path:q9(Q.path),headers:Q.headers,body:Q.body,upgrade:Q.upgrade};throw Error("preview_frame_invalid")}function D8($){let Q=[...$],Z=new Set(Q.filter(([J])=>J.toLowerCase()==="connection").flatMap(([,J])=>J.toLowerCase().split(",").map((Y)=>Y.trim()))),X=new Set(["authorization","proxy-authorization","cookie","set-cookie","host","origin","referer","connection","upgrade","keep-alive","transfer-encoding","te","trailer","content-length","forwarded","alt-svc","service-worker-allowed","clear-site-data","refresh"]);return Q.filter(([J])=>!X.has(J.toLowerCase())&&!Z.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function _8($){let Q;try{return await Promise.race([Promise.resolve().then($).then((Z)=>Z===!0||(Z===!1?!1:void 0),()=>{return}),new Promise((Z)=>{Q=setTimeout(()=>Z(void 0),v.authorizationMs)})])}finally{clearTimeout(Q)}}async function T9($){return await _8($)===!0}function v9($,Q){let Z=new URL($);if(Z.username||Z.password||Z.search||Z.hash||!(Z.protocol==="wss:"||Z.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Z.hostname))||!new RegExp(`^/${Q}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Z.pathname))throw Error("preview_relay_invalid");return Z.href}function k$($){if(!h9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:I0($.binding),deviceRelayUrl:v9($.deviceRelayUrl,"device")}}function f$($){if(!h9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:I0($.binding)}}import{request as D4}from"http";import{pipeline as _4}from"stream";import{constants as A8,createBrotliCompress as A4,createGzip as x4}from"zlib";import{WebSocket as O9}from"ws";import{randomBytes as q4,timingSafeEqual as T4}from"crypto";import{createServer as O4}from"net";var g$="x-preview-connection";async function m$($,Q){if(Q.aborted)throw Error("preview_closed");let Z=q4(32).toString("base64url"),X=new Set,J=!1,Y=O4((G)=>{if(J||Q.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let F=new AbortController;G.once("close",()=>{X.delete(G),F.abort()}),G.on("error",()=>G.destroy()),G.setTimeout(2000,()=>G.destroy());let B=Buffer.alloc(0),H=(L)=>{B=Buffer.concat([B,L]);let W=B.indexOf(`\r
2
+ import{Rb as bQ,Sb as kQ,Tb as G4,Ub as z4,Vb as V8}from"./vm-hands-entry-lite-h01d2fbm.js";import{$b as s9,Zb as NQ,_b as Y8,ac as _0,bc as L9,cc as n0,jc as K0}from"./vm-hands-entry-lite-5n6vc7je.js";import{oc as b0}from"./vm-hands-entry-lite-t5h3g60g.js";import{Qd as w9,Rd as o0,Sd as W8,Td as g0,Xd as C0,id as e$,ld as $Q}from"./vm-hands-entry-lite-9k57wmkv.js";import{we as x}from"./vm-hands-entry-lite-mtp2h66e.js";import{Ve as J4}from"./vm-hands-entry-lite-tf5mepq5.js";import{tf as HZ}from"./vm-hands-entry-lite-gmwz37w0.js";import{dg as yQ,jg as i9,kg as f8}from"./vm-hands-entry-lite-dhzcvvt2.js";import{Bg as XQ,Dg as d9,Eg as s$,Fg as n$,Gg as R8,Jg as p9,Sg as I8,Tg as S0,Ug as O0,Vg as l9,ah as w8,bh as JQ,ch as i$,mg as TZ,pg as B9,yg as QQ,zg as ZQ}from"./vm-hands-entry-lite-cnmd8nft.js";import{wh as vQ,xh as y8}from"./vm-hands-entry-lite-mm72ht4e.js";import{Fh as N8,Gh as u9,Jh as X4}from"./vm-hands-entry-lite-s64raarx.js";import{Kh as B8,Lh as i0,Mh as L8,Nh as a0,Oh as H9,Ph as J8,Qh as e8,Rh as s0,Sh as p0,Th as u$,ci as W$}from"./vm-hands-entry-lite-9rr6gh58.js";import{ii as Y4}from"./vm-hands-entry-lite-983czfdb.js";import{ki as C}from"./vm-hands-entry-lite-070nd0vy.js";import{li as P1,qi as KZ}from"./vm-hands-entry-lite-px64jhhn.js";var v={chunk:32768,upload:1048576,total:536870912,streams:16,queued:512,buffered:262144,relayBuffered:8388608,requestMs:30000,lifetimeMs:600000,authorizationMs:2000,window:8};function h9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function P0($,Q,Z=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Q&&$<=Z}function E$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function S$($,Q){let Z=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Z.length]),Z,Q])}function I0($){if(!h9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(E$)||!P0($.attachmentRevision,0)||!P0($.grantRevision,1)||!P0($.generation,1)||!P0($.port,1024,65535)||!P0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function c0($,Q){return Object.keys($).every((Z)=>$[Z]===Q[Z])}function q9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Q=decodeURIComponent($);if(Q.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Q))throw Error("preview_path_invalid");return $}function R$($){return Array.isArray($)&&$.length<=64&&$.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Q[0])&&typeof Q[1]==="string"&&Q[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Q[1]))}function C9($,Q=v.chunk){if($.length>Math.ceil(Q/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Z=Buffer.from($,"base64");if(Z.length>Q)throw Error("preview_data_too_large");return Z}function w$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function b$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Q=JSON.parse($);if(!h9(Q))throw Error("preview_frame_invalid");if(Q.type==="hello")return{type:"hello",binding:I0(Q.binding),...P0(Q.messages,v.chunk,v.upload)?{messages:Q.messages}:{},...P0(Q.window,1,v.window)?{window:Q.window}:{},...Q.bytes===!0?{bytes:!0}:{}};if(Q.type==="refused"&&typeof Q.reason==="string"&&/^[a-z_]{1,32}$/.test(Q.reason))return{type:"refused",binding:I0(Q.binding),reason:Q.reason};if(!E$(Q.id))throw Error("preview_frame_invalid");if(Q.type==="end"||Q.type==="cancel"||Q.type==="credit")return{type:Q.type,id:Q.id};if(Q.type==="ws"&&typeof Q.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Q.protocol))return{type:"ws",id:Q.id,protocol:Q.protocol};if(Q.type==="data"&&typeof Q.data==="string"&&typeof Q.binary==="boolean")return C9(Q.data,v.upload),{type:"data",id:Q.id,data:Q.data,binary:Q.binary};if(Q.type==="head"&&P0(Q.status,200,599)&&R$(Q.headers))return{type:"head",id:Q.id,status:Q.status,headers:Q.headers};if(Q.type==="request"&&typeof Q.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Q.method)&&typeof Q.path==="string"&&R$(Q.headers)&&typeof Q.body==="string"&&typeof Q.upgrade==="boolean")return C9(Q.body,v.upload),{type:"request",id:Q.id,method:Q.method,path:q9(Q.path),headers:Q.headers,body:Q.body,upgrade:Q.upgrade};throw Error("preview_frame_invalid")}function D8($){let Q=[...$],Z=new Set(Q.filter(([J])=>J.toLowerCase()==="connection").flatMap(([,J])=>J.toLowerCase().split(",").map((Y)=>Y.trim()))),X=new Set(["authorization","proxy-authorization","cookie","set-cookie","host","origin","referer","connection","upgrade","keep-alive","transfer-encoding","te","trailer","content-length","forwarded","alt-svc","service-worker-allowed","clear-site-data","refresh"]);return Q.filter(([J])=>!X.has(J.toLowerCase())&&!Z.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function _8($){let Q;try{return await Promise.race([Promise.resolve().then($).then((Z)=>Z===!0||(Z===!1?!1:void 0),()=>{return}),new Promise((Z)=>{Q=setTimeout(()=>Z(void 0),v.authorizationMs)})])}finally{clearTimeout(Q)}}async function T9($){return await _8($)===!0}function v9($,Q){let Z=new URL($);if(Z.username||Z.password||Z.search||Z.hash||!(Z.protocol==="wss:"||Z.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Z.hostname))||!new RegExp(`^/${Q}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Z.pathname))throw Error("preview_relay_invalid");return Z.href}function k$($){if(!h9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:I0($.binding),deviceRelayUrl:v9($.deviceRelayUrl,"device")}}function f$($){if(!h9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:I0($.binding)}}import{request as D4}from"http";import{pipeline as _4}from"stream";import{constants as A8,createBrotliCompress as A4,createGzip as x4}from"zlib";import{WebSocket as O9}from"ws";import{randomBytes as q4,timingSafeEqual as T4}from"crypto";import{createServer as O4}from"net";var g$="x-preview-connection";async function m$($,Q){if(Q.aborted)throw Error("preview_closed");let Z=q4(32).toString("base64url"),X=new Set,J=!1,Y=O4((G)=>{if(J||Q.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let F=new AbortController;G.once("close",()=>{X.delete(G),F.abort()}),G.on("error",()=>G.destroy()),G.setTimeout(2000,()=>G.destroy());let B=Buffer.alloc(0),H=(L)=>{B=Buffer.concat([B,L]);let W=B.indexOf(`\r
3
3
  \r
4
4
  `);if(W<0){if(B.length>16384)G.destroy();return}if(G.pause(),G.off("data",H),W>16384||B.length>v.upload+16384)return G.destroy();z(B,W).catch(()=>G.destroy())};G.on("data",H);async function z(L,W){let U=L.subarray(0,W).toString("latin1").split(`\r
5
5
  `),j=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS) (\S+) HTTP\/1\.1$/.exec(U.shift()??"");if(!j)throw Error("preview_request_invalid");q9(j[2]);let O=!1,q=0,A=[];for(let T of U){let S=/^([a-zA-Z0-9-]+):[ \t]*([^\x00-\x08\x0a-\x1f\x7f]*)$/.exec(T);if(!S)throw Error("preview_header_invalid");if(S[1].toLowerCase()===g$){q++;let g=Buffer.from(S[2].trim());O=g.length===Z.length&&T4(g,Buffer.from(Z))}else if(S[1].toLowerCase()!=="host")A.push(T)}if(!O||q!==1||J||F.signal.aborted)throw Error("preview_connection_denied");let R=await $.connect(F.signal);if(J||F.signal.aborted)throw R.destroy(),Error("preview_closed");X.add(R),R.on("error",()=>G.destroy()),R.once("close",()=>{X.delete(R),G.destroy()}),G.once("close",()=>R.destroy()),G.setTimeout(0);let P=[`${j[1]} ${j[2]} HTTP/1.1`,`Host: 127.0.0.1:${R.remotePort}`,...A,"",""].join(`\r
@@ -303,7 +303,7 @@ async (input) => {
303
303
  if (!bridge || typeof bridge.evaluate !== "function") throw new Error("Reason Hands browser bridge is not installed");
304
304
  return await bridge.evaluate(typeof input === "string" ? input : input && input.code);
305
305
  }
306
- `.trim();import{Buffer as X9}from"buffer";import{randomUUID as z1}from"crypto";class rQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var tQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),iQ=/^hands_[A-Za-z0-9_-]{8,128}$/,K1=2048,eQ=32,$Z=1e4,V1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function F1($){let Q=$.split("+"),Z=(Q.pop()??"").replace(/^Key/,"").toLowerCase();if(Z==="f12")return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Z))return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Q.includes("Shift")&&Z==="c")return!0;return Q.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Z)}var H1=($)=>{let Q=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Q&&!/^(https?:|about:blank)/i.test(Q.href))}},QZ={browser:{close:{returns:"void"},contexts:{returns:"context[]"},isConnected:{returns:"json"},version:{returns:"json"}},context:{addCookies:{returns:"void"},addInitScript:{returns:"void"},browser:{returns:"browser"},clearCookies:{returns:"void"},clearPermissions:{returns:"void"},close:{returns:"void"},cookies:{returns:"json"},grantPermissions:{returns:"void"},newPage:{returns:"page"},pages:{returns:"page[]"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setGeolocation:{returns:"void"},setHTTPCredentials:{returns:"void"},setOffline:{returns:"void"},setViewportSize:{returns:"void"},storageState:{returns:"json"},viewportSize:{returns:"json",special:"contextViewportSize"}},page:{addInitScript:{returns:"void"},addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},bringToFront:{returns:"void"},close:{returns:"void"},content:{returns:"json"},context:{returns:"context"},emulateMedia:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},frame:{returns:"frame"},frameLocator:{returns:"frameLocator"},frames:{returns:"frame[]"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goBack:{returns:"void"},goForward:{returns:"void"},goto:{returns:"void"},isClosed:{returns:"json"},locator:{returns:"locator"},mainFrame:{returns:"frame"},opener:{returns:"page"},pdf:{returns:"bytes"},reload:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setContent:{returns:"void"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setInputFiles:{returns:"void"},setViewportSize:{returns:"void"},title:{returns:"json"},url:{returns:"json"},viewportSize:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},locator:{all:{returns:"locator[]"},allInnerTexts:{returns:"json"},allTextContents:{returns:"json"},and:{returns:"locator"},ariaSnapshot:{returns:"json"},blur:{returns:"void"},boundingBox:{returns:"json"},check:{returns:"void"},clear:{returns:"void"},click:{returns:"void"},contentFrame:{returns:"frameLocator"},count:{returns:"json"},dblclick:{returns:"void"},dragTo:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},evaluateAll:{returns:"json",requiresStringSource:!0},fill:{returns:"void"},filter:{returns:"locator"},first:{returns:"locator",special:"property"},focus:{returns:"void"},getAttribute:{returns:"json"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},hover:{returns:"void"},innerHTML:{returns:"json"},innerText:{returns:"json"},inputValue:{returns:"json"},isChecked:{returns:"json"},isEditable:{returns:"json"},isEnabled:{returns:"json"},isHidden:{returns:"json"},isVisible:{returns:"json"},last:{returns:"locator",special:"property"},locator:{returns:"locator"},nth:{returns:"locator"},or:{returns:"locator"},page:{returns:"page"},press:{returns:"void"},pressSequentially:{returns:"void"},scrollIntoViewIfNeeded:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setInputFiles:{returns:"void"},tap:{returns:"void"},textContent:{returns:"json"},type:{returns:"void"},uncheck:{returns:"void"},waitFor:{returns:"void"}},frame:{addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},childFrames:{returns:"frame[]"},content:{returns:"json"},evaluate:{returns:"json",requiresStringSource:!0},frameLocator:{returns:"frameLocator"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goto:{returns:"void"},isDetached:{returns:"json"},locator:{returns:"locator"},name:{returns:"json"},page:{returns:"page"},parentFrame:{returns:"frame"},setContent:{returns:"void"},title:{returns:"json"},url:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},frameLocator:{getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},locator:{returns:"locator"},owner:{returns:"locator"}}};function I($){throw new rQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Q=Object.getPrototypeOf($);return Q===Object.prototype||Q===null}function J9($,Q=0,Z={nodes:0}){if(Q>eQ||++Z.nodes>$Z)I("hands_repl_json_too_complex");if($===null||typeof $==="boolean"||typeof $==="string")return;if(typeof $==="number"){if(!Number.isFinite($))I("hands_repl_invalid_json");return}if(Array.isArray($)){for(let X of $)J9(X,Q+1,Z);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(tQ.has(X))I("hands_repl_invalid_json");J9(J,Q+1,Z)}}function h8($){return typeof $==="string"&&Object.hasOwn(QZ,$)}function U1($){if(!$.endsWith("[]"))return null;let Q=$.slice(0,-2);return h8(Q)?Q:null}function aQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function W1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function oQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function r9(){return Object.freeze({$handsRepl:"undefined"})}function B1($){if(!X9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:X9.from($).toString("base64")})}function ZZ($){if(!k0($.browser)||!k0($.context)||!k0($.page))I("hands_repl_invalid_roots");if(typeof $.a11y!=="function"||typeof $.view!=="function")I("hands_repl_invalid_callbacks");let Q=$.maxHandles??K1;if(!Number.isInteger(Q)||Q<3||Q>1e5)I("hands_repl_invalid_handle_limit");let Z=new Map,X=new WeakMap,J=$.createOpaqueId??z1,Y=(z,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(z);if(W)return W;if(Z.size>=Q)I("hands_repl_handle_limit");let U="";for(let q=0;q<16;q+=1){let A=`hands_${J()}`;if(iQ.test(A)&&!Z.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:z});Z.set(U,{kind:z,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(z,j),j},K=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),V=(z)=>{if(!z0(z)||Object.keys(z).length!==3||z.$handsRepl!=="handle"||typeof z.id!=="string"||!iQ.test(z.id)||!h8(z.kind))I("hands_repl_invalid_handle");let L=Z.get(z.id);if(!L||L.kind!==z.kind)I("hands_repl_unknown_handle");return L},G=(z,L=0,W=new Set)=>{if(L>eQ)I("hands_repl_json_too_complex");if(z===void 0)return r9();if(z===null||typeof z==="boolean"||typeof z==="string")return z;if(typeof z==="number"){if(!Number.isFinite(z))I("hands_repl_non_json_result");return z}if(Array.isArray(z)){if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{return z.map((U)=>G(U,L+1,W))}finally{W.delete(z)}}if(!z0(z))I("hands_repl_non_json_result");if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{let U=Object.create(null);for(let j of Object.keys(z)){let O=Object.getOwnPropertyDescriptor(z,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(z)}},F=(z,L)=>{if(L==="void")return r9();if(L==="json")return G(z);if(L==="bytes")return B1(z);let W=U1(L);if(W){if(!Array.isArray(z))I("hands_repl_expected_target_list");if(W==="context"&&z.some((U)=>U!==$.context))I("hands_repl_foreign_context");return z.map((U)=>Y(W,U))}if(z===null||z===void 0)return r9();if(!h8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&z!==$.context)I("hands_repl_foreign_context");return Y(L,z)},B=(z)=>{if(z0(z)&&z.$handsRepl==="handle")return V(z).target;if(aQ(z))return X9.from(z.base64,"base64");if(W1(z))return;if(oQ(z))I("hands_repl_route_fulfill_only");if(Array.isArray(z))return z.map(B);if(!z0(z))return z;let L=Object.create(null);for(let[W,U]of Object.entries(z))L[W]=B(U);return L};return Object.freeze({roots:K,dispatch:async(z)=>{if(!z0(z)||typeof z.type!=="string")I("hands_repl_invalid_request");if(z.type==="a11y"){let T=z.target===void 0?Z.get(K.page.id):V(z.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(z.type==="view"){if(J9(z.source),z.options!==void 0)J9(z.options);let T=aQ(z.source)?X9.from(z.source.base64,"base64"):z.source;if($.privateProfile&&!X9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,z.options))}if(z.type!=="call")I("hands_repl_invalid_request");if(typeof z.method!=="string"||z.method.length===0||z.method.length>128)I("hands_repl_invalid_method");if(tQ.has(z.method))I("hands_repl_forbidden_method");let L=V(z.target),W=z.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(J9(W),L.kind==="page"&&z.method==="captureScreenshot"){if(W.length!==0)I("hands_repl_invalid_arguments");if(!$.screenshotExport)I("hands_repl_screenshot_export_unavailable");return G(await $.screenshotExport(L.target))}if(L.kind==="context"&&["startRecording","stopRecording"].includes(z.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(z.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(z.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=z.method;if(["evaluate","evaluateAll","waitForFunction","addInitScript","addScriptTag","addStyleTag","setContent","setInputFiles","route","content","cookies","storageState","addCookies","clearCookies","setExtraHTTPHeaders","setHTTPCredentials","grantPermissions","clearPermissions","innerHTML","textContent","allTextContents"].includes(T)||L.kind==="browser"&&T==="close"||L.kind==="context"&&T==="close")I("hands_repl_private_profile_method_denied");if(L.kind==="browser"&&T==="contexts")return F([$.context],"context[]");if((T==="screenshot"||T==="pdf")&&z0(W[0])&&(("path"in W[0])||("style"in W[0])))I("hands_repl_private_profile_path_denied");if(T==="goto"){if(typeof W[0]!=="string")I("hands_repl_private_profile_url_denied");try{let S=new URL(W[0]);if(!["http:","https:"].includes(S.protocol)&&W[0]!=="about:blank")I("hands_repl_private_profile_url_denied")}catch{I("hands_repl_private_profile_url_denied")}}if(T==="getAttribute"&&(typeof W[0]!=="string"||!V1.has(W[0].toLowerCase())))I("hands_repl_private_profile_attribute_denied");if(L.kind==="locator"&&["innerText","allInnerTexts","getAttribute"].includes(T)){let S=[L.target];if(T==="allInnerTexts"){let g=Reflect.get(L.target,"all");if(typeof g!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(g,L.target,[]);if(!Array.isArray(E)||E.length>$Z||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let g of S){let E=Reflect.get(g,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,g,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&F1(W[0]))I("hands_repl_private_profile_browser_shortcut_denied");if(L.kind==="locator"&&["inputValue","click","dblclick","tap","press"].includes(T)){let S=Reflect.get(L.target,"evaluate");if(typeof S!=="function")I("hands_repl_private_profile_probe_unavailable");let g=await Reflect.apply(S,L.target,[H1]);if(!z0(g)||typeof g.password!=="boolean"||typeof g.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&g.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&g.executableLink)I("hands_repl_private_profile_url_denied");if(T==="inputValue"){let E=Reflect.get(L.target,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,L.target,[]))I("hands_repl_private_profile_hidden_value_denied")}}}let U=QZ[L.kind][z.method];if(!U)I("hands_repl_method_not_allowed");if(U.requiresStringSource&&typeof W[0]!=="string")I("hands_repl_string_source_required");if(L.kind==="browser"&&z.method==="contexts")return[K.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(z.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(z.method==="goto"&&typeof W[0]==="string"){let T;try{T=new URL(W[0]).protocol}catch{I("hands_repl_invalid_url")}if(!["http:","https:","data:","about:","blob:"].includes(T))I("hands_repl_file_path_not_allowed")}if(U.special==="contextViewportSize"){let T=Reflect.get(L.target,"pages");if(typeof T!=="function")I("hands_repl_method_unavailable");let S=await Reflect.apply(T,L.target,[]),g=Array.isArray(S)?S[0]:void 0,E=k0(g)?Reflect.get(g,"viewportSize"):void 0;if(typeof E!=="function")return r9();return F(await Reflect.apply(E,g,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,z.method);return F(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,z.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!oQ(T))I("hands_repl_invalid_route_handler");J9(T.options);let S=B(T.options),g=async(M)=>{if(!k0(M))I("hands_repl_invalid_route");let D=Reflect.get(M,"fulfill");if(typeof D!=="function")I("hands_repl_invalid_route");await Reflect.apply(D,M,[S])},E=[B(W[0]??null),g],N=await Reflect.apply(j,L.target,E);return F(N,U.returns)}let O=W.map(B);if(z.method==="setInputFiles"){let T=L.kind==="locator"?0:1,S=async(E)=>{if(typeof E!=="string"){if(!z0(E)||typeof E.name!=="string"||typeof E.mimeType!=="string"||!X9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},g=O[T];O[T]=Array.isArray(g)?await Promise.all(g.map(S)):await S(g)}if(z.method==="goto")await $.beforeNavigation?.();let q=$.actionRecorder?.(),A=await Reflect.apply(j,L.target,O),P={click:"Click browser element",tap:"Click browser element",dblclick:"Double click browser element",fill:"Type text",type:"Type text",pressSequentially:"Type text",clear:"Clear browser field",press:"Press key",scrollIntoViewIfNeeded:"Scroll browser element into view",dragTo:"Drag on computer",selectOption:"Select browser option",check:"Check browser control",uncheck:"Uncheck browser control",hover:"Hover browser element",focus:"Focus browser element",goto:"Open browser page",reload:"Reload browser page",goBack:"Go back in browser",goForward:"Go forward in browser",screenshot:"Take browser screenshot"}[z.method];if(P){let T=Reflect.get(L.target,"page"),S=L.kind==="page"?L.target:typeof T==="function"?Reflect.apply(T,L.target,[]):void 0;q?.(P,k0(S)?S:void 0)}return F(A,U.returns)}})}import{isIP as zZ}from"net";import{Resolver as L1}from"dns/promises";import{isIP as e9}from"net";var N1=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function v8($){if(e9($)!==4)return null;let Q=$.split(".");if(Q.length!==4)return null;let Z=0;for(let X of Q){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Z=Z*256+J}return Z>>>0}function M1($,Q,Z){let X=v8(Q);if(X===null)return!1;let J=Z===0?0:4294967295<<32-Z>>>0;return($&J)>>>0===(X&J)>>>0}function XZ($){let Q=v8($);if(Q===null)return!0;return N1.some(([Z,X])=>M1(Q,Z,X))}function j1($){if(e9($)!==6)return null;let Q=$.toLowerCase(),Z=Q.indexOf("%");if(Z>=0)Q=Q.slice(0,Z);let X=[],J=Q.lastIndexOf(":"),Y=J>=0?Q.slice(J+1):"";if(Y.includes(".")){let z=v8(Y);if(z===null)return null;X=[z>>>16&65535,z&65535],Q=Q.slice(0,J+1)+"0:0"}let K=Q.split("::");if(K.length>2)return null;let V=(z)=>{if(z==="")return[];let L=[];for(let W of z.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=V(K[0]??"");if(G===null)return null;if(K.length===1){let z=G;if(z.length!==8)return null;return X.length>0?z.slice(0,6).concat(X):z}let F=V(K[1]??"");if(F===null)return null;let B=8-G.length-F.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),F);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function C1($,Q){return`${$>>8&255}.${$&255}.${Q>>8&255}.${Q&255}`}function q1($){let Q=j1($);if(Q===null)return!0;let[Z,X,J]=Q;if((Z&57344)!==8192)return!0;if(Z===8193&&(X&65024)===0)return!0;if(Z===8193&&X===3512)return!0;if(Z===16383&&(X&61440)===0)return!0;if(Z===8194)return XZ(C1(X,J));return!1}function JZ($){return $.replace(/^\[|\]$/g,"")}function t9($){let Q=JZ($.trim()),Z=e9(Q);if(Z===4)return XZ(Q);if(Z===6)return q1(Q);return!0}function YZ($){if($ instanceof Error&&$.name==="TimeoutError")return"dns_timeout";switch(typeof $==="object"&&$!==null&&"code"in $?$.code:void 0){case"ENOTFOUND":return"dns_not_found";case"ENODATA":return"dns_empty";case"EAI_AGAIN":case"ESERVFAIL":case"ECONNREFUSED":return"dns_temporary";case"ETIMEOUT":case"ETIMEDOUT":return"dns_timeout";default:return"dns_failed"}}var GZ=5000;function T1($){return async(Q,Z)=>{if(Z?.aborted)throw Error("aborted");let X=new L1({timeout:GZ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Z?.addEventListener("abort",J,{once:!0});try{let[Y,K]=await Promise.allSettled([X.resolve4(Q),X.resolve6(Q)]),V=[...Y.status==="fulfilled"?Y.value:[],...K.status==="fulfilled"?K.value:[]];if(V.length>0)return V;let G=[Y,K].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(YZ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Z?.removeEventListener("abort",J)}}}var O1=T1();async function D1($,Q,Z,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,K,V=Q($,J.signal);V.catch(()=>{});try{return await Promise.race([V,new Promise((G,F)=>{if(Y=setTimeout(()=>F(new DOMException("DNS lookup timed out","TimeoutError")),Z),X)K=()=>F(Error("aborted")),X.addEventListener("abort",K,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&K)X.removeEventListener("abort",K);J.abort()}}async function XX($,Q=O1,Z){let X=JZ($);if(e9(X))return t9(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await D1(X,Q,GZ,Z)}catch(Y){return{ok:!1,reason:Z?.aborted?Z.reason instanceof Error&&Z.reason.name==="TimeoutError"?"dns_timeout":"aborted":YZ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(t9))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var _1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function c8($){return $.length<=253&&_1.test($.toLowerCase())}function A1($,Q){let Z=$.trim().toLowerCase();if(!c8(Z))return!1;if(Z.startsWith("*.")){let X=Z.slice(2);return Q===X||Q.endsWith(`.${X}`)}return Z===Q}function x1($){let Q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Q)return null;let Z=Q.slice(1).map(Number);return Z.some((X)=>X>255)?null:Z}function d8($,Q=[]){let Z=(X)=>{if(X=X.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,""),!X.includes(":"))return X;try{X=new URL(`http://[${X}]/`).hostname.slice(1,-1)}catch{return X}let J=/^::ffff:([\da-f]+):([\da-f]+)$/.exec(X);if(!J)return X;let Y=parseInt(J[1],16),K=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${K>>8}.${K&255}`};return Q.some((X)=>Z(X)===Z($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Q=x1($);if(Q){let[Y,K,V]=Q;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&K>=64&&K<=127||Y===169&&K===254||Y===172&&K>=16&&K<=31||Y===192&&(K===168||K===0&&(V===0||V===2)||K===88&&V===99)||Y===198&&(K===18||K===19||K===51&&V===100)||Y===203&&K===0&&V===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Z=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Z){let Y=parseInt(Z[1],16),K=parseInt(Z[2],16);return l0(`${Y>>8}.${Y&255}.${K>>8}.${K&255}`)==="public"?"public":"private"}let[X,J=0]=$.split(":").map((Y)=>parseInt(Y||"0",16));return X<8192||X>16383||X===8194||X===8193&&(J<512||J===3512)||X===16383&&J<4096?"private":"public"}function I9($,Q){let Z;try{Z=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Z.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Z.protocol))return{allowed:!1,url:$,host:Z.hostname||null,reason:"unsupported_protocol"};let X=Z.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Q.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(V)=>({allowed:!1,url:$,host:X,reason:V});if(Z.username||Z.password)return J("invalid_url");if(Q.mode==="public_web"){let V=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!zZ(X)||Boolean(zZ(X)&&t9(X));return{allowed:!V,url:$,host:X,reason:V?"private_network":"public_web"}}let Y=Number(Z.port||(["https:","wss:"].includes(Z.protocol)?443:80));if(Q.deniedPorts?.includes(Y)||d8(X,Q.deniedHosts))return J("destination_not_allowed");let K=l0(X);if(K==="private"||["local","internal","arpa"].some((V)=>X===V||X.endsWith(`.${V}`)))return J("private_network");if(K==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Q.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Q.allowedDomains.some((V)=>A1(V,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import VZ from"child_process";import{accessSync as I1,constants as R1,readFileSync as E1,statSync as UZ}from"fs";import{createRequire as WZ}from"module";import{homedir as FZ}from"os";import{dirname as S1,isAbsolute as p8,join as Y9,resolve as w1}from"path";var $8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:HZ.dependencies["playwright-core"],browser:"chromium"}),BZ=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Chromium.app/Contents/MacOS/Chromium"],l8=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function R9($){try{return I1($,R1.X_OK),p8($)&&UZ($).isFile()}catch{return!1}}function u8($,Q=process.platform){let Z=Q==="darwin"?BZ:Q==="linux"?l8:null;return Z?($??Z).find(R9)??null:null}function b1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Q=[];VZ.spawn=new Proxy(VZ.spawn,{apply(Z,X,J){let Y=Reflect.apply(Z,X,J),K=J[1],V=J[2]?.stdio;if(Array.isArray(K)&&K.includes("--remote-debugging-pipe")&&Array.isArray(V)&&V[3]==="pipe"&&V[4]==="pipe")Q.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Q})}async function Q8($){if(b1(),$!==void 0){if(!p8($))throw Error("hands_browser_driver_path_must_be_absolute");let X=Y9($,"package.json"),J=JSON.parse(E1(X,"utf8"));if(J.name!==$8.driver)throw Error("hands_browser_wrong_driver");let Y=WZ(X)($),K=Y.default?.chromium??Y.chromium;if(!K)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:K}}let[Q,Z]=await Promise.all([import("./index-wx03jedr.js"),import("./package-bzy9agdv.js").then((m)=>P1(m.default,1))]);return{version:Z.default.version,chromium:Q.chromium}}var k1=($,Q=$8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Q}),f1=($)=>$.loadDriver?.()??Q8($.driverModuleDirectory),g1={"1.60.0":"1223"};function BX(){let $=process.platform,Q=g1[$8.driverVersion];if(!Q||$!=="linux"&&$!=="darwin")return!1;let Z=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Z("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?Y9(S1(WZ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?w1(Z("INIT_CWD")||process.cwd(),X):Y9($==="darwin"?Y9(FZ(),"Library","Caches"):process.env.XDG_CACHE_HOME||Y9(FZ(),".cache"),"ms-playwright");return UZ(Y9(J,`chromium-${Q}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function G9($={}){return LZ($,$8.driverVersion)}async function s8($,Q={}){if($.driverVersion!=="1.61.1"||!p8($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return LZ({...Q,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function LZ($,Q){let Z=(G)=>k1(G,Q),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin")return Z("unsupported_platform");let J;try{J=await f1($)}catch{return Z("driver_missing")}if(J.version!==Q)return Z("driver_version_mismatch");let Y=(G,F)=>({status:"resolved",executablePath:G,source:F,driverVersion:J.version});if($.executablePath!==void 0)return R9($.executablePath)?Y($.executablePath,"configured"):Z("executable_missing");let K=J.chromium.executablePath();if(R9(K))return Y(K,"managed");let V=$.allowSystemBrowser===!0?u8($.systemCandidates,X):null;return V?Y(V,"system"):Z("executable_missing")}var a1=["/usr/local/bin/chromium",...l8];function o1($,Q=OZ()){return u8($??(Q==="linux"?a1:void 0),Q)}async function r1(){try{return(await Q8()).chromium}catch{return l1(import.meta.url)("playwright-core").chromium}}var t1=1048576,e1=105000,$7=20000,jZ=5000,Q7=2000,Z7=1000,X7=30000,CZ=81920,J7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function Y7($,Q){let Z=new URL($.url()),X={...await $.allHeaders(),host:Z.host};for(let J of Object.keys(X))if(/^(?:proxy-|connection$|upgrade$|transfer-encoding$|content-length$)/i.test(J))delete X[J];return new Promise((J,Y)=>{let V=(Z.protocol==="https:"?s1:u1)(Z,{method:$.method(),headers:X,agent:!1,lookup:(F,B,H)=>{let z=u0.isIP(Q);if(B.all)H(null,[{address:Q,family:z}]);else H(null,Q,z)}},(F)=>{let B=[],H=0;F.on("data",(z)=>{if(H+=z.length,H>33554432)V.destroy(Error("hands_browser_response_too_large"));else B.push(z)}),F.on("error",Y),F.on("end",()=>{let z={};for(let[L,W]of Object.entries(F.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))z[L]=Array.isArray(W)?W.join(`
306
+ `.trim();import{Buffer as X9}from"buffer";import{randomUUID as z1}from"crypto";class rQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var tQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),iQ=/^hands_[A-Za-z0-9_-]{8,128}$/,K1=2048,eQ=32,$Z=1e4,V1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function F1($){let Q=$.split("+"),Z=(Q.pop()??"").replace(/^Key/,"").toLowerCase();if(Z==="f12")return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Z))return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Q.includes("Shift")&&Z==="c")return!0;return Q.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Z)}var H1=($)=>{let Q=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Q&&!/^(https?:|about:blank)/i.test(Q.href))}},QZ={browser:{close:{returns:"void"},contexts:{returns:"context[]"},isConnected:{returns:"json"},version:{returns:"json"}},context:{addCookies:{returns:"void"},addInitScript:{returns:"void"},browser:{returns:"browser"},clearCookies:{returns:"void"},clearPermissions:{returns:"void"},close:{returns:"void"},cookies:{returns:"json"},grantPermissions:{returns:"void"},newPage:{returns:"page"},pages:{returns:"page[]"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setGeolocation:{returns:"void"},setHTTPCredentials:{returns:"void"},setOffline:{returns:"void"},setViewportSize:{returns:"void"},storageState:{returns:"json"},viewportSize:{returns:"json",special:"contextViewportSize"}},page:{addInitScript:{returns:"void"},addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},bringToFront:{returns:"void"},close:{returns:"void"},content:{returns:"json"},context:{returns:"context"},emulateMedia:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},frame:{returns:"frame"},frameLocator:{returns:"frameLocator"},frames:{returns:"frame[]"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goBack:{returns:"void"},goForward:{returns:"void"},goto:{returns:"void"},isClosed:{returns:"json"},locator:{returns:"locator"},mainFrame:{returns:"frame"},opener:{returns:"page"},pdf:{returns:"bytes"},reload:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setContent:{returns:"void"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setInputFiles:{returns:"void"},setViewportSize:{returns:"void"},title:{returns:"json"},url:{returns:"json"},viewportSize:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},locator:{all:{returns:"locator[]"},allInnerTexts:{returns:"json"},allTextContents:{returns:"json"},and:{returns:"locator"},ariaSnapshot:{returns:"json"},blur:{returns:"void"},boundingBox:{returns:"json"},check:{returns:"void"},clear:{returns:"void"},click:{returns:"void"},contentFrame:{returns:"frameLocator"},count:{returns:"json"},dblclick:{returns:"void"},dragTo:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},evaluateAll:{returns:"json",requiresStringSource:!0},fill:{returns:"void"},filter:{returns:"locator"},first:{returns:"locator",special:"property"},focus:{returns:"void"},getAttribute:{returns:"json"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},hover:{returns:"void"},innerHTML:{returns:"json"},innerText:{returns:"json"},inputValue:{returns:"json"},isChecked:{returns:"json"},isEditable:{returns:"json"},isEnabled:{returns:"json"},isHidden:{returns:"json"},isVisible:{returns:"json"},last:{returns:"locator",special:"property"},locator:{returns:"locator"},nth:{returns:"locator"},or:{returns:"locator"},page:{returns:"page"},press:{returns:"void"},pressSequentially:{returns:"void"},scrollIntoViewIfNeeded:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setInputFiles:{returns:"void"},tap:{returns:"void"},textContent:{returns:"json"},type:{returns:"void"},uncheck:{returns:"void"},waitFor:{returns:"void"}},frame:{addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},childFrames:{returns:"frame[]"},content:{returns:"json"},evaluate:{returns:"json",requiresStringSource:!0},frameLocator:{returns:"frameLocator"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goto:{returns:"void"},isDetached:{returns:"json"},locator:{returns:"locator"},name:{returns:"json"},page:{returns:"page"},parentFrame:{returns:"frame"},setContent:{returns:"void"},title:{returns:"json"},url:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},frameLocator:{getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},locator:{returns:"locator"},owner:{returns:"locator"}}};function I($){throw new rQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Q=Object.getPrototypeOf($);return Q===Object.prototype||Q===null}function J9($,Q=0,Z={nodes:0}){if(Q>eQ||++Z.nodes>$Z)I("hands_repl_json_too_complex");if($===null||typeof $==="boolean"||typeof $==="string")return;if(typeof $==="number"){if(!Number.isFinite($))I("hands_repl_invalid_json");return}if(Array.isArray($)){for(let X of $)J9(X,Q+1,Z);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(tQ.has(X))I("hands_repl_invalid_json");J9(J,Q+1,Z)}}function h8($){return typeof $==="string"&&Object.hasOwn(QZ,$)}function U1($){if(!$.endsWith("[]"))return null;let Q=$.slice(0,-2);return h8(Q)?Q:null}function aQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function W1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function oQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function r9(){return Object.freeze({$handsRepl:"undefined"})}function B1($){if(!X9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:X9.from($).toString("base64")})}function ZZ($){if(!k0($.browser)||!k0($.context)||!k0($.page))I("hands_repl_invalid_roots");if(typeof $.a11y!=="function"||typeof $.view!=="function")I("hands_repl_invalid_callbacks");let Q=$.maxHandles??K1;if(!Number.isInteger(Q)||Q<3||Q>1e5)I("hands_repl_invalid_handle_limit");let Z=new Map,X=new WeakMap,J=$.createOpaqueId??z1,Y=(z,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(z);if(W)return W;if(Z.size>=Q)I("hands_repl_handle_limit");let U="";for(let q=0;q<16;q+=1){let A=`hands_${J()}`;if(iQ.test(A)&&!Z.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:z});Z.set(U,{kind:z,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(z,j),j},K=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),V=(z)=>{if(!z0(z)||Object.keys(z).length!==3||z.$handsRepl!=="handle"||typeof z.id!=="string"||!iQ.test(z.id)||!h8(z.kind))I("hands_repl_invalid_handle");let L=Z.get(z.id);if(!L||L.kind!==z.kind)I("hands_repl_unknown_handle");return L},G=(z,L=0,W=new Set)=>{if(L>eQ)I("hands_repl_json_too_complex");if(z===void 0)return r9();if(z===null||typeof z==="boolean"||typeof z==="string")return z;if(typeof z==="number"){if(!Number.isFinite(z))I("hands_repl_non_json_result");return z}if(Array.isArray(z)){if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{return z.map((U)=>G(U,L+1,W))}finally{W.delete(z)}}if(!z0(z))I("hands_repl_non_json_result");if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{let U=Object.create(null);for(let j of Object.keys(z)){let O=Object.getOwnPropertyDescriptor(z,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(z)}},F=(z,L)=>{if(L==="void")return r9();if(L==="json")return G(z);if(L==="bytes")return B1(z);let W=U1(L);if(W){if(!Array.isArray(z))I("hands_repl_expected_target_list");if(W==="context"&&z.some((U)=>U!==$.context))I("hands_repl_foreign_context");return z.map((U)=>Y(W,U))}if(z===null||z===void 0)return r9();if(!h8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&z!==$.context)I("hands_repl_foreign_context");return Y(L,z)},B=(z)=>{if(z0(z)&&z.$handsRepl==="handle")return V(z).target;if(aQ(z))return X9.from(z.base64,"base64");if(W1(z))return;if(oQ(z))I("hands_repl_route_fulfill_only");if(Array.isArray(z))return z.map(B);if(!z0(z))return z;let L=Object.create(null);for(let[W,U]of Object.entries(z))L[W]=B(U);return L};return Object.freeze({roots:K,dispatch:async(z)=>{if(!z0(z)||typeof z.type!=="string")I("hands_repl_invalid_request");if(z.type==="a11y"){let T=z.target===void 0?Z.get(K.page.id):V(z.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(z.type==="view"){if(J9(z.source),z.options!==void 0)J9(z.options);let T=aQ(z.source)?X9.from(z.source.base64,"base64"):z.source;if($.privateProfile&&!X9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,z.options))}if(z.type!=="call")I("hands_repl_invalid_request");if(typeof z.method!=="string"||z.method.length===0||z.method.length>128)I("hands_repl_invalid_method");if(tQ.has(z.method))I("hands_repl_forbidden_method");let L=V(z.target),W=z.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(J9(W),L.kind==="page"&&z.method==="captureScreenshot"){if(W.length!==0)I("hands_repl_invalid_arguments");if(!$.screenshotExport)I("hands_repl_screenshot_export_unavailable");return G(await $.screenshotExport(L.target))}if(L.kind==="context"&&["startRecording","stopRecording"].includes(z.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(z.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(z.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=z.method;if(["evaluate","evaluateAll","waitForFunction","addInitScript","addScriptTag","addStyleTag","setContent","setInputFiles","route","content","cookies","storageState","addCookies","clearCookies","setExtraHTTPHeaders","setHTTPCredentials","grantPermissions","clearPermissions","innerHTML","textContent","allTextContents"].includes(T)||L.kind==="browser"&&T==="close"||L.kind==="context"&&T==="close")I("hands_repl_private_profile_method_denied");if(L.kind==="browser"&&T==="contexts")return F([$.context],"context[]");if((T==="screenshot"||T==="pdf")&&z0(W[0])&&(("path"in W[0])||("style"in W[0])))I("hands_repl_private_profile_path_denied");if(T==="goto"){if(typeof W[0]!=="string")I("hands_repl_private_profile_url_denied");try{let S=new URL(W[0]);if(!["http:","https:"].includes(S.protocol)&&W[0]!=="about:blank")I("hands_repl_private_profile_url_denied")}catch{I("hands_repl_private_profile_url_denied")}}if(T==="getAttribute"&&(typeof W[0]!=="string"||!V1.has(W[0].toLowerCase())))I("hands_repl_private_profile_attribute_denied");if(L.kind==="locator"&&["innerText","allInnerTexts","getAttribute"].includes(T)){let S=[L.target];if(T==="allInnerTexts"){let g=Reflect.get(L.target,"all");if(typeof g!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(g,L.target,[]);if(!Array.isArray(E)||E.length>$Z||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let g of S){let E=Reflect.get(g,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,g,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&F1(W[0]))I("hands_repl_private_profile_browser_shortcut_denied");if(L.kind==="locator"&&["inputValue","click","dblclick","tap","press"].includes(T)){let S=Reflect.get(L.target,"evaluate");if(typeof S!=="function")I("hands_repl_private_profile_probe_unavailable");let g=await Reflect.apply(S,L.target,[H1]);if(!z0(g)||typeof g.password!=="boolean"||typeof g.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&g.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&g.executableLink)I("hands_repl_private_profile_url_denied");if(T==="inputValue"){let E=Reflect.get(L.target,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,L.target,[]))I("hands_repl_private_profile_hidden_value_denied")}}}let U=QZ[L.kind][z.method];if(!U)I("hands_repl_method_not_allowed");if(U.requiresStringSource&&typeof W[0]!=="string")I("hands_repl_string_source_required");if(L.kind==="browser"&&z.method==="contexts")return[K.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(z.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(z.method==="goto"&&typeof W[0]==="string"){let T;try{T=new URL(W[0]).protocol}catch{I("hands_repl_invalid_url")}if(!["http:","https:","data:","about:","blob:"].includes(T))I("hands_repl_file_path_not_allowed")}if(U.special==="contextViewportSize"){let T=Reflect.get(L.target,"pages");if(typeof T!=="function")I("hands_repl_method_unavailable");let S=await Reflect.apply(T,L.target,[]),g=Array.isArray(S)?S[0]:void 0,E=k0(g)?Reflect.get(g,"viewportSize"):void 0;if(typeof E!=="function")return r9();return F(await Reflect.apply(E,g,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,z.method);return F(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,z.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!oQ(T))I("hands_repl_invalid_route_handler");J9(T.options);let S=B(T.options),g=async(M)=>{if(!k0(M))I("hands_repl_invalid_route");let D=Reflect.get(M,"fulfill");if(typeof D!=="function")I("hands_repl_invalid_route");await Reflect.apply(D,M,[S])},E=[B(W[0]??null),g],N=await Reflect.apply(j,L.target,E);return F(N,U.returns)}let O=W.map(B);if(z.method==="setInputFiles"){let T=L.kind==="locator"?0:1,S=async(E)=>{if(typeof E!=="string"){if(!z0(E)||typeof E.name!=="string"||typeof E.mimeType!=="string"||!X9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},g=O[T];O[T]=Array.isArray(g)?await Promise.all(g.map(S)):await S(g)}if(z.method==="goto")await $.beforeNavigation?.();let q=$.actionRecorder?.(),A=await Reflect.apply(j,L.target,O),P={click:"Click browser element",tap:"Click browser element",dblclick:"Double click browser element",fill:"Type text",type:"Type text",pressSequentially:"Type text",clear:"Clear browser field",press:"Press key",scrollIntoViewIfNeeded:"Scroll browser element into view",dragTo:"Drag on computer",selectOption:"Select browser option",check:"Check browser control",uncheck:"Uncheck browser control",hover:"Hover browser element",focus:"Focus browser element",goto:"Open browser page",reload:"Reload browser page",goBack:"Go back in browser",goForward:"Go forward in browser",screenshot:"Take browser screenshot"}[z.method];if(P){let T=Reflect.get(L.target,"page"),S=L.kind==="page"?L.target:typeof T==="function"?Reflect.apply(T,L.target,[]):void 0;q?.(P,k0(S)?S:void 0)}return F(A,U.returns)}})}import{isIP as zZ}from"net";import{Resolver as L1}from"dns/promises";import{isIP as e9}from"net";var N1=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function v8($){if(e9($)!==4)return null;let Q=$.split(".");if(Q.length!==4)return null;let Z=0;for(let X of Q){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Z=Z*256+J}return Z>>>0}function M1($,Q,Z){let X=v8(Q);if(X===null)return!1;let J=Z===0?0:4294967295<<32-Z>>>0;return($&J)>>>0===(X&J)>>>0}function XZ($){let Q=v8($);if(Q===null)return!0;return N1.some(([Z,X])=>M1(Q,Z,X))}function j1($){if(e9($)!==6)return null;let Q=$.toLowerCase(),Z=Q.indexOf("%");if(Z>=0)Q=Q.slice(0,Z);let X=[],J=Q.lastIndexOf(":"),Y=J>=0?Q.slice(J+1):"";if(Y.includes(".")){let z=v8(Y);if(z===null)return null;X=[z>>>16&65535,z&65535],Q=Q.slice(0,J+1)+"0:0"}let K=Q.split("::");if(K.length>2)return null;let V=(z)=>{if(z==="")return[];let L=[];for(let W of z.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=V(K[0]??"");if(G===null)return null;if(K.length===1){let z=G;if(z.length!==8)return null;return X.length>0?z.slice(0,6).concat(X):z}let F=V(K[1]??"");if(F===null)return null;let B=8-G.length-F.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),F);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function C1($,Q){return`${$>>8&255}.${$&255}.${Q>>8&255}.${Q&255}`}function q1($){let Q=j1($);if(Q===null)return!0;let[Z,X,J]=Q;if((Z&57344)!==8192)return!0;if(Z===8193&&(X&65024)===0)return!0;if(Z===8193&&X===3512)return!0;if(Z===16383&&(X&61440)===0)return!0;if(Z===8194)return XZ(C1(X,J));return!1}function JZ($){return $.replace(/^\[|\]$/g,"")}function t9($){let Q=JZ($.trim()),Z=e9(Q);if(Z===4)return XZ(Q);if(Z===6)return q1(Q);return!0}function YZ($){if($ instanceof Error&&$.name==="TimeoutError")return"dns_timeout";switch(typeof $==="object"&&$!==null&&"code"in $?$.code:void 0){case"ENOTFOUND":return"dns_not_found";case"ENODATA":return"dns_empty";case"EAI_AGAIN":case"ESERVFAIL":case"ECONNREFUSED":return"dns_temporary";case"ETIMEOUT":case"ETIMEDOUT":return"dns_timeout";default:return"dns_failed"}}var GZ=5000;function T1($){return async(Q,Z)=>{if(Z?.aborted)throw Error("aborted");let X=new L1({timeout:GZ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Z?.addEventListener("abort",J,{once:!0});try{let[Y,K]=await Promise.allSettled([X.resolve4(Q),X.resolve6(Q)]),V=[...Y.status==="fulfilled"?Y.value:[],...K.status==="fulfilled"?K.value:[]];if(V.length>0)return V;let G=[Y,K].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(YZ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Z?.removeEventListener("abort",J)}}}var O1=T1();async function D1($,Q,Z,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,K,V=Q($,J.signal);V.catch(()=>{});try{return await Promise.race([V,new Promise((G,F)=>{if(Y=setTimeout(()=>F(new DOMException("DNS lookup timed out","TimeoutError")),Z),X)K=()=>F(Error("aborted")),X.addEventListener("abort",K,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&K)X.removeEventListener("abort",K);J.abort()}}async function XX($,Q=O1,Z){let X=JZ($);if(e9(X))return t9(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await D1(X,Q,GZ,Z)}catch(Y){return{ok:!1,reason:Z?.aborted?Z.reason instanceof Error&&Z.reason.name==="TimeoutError"?"dns_timeout":"aborted":YZ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(t9))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var _1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function c8($){return $.length<=253&&_1.test($.toLowerCase())}function A1($,Q){let Z=$.trim().toLowerCase();if(!c8(Z))return!1;if(Z.startsWith("*.")){let X=Z.slice(2);return Q===X||Q.endsWith(`.${X}`)}return Z===Q}function x1($){let Q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Q)return null;let Z=Q.slice(1).map(Number);return Z.some((X)=>X>255)?null:Z}function d8($,Q=[]){let Z=(X)=>{if(X=X.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,""),!X.includes(":"))return X;try{X=new URL(`http://[${X}]/`).hostname.slice(1,-1)}catch{return X}let J=/^::ffff:([\da-f]+):([\da-f]+)$/.exec(X);if(!J)return X;let Y=parseInt(J[1],16),K=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${K>>8}.${K&255}`};return Q.some((X)=>Z(X)===Z($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Q=x1($);if(Q){let[Y,K,V]=Q;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&K>=64&&K<=127||Y===169&&K===254||Y===172&&K>=16&&K<=31||Y===192&&(K===168||K===0&&(V===0||V===2)||K===88&&V===99)||Y===198&&(K===18||K===19||K===51&&V===100)||Y===203&&K===0&&V===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Z=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Z){let Y=parseInt(Z[1],16),K=parseInt(Z[2],16);return l0(`${Y>>8}.${Y&255}.${K>>8}.${K&255}`)==="public"?"public":"private"}let[X,J=0]=$.split(":").map((Y)=>parseInt(Y||"0",16));return X<8192||X>16383||X===8194||X===8193&&(J<512||J===3512)||X===16383&&J<4096?"private":"public"}function I9($,Q){let Z;try{Z=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Z.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Z.protocol))return{allowed:!1,url:$,host:Z.hostname||null,reason:"unsupported_protocol"};let X=Z.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Q.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(V)=>({allowed:!1,url:$,host:X,reason:V});if(Z.username||Z.password)return J("invalid_url");if(Q.mode==="public_web"){let V=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!zZ(X)||Boolean(zZ(X)&&t9(X));return{allowed:!V,url:$,host:X,reason:V?"private_network":"public_web"}}let Y=Number(Z.port||(["https:","wss:"].includes(Z.protocol)?443:80));if(Q.deniedPorts?.includes(Y)||d8(X,Q.deniedHosts))return J("destination_not_allowed");let K=l0(X);if(K==="private"||["local","internal","arpa"].some((V)=>X===V||X.endsWith(`.${V}`)))return J("private_network");if(K==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Q.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Q.allowedDomains.some((V)=>A1(V,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import VZ from"child_process";import{accessSync as I1,constants as R1,readFileSync as E1,statSync as UZ}from"fs";import{createRequire as WZ}from"module";import{homedir as FZ}from"os";import{dirname as S1,isAbsolute as p8,join as Y9,resolve as w1}from"path";var $8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:HZ.dependencies["playwright-core"],browser:"chromium"}),BZ=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Chromium.app/Contents/MacOS/Chromium"],l8=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function R9($){try{return I1($,R1.X_OK),p8($)&&UZ($).isFile()}catch{return!1}}function u8($,Q=process.platform){let Z=Q==="darwin"?BZ:Q==="linux"?l8:null;return Z?($??Z).find(R9)??null:null}function b1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Q=[];VZ.spawn=new Proxy(VZ.spawn,{apply(Z,X,J){let Y=Reflect.apply(Z,X,J),K=J[1],V=J[2]?.stdio;if(Array.isArray(K)&&K.includes("--remote-debugging-pipe")&&Array.isArray(V)&&V[3]==="pipe"&&V[4]==="pipe")Q.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Q})}async function Q8($){if(b1(),$!==void 0){if(!p8($))throw Error("hands_browser_driver_path_must_be_absolute");let X=Y9($,"package.json"),J=JSON.parse(E1(X,"utf8"));if(J.name!==$8.driver)throw Error("hands_browser_wrong_driver");let Y=WZ(X)($),K=Y.default?.chromium??Y.chromium;if(!K)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:K}}let[Q,Z]=await Promise.all([import("./index-g4t2q0ep.js"),import("./package-s8sef5wh.js").then((m)=>P1(m.default,1))]);return{version:Z.default.version,chromium:Q.chromium}}var k1=($,Q=$8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Q}),f1=($)=>$.loadDriver?.()??Q8($.driverModuleDirectory),g1={"1.60.0":"1223"};function BX(){let $=process.platform,Q=g1[$8.driverVersion];if(!Q||$!=="linux"&&$!=="darwin")return!1;let Z=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Z("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?Y9(S1(WZ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?w1(Z("INIT_CWD")||process.cwd(),X):Y9($==="darwin"?Y9(FZ(),"Library","Caches"):process.env.XDG_CACHE_HOME||Y9(FZ(),".cache"),"ms-playwright");return UZ(Y9(J,`chromium-${Q}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function G9($={}){return LZ($,$8.driverVersion)}async function s8($,Q={}){if($.driverVersion!=="1.61.1"||!p8($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return LZ({...Q,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function LZ($,Q){let Z=(G)=>k1(G,Q),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin")return Z("unsupported_platform");let J;try{J=await f1($)}catch{return Z("driver_missing")}if(J.version!==Q)return Z("driver_version_mismatch");let Y=(G,F)=>({status:"resolved",executablePath:G,source:F,driverVersion:J.version});if($.executablePath!==void 0)return R9($.executablePath)?Y($.executablePath,"configured"):Z("executable_missing");let K=J.chromium.executablePath();if(R9(K))return Y(K,"managed");let V=$.allowSystemBrowser===!0?u8($.systemCandidates,X):null;return V?Y(V,"system"):Z("executable_missing")}var a1=["/usr/local/bin/chromium",...l8];function o1($,Q=OZ()){return u8($??(Q==="linux"?a1:void 0),Q)}async function r1(){try{return(await Q8()).chromium}catch{return l1(import.meta.url)("playwright-core").chromium}}var t1=1048576,e1=105000,$7=20000,jZ=5000,Q7=2000,Z7=1000,X7=30000,CZ=81920,J7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function Y7($,Q){let Z=new URL($.url()),X={...await $.allHeaders(),host:Z.host};for(let J of Object.keys(X))if(/^(?:proxy-|connection$|upgrade$|transfer-encoding$|content-length$)/i.test(J))delete X[J];return new Promise((J,Y)=>{let V=(Z.protocol==="https:"?s1:u1)(Z,{method:$.method(),headers:X,agent:!1,lookup:(F,B,H)=>{let z=u0.isIP(Q);if(B.all)H(null,[{address:Q,family:z}]);else H(null,Q,z)}},(F)=>{let B=[],H=0;F.on("data",(z)=>{if(H+=z.length,H>33554432)V.destroy(Error("hands_browser_response_too_large"));else B.push(z)}),F.on("error",Y),F.on("end",()=>{let z={};for(let[L,W]of Object.entries(F.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))z[L]=Array.isArray(W)?W.join(`
307
307
  `):W;J({status:F.statusCode??502,headers:z,body:Buffer.concat(B)})})}),G=setTimeout(()=>V.destroy(Error("hands_browser_fetch_timeout")),X7);V.once("close",()=>clearTimeout(G)),V.on("error",Y),V.end($.postDataBuffer()??void 0)})}async function G7($,Q,Z=()=>{},X={lookup:(J)=>p1(J,{all:!0}),fetch:Y7}){let J=new WeakSet,Y=new WeakMap,K=(V)=>{let G=Y.get(V);if(G)return G;let F=(async()=>{if(!$.newCDPSession)return;let B=await $.newCDPSession(V),H=new Map;B.on("Network.loadingFinished",({requestId:z})=>H.delete(z)),B.on("Network.loadingFailed",({requestId:z})=>H.delete(z)),B.on("Fetch.requestPaused",async(z)=>{let L=z.networkId??z.requestId,W=z.redirectedRequestId?(H.get(L)??0)+1:0;H.set(L,W);let U=I9(z.request.url,Q),j=Q.mode==="enforce"&&Boolean(z.redirectedRequestId)&&U.host!==null&&!u0.isIP(U.host),O=!U.allowed?U:j?{...U,allowed:!1,reason:"destination_not_allowed"}:W>20?{...U,allowed:!1,reason:"redirect_not_supported"}:null;try{if(O)Z(O),await B.send("Fetch.failRequest",{requestId:z.requestId,errorReason:"BlockedByClient"});else await B.send("Fetch.continueRequest",{requestId:z.requestId})}catch{await B.send("Fetch.failRequest",{requestId:z.requestId,errorReason:"Failed"}).catch(()=>{})}}),await B.send("Network.enable"),await B.send("Fetch.enable",{patterns:[{urlPattern:"*",requestStage:"Request"}]}),J.add(V)})();return Y.set(V,F),F};return await $.route("**/*",async(V)=>{let G=V.request().url(),F=I9(G,Q);if(F.allowed&&Q.mode==="public_web"){await V.continue();return}let B=V.request();if(F.allowed&&F.host&&u0.isIP(F.host)&&B.isNavigationRequest?.()){let H=B.frame();if(J.has(H.page())&&H===H.page().mainFrame()){await V.continue();return}}if(F.allowed&&(Q.mode==="off"||F.reason==="local_document")){await V.continue();return}if(F.allowed&&F.host)try{let H=F.host,z=l0(H),L,W=await(async()=>{if(z!=="hostname")return[{address:H,family:u0.isIP(H)}];if(F.reason==="loopback")return[{address:"127.0.0.1",family:4}];try{return await Promise.race([X.lookup(H),new Promise((U,j)=>{L=setTimeout(()=>j(Error("hands_browser_dns_timeout")),5000)})])}finally{if(L)clearTimeout(L)}})();if(!W.length||W.some(({address:U})=>{let j=l0(U);return!u0.isIP(U)||Q.mode==="enforce"&&d8(U,Q.deniedHosts)||(F.reason==="loopback"?j!=="loopback":j!=="public")}))F={...F,allowed:!1,reason:"private_network"};else{let U=await X.fetch(V.request(),W[0].address);if(U.status>=300&&U.status<400){let j=U.headers.location??G;try{j=new URL(j,G).href}catch{}let O=I9(j,Q);F=O.allowed?{...O,allowed:!1,reason:"redirect_not_supported"}:O}else{await V.fulfill(U);return}}}catch{await V.abort("failed");return}Z(F),await V.abort("blockedbyclient")}),await $.routeWebSocket("**/*",async(V)=>{let G=I9(V.url(),Q);if(Q.mode==="enforce"&&G.allowed&&(!G.host||!u0.isIP(G.host)))G={...G,allowed:!1,reason:"destination_not_allowed"};if(G.allowed){V.connectToServer();return}Z(G),await V.close({code:1008,reason:"Reason egress policy denied"})}),Q.mode==="off"?void 0:{preparePage:K}}async function DZ($,Q=OZ(),Z){if(Z){let J=await s8(Z,{platform:Q,systemCandidates:$});return J.status==="resolved"?J.executablePath:null}if($!==void 0){let J=o1($,Q);if(J)return J}let X=await G9({platform:Q,systemCandidates:$,allowSystemBrowser:!0});return X.status==="resolved"?X.executablePath:null}function qZ($,Q){if(!$)throw Error("hands_repl_workspace_required");let Z=i8($),X=z9($),J=a8(X,z9(X,Q)),K=J!==".."&&!J.startsWith(`..${o8}`)&&!MZ(J)?z9(Z,J):z9(Z,Q);if(b0(z9(X,Q))||b0(K))throw Error("hands_repl_protected_path");let V=(W)=>{let U=a8(Z,W);return U!==""&&U!==".."&&!U.startsWith(`..${o8}`)&&!MZ(U)},G=i8(K);if(b0(G))throw Error("hands_repl_protected_path");if(!V(K)||!V(G))throw Error("hands_repl_file_outside_workspace");let F=a8(Z,K).split(o8),B=[Z,...F.map((W,U)=>z9(Z,...F.slice(0,U+1)))],H=B.map((W)=>NZ(W));if(H.some((W)=>W.isSymbolicLink()))throw Error("hands_repl_file_symlink");let z=H[H.length-1];if(!z.isFile()||z.nlink!==1||z.size>16777216)throw Error("hands_repl_file_not_regular_or_too_large");let L=v1(K,n8.O_RDONLY|n8.O_NOFOLLOW|n8.O_NONBLOCK);try{let W=h1(L);if(W.dev!==z.dev||W.ino!==z.ino||!W.isFile())throw Error("hands_repl_file_changed");for(let q=0;q<B.length;q++){let A=NZ(B[q]);if(A.dev!==H[q].dev||A.ino!==H[q].ino||A.isSymbolicLink())throw Error("hands_repl_file_changed")}if(!V(i8(K)))throw Error("hands_repl_file_outside_workspace");let U=Buffer.alloc(16777217),j=0;while(j<U.length){let q=c1(L,U,j,U.length-j,null);if(!q)break;j+=q}if(j===U.length)throw Error("hands_repl_file_too_large");let O=U.subarray(0,j);return{name:n1(K),mimeType:J7[i1(K).toLowerCase()]??"application/octet-stream",buffer:O}}finally{y1(L)}}function K9($,Q){$.end(`${JSON.stringify(Q)}
308
308
  `)}function Z8($){try{d1($)}catch{}}async function _Z($){if($.managedBrowser&&$.driverModuleDirectory!==void 0)throw Error("hands_browser_ambiguous_driver_configuration");let Q=$.launch||$.targetContext?null:$.managedBrowser?await s8($.managedBrowser,{executablePath:$.browserExecutablePath}):await G9({executablePath:$.browserExecutablePath,driverModuleDirectory:$.driverModuleDirectory});if(Q?.status==="unavailable")throw Error(`hands_browser_${Q.reason}`);let Z=Q?.status==="resolved"?Q.executablePath:$.browserExecutablePath;if(!Z||!R9(Z))throw Error("hands_browser_unavailable");let X=$.launch??(async(N)=>($.targetContext?await r1():(await Q8($.managedBrowser?.driverModuleDirectory??$.driverModuleDirectory)).chromium).launch(N)),J=[],Y={},K=null,V=null,G=null,F=null,B=!1,H=null,z=new Map,L=new WeakMap,W=null,U=()=>{if(B)throw Error("hands_repl_stopped");if(F)throw F},j=(N)=>{let M=L.get(N);if(M)return M;let D=Promise.resolve().then(()=>N.close()).then(()=>{z.delete(N)});return L.set(N,D),D},O=async()=>{let N=[...z.entries()].reverse(),M=W??=performance.now()+Z7,D=Promise.allSettled(N.filter(([,_])=>_==="context").map(([_])=>j(_))),w;try{await Promise.race([D,new Promise((_)=>{w=setTimeout(_,Math.max(0,M-performance.now()))})])}finally{if(w)clearTimeout(w)}let k=await Promise.allSettled(N.map(([_])=>j(_))),f=[];for(let[_,m]of k.entries()){if(m.status!=="rejected")continue;let c=m.reason instanceof Error&&["Error","TimeoutError","ProtocolError"].includes(m.reason.name)?m.reason.name:"unknown";f.push(Error(`hands_repl_close_failed: ${N[_][1]}: ${c}`))}if(f.length)throw AggregateError(f,"hands_repl_stop_unconfirmed")},q=(N,M)=>{if(z.set(N,M),B||F)j(N).catch(()=>{return}),U();return N},A=async()=>{let N=await X({executablePath:Z,headless:!0,chromiumSandbox:$.managedBrowser===void 0,args:["--disable-background-networking","--disable-quic","--disable-dev-shm-usage","--disable-gpu","--disable-software-rasterizer","--dns-prefetch-disable","--force-webrtc-ip-handling-policy=disable_non_proxied_udp","--no-pings"]}),M=null;try{q(N,"browser"),M=$.targetContext??q(await N.newContext({viewport:{width:1440,height:900},screen:{width:1440,height:900},serviceWorkers:"block",acceptDownloads:!1}),"context");let D=await G7(M,$.networkPolicy??{mode:"off"},$.onEgressDenied);if(U(),D){let b=M.newPage.bind(M);M.newPage=async()=>{let y=await b();return await D.preparePage(y),y}}let k=M.pages()[0]??await M.newPage();await D?.preparePage(k),U();let f=async(b=k)=>{let y=b;if(typeof y.ariaSnapshot==="function")return y.ariaSnapshot({timeout:1e4});return k.locator("body").innerText({timeout:1e4})},_=async(b,y={})=>{let d=y&&typeof y==="object"&&!Array.isArray(y)?y:{},u,G0="image/png";if(Buffer.isBuffer(b)||b instanceof Uint8Array)u=Buffer.from(b);else if(typeof b==="string"&&(b.startsWith("data:")||/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(b)))u=Buffer.from(b.replace(/^data:[^,]*,/,""),"base64");else if(typeof b==="string"){let q0=qZ($.workspaceRoot,b);u=q0.buffer,G0=q0.mimeType}else throw Error("view() needs a Buffer, a base64 string, or a path to an image file");if(u.length===0)throw Error("view(): the image is empty");let N0=String(d.label??"").replace(/[\r\n>]+/g," ").trim().slice(0,120),H0=Number(d.maxWidth)||1024,U0=Number(d.quality)||72,y0=$.targetContext?await N.newPage():await M.newPage();try{let q0=`data:${G0};base64,${u.toString("base64")}`;for(let r=0;r<5;r+=1){let M0=await y0.evaluate(async(W0)=>{let j0=new Image;j0.src=W0.url,await j0.decode();let h0=Math.min(1,W0.maxWidth/j0.naturalWidth),Y0=document.createElement("canvas");Y0.width=Math.max(1,Math.round(j0.naturalWidth*h0)),Y0.height=Math.max(1,Math.round(j0.naturalHeight*h0));let X0=Y0.getContext("2d");if(!X0)throw Error("view(): canvas unavailable");return X0.fillStyle="#ffffff",X0.fillRect(0,0,Y0.width,Y0.height),X0.drawImage(j0,0,0,Y0.width,Y0.height),{data:Y0.toDataURL("image/jpeg",W0.q/100).split(",")[1]??"",width:Y0.width,height:Y0.height,sourceWidth:j0.naturalWidth,sourceHeight:j0.naturalHeight}},{url:q0,maxWidth:H0,q:U0}),r0=Buffer.from(M0.data,"base64");if(r0.length<=CZ){let W0=N0||"image";return`<<<ARA_VIEW_IMAGE ${M0.data} image/jpeg ${W0}>>>
309
309
  Viewing ${W0} (${M0.sourceWidth}x${M0.sourceHeight} source, sent at ${M0.width}x${M0.height}, ${Math.round(r0.length/1024)}KB).`}if(H0>640)H0=Math.round(H0*0.75);else U0=Math.max(30,U0-15)}throw Error(`view(): could not reduce the image under ${Math.round(CZ/1024)}KB`)}finally{await y0.close().catch(()=>{return})}},m=ZZ({browser:$.targetContext?.browser()??N,context:M,page:k,a11y:f,view:_,readWorkspaceFile:(b)=>qZ($.workspaceRoot,b),privateProfile:$.privateProfile,beforeNavigation:$.beforeNavigation,recording:$.recording,screenshotExport:$.screenshotExport,actionRecorder:()=>{let b=J,y=Y;return(d,u)=>{if(b.length<TZ)b.push(d);if(u)y.page=u}}}),c=async(b)=>{U();let y=q(await N.newContext({serviceWorkers:"block",acceptDownloads:!1}),"context");try{await y.route("**/*",(u)=>u.abort()),U(),await y.routeWebSocket("**/*",(u)=>u.close({code:1008,reason:"Reason evaluator network denied"})),U(),await y.exposeBinding("__araHandsRpc",async(u,G0)=>$.onBrowserOperation?$.onBrowserOperation(b,()=>m.dispatch(G0)):m.dispatch(G0)),U();let d=await y.newPage();return U(),await d.goto("data:text/html,<title>Reason Hands evaluator</title>"),U(),await d.evaluate(`(${sQ})(${JSON.stringify(m.roots)})`),{context:y,page:d,runId:b}}catch(d){throw await j(y).catch(()=>{return}),d}},l=await c(),o={browser:N,context:M,page:k,evaluator:l,async captureProgressFrame(b){return _(await b.screenshot({type:"jpeg",quality:65,timeout:2000}),{label:"Screen after browser action"})},async resetEvaluator(b){await j(o.evaluator.context),o.evaluator=await c(b)}};return U(),o}catch(D){throw await O().catch(()=>{return}),D}},R=async()=>{if(U(),K)return K;if(!G){V=A();let N;G=Promise.race([V,new Promise((M,D)=>{N=setTimeout(()=>D(Error("hands_browser_unavailable: startup timed out")),$7)})]).then((M)=>{return U(),K=M,M}).catch(async()=>{F=Error("hands_browser_unavailable: startup failed or timed out");let M;try{await Promise.race([O(),new Promise((D,w)=>{M=setTimeout(()=>w(Error("hands_repl_stop_timeout")),jZ)})])}catch{F=Error("hands_browser_unavailable: startup cleanup unconfirmed")}finally{if(M)clearTimeout(M)}throw F}).finally(()=>{if(N)clearTimeout(N)})}return G},P=async(N,M,D=!1)=>{let w=await R(),k=Y;if($.onBrowserOperation&&w.evaluator.runId!==M)await w.resetEvaluator(M);let _=(async()=>{let l=await w.evaluator.page.evaluate(`(${nQ})(${JSON.stringify({code:N})})`);if(typeof l!=="string")throw Error("hands_repl_invalid_evaluator_output");let o=k.page;if(D&&o&&!l.includes("<<<ARA_VIEW_IMAGE")){let b=()=>w.captureProgressFrame(o);try{let y=await($.onBrowserOperation?$.onBrowserOperation(M,b):b());return k.automaticProgressImage=!0,`${l}
@@ -456,4 +456,4 @@ lines.on("line", (line) => {
456
456
  `,(S)=>{if(!S)return;B(T,void 0,S)})});try{if(!G){if(Z.pid===void 0)await S9(X);throw J??Error("hands_node_repl_control_pipe_missing")}let q=await W({action:"probe"});if(q.ok!==!0||q.output!=="ARA_HANDS_REPL_READY")throw Error("hands_node_repl_probe_failed")}catch(q){Y=!0,Z.kill("SIGKILL");try{await S9(X)}finally{await Q.cleanup()}throw q}let U=Promise.resolve(),j=new Set;Y$($.socketPath);let O=e7.createServer((q)=>{j.add(q),q.once("close",()=>j.delete(q)),q.setEncoding("utf8");let A="",R=!1,P=!1;q.once("close",()=>{if(P)H()}),q.on("error",()=>q.destroy()),q.on("data",(T)=>{if(R)return;if(A+=T,A.length>nZ){R=!0,K8(q,{ok:!1,error:"REPL request exceeds 1 MiB"});return}let S=A.indexOf(`
457
457
  `);if(S===-1)return;R=!0;let g=A.slice(0,S);U=U.then(async()=>{if(q.destroyed)return;try{let E=JSON.parse(g);if(E.action!=="evaluate"||typeof E.code!=="string")throw Error("Invalid REPL request");P=!0;let N=await W({action:"evaluate",code:E.code});if(P=!1,N.ok!==!0||typeof N.output!=="string")throw Error(typeof N.error==="string"?N.error:"hands_node_repl_failed");K8(q,{ok:!0,output:N.output})}catch(E){P=!1,K8(q,{ok:!1,error:E instanceof Error?E.message:String(E),stack:E instanceof Error?E.stack:void 0})}}).catch((E)=>{K8(q,{ok:!1,error:E instanceof Error?E.message:String(E)})})})});try{await new Promise((q,A)=>{O.once("error",A),O.listen($.socketPath,()=>{O.off("error",A);try{n7($.socketPath,384),q()}catch(R){O.close(()=>A(R))}})})}catch(q){Y=!0,Z.kill("SIGKILL");try{await S9(X)}finally{await Q.cleanup(),Y$($.socketPath)}throw q}return{socketPath:$.socketPath,async stop(){if(Y)return;Y=!0;let q=new Promise((A)=>O.close(()=>A()));for(let A of j)A.destroy();await q,U.catch(()=>{return}),H();try{await S9(X)}finally{await Q.cleanup(),Y$($.socketPath)}}}}var K$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var aZ="/workspace",oZ="/var/lib/reason/sessions",z6="/var/lib/reason/session-controls";function rZ($){let Q=`${oZ}/`;if(!$.startsWith(Q))return null;let Z=$.slice(Q.length);if(!K$.test(Z)||Z!==Z.toLowerCase())throw Error("personal_computer_invalid_runtime_root");return`${z6}/${Z}/job.env`}function K6($){if(!K$.test($))throw Error("personal_computer_invalid_identity");return $.toLowerCase()}function F8($){let Q=K6($);return{runtimeRoot:`${oZ}/${Q}`,workspaceRoot:`${aZ}/sessions/${Q}`,sharedRoot:aZ}}var tZ="/root/.ara/cloud-browser/repl.sock";function V$($){return $==="compute"}function eZ($,Q,Z="linux"){if($)F8($);if(Z!=="linux")throw Error("cloud_browser_os_invalid");if(Q!==void 0&&(!$||!/^[1-9][0-9]{0,18}$/.test(Q)))throw Error("cloud_browser_generation_invalid");let X=$?`/var/lib/reason/browsers/${$.toLowerCase()}`:"/root/.ara/cloud-browser",J=$?`${X}/${Q?`g${Q}`:"current"}`:X,Y=$?`/root/.b/${$.toLowerCase().replaceAll("-","")}`:X;return{temporarySessionDirectory:Y,temporaryDirectory:$?`${Y}/${Q??"current"}`:`${J}/tmp`,directory:J,sessionDirectory:X,config:`${J}/config.json`,status:`${J}/status.json`,socket:`${J}/repl.sock`,bundle:`${J}/driver.mjs`,processName:$?`ara-browser-${$.toLowerCase()}${Q?`-${Q}`:""}`:"ara-cloud-browser"}}var H$="browser_egress",$4=LQ,T6=45000,O6=p9+1500,m0=/^[A-Za-z0-9._:-]{1,160}$/,D6="/run/ara-hands";function _6($,Q,Z=K4()){if($==="darwin")return{temporaryRoot:Z,prepareRoot:!1,sessionMode:448};return{temporaryRoot:Q??D6,prepareRoot:!0,sessionMode:457}}function Q4($,Q=process.platform,Z=process.geteuid?.()){return $===!0&&Q==="linux"&&Z===0}function B$($=J4(),Q=process.platform,Z=process.geteuid?.()){return $&&Q==="linux"&&Z===0?{uid:$.uid,gid:$.gid,home:$.home,username:$.username}:null}function A6($=B$(),Q=xZ){return $&&Q()?r8:null}function yY($=B$(),Q=process.platform,Z=process.geteuid?.()){return Q!=="linux"||Z!==0||$!==null}function hY($=process.platform,Q=process.geteuid?.()){return $!=="linux"||Q!==0}function x6($,Q){if(!Q&&($??"linux")==="linux")return tZ;return eZ(Q,void 0,$??"linux").socket}function P6($){return $[L0]===!0?"sandbox_loopback":"ara_device_wss"}function W9($){return Boolean($)&&typeof $==="object"&&!Array.isArray($)}function F4($){let Q=$.toLowerCase().replace(/^\[|\]$/g,"");return Q==="localhost"||Q.endsWith(".localhost")||Q==="::1"||Q==="0:0:0:0:0:0:0:1"||Q==="0.0.0.0"||Q.startsWith("127.")}class H4 extends C{expiryDiagnostic;constructor($){super("invalid_hands_expiry","Reason Hands connection expiry is invalid.");this.expiryDiagnostic=$}}function I6($){return W9($)&&Object.keys($).every((Q)=>Q==="source_path"||Q==="branch")&&($.source_path===void 0||s0($.source_path))&&typeof $.branch==="string"&&$$.test($.branch)}function R6($,Q,Z){let X=Q===void 0?Date.now():Q,J=["relay_url","session_id","environment_id","expires_at","policy_mode","policy_version","hands_protocol_version","hands_worker_version","hands_worker_artifact_sha256","hands_worker_entrypoint","target_generation","target_fence_id"],Y=new Set([...J,"workspace_id","legacy_workspace_id",i0,a0,"environment_binding","cloud_browser","sandbox_provider","sandbox_os","personal_workspace","workspace_path","workspace_worktree",p,L0,H$,F9,C0,o0,g0]),K=W9($)?$:null,V=K?.[H$],G=K?.[F9],F=K?.[o0],B=V===void 0||(K?.[p]===f0||F===w9&&K?.[p]===void 0)&&W9(V)&&Object.keys(V).every((q)=>q==="mode"||q==="allowed_domains")&&V.mode==="enforce"&&Array.isArray(V.allowed_domains)&&V.allowed_domains.length<=256&&V.allowed_domains.every((q)=>typeof q==="string"&&c8(q));if(!W9($)||J.some((q)=>!(q in $))||Object.keys($).some((q)=>!Y.has(q))||!B||F!==void 0&&F!==w9||K?.[g0]!==void 0&&K[g0]!==W8||K?.personal_workspace!==void 0&&(K.personal_workspace!==!0||K[p]!==f0)||K?.cloud_browser!==void 0&&(K.cloud_browser!==!0||K[p]!==f0)||K?.sandbox_provider!==void 0&&!V$(K.sandbox_provider)||K?.sandbox_os!==void 0&&K.sandbox_os!=="linux"||G!==void 0&&(K?.[p]!==V9||!t8(G))||p in $&&$[p]!==f0&&$[p]!==V9&&$[p]!==B0||L0 in $&&$[L0]!==!0||$.workspace_path!==void 0&&(!s0($.workspace_path)||$[p]!==B0)||$.workspace_worktree!==void 0&&($.workspace_path===void 0||!I6($.workspace_worktree))||typeof $.relay_url!=="string"||typeof $.session_id!=="string"||!m0.test($.session_id)||$.workspace_id!==void 0&&(typeof $.workspace_id!=="string"||!m0.test($.workspace_id))||$.legacy_workspace_id!==void 0&&(typeof $.legacy_workspace_id!=="string"||!m0.test($.legacy_workspace_id))||$[i0]!==void 0&&($[i0]!==B8||(p in $))||$[a0]!==void 0&&($[a0]!==L8||(p in $))||$[C0]!==void 0&&(typeof $[C0]!=="string"||!m0.test($[C0]))||typeof $.environment_id!=="string"||!m0.test($.environment_id)||typeof $.expires_at!=="string"||$.policy_mode!=="full_access"||$.policy_version!==1||$.hands_protocol_version!==B9||$.hands_worker_version!==L9||$.hands_worker_artifact_sha256!==K0||!cZ($.hands_worker_entrypoint)||!S0($.target_generation)||!O0($.target_fence_id))throw new C("invalid_hands_payload","Reason Hands connection payload is invalid.");let H;try{H=new URL($.relay_url)}catch{throw new C("invalid_hands_relay","Reason Hands relay URL is invalid.")}let z=$[L0]===!0,L=F4(H.hostname);if((z?H.protocol!=="ws:"||!L:L?H.protocol!=="ws:":H.protocol!=="wss:")||H.username||H.password||H.hash||!/^\/device\/[A-Za-z0-9-]+\/[A-Za-z0-9]+$/.test(H.pathname))throw new C("invalid_hands_relay","Reason Hands relay URL is not allowed.");let W=Date.parse($.expires_at),U=Number.isNaN(W)?"parse":new Date(W).toISOString()!==$.expires_at?"noncanonical":W<=X?"expired":W-X>$4?"over_cap":"accepted",j={version:1,outcome:U,clock_source:Q===void 0?"date_now":"injected",validation_now_ms:Z9(X),expiry_ms:Z9(W),remaining_ms:Number.isSafeInteger(W-X)?W-X:null,maximum_lifetime_ms:$4,cli_artifact:dZ()};if(U!=="accepted")throw new H4(j);try{Z?.(j)}catch{}let O=$.environment_binding===void 0?void 0:b8.safeParse($.environment_binding);if(O&&!O.success)throw new C("invalid_hands_request","Reason Hands environment binding is invalid.");return{...$.cloud_browser===!0?{cloud_browser:!0}:{},...V$($.sandbox_provider)?{sandbox_provider:$.sandbox_provider}:{},...$.sandbox_os==="linux"?{sandbox_os:$.sandbox_os}:{},...$.personal_workspace===!0?{personal_workspace:!0}:{},relay_url:H.toString(),...O?.success?{environment_binding:O.data}:{},session_id:$.session_id,...$.workspace_id===void 0?{}:{workspace_id:$.workspace_id},...$.legacy_workspace_id===void 0?{}:{legacy_workspace_id:$.legacy_workspace_id},...$[i0]===B8?{[i0]:B8}:{},...$[a0]===L8?{[a0]:L8}:{},...typeof $[C0]==="string"?{[C0]:$[C0]}:{},...$[o0]===w9?{[o0]:w9}:{},...$[g0]===W8?{[g0]:W8}:{},...typeof $.workspace_path==="string"?{workspace_path:$.workspace_path}:{},...W9($.workspace_worktree)?{workspace_worktree:{...typeof $.workspace_worktree.source_path==="string"?{source_path:$.workspace_worktree.source_path}:{},branch:String($.workspace_worktree.branch)}}:{},environment_id:$.environment_id,expires_at:$.expires_at,policy_mode:"full_access",policy_version:1,hands_protocol_version:B9,hands_worker_version:L9,hands_worker_artifact_sha256:K0,hands_worker_entrypoint:n0,target_generation:$.target_generation,target_fence_id:$.target_fence_id,...p in $?{[p]:$[p]}:{},...z?{[L0]:!0}:{},...G===void 0?{}:{[F9]:G},...V===void 0?{}:{[H$]:{mode:"enforce",allowed_domains:[...new Set(V.allowed_domains)].sort()}}}}function E6(){let $=new Map;return{acquire(Q,Z){if($.has(Q))return null;let X=[...$.values()],J=(K)=>Z.group!==void 0&&K.group===Z.group;if(Z.exclusive?!X.every(J):X.some((K)=>K.exclusive))return null;if(Z.limit!==void 0&&!X.some(J)&&new Set(X.map((K,V)=>K.group??V)).size>=Z.limit)return null;$.set(Q,Z);let Y=!1;return()=>{if(Y)return;Y=!0,$.delete(Q)}},activeOwners:()=>[...$.keys()]}}var S6=E6();function w6($,Q){N9($,{recursive:!0,mode:448});let Z=n($),X=()=>new C("invalid_hands_workspace","Reason Hands managed workspace ancestor must be a real directory, not a link.");for(let K of Q.split("/")){let V=a(Z,K);try{let F=t(V);if(F.isSymbolicLink()||!F.isDirectory())throw X()}catch(F){if(!(F&&typeof F==="object"&&("code"in F)&&F.code==="ENOENT"))throw F;try{N9(V,{mode:448})}catch(B){if(!(B&&typeof B==="object"&&("code"in B)&&B.code==="EEXIST"))throw B}}let G=t(V);if(G.isSymbolicLink()||!G.isDirectory()||n(V)!==V)throw X();Z=V}let J=t(Z),Y=L6(Z,F$.O_RDONLY|F$.O_DIRECTORY|F$.O_NOFOLLOW);try{let K=B6(Y);if(!K.isDirectory()||K.dev!==J.dev||K.ino!==J.ino||n(Z)!==Z)throw X();W6(Y,448)}finally{U6(Y)}return Z}function b6($,Q=X4(),Z,X,J){if(!m0.test($)||Z!==void 0&&!m0.test(Z))throw new C("invalid_hands_workspace","Reason Hands run identity is invalid.");let Y=V0(p0({kind:"managed",workspaceId:$,...X?{base:X}:{},...J?{layout:J}:{}})),K=w6(Q,V0(Y)),V=a(K,q6(Y)),G=!1;try{let z=t(V);if(G=!0,z.isSymbolicLink())throw new C("invalid_hands_workspace","Reason Hands workspace cannot be a symbolic link.");if(!z.isDirectory())throw new C("invalid_hands_workspace","Reason Hands workspace must be a managed directory.")}catch(z){if(z instanceof C||!(z&&typeof z==="object"&&("code"in z)&&z.code==="ENOENT"))throw z}if(J&&!G)try{let z=a(n(Q),V0(p0({kind:"managed",workspaceId:$,...X?{base:X}:{}}))),L=t(z);if(!L.isSymbolicLink()&&L.isDirectory()&&n(z)===z)H8(z,V),G=!0}catch{}if(Z&&Z!==$){let z=a(K,Z);try{let L=t(z);if(L.isSymbolicLink()||!L.isDirectory())throw new C("invalid_hands_workspace","Reason Hands legacy workspace must be a managed directory.");let W=n(z);if(V0(W)!==K)throw new C("invalid_hands_workspace","Reason Hands legacy workspace escaped its managed parent.");let U=null;if(G){U=a(K,`.${$}.previous`);try{throw t(U),new C("invalid_hands_workspace","Reason Hands previous workspace backup already exists.")}catch(j){if(j instanceof C||!(j&&typeof j==="object"&&("code"in j)&&j.code==="ENOENT"))throw j}H8(V,U)}try{H8(W,V)}catch(j){if(U)H8(U,V);throw j}G=!0}catch(L){if(L instanceof C||!(L&&typeof L==="object"&&("code"in L)&&L.code==="ENOENT"))throw L}}N9(V,{recursive:!0,mode:448}),b9(V,448);let F=n(V);if(V0(F)!==K)throw new C("invalid_hands_workspace","Reason Hands workspace escaped its managed parent.");let B=a(F,"repo");try{let z=t(B);if(z.isSymbolicLink()||!z.isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a managed directory.")}catch(z){if(z instanceof C||!(z&&typeof z==="object"&&("code"in z)&&z.code==="ENOENT"))throw z}N9(B,{recursive:!0,mode:448}),b9(B,448);let H=n(B);if(V0(H)!==F)throw new C("invalid_hands_workspace","Reason Hands repository escaped its managed run workspace.");return{workRoot:F,repoPath:H}}function U4($){let Q=null;try{Q=t($)}catch{}if(!Q||Q.isSymbolicLink()||!Q.isDirectory()||Q.uid!==0||Q.gid!==0||(Q.mode&4095)!==493)throw new C("cloud_workspace_root_invalid","This cloud Session's workspace root is not root's 0755 directory, so Reason Hands cannot use it.")}function k6($,Q){let Z="/";for(let X of["",...$.split("/"),...Q.split("/")].filter((J,Y)=>Y===0||J)){if(X)Z=a(Z,X);let J;try{J=t(Z)}catch{return null}if(J.uid!==0)return J.uid;if((J.mode&2)!==0&&(J.mode&512)===0&&!J.isSymbolicLink())return-1;if(J.isSymbolicLink()||!J.isDirectory())return null}return null}function f6($,Q,Z,X=process.geteuid?.(),J){if(!m0.test(Q))return null;let Y,K;try{Y=n($),K=V0(p0({kind:"managed",workspaceId:Q,...Z?{base:Z}:{},...J?{layout:J}:{}}))}catch{return null}let V=a(Y,K),G=W$(V)!==null,F=(W)=>new C("cloud_workspace_root_invalid",W),B;if(X===0){let W=k6(Y,K);if(W===null)return null;if(!G)throw new C("invalid_hands_workspace","As root, Reason Hands never prepares a workspace in folders another user owns.");B=W}else{if(!G)return null;let W,U;try{W=t(V0(V)),U=t(V)}catch{return null}if(W.isSymbolicLink()||!W.isDirectory()||W.uid===0||U.uid!==0)return null;B=W.uid}let H=Y;for(let W of K.split("/")){let U=a(H,W),j=!1;try{let O=t(U);j=!O.isSymbolicLink()&&O.isDirectory()&&n(U)===U}catch{}if(!j)throw F("This cloud Session's workspace root is missing or is not a real directory.");H=U}U4(V);let z;try{z=W4(V)}catch(W){if(W instanceof C)throw W;throw F("This cloud Session's workspace root changed while Reason Hands checked it.")}let L=null;try{L=k9(z.repoPath).uid}catch{}if(L!==B)throw new C("invalid_hands_workspace","Reason Hands repository must belong to the cloud Session's user.");return z}function W4($,Q=!1){let Z=n($),X=a(Z,"repo"),J;try{J=t(X)}catch{throw new C("invalid_hands_workspace","Reason Hands repository is missing from the granted root.")}if(Q){if(!/^\/var\/lib\/reason\/sessions\/[0-9a-f-]{36}$/.test(Z))throw new C("invalid_hands_workspace","Personal runtime identity is invalid.");if(F8(Z.slice(Z.lastIndexOf("/")+1)).runtimeRoot!==Z)throw new C("invalid_hands_workspace","Personal runtime identity is invalid.");let V=n("/workspace"),G=n(X);if(V!=="/workspace"||!k9(G).isDirectory()||!G.startsWith("/workspace/"))throw new C("invalid_hands_workspace","Personal files escaped the personal computer.");return{workRoot:Z,repoPath:G}}let Y=PZ(Z);if(Y&&J.isSymbolicLink()){let V=n(X);if(V!==n(Y)||!k9(V).isDirectory())throw new C("invalid_hands_workspace","Side chat repository must be its parent's checkout.");return{workRoot:Z,repoPath:V}}if(J.isSymbolicLink()||!J.isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a managed directory.");let K=n(X);if(V0(K)!==Z)throw new C("invalid_hands_workspace","Reason Hands repository escaped its granted root.");return{workRoot:Z,repoPath:K}}function L$($,Q,Z){if(Q!==void 0&&!s0(Q))throw new C("invalid_hands_workspace",`Reason Hands ${Z} is invalid.`);let X=V4($,Q??".");if(!w0($,X))throw new C("invalid_hands_workspace",`Reason Hands ${Z} escapes its granted root.`);return X}function B4($,Q,Z){if(e8(Q)){let X=n(Z);return{anchor:X,target:V4(X,Q),boundary:a(X,H9)}}return{anchor:$,target:L$($,Q,"folder"),boundary:$}}function g6($,Q){if(!w0($,Q))throw new C("invalid_hands_workspace","Reason Hands folder escapes its granted root.");let Z=$;for(let X of Q.slice($.length).split("/").filter(Boolean)){Z=a(Z,X);let J=null;try{J=t(Z)}catch(Y){if(Y.code!=="ENOENT")throw Y}if(!J)N9(Z,{mode:448});else if(J.isSymbolicLink()||!J.isDirectory())throw new C("invalid_hands_workspace","Reason Hands folder must be made of real directories.")}}function L4($,Q){let Z=n(L$($,Q.source_path,"repository"));if(!w0($,Z)||!k9(Z).isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a folder in its granted root.");return Z}async function m6($,Q,Z,X=N8()){try{let J=n($);if(U$(B4(J,Q,X).target))return;return await bZ(L4(J,Z))??void 0}catch{return}}function y6($,Q,Z,X,J=h6,Y=N8()){let K=n($),{target:V,boundary:G,anchor:F}=B4(K,Q,Y);if(Z&&!U$(V)){let z=L4(K,Z);g6(F,V0(V));let L=["-c","core.hooksPath=/dev/null","-C",z];if(X)J([...L,"update-ref","--create-reflog","-m",X.note,`refs/heads/${Z.branch}`,X.commit,""]);let W=X?J([...L,"worktree","add",V,Z.branch]):J([...L,"worktree","add","-b",Z.branch,V]);if(!X&&W.status!==0&&/already exists/.test(W.stderr)&&!U$(V))W=J([...L,"worktree","add",V,Z.branch]);if(W.status!==0)throw new C(/not a git repository/i.test(W.stderr)?"workspace_not_git_repository":"workspace_worktree_failed","Reason could not create this Session's git worktree.")}let B;try{B=t(V)}catch{throw new C("workspace_folder_missing","This Session's folder no longer exists.")}let H=n(V);if(B.isSymbolicLink()&&!w0(G,H))throw new C("invalid_hands_workspace","Reason Hands folder resolves outside its granted root.");if(!k9(H).isDirectory()||!w0(G,H))throw new C("invalid_hands_workspace","Reason Hands folder must be a directory in its granted root.");if(b0(H))throw new C("protected_path","Credential and secret folders are unavailable to Sessions.");return H}function h6($){let Q=H6("git",$,{encoding:"utf8",timeout:60000,env:{...process.env,GIT_TERMINAL_PROMPT:"0"},stdio:["ignore","ignore","pipe"]});return{status:Q.status,stderr:Q.stderr??""}}function N4($){return rZ($)??W$($)?.jobEnv??a($,"job.env")}function v6($,Q){let Z=N4($),X=t(Z);if(X.isSymbolicLink()||!X.isFile())throw new C("invalid_hands_workspace","Reason Hands job environment must be a managed regular file.");N6(Z,Q),b9(Q,384)}function c6($){if($.workspaceMode===B0&&$.workspacePath!==void 0){let K=$.home??N8(),V=y6($.grantedRoot,$.workspacePath,$.workspaceWorktree,$.workspaceWorktreeStart,void 0,K);if($.workspaceWorktree&&$.deviceId)mZ(K,$.workspacePath,$.deviceId);return{workRoot:V,repoPath:V,workspace:{kind:"root",path:$.workspacePath},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!0}}if($.workspaceMode===f0)return{...W4($.grantedRoot,$.personalWorkspace),workspace:{kind:"root"},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!1};if($.workspaceMode===V9||$.workspaceMode===B0){let K=t($.grantedRoot);if(K.isSymbolicLink()||!K.isDirectory())throw new C("invalid_hands_workspace","Reason Hands root must be a real directory.");let V=n($.grantedRoot);return{workRoot:V,repoPath:V,workspace:{kind:"root"},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!0}}let Q=$.workspaceId??$.runId,Z={kind:"managed",workspaceId:Q,...$.workspaceBase?{base:$.workspaceBase}:{},...$.workspaceLayout?{layout:$.workspaceLayout}:{}},X=u9($.grantedRoot,Z,$.home).anchor,J=f6(X,Q,$.workspaceBase,void 0,$.workspaceLayout);if(J)return{...J,workspace:Z,jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!1,cloudSessionRoot:!0};let Y=b6(Q,X,$.legacyWorkspaceId,$.workspaceBase,$.workspaceLayout);return{...Y,workspace:Z,jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:V0(Y.workRoot),managedWorkspace:!0}}function d6($){let{command:Q,prefix:Z}=k8($.executablePath,$.sourceEntrypoint),X=V8({home:C6(),temporaryDirectory:$.temporaryDirectory,path:$.path});if(X.REASON_DEVICE_ROOT=X.ARA_DEVICE_ROOT=$.grantedRoot,X.REASON_HANDS_WORKSPACE=X.ARA_HANDS_WORKSPACE=$.workRoot,X.REASON_HANDS_REPO=X.ARA_HANDS_REPO=$.root,$.workspacePoolPath)X.REASON_HANDS_WORKSPACE_POOL=X.ARA_HANDS_WORKSPACE_POOL=$.workspacePoolPath;return{command:Q,args:[...Z,"__device","__hands-worker","--config",$.configPath],options:{cwd:$.root,env:X,shell:!1,stdio:["ignore","ignore","pipe"]}}}function p6($,Q){let Z="",X=!1,J=Date.now(),Y=0,K=new Set(["connecting","open","dial_pending","socket_error","close","claim_accepted","claim_rejected","stopping","stopped","request_cancelled"].map((H)=>`hands.worker.${H}`)),V=new Set([null,"open_not_received","current_connection","obsolete_connection","request_aborted","request_timeout","client_closed","driver_stopped","driver_handoff","run_cancelled","run_finished","other","frame_too_large","invalid_json","invalid_claim","executor_mismatch","stale_generation","fence_conflict","SIGTERM","SIGINT","SIGHUP","expired","cleanup_complete","cleanup_failed","cancelled","settled","unsupported","unconfirmed"]),G=["timestampMs","connectionAttempt","connectionGeneration","targetGeneration","activeRequestCount","remainingLifetimeMs","suppressedDiagnostics"],F=["peerGeneration","socketState","closeCode"],B=new Set(["event","reason","launchId",...G,...F]);return(H)=>{for(let z of H.toString().split(/(?<=\n)/)){let L=z.endsWith(`
458
458
  `);if(!X&&Z.length+z.length<=2048)Z+=z;else X=!0;if(!L)continue;let W=Z;if(Z="",X){X=!1;continue}try{let U=JSON.parse(W);if(!U||typeof U!=="object"||Array.isArray(U)||Object.keys(U).some((j)=>!B.has(j))||!K.has(U.event)||!V.has(U.reason)||U.launchId!==$||G.some((j)=>!Number.isSafeInteger(U[j])||U[j]<0)||F.some((j)=>U[j]!==null&&(!Number.isSafeInteger(U[j])||U[j]<0)))continue;if(Date.now()-J>=60000)J=Date.now(),Y=0;if(Y>=122)continue;Y+=1,Q(U)}catch{}}}}async function l6($){let Q=$.now()+$.timeoutMs;while($.now()<Q){if($.signal.aborted)throw new C("cancelled","Reason Hands start was cancelled.");if($.spawnFailed?.()||$.child.exitCode!==null||$.child.signalCode!==null)throw new C("hands_worker_exited","Reason Hands exited before ready.");let Z=z8($.path,{pid:$.child.pid??-1,launchId:$.launchId,workerVersion:L9,protocolVersion:B9,workerArtifactSha256:K0,workerEntrypoint:n0});if(Z?.targetGeneration===$.targetGeneration&&Z.fenceId===$.fenceId)return Z;await new Promise((X)=>setTimeout(X,10))}throw new C("hands_ready_timeout","Reason Hands did not become ready.")}async function u6($,Q){let Z=()=>$.exitCode===0&&$.signalCode===null;if($.exitCode!==null||$.signalCode!==null)return Z()?"stopped":"already_exited";let X=new Promise((K)=>$.once("exit",()=>K()));try{if(!$.kill("SIGTERM"))return Z()?"stopped":"unobserved"}catch{return Z()?"stopped":"unobserved"}if(await Z4(X,Q))return Z()?"stopped":"unobserved";try{$.kill("SIGKILL")}catch{}return await Z4(X,Q)?"forced":"unobserved"}async function Z4($,Q){let Z;try{return await Promise.race([$.then(()=>!0),new Promise((X)=>{Z=setTimeout(()=>X(!1),Q)})])}finally{clearTimeout(Z)}}function s6($){return new Promise((Q)=>{let Z=!1,X=(V)=>{if(Z)return;Z=!0,clearTimeout(K),$.signal.removeEventListener("abort",J),$.child.off("exit",Y),Q(V)},J=()=>X("cancelled"),Y=()=>X("exited"),K=setTimeout(()=>X("expired"),Math.max(0,$.expiresAt-$.now()));if($.signal.addEventListener("abort",J,{once:!0}),$.child.once("exit",Y),$.signal.aborted)J();else if($.child.exitCode!==null||$.child.signalCode!==null)Y()})}var M4=z4();function n6($,Q){if(!($ instanceof Error)||$ instanceof C)return!1;let Z=["hands_browser_driver_missing","hands_browser_driver_version_mismatch","hands_browser_executable_missing","hands_browser_unsupported_platform","hands_browser_unavailable"].includes($.message),X=["ENOENT","EACCES","EPERM"].includes($.code??"");if(!Z&&!X)return!1;try{return t(Q),!1}catch(J){return W9(J)&&J.code==="ENOENT"}}function i6($){return $.sandbox_provider==="compute"&&!$.cloud_browser&&!$[L0]&&$[p]===f0}function a6($,Q,Z){return $===void 0?{}:{dispatch_stages:{version:1,claim_to_entered_ms:F0($,Q),...Z===void 0?{}:{worker_prespawned:Z}}}}function vY(){M4().catch(()=>{return}),G9().catch(()=>{return})}async function cY($,Q={}){let Z=Q.logDiagnostic??((N)=>console.warn(N)),X=new Map,J=(N)=>{let M=Date.now();X.set(N,M);try{Z(JSON.stringify({event:"sandbox.hands_startup",stage:N,timestampMs:M}))}catch{}};J("entered");let Y=$.claimEnvironment;$.claimEnvironment=void 0;let K=Q.now??Date.now,V,G=R6($.payload,Q.now?.(),(N)=>{V=N});if($.managedPty&&($.managedPty.version!==1||!$.headless||!$.runtimeDirectory||![void 0,!0].includes($.managedPty.startupVerified)||!$.deviceIdentity||!$.claimOwner||$.claimOwner.device_id!==$.deviceIdentity.deviceId||!G.environment_binding||!["darwin","linux"].includes(process.platform)))throw new C("pty_unsupported","Bound PTY requires qualified headless Hands with private jobs and environment.");let F=async(N)=>{let M;try{await Promise.race([N,new Promise((D,w)=>{M=setTimeout(()=>w(new C("hands_event_delivery_unavailable","Hands event delivery did not settle within its deadline.")),Math.max(1,Math.min(Q.eventDeliveryTimeoutMs??5000,5000)))})])}finally{clearTimeout(M)}},B=async(N,M)=>F($.emitEvent(N,M));if($.headless&&(G.cloud_browser===!0||$.managedBrowser!==void 0||G[L0]!==void 0||G[F9]!==void 0||G[p]!==void 0&&G[p]!==B0))throw new C("invalid_hands_request","Managed sandbox extensions are unavailable to a headless worker.");let H=B$(),z=G[g0]===void 0?null:A6(H);if(G[g0]!==void 0&&(z===null||!$.headless||!Q4($.hostExecution,Q.hostIdentity?.platform,Q.hostIdentity?.euid)))throw new C("hands_model_jobs_egress_unavailable","This worker cannot hold its jobs to the guest egress guard; the Hands did not start.");if(G[o0]!==void 0&&!($.headless&&Q4($.hostExecution,Q.hostIdentity?.platform,Q.hostIdentity?.euid)))throw new C("hands_confinement_unavailable","Confined Hands need a root Linux worker in host mode.");if(G.cloud_browser&&process.platform!=="linux")throw new C("cloud_browser_target_invalid","Cloud browser is available only on a cloud machine.");let L=`${$.operationId}:${$.attemptId}`,W=G[p]===V9,U=$.headless||process.platform==="darwin"&&$.managedBrowser===void 0&&!G.cloud_browser&&!G.browser_egress&&!G[L0]&&(G[p]===void 0||G[p]===B0)||i6(G),j=W?G[F9]??"bash":null,O=j?EZ(j):null;if(O)throw new C(O,"Persistent Node REPL execution is unavailable; this benchmark profile cannot start.");let q=G[p],A=$.headless===!0?$.handsSlots??1:void 0,R=(Q.slot??S6).acquire(L,{exclusive:A===1||q!==void 0&&q!==B0,...A!==void 0&&A>1?{limit:A}:{},...$.headless===!0&&G[C0]!==void 0?{group:G[C0]}:{}});if(!R)throw new C("hands_slot_busy",A!==void 0&&A>1?`This Reason worker runs at most ${A} sessions at a time.`:"This Reason Device runs one session at a time.");let P=$.headless===!0?Y4($.runId):null,T=null,S=null,g,E;try{J("browser_resolution");let N=$.headless&&Q.browserExecutablePath===void 0?await G9():null,M=W||G.cloud_browser?null:Q.browserExecutablePath===void 0?$.headless?N?.status==="resolved"?N.executablePath:null:await DZ(void 0,process.platform,$.managedBrowser):Q.browserExecutablePath;if(!W&&!G.cloud_browser&&!U&&!M)throw new C("hands_browser_unavailable","Reason Hands requires Chrome, Edge, Brave, Chromium, or a Playwright Chromium install.");J("path_resolution");let D;try{D=await(Q.resolvePathEnvironment??M4)()}catch{D={path:G4(),source:"fallback"}}if(J("workspace_setup"),process.platform==="darwin"){let s=G[p]===B0&&G.workspace_path!==void 0?L$($.root,G.workspace_worktree?G.workspace_worktree.source_path:G.workspace_path,"folder"):null;for(let Z0 of new Set([$.root,...s?[s]:[]]))await uQ(Z0)}let k=G[p]===f0||G[p]===V9?_6(process.platform,Q.sandboxRuntimeRoot):null,f=$.headless&&$.runtimeDirectory?$.runtimeDirectory:k?k.temporaryRoot:K4();if(T="private_runtime",$.headless&&$.runtimeDirectory){_9(f);let s=n($.root);if(!P9(s,f))throw new C("invalid_hands_workspace","Private worker state must not overlap the granted workspace.")}if($.headless&&$.runtimeDirectory&&(!$.deviceIdentity||!G.environment_binding))throw new C("environment_unavailable","Headless Hands requires a server-bound private environment.");if(T="runtime_root",k?.prepareRoot)N9(f,{recursive:!0,mode:457}),b9(f,457);T="temporary_directory";let _=n(M6(a(f,"reason-hands-session-")));S=_,b9(_,k?.sessionMode??448);let m=a(_,"hands-config.json"),c=a(_,"hands-ready.json"),l=V6(),o=G.target_fence_id;T="granted_root";let b=n($.root);T="workspace_layout";let y=G[p]===B0&&G.workspace_path!==void 0&&G.workspace_worktree?await m6(b,G.workspace_path,G.workspace_worktree):void 0,{workRoot:d,repoPath:u,jobEnvPath:G0,workspacePoolPath:N0,managedWorkspace:H0,workspace:U0,cloudSessionRoot:y0}=c6({grantedRoot:b,personalWorkspace:G.personal_workspace===!0,runId:$.runId,workspaceId:G.workspace_id,legacyWorkspaceId:G.legacy_workspace_id,workspaceBase:G[i0],workspaceLayout:G[a0],temporaryDirectory:_,workspaceMode:G[p],applicationSupportPath:Q.applicationSupportPath,...G.workspace_path===void 0?{}:{workspacePath:G.workspace_path},...G.workspace_worktree?{workspaceWorktree:G.workspace_worktree}:{},...y?{workspaceWorktreeStart:y}:{},...$.deviceIdentity?{deviceId:$.deviceIdentity.deviceId}:{}}),q0=P6(G);T="jobs";let r=$.headless&&$.runtimeDirectory?KQ({runtimeDirectory:$.runtimeDirectory,root:b,runId:$.runId}):void 0;g=r?.disposeSocket;let M0=r?VQ(r):null;if(M0)try{Z(JSON.stringify({event:"hands.journal_owner_retired",run_id:$.runId,reason:M0.reason,prior_executor_launch_id:M0.executorLaunchId}))}catch{}if(r&&[d,u].some((s)=>!P9(s,r.journalDirectory)))throw new C("invalid_hands_workspace","A Session can't work in the folder that holds this worker's settings; start it in a project or repository inside it.");let r0=G.personal_workspace?d.slice(d.lastIndexOf("/")+1):void 0;if(r0&&r0!==G.workspace_id)throw new C("invalid_hands_workspace","Personal session identity does not match its Device grant.");T="browser_socket";let W0=G.cloud_browser?x6(G.sandbox_os,r0):a(r?V0(r.socketPath):_,"repl.sock");T="relay_url";let j0=F4(new URL(G.relay_url).hostname),h0=q0==="ara_device_wss"&&!j0?(Q.loadProxy??f8)()?.url:void 0,Y0;T="environment_owner";let X0=$.headless&&$.deviceIdentity&&G.environment_binding?hZ(_,{runId:$.runId,...$.deviceIdentity,binding:G.environment_binding,expiresAtMs:Date.parse(G.expires_at),identity:()=>Y0?.()??null}):void 0;T="job_environment";let M9=!X0&&U0.kind==="managed"&&H0?a(d,"job.env"):null;if(M9)try{U8(M9,"",{mode:384,flag:"wx"})}catch(s){if(!(s instanceof Error&&("code"in s)&&s.code==="EEXIST"))throw s}let M8={url:G.relay_url,transport:q0,...h0===void 0?{}:{proxyUrl:h0},...$.localGithubConfinement?{localGithubConfinement:!0}:{},...G[o0]&&X0?{gitCredentialEnvironment:!0}:{},workerVersion:L9,protocolVersion:B9,workerArtifactSha256:K0,workerEntrypoint:n0,targetGeneration:G.target_generation,fenceId:o,workRoot:d,workspaceAliasPath:d,jobEnvPath:G0,...X0?{environmentSnapshotPath:X0.path,...$.hostExecution?{executionEnvironment:fQ()}:{},environmentExpectedBinding:{runId:$.runId,...$.deviceIdentity,binding:G.environment_binding}}:M9?{jobEnvSourcePath:M9,workspacePoolPath:V0(d)}:H0?{}:{jobEnvSourcePath:N4(d)},repoPath:u,replSocketPath:W0,...G.cloud_browser?{browserRunId:$.runId}:{},readyPath:c,launchId:l,expiresAtMs:Date.parse(G.expires_at),bashTimeoutMs:300000,replTimeoutMs:120000,...r?{managedJobs:{journalDirectory:r.journalDirectory,scopeId:r.scopeId},jobControlSocketPath:r.socketPath}:{},...r&&H?{jobsUser:{...H,...z!==null?{modelGid:z}:{}}}:{},...$.managedPty&&r&&X0?{managedPty:{version:1,...$.managedPty.startupVerified===!0?{persistent:!0}:{},...process.platform==="darwin"?{shell:gQ()}:{}}}:{},...U&&!M?{allowedTools:["bash","read","write","edit"]}:W?{allowedTools:j==="bash"?["bash"]:["bash","repl"]}:{}};if(X0||H0&&!M9)U8(G0,"",{mode:384});else v6(d,G0);T="config_write",U8(m,JSON.stringify(M8),{mode:384}),T=null;let v0={session_id:G.session_id,environment_id:G.environment_id,hands_protocol_version:B9,hands_worker_version:L9,hands_worker_artifact_sha256:K0,hands_worker_entrypoint:n0,target_generation:G.target_generation,target_fence_id:G.target_fence_id,executor_launch_id:l},f9=null,N$=!1,M$=!1,j$,Q0=null,C$,q$,g9="failed",T$=null,j8=Promise.resolve(),O$=null,C8=async(s,Z0)=>{try{await B(s,Z0)}catch{}};try{J("event_started");let s,Z0=(async()=>{await $.emitEvent("hands.started",{...v0,policy_mode:"full_access",policy_version:1,path_source:D.source}),s=Date.now()})();Z0.catch(()=>{return}),J("worker_setup");let m9=G.browser_egress?{mode:"enforce",allowedDomains:G.browser_egress.allowed_domains}:{mode:"off"};if(j&&j!=="bash")f9=await(Q.startNodeRepl??iZ)({socketPath:W0,workRoot:d});else if(!W&&!G.cloud_browser&&M)f9=await(Q.startRepl??_Z)({socketPath:W0,browserExecutablePath:M,workspaceRoot:u,...$.managedBrowser?{managedBrowser:$.managedBrowser}:{},...$.desktopRecording?{recording:$.desktopRecording}:{},networkPolicy:m9,onEgressDenied:(h)=>{let T0=IZ(h.host);Z(JSON.stringify({event:"sandbox.repl_egress_denied",destination_id:T0,reason:h.reason,run_id:$.runId})),j8=j8.then(()=>B("hands.browser_egress_denied",{destination_id:T0,reason:h.reason})).catch((C4)=>{O$??=C4})}}).catch((h)=>{if(!U||$.signal.aborted||K()>=Date.parse(G.expires_at)||!n6(h,W0))throw h;return Object.assign(M8,{allowedTools:["bash","read","write","edit"]}),U8(m,JSON.stringify(M8),{mode:384}),M$=!0,null});let D$=d6({configPath:m,root:u,grantedRoot:b,workRoot:d,workspacePoolPath:N0,temporaryDirectory:_,path:D.path,executablePath:Q.executablePath,sourceEntrypoint:Q.sourceEntrypoint}),q8=Date.now(),T8,_$,O8=Q.takePrespawnedWorker?.(D$)??null;if(j$=Q.takePrespawnedWorker?O8!==null:void 0,Q0=O8??(Q.spawnWorker??((h)=>F6(h.command,h.args,h.options)))(D$),!O8)Q.adoptSpawnedWorker?.(Q0);Q0.stderr?.on("data",p6(l,(h)=>{if(h.event==="hands.worker.connecting")T8??=h.timestampMs;else if(h.event==="hands.worker.open")_$??=h.timestampMs;Z(JSON.stringify({...h,run_id:$.runId}))}));let A$=!1;Q0.on("error",()=>{A$=!0}),Q0.once("exit",(h,T0)=>{try{Z(JSON.stringify({event:"hands.worker.exited",run_id:$.runId,launchId:l,exit_code:h,exit_signal:T0}))}catch{}}),E=Q0,J("worker_ready_wait");let j9=await l6({path:c,launchId:l,fenceId:o,targetGeneration:G.target_generation,child:Q0,spawnFailed:()=>A$,signal:$.signal,timeoutMs:Q.readyTimeoutMs??T6,now:K}),j4=Date.now();if(Y0=()=>{if(!Q0||Q0.exitCode!==null||Q0.signalCode!==null)return null;let h=z8(c,j9);return h?{generation:h.targetGeneration,fenceId:h.fenceId}:null},r){let h={root:b,runId:$.runId,operationId:$.operationId,scopeId:r.scopeId,socketPath:r.socketPath,generation:j9.targetGeneration,fenceId:j9.fenceId,executorLaunchId:l,expiresAtMs:Date.parse(G.expires_at),readIdentity:Y0,workspace:U0,localGithubConfinement:$.localGithubConfinement===!0};if(X0)h.environment=X0;if($.claimOwner&&$.deviceIdentity&&$.claimOwner.device_id===$.deviceIdentity.deviceId){let T0=[$.deviceIdentity.apiOrigin,G.relay_url];if(h0)T0.push(h0);h.previewAuthority={owner:Object.freeze({...$.claimOwner}),rootId:$.deviceIdentity.rootId,relayOrigin:new URL(G.relay_url).origin,deniedPorts:c$(T0)}}q$=FQ(h)}if(await new Promise((h)=>{setImmediate(h)}),y0)U4(d);let y9;if(Y&&X0){try{let h=X0.install(Y);y9={snapshot_id:h.snapshot_id,installed_revision:h.installed_revision}}catch{}try{Z(JSON.stringify({event:"hands.environment_at_claim",run_id:$.runId,installed:y9!==void 0}))}catch{}}Y=void 0,J("event_ready");let x$=F(Z0);x$.catch(()=>{return});let P$=Date.now();N$=!0,await B("hands.ready",{...v0,expiry_diagnostic:V,startup_stages:{version:1,browser_resolution_ms:F0(X.get("browser_resolution"),X.get("path_resolution")),path_resolution_ms:F0(X.get("path_resolution"),X.get("workspace_setup")),workspace_setup_ms:F0(X.get("workspace_setup"),X.get("event_started")),repl_setup_ms:F0(X.get("worker_setup"),q8),worker_boot_ms:F0(q8,T8),worker_dial_ms:F0(T8,_$),worker_ready_ms:F0(q8,j4),started_event_ms:F0(X.get("event_started"),s),started_join_wait_ms:F0(X.get("event_ready"),P$),total_ms:F0(X.get("entered"),P$)},...a6($.claimedAtMs,X.get("entered"),j$),...$.managedPty?.startupVerified===!0?{managed_pty:{version:1,execution_mode:"host",descendant_cleanup_verified:!0}}:{},policy_mode:"full_access",policy_version:1,path_source:D.source,connection_generation:j9.generation,...y9?{environment_installed:y9}:{},...U&&!f9?{browser_state:"unavailable",browser_reason_code:M$?"setup_failed":"not_resolved"}:{viewport_width:1440,viewport_height:900}}),await x$,J("ready"),C$=uZ({path:c,initial:j9,signal:$.signal,isAlive:()=>Q0!==null&&Q0.exitCode===null&&Q0.signalCode===null&&K()<Date.parse(G.expires_at),publish:(h,T0)=>$.emitEvent("hands.reconnected",{...v0,target_generation:h.targetGeneration,target_fence_id:h.fenceId,connection_generation:h.generation},T0),failed:()=>Z(JSON.stringify({event:"hands.worker.generation_proof_failed",run_id:$.runId,executor_launch_id:l}))});let I$=await s6({child:Q0,signal:$.signal,expiresAt:Date.parse(G.expires_at),now:K});if(I$==="cancelled"){let h=$.signal.reason instanceof C?$.signal.reason.code:"cancelled";throw g9=h,new C(h,"Reason Hands was cancelled.")}if(I$==="exited")throw new C("hands_worker_exited","Reason Hands exited unexpectedly.");return g9="expired",{...v0,policy_mode:"full_access",policy_version:1,ended:"expired"}}catch(s){T$=s;let Z0=s instanceof C?s.code:"hands_failed",m9=Z0==="cancelled"||["run_finished","run_cancelled","driver_handoff","driver_stopped"].includes(Z0);if(g9=m9?Z0:"failed",!m9)await C8("hands.failed",{...v0,reason_code:Z0});throw s}finally{C$?.stop(),q$?.();let s=Q0?await u6(Q0,Q.stopTimeoutMs??O6):null,Z0=!1;await $.desktopRecording?.close();try{await f9?.stop()}catch{Z0=!0}if(await j8,(s==="stopped"||s==="already_exited"&&!N$)&&!Z0)await C8("hands.stopped",{...v0,reason_code:g9});else if(s!==null||Z0){if(await C8("hands.failed",{...v0,reason_code:s==="forced"?"hands_stop_forced":"hands_stop_unconfirmed"}),T$===null||Z0)throw new C("hands_stop_unconfirmed","Reason Hands resource cleanup could not be proven.")}if(O$!==null)throw new C("hands_egress_audit_failed","Reason Hands could not persist a browser egress denial receipt.")}}catch(N){let M=AZ(T,N);if(M)try{Z(JSON.stringify({event:"sandbox.hands_workspace_failed",...M}))}catch{}throw N}finally{try{if(!E||E.exitCode!==null||E.signalCode!==null)g?.();if(S!==null&&(!E||E.exitCode!==null||E.signalCode!==null))j6(S,{recursive:!0,force:!0})}finally{P?.(),R()}}}
459
- export{v as ja,b$ as ka,k$ as la,b4 as ma,y$ as na,v$ as oa,c$ as pa,D2 as qa,KQ as ra,y2 as sa,h2 as ta,v2 as ua,c2 as va,d2 as wa,p2 as xa,UQ as ya,l2 as za,s2 as Aa,p as Ba,B0 as Ca,yX as Da,hX as Ea,QJ as Fa,ZJ as Ga,qQ as Ha,n9 as Ia,_9 as Ja,A9 as Ka,RQ as La,hZ as Ma,Y5 as Na,wQ as Oa,fQ as Pa,gQ as Qa,S5 as Ra,w5 as Sa,J0 as Ta,b5 as Ua,k5 as Va,f5 as Wa,l5 as Xa,Z1 as Ya,u5 as Za,P9 as _a,w0 as $a,s5 as ab,BX as bb,Y1 as cb,G1 as db,JZ as eb,XX as fb,I9 as gb,o1 as hb,K$ as ib,rZ as jb,Q4 as kb,B$ as lb,A6 as mb,yY as nb,hY as ob,H4 as pb,E6 as qb,U4 as rb,W4 as sb,d6 as tb,vY as ub,cY as vb};
459
+ export{v as xa,b$ as ya,k$ as za,b4 as Aa,y$ as Ba,v$ as Ca,c$ as Da,D2 as Ea,KQ as Fa,y2 as Ga,h2 as Ha,v2 as Ia,c2 as Ja,d2 as Ka,p2 as La,UQ as Ma,l2 as Na,s2 as Oa,p as Pa,B0 as Qa,yX as Ra,hX as Sa,QJ as Ta,ZJ as Ua,qQ as Va,n9 as Wa,_9 as Xa,A9 as Ya,RQ as Za,hZ as _a,Y5 as $a,wQ as ab,fQ as bb,gQ as cb,S5 as db,w5 as eb,J0 as fb,b5 as gb,k5 as hb,f5 as ib,l5 as jb,Z1 as kb,u5 as lb,P9 as mb,w0 as nb,s5 as ob,BX as pb,Y1 as qb,G1 as rb,JZ as sb,XX as tb,I9 as ub,o1 as vb,K$ as wb,rZ as xb,Q4 as yb,B$ as zb,A6 as Ab,yY as Bb,hY as Cb,H4 as Db,E6 as Eb,U4 as Fb,W4 as Gb,d6 as Hb,vY as Ib,cY as Jb};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Tb as D}from"./vm-hands-entry-lite-n8gsyjq7.js";import{Wh as j}from"./vm-hands-entry-lite-40t7d4p5.js";import{statSync as i}from"fs";import{delimiter as n,join as t}from"path";function _(q,z=process.env.PATH??""){if(!q||q.includes("/")||q.includes("\x00"))return!1;return z.split(n).some((G)=>{if(!G)return!1;try{let Q=i(t(G,q));return Q.isFile()&&(Q.mode&73)!==0}catch{return!1}})}import{spawn as r,spawnSync as e}from"child_process";import{existsSync as k,mkdtempSync as E,readFileSync as O,readdirSync as o,realpathSync as qq,rmSync as b,statSync as zq}from"fs";import{platform as y,tmpdir as g}from"os";import{dirname as A,join as Z}from"path";import{fileURLToPath as Gq,pathToFileURL as T}from"url";var Hq=["bwrap","socat","rg"],Jq=2000,v=20000,Qq=3,P=4000,Vq=new Set([".git",".hg",".svn","node_modules"]),Wq=["runAsHostUid","sysrq-trigger"],Yq=Z(A(A(Gq(import.meta.url))),"packages/sandbox-runtime/src/index.ts"),h=!1;function fq(){h=!0}async function u(){let z=h?Z(A(qq(process.execPath)),"runtime","srt"):void 0;if(z&&process.platform==="linux"&&!k(Z(z,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(z){let J=O(Z(z,"sandbox-runtime.mjs"),"utf8");for(let Y of Wq)if(!J.includes(Y))throw Error(`packaged_sandbox_runtime_fork_missing:${Y}`)}let H=(await import(z?T(Z(z,"sandbox-runtime.mjs")).href:T(Yq).href)).SandboxManager;if(!H||typeof H.initialize!=="function"||typeof H.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:H}}function Zq(q={}){if((q.platformName??y())!=="linux")return!1;let G=q.fileExists??k,Q=q.readFile??((H)=>O(H,"utf8"));for(let H of["/.dockerenv","/run/.containerenv"])try{if(G(H))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(Q("/proc/1/cgroup"))}catch{return!1}}function l(q){return["/bin/true","/usr/bin/true"].find((z)=>q(z))??null}function $q(q,z){return q==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",z]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",z]}function jq(q,z){try{let G=e("bwrap",$q(q,z),{stdio:"ignore",timeout:Jq});return!G.error&&G.status===0}catch{return!1}}function Bq(q){let z=q.platformName??y();if(z!=="linux")return null;let G=q.hasExecutable??_;if(!Hq.every((V)=>G(V)))return null;let Q=q.fileExists??k,H=l(Q);if(!H)return null;let J=B??(q.containerized??Zq({platformName:z})?"weak":"strict");return(q.probeNamespaces??((V)=>jq(V,H)))(J)?J:null}var L=null,C=!1,K=null,S=null,f=null,B=null,F=null;function M(){throw I("sandbox_mode_conflict"),new j("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function xq(q){if(B!==null&&B!==q||C&&L!==null&&L!==q||F!==null&&F!==q)M();B=q}function I(q){K=q}function c(q){if(K)return!1;if(!C){if(L=Bq(q??{}),C=!0,L&&!q)d()}return L!==null}function Lq(){return c()?L:null}var U=null,w=0;function m(q){if(K)throw new j("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(B&&q.sandboxMode&&B!==q.sandboxMode)M();let z=B??q.sandboxMode??Lq();if(!z)throw new j("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(F&&F!==z)M();return F=z,U??=(async()=>{let{SandboxManager:G}=await(q.loadSandboxRuntime??u)();return await G.initialize(Iq(z)),G})().catch((G)=>{throw U=null,I(`initialize_failed: ${String(G)}`),G instanceof j?G:new j("sandbox_unavailable","The confined execution sandbox failed to start.")}),U.then((G)=>{if(K)throw new j("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return G})}async function Kq(){let q=U;if(U=null,!q)return;try{await(await q).reset()}catch{}}async function d(q={}){if(K)return!1;if(q.loadSandboxRuntime)return x(q.loadSandboxRuntime);if(!c())return!1;return S??=x(u),S}async function x(q){try{let{SandboxManager:z}=await q(),G=z.checkDependencies().errors;if(G.length>0)return I(`dependencies_missing: ${G.join(", ")}`),!1;return!K}catch(z){return I(`load_failed: ${String(z)}`),!1}}async function Rq(q={}){if(!q.loadSandboxRuntime&&!q.sandboxMode){if(!await d())return!1;return f??=R({}),f}return R(q)}async function R(q){let z;try{z=await m(q)}catch{return!1}let G=await Xq(z);if(!G)I("confined_command_failed");if(w===0)await Kq();return G}async function Xq(q){let z=l(k);if(!z)return!1;let G=E(Z(g(),"reason-device-probe-"));try{let{argv:Q}=await q.wrapWithSandboxArgv(a([z]),p(),{filesystem:s({root:G,allowWrite:!1,temporaryDirectory:G,protectedPaths:[]})},void 0,G),[H,...J]=Q;if(!H)return!1;return await Fq(H,J,G)}catch{return!1}finally{try{q.cleanupAfterCommand()}catch{}b(G,{recursive:!0,force:!0})}}function Fq(q,z,G,Q={}){return new Promise((H)=>{let J=!1,Y,V=(X)=>{if(J)return;J=!0,clearTimeout(Y),H(X)},W;try{W=(Q.spawnChild??r)(q,z,{cwd:G,env:{PATH:D,HOME:G,TMPDIR:G},stdio:"ignore"})}catch{V(!1);return}W.once("error",()=>V(!1));let $=(X,N)=>V(X===0&&N===null);if(W.once("exit",$),W.once("close",$),W.exitCode!==null||W.signalCode!==null)$(W.exitCode,W.signalCode);if(J)return;Y=setTimeout(()=>{V(!1);try{W.kill("SIGKILL")}catch{}},Math.min(Q.timeoutMs??v,v))})}function p(q=k){return["/bin/bash","/bin/sh"].find((z)=>q(z))??"/bin/sh"}function a(q){return q.map((z)=>`'${z.replaceAll("'","'\\''")}'`).join(" ")}function Uq(q,z,G=(Q)=>o(Q,{withFileTypes:!0}).filter((H)=>H.isDirectory()||H.isFile()).map((H)=>H.name)){let Q=[],H=[{path:q,depth:0}],J=0;while(H.length>0&&J<P){let Y=H.pop(),V;try{V=G(Y.path)}catch{continue}for(let W of V){if(J+=1,J>P)break;let $=Z(Y.path,W);if(z($)){Q.push($);continue}if(Y.depth+1<Qq&&!Vq.has(W))H.push({path:$,depth:Y.depth+1})}}return Q}function s(q){let z=Z(q.root,".git"),G=[];try{if(zq(z).isDirectory())G=[Z(z,"config"),Z(z,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...q.protectedPaths],allowRead:[q.root,q.temporaryDirectory],allowWrite:[...q.allowWrite?[q.root]:[],q.temporaryDirectory],denyWrite:[...q.protectedPaths,...G]}}function Iq(q){return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...q==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Dq(q){let z=q.createTemporaryDirectory??(()=>E(Z(g(),"reason-device-"))),G=q.removeTemporaryDirectory??((Q)=>b(Q,{recursive:!0,force:!0}));return async(Q,H,J)=>{let Y=await m(q),V=z();w+=1;try{let W;try{W=await Y.wrapWithSandboxArgv(a([Q,...H]),q.shell??p(),{filesystem:s({root:J.root,allowWrite:J.allowWrite,temporaryDirectory:V,protectedPaths:Uq(J.root,q.isProtectedPath)})},J.signal,J.cwd)}catch(N){throw N instanceof j?N:new j("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[$,...X]=W.argv;if(!$)throw new j("sandbox_unavailable","The confined execution sandbox produced no command.");return await q.spawnCaptured($,X,{cwd:J.cwd,timeoutMs:J.timeoutMs,signal:J.signal,env:q.scrubEnvironment(J.root,V)})}finally{w-=1;try{Y.cleanupAfterCommand()}catch{}G(V)}}}
3
- export{_ as Mb,fq as Nb,xq as Ob,c as Pb,Rq as Qb,p as Rb,Dq as Sb};
2
+ import{Rb as D}from"./vm-hands-entry-lite-h01d2fbm.js";import{ki as j}from"./vm-hands-entry-lite-070nd0vy.js";import{statSync as i}from"fs";import{delimiter as n,join as t}from"path";function _(q,z=process.env.PATH??""){if(!q||q.includes("/")||q.includes("\x00"))return!1;return z.split(n).some((G)=>{if(!G)return!1;try{let Q=i(t(G,q));return Q.isFile()&&(Q.mode&73)!==0}catch{return!1}})}import{spawn as r,spawnSync as e}from"child_process";import{existsSync as k,mkdtempSync as E,readFileSync as O,readdirSync as o,realpathSync as qq,rmSync as b,statSync as zq}from"fs";import{platform as y,tmpdir as g}from"os";import{dirname as A,join as Z}from"path";import{fileURLToPath as Gq,pathToFileURL as T}from"url";var Hq=["bwrap","socat","rg"],Jq=2000,v=20000,Qq=3,P=4000,Vq=new Set([".git",".hg",".svn","node_modules"]),Wq=["runAsHostUid","sysrq-trigger"],Yq=Z(A(A(Gq(import.meta.url))),"packages/sandbox-runtime/src/index.ts"),h=!1;function fq(){h=!0}async function u(){let z=h?Z(A(qq(process.execPath)),"runtime","srt"):void 0;if(z&&process.platform==="linux"&&!k(Z(z,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(z){let J=O(Z(z,"sandbox-runtime.mjs"),"utf8");for(let Y of Wq)if(!J.includes(Y))throw Error(`packaged_sandbox_runtime_fork_missing:${Y}`)}let H=(await import(z?T(Z(z,"sandbox-runtime.mjs")).href:T(Yq).href)).SandboxManager;if(!H||typeof H.initialize!=="function"||typeof H.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:H}}function Zq(q={}){if((q.platformName??y())!=="linux")return!1;let G=q.fileExists??k,Q=q.readFile??((H)=>O(H,"utf8"));for(let H of["/.dockerenv","/run/.containerenv"])try{if(G(H))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(Q("/proc/1/cgroup"))}catch{return!1}}function l(q){return["/bin/true","/usr/bin/true"].find((z)=>q(z))??null}function $q(q,z){return q==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",z]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",z]}function jq(q,z){try{let G=e("bwrap",$q(q,z),{stdio:"ignore",timeout:Jq});return!G.error&&G.status===0}catch{return!1}}function Bq(q){let z=q.platformName??y();if(z!=="linux")return null;let G=q.hasExecutable??_;if(!Hq.every((V)=>G(V)))return null;let Q=q.fileExists??k,H=l(Q);if(!H)return null;let J=B??(q.containerized??Zq({platformName:z})?"weak":"strict");return(q.probeNamespaces??((V)=>jq(V,H)))(J)?J:null}var L=null,C=!1,K=null,S=null,f=null,B=null,F=null;function M(){throw I("sandbox_mode_conflict"),new j("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function xq(q){if(B!==null&&B!==q||C&&L!==null&&L!==q||F!==null&&F!==q)M();B=q}function I(q){K=q}function c(q){if(K)return!1;if(!C){if(L=Bq(q??{}),C=!0,L&&!q)d()}return L!==null}function Lq(){return c()?L:null}var U=null,w=0;function m(q){if(K)throw new j("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(B&&q.sandboxMode&&B!==q.sandboxMode)M();let z=B??q.sandboxMode??Lq();if(!z)throw new j("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(F&&F!==z)M();return F=z,U??=(async()=>{let{SandboxManager:G}=await(q.loadSandboxRuntime??u)();return await G.initialize(Iq(z)),G})().catch((G)=>{throw U=null,I(`initialize_failed: ${String(G)}`),G instanceof j?G:new j("sandbox_unavailable","The confined execution sandbox failed to start.")}),U.then((G)=>{if(K)throw new j("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return G})}async function Kq(){let q=U;if(U=null,!q)return;try{await(await q).reset()}catch{}}async function d(q={}){if(K)return!1;if(q.loadSandboxRuntime)return x(q.loadSandboxRuntime);if(!c())return!1;return S??=x(u),S}async function x(q){try{let{SandboxManager:z}=await q(),G=z.checkDependencies().errors;if(G.length>0)return I(`dependencies_missing: ${G.join(", ")}`),!1;return!K}catch(z){return I(`load_failed: ${String(z)}`),!1}}async function Rq(q={}){if(!q.loadSandboxRuntime&&!q.sandboxMode){if(!await d())return!1;return f??=R({}),f}return R(q)}async function R(q){let z;try{z=await m(q)}catch{return!1}let G=await Xq(z);if(!G)I("confined_command_failed");if(w===0)await Kq();return G}async function Xq(q){let z=l(k);if(!z)return!1;let G=E(Z(g(),"reason-device-probe-"));try{let{argv:Q}=await q.wrapWithSandboxArgv(a([z]),p(),{filesystem:s({root:G,allowWrite:!1,temporaryDirectory:G,protectedPaths:[]})},void 0,G),[H,...J]=Q;if(!H)return!1;return await Fq(H,J,G)}catch{return!1}finally{try{q.cleanupAfterCommand()}catch{}b(G,{recursive:!0,force:!0})}}function Fq(q,z,G,Q={}){return new Promise((H)=>{let J=!1,Y,V=(X)=>{if(J)return;J=!0,clearTimeout(Y),H(X)},W;try{W=(Q.spawnChild??r)(q,z,{cwd:G,env:{PATH:D,HOME:G,TMPDIR:G},stdio:"ignore"})}catch{V(!1);return}W.once("error",()=>V(!1));let $=(X,N)=>V(X===0&&N===null);if(W.once("exit",$),W.once("close",$),W.exitCode!==null||W.signalCode!==null)$(W.exitCode,W.signalCode);if(J)return;Y=setTimeout(()=>{V(!1);try{W.kill("SIGKILL")}catch{}},Math.min(Q.timeoutMs??v,v))})}function p(q=k){return["/bin/bash","/bin/sh"].find((z)=>q(z))??"/bin/sh"}function a(q){return q.map((z)=>`'${z.replaceAll("'","'\\''")}'`).join(" ")}function Uq(q,z,G=(Q)=>o(Q,{withFileTypes:!0}).filter((H)=>H.isDirectory()||H.isFile()).map((H)=>H.name)){let Q=[],H=[{path:q,depth:0}],J=0;while(H.length>0&&J<P){let Y=H.pop(),V;try{V=G(Y.path)}catch{continue}for(let W of V){if(J+=1,J>P)break;let $=Z(Y.path,W);if(z($)){Q.push($);continue}if(Y.depth+1<Qq&&!Vq.has(W))H.push({path:$,depth:Y.depth+1})}}return Q}function s(q){let z=Z(q.root,".git"),G=[];try{if(zq(z).isDirectory())G=[Z(z,"config"),Z(z,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...q.protectedPaths],allowRead:[q.root,q.temporaryDirectory],allowWrite:[...q.allowWrite?[q.root]:[],q.temporaryDirectory],denyWrite:[...q.protectedPaths,...G]}}function Iq(q){return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...q==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Dq(q){let z=q.createTemporaryDirectory??(()=>E(Z(g(),"reason-device-"))),G=q.removeTemporaryDirectory??((Q)=>b(Q,{recursive:!0,force:!0}));return async(Q,H,J)=>{let Y=await m(q),V=z();w+=1;try{let W;try{W=await Y.wrapWithSandboxArgv(a([Q,...H]),q.shell??p(),{filesystem:s({root:J.root,allowWrite:J.allowWrite,temporaryDirectory:V,protectedPaths:Uq(J.root,q.isProtectedPath)})},J.signal,J.cwd)}catch(N){throw N instanceof j?N:new j("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[$,...X]=W.argv;if(!$)throw new j("sandbox_unavailable","The confined execution sandbox produced no command.");return await q.spawnCaptured($,X,{cwd:J.cwd,timeoutMs:J.timeoutMs,signal:J.signal,env:q.scrubEnvironment(J.root,V)})}finally{w-=1;try{Y.cleanupAfterCommand()}catch{}G(V)}}}
3
+ export{_ as Kb,fq as Lb,xq as Mb,c as Nb,Rq as Ob,p as Pb,Dq as Qb};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Wh as C}from"./vm-hands-entry-lite-40t7d4p5.js";import{execFileSync as W}from"child_process";import{mkdirSync as b,readdirSync as R,readFileSync as F,rmSync as B,statSync as K,writeFileSync as f}from"fs";import{join as $}from"path";import{setTimeout as k}from"timers/promises";var A=3000,X=null;function G(z){return $(z,"users")}function m(z){if(X?.root===z.root)return;let H=G(z.root);b(H,{recursive:!0,mode:448}),f($(H,String(process.pid)),"",{mode:384}),X=z}function S(){if(!X)return;B($(G(X.root),String(process.pid)),{force:!0}),X=null}function x(z){try{return process.kill(z,0),!0}catch(H){return H instanceof Error&&"code"in H&&H.code==="EPERM"}}function L(){let z=process.getuid?.();if(process.platform==="linux")return R("/proc").flatMap((N)=>{if(!/^\d+$/.test(N))return[];try{if(K(`/proc/${N}`).uid!==z)return[];let Q=F(`/proc/${N}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return Q?[{pid:Number(N),command:Q}]:[]}catch{return[]}});return W("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
2
+ import{ki as C}from"./vm-hands-entry-lite-070nd0vy.js";import{execFileSync as W}from"child_process";import{mkdirSync as b,readdirSync as R,readFileSync as F,rmSync as B,statSync as K,writeFileSync as f}from"fs";import{join as $}from"path";import{setTimeout as k}from"timers/promises";var A=3000,X=null;function G(z){return $(z,"users")}function m(z){if(X?.root===z.root)return;let H=G(z.root);b(H,{recursive:!0,mode:448}),f($(H,String(process.pid)),"",{mode:384}),X=z}function S(){if(!X)return;B($(G(X.root),String(process.pid)),{force:!0}),X=null}function x(z){try{return process.kill(z,0),!0}catch(H){return H instanceof Error&&"code"in H&&H.code==="EPERM"}}function L(){let z=process.getuid?.();if(process.platform==="linux")return R("/proc").flatMap((N)=>{if(!/^\d+$/.test(N))return[];try{if(K(`/proc/${N}`).uid!==z)return[];let Q=F(`/proc/${N}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return Q?[{pid:Number(N),command:Q}]:[]}catch{return[]}});return W("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
3
  `).flatMap((N)=>{let Q=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(N);return Q&&Number(Q[2])===z?[{pid:Number(Q[1]),command:Q[3]}]:[]})}async function p(){let z=X;if(!z)return{released:"unused",stopped:0};let H=G(z.root);B($(H,String(process.pid)),{force:!0}),X=null;let N=!1;for(let J of R(H)){let U=Number(J);if(Number.isSafeInteger(U)&&U>0&&x(U))N=!0;else B($(H,J),{force:!0})}if(N)return{released:"shared",stopped:0};let Q=L().filter((J)=>J.pid!==process.pid&&(J.command.includes(`${z.root}/`)||J.command.includes(`${z.automation}/`)||J.command.includes(z.extensionDir))),Y=(J,U)=>{try{process.kill(J,U)}catch{}};for(let J of Q)Y(J.pid,"SIGTERM");for(let J=Date.now()+A;Date.now()<J&&Q.some((U)=>x(U.pid));)await new Promise((U)=>setTimeout(U,100));for(let J of Q)if(x(J.pid))Y(J.pid,"SIGKILL");return{released:"stopped",stopped:Q.length}}var O=20000,j=30000,v=100,Z=new Map,V=null,q=[];function h(z){Z.set(z,(Z.get(z)??0)+1);let H=!1;return()=>{if(H)return;H=!0;let N=(Z.get(z)??1)-1;if(N>0){Z.set(z,N);return}if(Z.delete(z),V?.run===z)V.idleUntil=0}}function M(){return new C("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function P(z,H){return V!==null&&V.run!==z&&(V.calls>0||H<V.idleUntil)}async function I(z,H,N=Date.now){let Q=Symbol(z);q.push(Q);try{let U=N()+j;for(;;){if(!P(z,N())&&(V?.run===z||q[0]===Q))break;if(N()>=U)throw M();await k(v,void 0,{signal:H}).catch(()=>H.throwIfAborted())}}finally{q.splice(q.indexOf(Q),1)}if(V?.run!==z)V={run:z,calls:0,idleUntil:0};let Y=V;Y.calls+=1;let J=!1;return()=>{if(J)return;J=!0,Y.calls-=1,Y.idleUntil=N()+O}}
4
- export{m as Ph,S as Qh,p as Rh,O as Sh,j as Th,h as Uh,I as Vh};
4
+ export{m as di,S as ei,p as fi,O as gi,j as hi,h as ii,I as ji};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{he as W}from"./vm-hands-entry-lite-669hk342.js";var E=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),g=W.string().regex(/^[a-f0-9]{40}$/),N=W.number().int().positive(),T=W.string().min(1).max(256),A=W.string().max(60000),q={version:W.literal(1),repoFullName:E},S=W.array(W.string().max(1024).regex(/^Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>$/)).max(500),y=W.strictObject({expectedTrailers:S,missingFromHead:S}),d=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:T.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),a=W.discriminatedUnion("kind",[W.strictObject({...q,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...q,kind:W.literal("pr_review_context"),number:N,after:W.string().min(1).max(1024).optional()}),W.strictObject({...q,kind:W.literal("prepare"),branch:G,baseSha:g,defaultBranch:G}),W.strictObject({...q,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:g,remoteHeadSha:g.nullable(),contributorTrailers:S.optional()}),W.strictObject({...q,kind:W.literal("pr_create"),head:G,base:G,title:T,body:A,draft:W.boolean()}),W.strictObject({...q,kind:W.literal("pr_mutation"),number:N,mutation:d}),W.strictObject({...q,kind:W.literal("pr_merge"),number:N,expectedHeadSha:g,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),I=245760,e=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(I)}),W.strictObject({kind:W.literal("prepare"),headSha:g}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(I)}),W.strictObject({kind:W.literal("publish"),headSha:g,scannedObjectCount:W.number().int().min(0).max(5000),attribution:y.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:N,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:N,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=I,"local_device_gh_result_too_large"),O=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),j=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:O.optional(),contributorRefresh:W.guid().optional(),repoFullName:E.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function C(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function QQ(Q,Z,$={},H="read"){if(C(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return z(Q,Z,$);if(!C(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((K)=>K==="."||K===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((K)=>K.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((K,B)=>{if(B==="per_page"&&/^[1-9][0-9]*$/.test(K)&&Number(K)<=100)return;if(B==="page"&&/^[1-9][0-9]*$/.test(K)&&Number(K)<=100)return;if(Y==="/pulls"&&B==="state"&&["open","closed","all"].includes(K))return;if(Y==="/pulls"&&B==="sort"&&K==="updated")return;if(Y==="/pulls"&&B==="direction"&&K==="desc")return;if(Y==="/pulls"&&["head","base"].includes(B)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(K))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((B,c)=>{if(c!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(B))throw Error("local_device_gh_header_denied")})}function z(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let H=new URL(Z,"https://api.github.com");if(H.pathname!=="/search/issues"||H.username||H.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;H.searchParams.forEach((X,K)=>{if(K==="q"&&V===null){V=X;return}if(K==="per_page"&&/^[1-9][0-9]*$/.test(X)&&Number(X)<=100)return;if(K==="page"&&/^[1-9][0-9]*$/.test(X)&&Number(X)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,U=V?.toLowerCase()??"";if(U.length>512||!(U+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(U.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((X,K)=>{if(K!=="accept"||X!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var WQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
2
+ import{we as W}from"./vm-hands-entry-lite-mtp2h66e.js";var E=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),g=W.string().regex(/^[a-f0-9]{40}$/),N=W.number().int().positive(),T=W.string().min(1).max(256),A=W.string().max(60000),q={version:W.literal(1),repoFullName:E},S=W.array(W.string().max(1024).regex(/^Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>$/)).max(500),y=W.strictObject({expectedTrailers:S,missingFromHead:S}),d=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:T.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),a=W.discriminatedUnion("kind",[W.strictObject({...q,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...q,kind:W.literal("pr_review_context"),number:N,after:W.string().min(1).max(1024).optional()}),W.strictObject({...q,kind:W.literal("prepare"),branch:G,baseSha:g,defaultBranch:G}),W.strictObject({...q,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:g,remoteHeadSha:g.nullable(),contributorTrailers:S.optional()}),W.strictObject({...q,kind:W.literal("pr_create"),head:G,base:G,title:T,body:A,draft:W.boolean()}),W.strictObject({...q,kind:W.literal("pr_mutation"),number:N,mutation:d}),W.strictObject({...q,kind:W.literal("pr_merge"),number:N,expectedHeadSha:g,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),I=245760,e=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(I)}),W.strictObject({kind:W.literal("prepare"),headSha:g}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(I)}),W.strictObject({kind:W.literal("publish"),headSha:g,scannedObjectCount:W.number().int().min(0).max(5000),attribution:y.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:N,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:N,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=I,"local_device_gh_result_too_large"),O=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),j=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:O.optional(),contributorRefresh:W.guid().optional(),repoFullName:E.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function C(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function QQ(Q,Z,$={},H="read"){if(C(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return z(Q,Z,$);if(!C(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((K)=>K==="."||K===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((K)=>K.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((K,B)=>{if(B==="per_page"&&/^[1-9][0-9]*$/.test(K)&&Number(K)<=100)return;if(B==="page"&&/^[1-9][0-9]*$/.test(K)&&Number(K)<=100)return;if(Y==="/pulls"&&B==="state"&&["open","closed","all"].includes(K))return;if(Y==="/pulls"&&B==="sort"&&K==="updated")return;if(Y==="/pulls"&&B==="direction"&&K==="desc")return;if(Y==="/pulls"&&["head","base"].includes(B)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(K))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((B,c)=>{if(c!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(B))throw Error("local_device_gh_header_denied")})}function z(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let H=new URL(Z,"https://api.github.com");if(H.pathname!=="/search/issues"||H.username||H.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;H.searchParams.forEach((X,K)=>{if(K==="q"&&V===null){V=X;return}if(K==="per_page"&&/^[1-9][0-9]*$/.test(X)&&Number(X)<=100)return;if(K==="page"&&/^[1-9][0-9]*$/.test(X)&&Number(X)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,U=V?.toLowerCase()??"";if(U.length>512||!(U+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(U.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((X,K)=>{if(K!=="accept"||X!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var WQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
3
3
  repository(owner: $owner, name: $repo) {
4
4
  nameWithOwner
5
5
  pullRequest(number: $number) {
@@ -39,4 +39,4 @@ import{he as W}from"./vm-hands-entry-lite-669hk342.js";var E=W.string().max(201)
39
39
  `)||!/^[a-f0-9]{64}$/.test(Q.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([Z,$,Q.pathAndQuery,Q.timestamp,Q.nonce,Q.challenge,Q.bodySha256].join(`
40
40
  `),"utf8")}function D(Q){return Boolean(Q)&&typeof Q==="object"&&!Array.isArray(Q)}function n(Q,Z){return typeof Q==="string"&&Z.some(($)=>$===Q)}function _(Q){return D(Q)&&typeof Q.id==="string"&&typeof Q.label==="string"&&typeof Q.path_fingerprint==="string"}function s(Q){return D(Q)&&Number.isInteger(Q.seq)&&Number(Q.seq)>=0&&typeof Q.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(Q.kind)&&D(Q.payload)}function w(Q){throw Error(Q)}function iQ(Q,Z){let $=D(Q)?Q:{},H=typeof $.error==="string"?$.error:`http_${Z}`,V=typeof $.detail==="string"?$.detail:typeof $.message==="string"?$.message:`Reason Device request failed (${Z})`;return{code:H,message:V}}function o(Q){if(!D(Q)||typeof Q.challenge!=="string"||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
41
41
  `)||typeof Q.expires_at!=="string"||!Number.isFinite(Date.parse(Q.expires_at)))w("Reason returned an invalid Device proof challenge.");return{challenge:Q.challenge,expires_at:Q.expires_at}}function f(Q,Z){if(!D(Q)||typeof Q.device_id!=="string"||Q.auth_scheme!=="p256"||Q.organization_id!==void 0&&typeof Q.organization_id!=="string"||Q.protocol_version!==x||!Array.isArray(Q.roots)||!Q.roots.every(_)||Z&&typeof Q.organization_id!=="string"||Q.device_credential!==void 0)w(Z?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:Q.device_id,...typeof Q.organization_id==="string"?{organization_id:Q.organization_id}:{},protocol_version:x,roots:Q.roots},auth_scheme:"p256"}}function tQ(Q){return f(Q,!1)}function vQ(Q){let Z=f(Q,!0);if(typeof Z.organization_id!=="string")return w("Reason returned an invalid Device enrollment.");return{...Z,organization_id:Z.organization_id}}function lQ(Q){if(!D(Q)||typeof Q.server_time!=="string"||typeof Q.drain!=="boolean")return w("Reason returned an invalid Device heartbeat.");return{server_time:Q.server_time,drain:Q.drain,...b(Q),...typeof Q.update_policy==="string"||Q.update_policy===null?{update_policy:Q.update_policy}:{},...typeof Q.supported_protocol_version==="number"?{supported_protocol_version:Q.supported_protocol_version}:{},...t(Q.latest_cli_versions),...Q.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var i=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function b(Q){return Object.fromEntries(i.filter((Z)=>Q[Z]===!0).map((Z)=>[Z,!0]))}function uQ(Q){if(!D(Q))return;try{return{...o(Q),...b(Q)}}catch{return}}function t(Q){if(!D(Q))return{};let Z={};for(let $ of p){let H=Q[$];if(typeof H==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(H))Z[$]=H}return Object.keys(Z).length>0?{latest_cli_versions:Z}:{}}function aQ(Q){if(!D(Q)||!Array.isArray(Q.roots)||!Q.roots.every(_))return w("Reason returned an invalid Device root sync.");return{roots:Q.roots}}function eQ(Q){if(!D(Q)||Q.user_id!==void 0&&typeof Q.user_id!=="string"||typeof Q.organization_id!=="string"||typeof Q.organization_name!=="string"||typeof Q.organization_slug!=="string")return w("Reason returned an invalid Device identity.");return{...typeof Q.user_id==="string"?{user_id:Q.user_id}:{},organization_id:Q.organization_id,organization_name:Q.organization_name,organization_slug:Q.organization_slug}}function QW(Q){if(!D(Q)||Q.disconnected!==!0)return w("Reason did not disconnect this Device.");let Z=Q.sessions_moved;return typeof Z==="number"&&Number.isSafeInteger(Z)&&Z>=0?{disconnected:!0,sessions_moved:Z}:{disconnected:!0}}function WW(Q){if(D(Q)&&Q.ok===!0&&typeof Q.expires==="number")return{ok:!0,expires:Q.expires};if(D(Q)&&Q.ok===!1&&typeof Q.error==="string")return{ok:!1,error:Q.error};return w("Reason did not answer the local login hand-over.")}function ZW(Q){if(!D(Q)||Q.accepted!==!0)return w("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function v(Q){return Buffer.byteLength(JSON.stringify(Q),"utf8")}function $W(Q,Z=k){if(!D(Q)||typeof Q.operation_id!=="string"||typeof Q.attempt_id!=="string"||typeof Q.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(Q.attempt_token)||typeof Q.lease_until!=="string"||typeof Q.run_id!=="string"||typeof Q.root_id!=="string"||Q.owner!==void 0&&!L(Q.owner)||!n(Q.capability,Z)||!D(Q.payload)||Q.protocol_version!==x||v(Q.payload)>R||Q.authority!==void 0&&!J(Q.authority)||Q.local_github_authority!==void 0&&!j.safeParse(Q.local_github_authority).success||Q.capability==="github.local.v1"&&!j.safeParse(Q.local_github_authority).success||Q.recording_authority!==void 0&&!m(Q.recording_authority)||Q.capability==="browser.recording.v1"&&(!m(Q.recording_authority)||!L(Q.owner))||Q.capability!=="browser.recording.v1"&&Q.recording_authority!==void 0)return w("Reason returned an invalid Device operation claim.");let $={operation_id:Q.operation_id,attempt_id:Q.attempt_id,attempt_token:Q.attempt_token,lease_until:Q.lease_until,run_id:Q.run_id,root_id:Q.root_id,capability:Q.capability,payload:Q.payload,...J(Q.authority)?{authority:Q.authority}:{},...m(Q.recording_authority)?{recording_authority:Object.freeze({...Q.recording_authority})}:{},...Q.local_github_authority!==void 0?{local_github_authority:j.parse(Q.local_github_authority)}:{},...Q.capability==="hands.connect"&&D(Q.environment)&&D(Q.environment.payload)&&J(Q.environment.authority)?{environment:{payload:Q.environment.payload,authority:Q.environment.authority}}:{},protocol_version:x};if(Q.owner!==void 0)$.owner=Object.freeze({...Q.owner});return $}function DW(Q){if(!D(Q)||typeof Q.lease_until!=="string"||!Array.isArray(Q.controls)||!Q.controls.every(s)||!Number.isInteger(Q.next_control_seq)||Number(Q.next_control_seq)<0)return w("Reason returned an invalid Device operation heartbeat.");return{lease_until:Q.lease_until,controls:Q.controls,next_control_seq:Number(Q.next_control_seq)}}function KW(Q){if(!D(Q)||!Number.isInteger(Q.next_event_seq)||Number(Q.next_event_seq)<0||typeof Q.duplicate!=="boolean"||!Number.isInteger(Q.accepted_count)||Number(Q.accepted_count)<0)return w("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(Q.next_event_seq),duplicate:Q.duplicate,accepted_count:Number(Q.accepted_count)}}function FW(Q){if(!D(Q)||!D(Q.payload)||!J(Q.authority))return w("Reason returned an invalid Device environment delivery.");return{payload:Q.payload,authority:Q.authority}}function l(Q){return Q==="succeeded"||Q==="failed"||Q==="cancelled"||Q==="expired"}function wW(Q){if(!D(Q)||!l(Q.status)||typeof Q.idempotent!=="boolean")return w("Reason returned an invalid Device operation completion.");return{status:Q.status,idempotent:Q.idempotent}}
42
- export{a as Vc,I as Wc,e as Xc,j as Yc,QQ as Zc,WQ as _c,ZQ as $c,k as ad,x as bd,P as cd,R as dd,wQ as ed,HQ as fd,VQ as gd,YQ as hd,XQ as id,BQ as jd,GQ as kd,qQ as ld,gQ as md,MQ as nd,NQ as od,UQ as pd,jQ as qd,JQ as rd,xQ as sd,IQ as td,SQ as ud,mQ as vd,PQ as wd,CQ as xd,EQ as yd,TQ as zd,AQ as Ad,kQ as Bd,LQ as Cd,_Q as Dd,fQ as Ed,bQ as Fd,cQ as Gd,yQ as Hd,dQ as Id,OQ as Jd,zQ as Kd,RQ as Ld,hQ as Md,pQ as Nd,rQ as Od,nQ as Pd,r as Qd,sQ as Rd,oQ as Sd,iQ as Td,o as Ud,tQ as Vd,vQ as Wd,lQ as Xd,uQ as Yd,aQ as Zd,eQ as _d,QW as $d,WW as ae,ZW as be,$W as ce,DW as de,KW as ee,FW as fe,wW as ge};
42
+ export{a as id,I as jd,e as kd,j as ld,QQ as md,WQ as nd,ZQ as od,k as pd,x as qd,P as rd,R as sd,wQ as td,HQ as ud,VQ as vd,YQ as wd,XQ as xd,BQ as yd,GQ as zd,qQ as Ad,gQ as Bd,MQ as Cd,NQ as Dd,UQ as Ed,jQ as Fd,JQ as Gd,xQ as Hd,IQ as Id,SQ as Jd,mQ as Kd,PQ as Ld,CQ as Md,EQ as Nd,TQ as Od,AQ as Pd,kQ as Qd,LQ as Rd,_Q as Sd,fQ as Td,bQ as Ud,cQ as Vd,yQ as Wd,dQ as Xd,OQ as Yd,zQ as Zd,RQ as _d,hQ as $d,pQ as ae,rQ as be,nQ as ce,r as de,sQ as ee,oQ as fe,iQ as ge,o as he,tQ as ie,vQ as je,lQ as ke,uQ as le,aQ as me,eQ as ne,QW as oe,WW as pe,ZW as qe,$W as re,DW as se,KW as te,FW as ue,wW as ve};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var U=".reason/workspace",T="workspace_base",y="sessions",W="workspace_layout",g=".reason/workspace/sessions",B=/^[0-9a-f]{8}$/;function C(j){if(!J(j))return!1;let q=".reason/workspace/sessions/";if(!j.startsWith(q))return!1;let z=j.slice(q.length).split("/");return z.length===2&&B.test(z[0])}var G=4096,X="workspaces/pi";function J(j){if(typeof j!=="string"||!j||j.length>G)return!1;if(j.startsWith("/")||j.includes("\x00")||j.includes("\\"))return!1;return j.split("/").every((q)=>q!==""&&q!=="."&&q!=="..")}function Z(j){if(j.kind==="root"){if(j.path===void 0)return".";if(!J(j.path))throw Error("invalid_device_workspace_identity");return j.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(j.workspaceId)||j.workspaceId==="."||j.workspaceId==="..")throw Error("invalid_device_workspace_identity");let q=j.layout==="sessions"?"sessions":X;return`${j.base?`${j.base}/`:""}${q}/${j.workspaceId}/repo`}function L(j){if(!j||typeof j!=="object"||Array.isArray(j))return null;let q=j;if(q.kind==="root"&&Object.keys(q).length===1)return{kind:"root"};if(q.kind==="root"&&Object.keys(q).length===2&&J(q.path))return{kind:"root",path:q.path};if(q.kind!=="managed"||typeof q.workspaceId!=="string"||Object.keys(q).length!==2+(q.base===void 0?0:1)+(q.layout===void 0?0:1)||q.base!==void 0&&q.base!==".reason/workspace"||q.layout!==void 0&&q.layout!=="sessions")return null;let z={kind:"managed",workspaceId:q.workspaceId,...q.base===".reason/workspace"?{base:".reason/workspace"}:{},...q.layout==="sessions"?{layout:"sessions"}:{}};try{return Z(z),z}catch{return null}}var b="/home/runner",P=10001,x="/run/reason/sessions",f=/^(?:\/[A-Za-z0-9._-]+)+$/,M=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,H=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function K(j){return M.exec(j)?.[1]??H.exec(j)?.[1]??j}var $=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/,A="*/.reason/workspace/workspaces/pi/*|*/.reason/workspace/sessions/*";function N(j,q=b,z="sessions"){if(!f.test(q)||q.split("/").some((V)=>V==="."||V===".."))throw Error("invalid_cloud_payload_home");let Q=`${q}/${Z({kind:"managed",workspaceId:j,base:".reason/workspace",...z?{layout:z}:{}})}`,F=`${x}/${K(j)}`;return{home:q,root:Q.slice(0,-5),checkout:Q,control:F,jobEnv:`${F}/job.env`,cloudAccess:`${F}/cloud-access`,logs:`${F}/logs`,pin:`${F}/ws`}}function Y(j){return $.exec(j.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function D(j){return{kind:"managed",workspaceId:j,layout:"sessions"}}function R(j){let q=$.exec(j.replace(/\/+$/,""));if(!q)return null;try{let z=N(q[3],q[1],Y(j));return z.root===j.replace(/\/+$/,"")?z:null}catch{return null}}
3
- export{U as uh,T as vh,y as wh,W as xh,g as yh,B as zh,C as Ah,J as Bh,Z as Ch,L as Dh,b as Eh,P as Fh,x as Gh,M as Hh,H as Ih,$ as Jh,A as Kh,N as Lh,Y as Mh,D as Nh,R as Oh};
3
+ export{U as Kh,T as Lh,y as Mh,W as Nh,g as Oh,B as Ph,C as Qh,J as Rh,Z as Sh,L as Th,b as Uh,P as Vh,x as Wh,M as Xh,H as Yh,$ as Zh,A as _h,N as $h,Y as ai,D as bi,R as ci};