@reason-machines/cli-linux-arm64-musl 0.2.387 → 0.2.389

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 (97) hide show
  1. package/bin/ara +1 -1
  2. package/bin/vm-hands/api-2edgrjpe.js +2 -0
  3. package/bin/vm-hands/api-credentials-1bfy2pqp.js +2 -0
  4. package/bin/vm-hands/{ask-relay-xa9bffq4.js → ask-relay-72awrbwx.js} +3 -3
  5. package/bin/vm-hands/connect-cli-rss8z5bk.js +2 -0
  6. package/bin/vm-hands/{custom-endpoint-device-bm94e9r0.js → custom-endpoint-device-3g0rc3wp.js} +1 -1
  7. package/bin/vm-hands/desktop-account-8yf4aqgb.js +2 -0
  8. package/bin/vm-hands/{device-workspace-0xsj5ykf.js → device-workspace-35hjc1ff.js} +1 -1
  9. package/bin/vm-hands/{hands-worker-source-azdrrhsz.js → hands-worker-source-msdkfx9x.js} +1 -1
  10. package/bin/vm-hands/{index-7f2kwwen.js → index-m32pjcjr.js} +1 -1
  11. package/bin/vm-hands/{install-receipt-3xyx3rdd.js → install-receipt-7qanbz38.js} +1 -1
  12. package/bin/vm-hands/local-automation-gb4jmhmg.js +2 -0
  13. package/bin/vm-hands/local-capabilities-gtdp4pz0.js +2 -0
  14. package/bin/vm-hands/local-desktop-users-p6n48895.js +2 -0
  15. package/bin/vm-hands/local-display-mac-7havkbhd.js +2 -0
  16. package/bin/vm-hands/local-display-session-yz5szy3t.js +2 -0
  17. package/bin/vm-hands/local-pty-session-8ny1n2fv.js +2 -0
  18. package/bin/vm-hands/managed-runtime-gyd32324.js +2 -0
  19. package/bin/vm-hands/network-contract-3h853c6e.js +2 -0
  20. package/bin/vm-hands/package-04cf0m62.js +2 -0
  21. package/bin/vm-hands/permissions-6pfayzkx.js +2 -0
  22. package/bin/vm-hands/{reason-hands-protocol-7d7xj1h3.js → reason-hands-protocol-mw7ba8vz.js} +1 -1
  23. package/bin/vm-hands/serve-service-mcnkk9hs.js +2 -0
  24. package/bin/vm-hands/{status-qm9cztrx.js → status-s1g9gt1e.js} +2 -2
  25. package/bin/vm-hands/version-cta9ffcc.js +2 -0
  26. package/bin/vm-hands/{vm-hands-entry-lite-xrthfx3q.js → vm-hands-entry-lite-00800vjk.js} +2 -2
  27. package/bin/vm-hands/{vm-hands-entry-lite-5n4vsm6b.js → vm-hands-entry-lite-02zaqpgh.js} +5 -5
  28. package/bin/vm-hands/{vm-hands-entry-lite-8fj07njx.js → vm-hands-entry-lite-0seprnh3.js} +1 -1
  29. package/bin/vm-hands/{vm-hands-entry-lite-qnnfvm5r.js → vm-hands-entry-lite-0z73amf7.js} +1 -1
  30. package/bin/vm-hands/{vm-hands-entry-lite-h8dbw0c7.js → vm-hands-entry-lite-180h5amj.js} +1 -1
  31. package/bin/vm-hands/{vm-hands-entry-lite-4g9dqrgy.js → vm-hands-entry-lite-2yx44ayr.js} +34 -34
  32. package/bin/vm-hands/{vm-hands-entry-lite-pk3q774c.js → vm-hands-entry-lite-3nr9q3nf.js} +1 -1
  33. package/bin/vm-hands/{vm-hands-entry-lite-9cmfthkq.js → vm-hands-entry-lite-3ptq7p60.js} +1 -1
  34. package/bin/vm-hands/{vm-hands-entry-lite-fyvgav60.js → vm-hands-entry-lite-5x04hakp.js} +2 -2
  35. package/bin/vm-hands/{vm-hands-entry-lite-6wsa0qrb.js → vm-hands-entry-lite-73akm1q1.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-f5230h6t.js → vm-hands-entry-lite-88h9vwrv.js} +1 -1
  37. package/bin/vm-hands/vm-hands-entry-lite-8e932j3c.js +3 -0
  38. package/bin/vm-hands/{vm-hands-entry-lite-zjfr0zh8.js → vm-hands-entry-lite-8pgggvbb.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-ew076kpd.js → vm-hands-entry-lite-8q63t2c0.js} +2 -2
  40. package/bin/vm-hands/{vm-hands-entry-lite-ammr3xbc.js → vm-hands-entry-lite-a1yy1yp3.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-j8q0pdsq.js → vm-hands-entry-lite-a8pdf1yx.js} +2 -2
  42. package/bin/vm-hands/vm-hands-entry-lite-adpzn7fe.js +3 -0
  43. package/bin/vm-hands/{vm-hands-entry-lite-hnsm5t36.js → vm-hands-entry-lite-atg4z1vg.js} +1 -1
  44. package/bin/vm-hands/{vm-hands-entry-lite-y2s2w174.js → vm-hands-entry-lite-bwpay74g.js} +1 -1
  45. package/bin/vm-hands/{vm-hands-entry-lite-e2mjbqmr.js → vm-hands-entry-lite-csecgmaa.js} +2 -2
  46. package/bin/vm-hands/{vm-hands-entry-lite-xq8bkqrd.js → vm-hands-entry-lite-dbcsvq0f.js} +2 -2
  47. package/bin/vm-hands/{vm-hands-entry-lite-rpn0frzb.js → vm-hands-entry-lite-e73s63fb.js} +1 -1
  48. package/bin/vm-hands/{vm-hands-entry-lite-1gxktkpe.js → vm-hands-entry-lite-ebgackey.js} +2 -2
  49. package/bin/vm-hands/vm-hands-entry-lite-ezahexcb.js +5 -0
  50. package/bin/vm-hands/{vm-hands-entry-lite-d00dg3ys.js → vm-hands-entry-lite-f5v3wap5.js} +1 -1
  51. package/bin/vm-hands/{vm-hands-entry-lite-2t0vcvd8.js → vm-hands-entry-lite-f78n4wqt.js} +1 -1
  52. package/bin/vm-hands/vm-hands-entry-lite-fb02h1zm.js +3 -0
  53. package/bin/vm-hands/{vm-hands-entry-lite-51hmj6am.js → vm-hands-entry-lite-g87z5eb6.js} +1 -1
  54. package/bin/vm-hands/{vm-hands-entry-lite-qef2ndkd.js → vm-hands-entry-lite-h0keewxv.js} +1 -1
  55. package/bin/vm-hands/{vm-hands-entry-lite-fb5dzy9x.js → vm-hands-entry-lite-hfv2tsm9.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-2j141pnw.js → vm-hands-entry-lite-jt9fmk7y.js} +2 -2
  57. package/bin/vm-hands/{vm-hands-entry-lite-ma001vzh.js → vm-hands-entry-lite-ksz1k1dh.js} +1 -1
  58. package/bin/vm-hands/{vm-hands-entry-lite-ejm5er3h.js → vm-hands-entry-lite-mc3pkj0q.js} +1 -1
  59. package/bin/vm-hands/{vm-hands-entry-lite-sex82vb1.js → vm-hands-entry-lite-mft9ke08.js} +1 -1
  60. package/bin/vm-hands/{vm-hands-entry-lite-f7f1zb7s.js → vm-hands-entry-lite-nq5np26e.js} +1 -1
  61. package/bin/vm-hands/{vm-hands-entry-lite-rd0ak4ye.js → vm-hands-entry-lite-p1s0xyc2.js} +2 -2
  62. package/bin/vm-hands/{vm-hands-entry-lite-mn64e4pt.js → vm-hands-entry-lite-r166b92s.js} +1 -1
  63. package/bin/vm-hands/{vm-hands-entry-lite-f02906k8.js → vm-hands-entry-lite-trm3dn8c.js} +1 -1
  64. package/bin/vm-hands/{vm-hands-entry-lite-7a01dgje.js → vm-hands-entry-lite-vvv3m6wy.js} +3 -3
  65. package/bin/vm-hands/{vm-hands-entry-lite-w7havvz8.js → vm-hands-entry-lite-w4tyr264.js} +1 -1
  66. package/bin/vm-hands/{vm-hands-entry-lite-vj9h1knv.js → vm-hands-entry-lite-w844s03h.js} +2 -2
  67. package/bin/vm-hands/{vm-hands-entry-lite-2e18tm6w.js → vm-hands-entry-lite-wpcagqfw.js} +1 -1
  68. package/bin/vm-hands/{vm-hands-entry-lite-wc6skbhf.js → vm-hands-entry-lite-wxzh22y4.js} +2 -2
  69. package/bin/vm-hands/{vm-hands-entry-lite-9w5vs9zv.js → vm-hands-entry-lite-y99g8x7f.js} +1 -1
  70. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  71. package/bin/vm-hands/{vm-hands-executor-d8wkv51n.js → vm-hands-executor-22jnr9y7.js} +1 -1
  72. package/bin/vm-hands/vm-hands-op-runner-dcweybjn.js +2 -0
  73. package/bin/vm-hands/vm-hands-runtime-bt8pe8cm.js +4 -0
  74. package/bin/vm-hands/worker-sandbox-nnk7fq89.js +2 -0
  75. package/package.json +1 -1
  76. package/bin/vm-hands/api-credentials-xppmbg0m.js +0 -2
  77. package/bin/vm-hands/api-xmpbsm6b.js +0 -2
  78. package/bin/vm-hands/connect-cli-c1ex48w5.js +0 -2
  79. package/bin/vm-hands/desktop-account-3tnm4z5w.js +0 -2
  80. package/bin/vm-hands/local-automation-06tkbypc.js +0 -2
  81. package/bin/vm-hands/local-capabilities-cktbbszh.js +0 -2
  82. package/bin/vm-hands/local-desktop-users-ajb81vjm.js +0 -2
  83. package/bin/vm-hands/local-display-mac-9h6btvvq.js +0 -2
  84. package/bin/vm-hands/local-display-session-9d20yat4.js +0 -2
  85. package/bin/vm-hands/local-pty-session-cjas515w.js +0 -2
  86. package/bin/vm-hands/managed-runtime-pjemjmd9.js +0 -2
  87. package/bin/vm-hands/network-contract-dsw79qkc.js +0 -2
  88. package/bin/vm-hands/package-smk3nqjs.js +0 -2
  89. package/bin/vm-hands/permissions-qrfwt9ez.js +0 -2
  90. package/bin/vm-hands/serve-service-403dqjk9.js +0 -2
  91. package/bin/vm-hands/version-gyns0vgm.js +0 -2
  92. package/bin/vm-hands/vm-hands-entry-lite-dh5gwmyf.js +0 -3
  93. package/bin/vm-hands/vm-hands-entry-lite-e0gdt6r5.js +0 -5
  94. package/bin/vm-hands/vm-hands-entry-lite-r8qg3wp1.js +0 -3
  95. package/bin/vm-hands/vm-hands-op-runner-4m334z7c.js +0 -2
  96. package/bin/vm-hands/vm-hands-runtime-6ajffhfb.js +0 -4
  97. package/bin/vm-hands/worker-sandbox-tgqbmy6b.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Hc as pZ,Ic as uZ,Jc as C4,Kc as T4,Lc as M8,Mc as lZ}from"./vm-hands-entry-lite-qef2ndkd.js";import{Nc as fZ,Oc as H8,Pc as t9,Qc as _0,Rc as M9,Sc as a0,Zc as K0}from"./vm-hands-entry-lite-mn64e4pt.js";import{ad as B8,bd as W8,cd as aQ}from"./vm-hands-entry-lite-h8dbw0c7.js";import{De as MZ,if as f9,jf as t0,kf as T8,lf as m0,pf as C0,ye as NZ}from"./vm-hands-entry-lite-5n4vsm6b.js";import{Fg as aZ,Lg as $8,Mg as s8}from"./vm-hands-entry-lite-xrthfx3q.js";import{Rg as j4}from"./vm-hands-entry-lite-fb5dzy9x.js";import{Ah as O0,Bh as o9,Ih as d8,Jh as TZ,Kh as HZ,Ug as SQ,Xg as N9,eh as jZ,fh as qZ,hh as CZ,jh as i9,kh as FZ,lh as VZ,mh as h8,ph as a9,yh as g8,zh as w0}from"./vm-hands-entry-lite-ammr3xbc.js";import{ti as rZ,ui as a8}from"./vm-hands-entry-lite-e2mjbqmr.js";import{Vi as b0}from"./vm-hands-entry-lite-sex82vb1.js";import{lj as _8,mj as r9,pj as M4}from"./vm-hands-entry-lite-fyvgav60.js";import{Kj as A$,qj as O8,rj as o0,sj as D8,tj as r0,uj as W9,vj as V8,wj as H$,xj as i0,yj as u0,zj as KZ}from"./vm-hands-entry-lite-pk3q774c.js";import{Pj as TQ}from"./vm-hands-entry-lite-ew076kpd.js";import{ik as x}from"./vm-hands-entry-lite-zjfr0zh8.js";import{ok as q4}from"./vm-hands-entry-lite-rd0ak4ye.js";import{Ak as N4,Bk as J9,rk as L4,tk as e9,uk as OZ,vk as d$,wk as DZ,xk as d9}from"./vm-hands-entry-lite-r8qg3wp1.js";import{Ek as q}from"./vm-hands-entry-lite-51hmj6am.js";import{Fk as u1,Kk as qQ}from"./vm-hands-entry-lite-2t0vcvd8.js";import{execFile as b4}from"child_process";import{createRequire as k4}from"module";import{win32 as p9}from"path";var f4=250,m4=50,y4=250,g4=4194304;function v$($){let Z=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec($??""),Q=Number(Z?.[3]);return Z&&Q<=65535?{address:Z[1]??Z[2],port:Q}:null}function h4($){let Z=[];for(let Q of $.split(/\r?\n/)){let X=Q.trim().split(/\s+/);if(X[0]!=="TCP"||X.length<5)continue;let J=v$(X[1]),Y=v$(X[2]),z=Number(X.at(-1));if(!J||!Y||!Number.isSafeInteger(z)||z<0)continue;Z.push({pid:z,localAddress:J.address,localPort:J.port,remoteAddress:Y.address,remotePort:Y.port,listening:Y.port===0})}return Z}function v4($){if($.localAddress==="0.0.0.0"||$.localAddress==="::")return`*:${$.localPort}`;return $.localAddress.includes(":")?`[${$.localAddress}]:${$.localPort}`:`${$.localAddress}:${$.localPort}`}var S8=($)=>new Promise((Z,Q)=>b4(p9.join(d$("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:$,maxBuffer:g4,encoding:"utf8",windowsHide:!0,env:d9()},(X,J)=>X?Q(X):Z(J)));function O9($){let Z=p9.normalize($.startsWith("\\\\?\\")?$.slice(4):$);return Z.length>3&&Z.endsWith("\\")?Z.slice(0,-1):Z}function c4($,Z){let Q=$.toLowerCase(),X=Z.toLowerCase();return X===Q||X.startsWith(Q.endsWith("\\")?Q:`${Q}\\`)}function p$($,Z,Q){let X=$.cwd(Q),J=X?O9(X):null;return J&&p9.isAbsolute(J)&&c4(Z,J)?J:null}var T9;function u9(){if(T9!==void 0)return T9;if(T9=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let $;try{$=k4(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:Z,ptr:Q}=$,X,J;try{X=$.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[Z.u32,Z.u32],returns:Z.u64},Process32FirstW:{args:[Z.u64,Z.ptr],returns:Z.i32},Process32NextW:{args:[Z.u64,Z.ptr],returns:Z.i32},OpenProcess:{args:[Z.u32,Z.i32,Z.u32],returns:Z.u64},ReadProcessMemory:{args:[Z.u64,Z.u64,Z.ptr,Z.u64,Z.ptr],returns:Z.i32},CloseHandle:{args:[Z.u64],returns:Z.i32}}).symbols,J=$.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[Z.u64,Z.i32,Z.ptr,Z.u32,Z.ptr],returns:Z.i32}}).symbols}catch{return null}let Y=0xFFFF_FFFF_FFFF_FFFFn,z=2,F=1040,G=568,V=(B,H,K)=>{let L=Buffer.alloc(K);return X.ReadProcessMemory(B,H,Q(L),K,null)?L:null};return T9={processes(){let B=BigInt(X.CreateToolhelp32Snapshot(z,0));if(B===Y)throw new q("process_inspection_failed","Reading this computer's processes did not complete.");try{let H=Buffer.alloc(G);H.writeUInt32LE(G,0);let K=Q(H),L=[];for(let W=X.Process32FirstW(B,K);W;W=X.Process32NextW(B,K)){let U=H.toString("utf16le",44,G),j=U.slice(0,U.includes("\x00")?U.indexOf("\x00"):void 0),O=H.readUInt32LE(8);if(O>0)L.push({pid:O,parentPid:H.readUInt32LE(32),command:j.replace(/\.exe$/i,"")||null})}return L}finally{X.CloseHandle(B)}},cwd(B){let H=BigInt(X.OpenProcess(F,0,B));if(H===0n)return null;try{let K=Buffer.alloc(48);if(J.NtQueryInformationProcess(H,0,Q(K),K.length,null)!==0)return null;let L=V(H,K.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),W=L?V(H,L+0x38n,16):null,U=W?.readUInt16LE(0)??0;if(!W||U===0||U%2!==0)return null;return V(H,W.readBigUInt64LE(8),U)?.toString("utf16le")??null}finally{X.CloseHandle(H)}}},T9}function w8($){if(!$)throw new q("process_inspection_failed","Reading this computer's processes is unavailable.");return $}async function u$($,Z){let Q;try{Q=await $(Z)}catch{throw new q("process_inspection_failed","Reading this computer's ports did not complete.")}return h4(Q)}async function O2($,Z=u9()){let Q=w8(Z),X=O9($),J=[];for(let Y of Q.processes()){if(J.length>=f4)break;let z=p$(Q,X,Y.pid);if(z)J.push({pid:Y.pid,command:Y.command,cwd:p9.relative(X,z)||"."})}return{processes:J}}async function D2($,Z=u9(),Q=S8){let X=w8(Z),J=O9($),Y=(await u$(Q,5000)).filter((V)=>V.listening&&V.pid>0).map((V)=>({pid:V.pid,port:V.localPort,address:v4(V)})).sort((V,B)=>V.pid-B.pid||V.port-B.port||(V.address<B.address?-1:V.address>B.address?1:0)),z=[...new Set(Y.map((V)=>V.pid))].slice(0,m4),F=new Set(z.filter((V)=>p$(X,J,V)!==null));if(F.size===0)return{ports:[]};let G=new Map(X.processes().map((V)=>[V.pid,V.command]));return{ports:Y.filter((V)=>F.has(V.pid)).slice(0,y4).map((V)=>({pid:V.pid,command:G.get(V.pid)??null,address:V.address}))}}function c$($,Z){let Q=new Set([Z]);for(let X=!0;X;){X=!1;for(let J of $)if(!Q.has(J.pid)&&Q.has(J.parentPid)&&J.pid!==J.parentPid)Q.add(J.pid),X=!0}return Q}function d4($,Z,Q,X){let J=(Y)=>Y==="127.0.0.1"||Y==="::ffff:127.0.0.1"||Y==="::1";return $.flatMap((Y)=>{if(!Z.has(Y.pid)||Y.localPort!==X)return[];let z=Y.listening&&(J(Y.localAddress)||["0.0.0.0","::"].includes(Y.localAddress)),F=!Y.listening&&J(Y.localAddress)&&J(Y.remoteAddress);if(!z&&!F)return[];let G=`${Y.localAddress}:${Y.localPort}>${Y.remoteAddress}:${Y.remotePort}`;return[{pid:Y.pid,processGroupId:Q,descriptor:String(Y.pid),kernelId:G,state:z?"listen":"established",port:X,peerPort:z?null:Y.remotePort,host:Y.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function l$($,Z,Q=u9(),X=S8){let J=w8(Q),Y=c$(J.processes(),$),z=await u$(X,1000),F=c$(J.processes(),$);return d4(z,new Set([...Y].filter((G)=>F.has(G))),$,Z)}async function _2($,Z=u9(),Q=S8){if(!Z||$.aborted)return!1;let X=Z.processes().some((F)=>F.pid===process.pid),J=Z.cwd(process.pid),Y=J!==null&&O9(J).toLowerCase()===O9(process.cwd()).toLowerCase(),z=await Q(5000).then((F)=>/^\s*TCP\s/m.test(F),()=>!1);return X&&Y&&z&&!$.aborted}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 l9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function I0($,Z,Q=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Z&&$<=Q}function n$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function i$($,Z){let Q=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Q.length]),Q,Z])}function R0($){if(!l9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(n$)||!I0($.attachmentRevision,0)||!I0($.grantRevision,1)||!I0($.generation,1)||!I0($.port,1024,65535)||!I0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function d0($,Z){return Object.keys($).every((Q)=>$[Q]===Z[Q])}function _9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Z=decodeURIComponent($);if(Z.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Z))throw Error("preview_path_invalid");return $}function s$($){return Array.isArray($)&&$.length<=64&&$.every((Z)=>Array.isArray(Z)&&Z.length===2&&typeof Z[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Z[0])&&typeof Z[1]==="string"&&Z[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Z[1]))}function D9($,Z=v.chunk){if($.length>Math.ceil(Z/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Q=Buffer.from($,"base64");if(Q.length>Z)throw Error("preview_data_too_large");return Q}function a$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function o$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Z=JSON.parse($);if(!l9(Z))throw Error("preview_frame_invalid");if(Z.type==="hello")return{type:"hello",binding:R0(Z.binding),...I0(Z.messages,v.chunk,v.upload)?{messages:Z.messages}:{},...I0(Z.window,1,v.window)?{window:Z.window}:{},...Z.bytes===!0?{bytes:!0}:{}};if(Z.type==="refused"&&typeof Z.reason==="string"&&/^[a-z_]{1,32}$/.test(Z.reason))return{type:"refused",binding:R0(Z.binding),reason:Z.reason};if(!n$(Z.id))throw Error("preview_frame_invalid");if(Z.type==="end"||Z.type==="cancel"||Z.type==="credit")return{type:Z.type,id:Z.id};if(Z.type==="ws"&&typeof Z.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Z.protocol))return{type:"ws",id:Z.id,protocol:Z.protocol};if(Z.type==="data"&&typeof Z.data==="string"&&typeof Z.binary==="boolean")return D9(Z.data,v.upload),{type:"data",id:Z.id,data:Z.data,binary:Z.binary};if(Z.type==="head"&&I0(Z.status,200,599)&&s$(Z.headers))return{type:"head",id:Z.id,status:Z.status,headers:Z.headers};if(Z.type==="request"&&typeof Z.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Z.method)&&typeof Z.path==="string"&&s$(Z.headers)&&typeof Z.body==="string"&&typeof Z.upgrade==="boolean")return D9(Z.body,v.upload),{type:"request",id:Z.id,method:Z.method,path:_9(Z.path),headers:Z.headers,body:Z.body,upgrade:Z.upgrade};throw Error("preview_frame_invalid")}function b8($){let Z=[...$],Q=new Set(Z.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 Z.filter(([J])=>!X.has(J.toLowerCase())&&!Q.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function k8($){let Z;try{return await Promise.race([Promise.resolve().then($).then((Q)=>Q===!0||(Q===!1?!1:void 0),()=>{return}),new Promise((Q)=>{Z=setTimeout(()=>Q(void 0),v.authorizationMs)})])}finally{clearTimeout(Z)}}async function A9($){return await k8($)===!0}function s9($,Z){let Q=new URL($);if(Q.username||Q.password||Q.search||Q.hash||!(Q.protocol==="wss:"||Q.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Q.hostname))||!new RegExp(`^/${Z}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Q.pathname))throw Error("preview_relay_invalid");return Q.href}function r$($){if(!l9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:R0($.binding),deviceRelayUrl:s9($.deviceRelayUrl,"device")}}function t$($){if(!l9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:R0($.binding)}}import{request as s4}from"http";import{pipeline as n4}from"stream";import{constants as f8,createBrotliCompress as i4,createGzip as a4}from"zlib";import{WebSocket as x9}from"ws";import{randomBytes as p4,timingSafeEqual as u4}from"crypto";import{createServer as l4}from"net";var e$="x-preview-connection";async function $Z($,Z){if(Z.aborted)throw Error("preview_closed");let Q=p4(32).toString("base64url"),X=new Set,J=!1,Y=l4((G)=>{if(J||Z.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let V=new AbortController;G.once("close",()=>{X.delete(G),V.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{Hc as pZ,Ic as uZ,Jc as C4,Kc as T4,Lc as M8,Mc as lZ}from"./vm-hands-entry-lite-h0keewxv.js";import{Nc as fZ,Oc as H8,Pc as t9,Qc as _0,Rc as M9,Sc as a0,Zc as K0}from"./vm-hands-entry-lite-r166b92s.js";import{ad as B8,bd as W8,cd as aQ}from"./vm-hands-entry-lite-180h5amj.js";import{De as MZ,jf as f9,kf as t0,lf as T8,mf as m0,qf as C0,ye as NZ}from"./vm-hands-entry-lite-02zaqpgh.js";import{Gg as aZ,Mg as $8,Ng as s8}from"./vm-hands-entry-lite-00800vjk.js";import{Sg as j4}from"./vm-hands-entry-lite-hfv2tsm9.js";import{Ah as w0,Bh as O0,Ch as o9,Jh as d8,Kh as TZ,Lh as HZ,Vg as SQ,Yg as N9,fh as jZ,gh as qZ,ih as CZ,kh as i9,lh as FZ,mh as VZ,nh as h8,qh as a9,zh as g8}from"./vm-hands-entry-lite-a1yy1yp3.js";import{ui as rZ,vi as a8}from"./vm-hands-entry-lite-csecgmaa.js";import{Wi as b0}from"./vm-hands-entry-lite-mft9ke08.js";import{mj as _8,nj as r9,qj as M4}from"./vm-hands-entry-lite-5x04hakp.js";import{Aj as KZ,Lj as A$,rj as O8,sj as o0,tj as D8,uj as r0,vj as W9,wj as V8,xj as H$,yj as i0,zj as u0}from"./vm-hands-entry-lite-3nr9q3nf.js";import{Qj as TQ}from"./vm-hands-entry-lite-8q63t2c0.js";import{jk as x}from"./vm-hands-entry-lite-8pgggvbb.js";import{pk as q4}from"./vm-hands-entry-lite-p1s0xyc2.js";import{Bk as N4,Ck as J9,sk as L4,uk as e9,vk as OZ,wk as d$,xk as DZ,yk as d9}from"./vm-hands-entry-lite-fb02h1zm.js";import{Gk as q}from"./vm-hands-entry-lite-g87z5eb6.js";import{Hk as u1,Mk as qQ}from"./vm-hands-entry-lite-f78n4wqt.js";import{execFile as b4}from"child_process";import{createRequire as k4}from"module";import{win32 as p9}from"path";var f4=250,m4=50,y4=250,g4=4194304;function v$($){let Z=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec($??""),Q=Number(Z?.[3]);return Z&&Q<=65535?{address:Z[1]??Z[2],port:Q}:null}function h4($){let Z=[];for(let Q of $.split(/\r?\n/)){let X=Q.trim().split(/\s+/);if(X[0]!=="TCP"||X.length<5)continue;let J=v$(X[1]),Y=v$(X[2]),z=Number(X.at(-1));if(!J||!Y||!Number.isSafeInteger(z)||z<0)continue;Z.push({pid:z,localAddress:J.address,localPort:J.port,remoteAddress:Y.address,remotePort:Y.port,listening:Y.port===0})}return Z}function v4($){if($.localAddress==="0.0.0.0"||$.localAddress==="::")return`*:${$.localPort}`;return $.localAddress.includes(":")?`[${$.localAddress}]:${$.localPort}`:`${$.localAddress}:${$.localPort}`}var S8=($)=>new Promise((Z,Q)=>b4(p9.join(d$("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:$,maxBuffer:g4,encoding:"utf8",windowsHide:!0,env:d9()},(X,J)=>X?Q(X):Z(J)));function O9($){let Z=p9.normalize($.startsWith("\\\\?\\")?$.slice(4):$);return Z.length>3&&Z.endsWith("\\")?Z.slice(0,-1):Z}function c4($,Z){let Q=$.toLowerCase(),X=Z.toLowerCase();return X===Q||X.startsWith(Q.endsWith("\\")?Q:`${Q}\\`)}function p$($,Z,Q){let X=$.cwd(Q),J=X?O9(X):null;return J&&p9.isAbsolute(J)&&c4(Z,J)?J:null}var T9;function u9(){if(T9!==void 0)return T9;if(T9=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let $;try{$=k4(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:Z,ptr:Q}=$,X,J;try{X=$.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[Z.u32,Z.u32],returns:Z.u64},Process32FirstW:{args:[Z.u64,Z.ptr],returns:Z.i32},Process32NextW:{args:[Z.u64,Z.ptr],returns:Z.i32},OpenProcess:{args:[Z.u32,Z.i32,Z.u32],returns:Z.u64},ReadProcessMemory:{args:[Z.u64,Z.u64,Z.ptr,Z.u64,Z.ptr],returns:Z.i32},CloseHandle:{args:[Z.u64],returns:Z.i32}}).symbols,J=$.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[Z.u64,Z.i32,Z.ptr,Z.u32,Z.ptr],returns:Z.i32}}).symbols}catch{return null}let Y=0xFFFF_FFFF_FFFF_FFFFn,z=2,F=1040,G=568,V=(B,H,K)=>{let L=Buffer.alloc(K);return X.ReadProcessMemory(B,H,Q(L),K,null)?L:null};return T9={processes(){let B=BigInt(X.CreateToolhelp32Snapshot(z,0));if(B===Y)throw new q("process_inspection_failed","Reading this computer's processes did not complete.");try{let H=Buffer.alloc(G);H.writeUInt32LE(G,0);let K=Q(H),L=[];for(let W=X.Process32FirstW(B,K);W;W=X.Process32NextW(B,K)){let U=H.toString("utf16le",44,G),j=U.slice(0,U.includes("\x00")?U.indexOf("\x00"):void 0),O=H.readUInt32LE(8);if(O>0)L.push({pid:O,parentPid:H.readUInt32LE(32),command:j.replace(/\.exe$/i,"")||null})}return L}finally{X.CloseHandle(B)}},cwd(B){let H=BigInt(X.OpenProcess(F,0,B));if(H===0n)return null;try{let K=Buffer.alloc(48);if(J.NtQueryInformationProcess(H,0,Q(K),K.length,null)!==0)return null;let L=V(H,K.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),W=L?V(H,L+0x38n,16):null,U=W?.readUInt16LE(0)??0;if(!W||U===0||U%2!==0)return null;return V(H,W.readBigUInt64LE(8),U)?.toString("utf16le")??null}finally{X.CloseHandle(H)}}},T9}function w8($){if(!$)throw new q("process_inspection_failed","Reading this computer's processes is unavailable.");return $}async function u$($,Z){let Q;try{Q=await $(Z)}catch{throw new q("process_inspection_failed","Reading this computer's ports did not complete.")}return h4(Q)}async function O2($,Z=u9()){let Q=w8(Z),X=O9($),J=[];for(let Y of Q.processes()){if(J.length>=f4)break;let z=p$(Q,X,Y.pid);if(z)J.push({pid:Y.pid,command:Y.command,cwd:p9.relative(X,z)||"."})}return{processes:J}}async function D2($,Z=u9(),Q=S8){let X=w8(Z),J=O9($),Y=(await u$(Q,5000)).filter((V)=>V.listening&&V.pid>0).map((V)=>({pid:V.pid,port:V.localPort,address:v4(V)})).sort((V,B)=>V.pid-B.pid||V.port-B.port||(V.address<B.address?-1:V.address>B.address?1:0)),z=[...new Set(Y.map((V)=>V.pid))].slice(0,m4),F=new Set(z.filter((V)=>p$(X,J,V)!==null));if(F.size===0)return{ports:[]};let G=new Map(X.processes().map((V)=>[V.pid,V.command]));return{ports:Y.filter((V)=>F.has(V.pid)).slice(0,y4).map((V)=>({pid:V.pid,command:G.get(V.pid)??null,address:V.address}))}}function c$($,Z){let Q=new Set([Z]);for(let X=!0;X;){X=!1;for(let J of $)if(!Q.has(J.pid)&&Q.has(J.parentPid)&&J.pid!==J.parentPid)Q.add(J.pid),X=!0}return Q}function d4($,Z,Q,X){let J=(Y)=>Y==="127.0.0.1"||Y==="::ffff:127.0.0.1"||Y==="::1";return $.flatMap((Y)=>{if(!Z.has(Y.pid)||Y.localPort!==X)return[];let z=Y.listening&&(J(Y.localAddress)||["0.0.0.0","::"].includes(Y.localAddress)),F=!Y.listening&&J(Y.localAddress)&&J(Y.remoteAddress);if(!z&&!F)return[];let G=`${Y.localAddress}:${Y.localPort}>${Y.remoteAddress}:${Y.remotePort}`;return[{pid:Y.pid,processGroupId:Q,descriptor:String(Y.pid),kernelId:G,state:z?"listen":"established",port:X,peerPort:z?null:Y.remotePort,host:Y.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function l$($,Z,Q=u9(),X=S8){let J=w8(Q),Y=c$(J.processes(),$),z=await u$(X,1000),F=c$(J.processes(),$);return d4(z,new Set([...Y].filter((G)=>F.has(G))),$,Z)}async function _2($,Z=u9(),Q=S8){if(!Z||$.aborted)return!1;let X=Z.processes().some((F)=>F.pid===process.pid),J=Z.cwd(process.pid),Y=J!==null&&O9(J).toLowerCase()===O9(process.cwd()).toLowerCase(),z=await Q(5000).then((F)=>/^\s*TCP\s/m.test(F),()=>!1);return X&&Y&&z&&!$.aborted}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 l9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function I0($,Z,Q=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Z&&$<=Q}function n$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function i$($,Z){let Q=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Q.length]),Q,Z])}function R0($){if(!l9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(n$)||!I0($.attachmentRevision,0)||!I0($.grantRevision,1)||!I0($.generation,1)||!I0($.port,1024,65535)||!I0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function d0($,Z){return Object.keys($).every((Q)=>$[Q]===Z[Q])}function _9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Z=decodeURIComponent($);if(Z.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Z))throw Error("preview_path_invalid");return $}function s$($){return Array.isArray($)&&$.length<=64&&$.every((Z)=>Array.isArray(Z)&&Z.length===2&&typeof Z[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Z[0])&&typeof Z[1]==="string"&&Z[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Z[1]))}function D9($,Z=v.chunk){if($.length>Math.ceil(Z/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Q=Buffer.from($,"base64");if(Q.length>Z)throw Error("preview_data_too_large");return Q}function a$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function o$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Z=JSON.parse($);if(!l9(Z))throw Error("preview_frame_invalid");if(Z.type==="hello")return{type:"hello",binding:R0(Z.binding),...I0(Z.messages,v.chunk,v.upload)?{messages:Z.messages}:{},...I0(Z.window,1,v.window)?{window:Z.window}:{},...Z.bytes===!0?{bytes:!0}:{}};if(Z.type==="refused"&&typeof Z.reason==="string"&&/^[a-z_]{1,32}$/.test(Z.reason))return{type:"refused",binding:R0(Z.binding),reason:Z.reason};if(!n$(Z.id))throw Error("preview_frame_invalid");if(Z.type==="end"||Z.type==="cancel"||Z.type==="credit")return{type:Z.type,id:Z.id};if(Z.type==="ws"&&typeof Z.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Z.protocol))return{type:"ws",id:Z.id,protocol:Z.protocol};if(Z.type==="data"&&typeof Z.data==="string"&&typeof Z.binary==="boolean")return D9(Z.data,v.upload),{type:"data",id:Z.id,data:Z.data,binary:Z.binary};if(Z.type==="head"&&I0(Z.status,200,599)&&s$(Z.headers))return{type:"head",id:Z.id,status:Z.status,headers:Z.headers};if(Z.type==="request"&&typeof Z.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Z.method)&&typeof Z.path==="string"&&s$(Z.headers)&&typeof Z.body==="string"&&typeof Z.upgrade==="boolean")return D9(Z.body,v.upload),{type:"request",id:Z.id,method:Z.method,path:_9(Z.path),headers:Z.headers,body:Z.body,upgrade:Z.upgrade};throw Error("preview_frame_invalid")}function b8($){let Z=[...$],Q=new Set(Z.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 Z.filter(([J])=>!X.has(J.toLowerCase())&&!Q.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function k8($){let Z;try{return await Promise.race([Promise.resolve().then($).then((Q)=>Q===!0||(Q===!1?!1:void 0),()=>{return}),new Promise((Q)=>{Z=setTimeout(()=>Q(void 0),v.authorizationMs)})])}finally{clearTimeout(Z)}}async function A9($){return await k8($)===!0}function s9($,Z){let Q=new URL($);if(Q.username||Q.password||Q.search||Q.hash||!(Q.protocol==="wss:"||Q.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Q.hostname))||!new RegExp(`^/${Z}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Q.pathname))throw Error("preview_relay_invalid");return Q.href}function r$($){if(!l9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:R0($.binding),deviceRelayUrl:s9($.deviceRelayUrl,"device")}}function t$($){if(!l9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:R0($.binding)}}import{request as s4}from"http";import{pipeline as n4}from"stream";import{constants as f8,createBrotliCompress as i4,createGzip as a4}from"zlib";import{WebSocket as x9}from"ws";import{randomBytes as p4,timingSafeEqual as u4}from"crypto";import{createServer as l4}from"net";var e$="x-preview-connection";async function $Z($,Z){if(Z.aborted)throw Error("preview_closed");let Q=p4(32).toString("base64url"),X=new Set,J=!1,Y=l4((G)=>{if(J||Z.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let V=new AbortController;G.once("close",()=>{X.delete(G),V.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();K(B,W).catch(()=>G.destroy())};G.on("data",H);async function K(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");_9(j[2]);let O=!1,C=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()===e$){C++;let m=Buffer.from(S[2].trim());O=m.length===Q.length&&u4(m,Buffer.from(Q))}else if(S[1].toLowerCase()!=="host")A.push(T)}if(!O||C!==1||J||V.signal.aborted)throw Error("preview_connection_denied");let R=await $.connect(V.signal);if(J||V.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
@@ -302,7 +302,7 @@ async (input) => {
302
302
  if (!bridge || typeof bridge.evaluate !== "function") throw new Error("Reason Hands browser bridge is not installed");
303
303
  return await bridge.evaluate(typeof input === "string" ? input : input && input.code);
304
304
  }
305
- `.trim();import{Buffer as G9}from"buffer";import{randomUUID as _1}from"crypto";class KQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var FQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),YQ=/^hands_[A-Za-z0-9_-]{8,128}$/,A1=2048,VQ=32,HQ=1e4,x1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function P1($){let Z=$.split("+"),Q=(Z.pop()??"").replace(/^Key/,"").toLowerCase();if(Q==="f12")return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Q))return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Z.includes("Shift")&&Q==="c")return!0;return Z.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Q)}var I1=($)=>{let Z=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Z&&!/^(https?:|about:blank)/i.test(Z.href))}},UQ={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 KQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Z=Object.getPrototypeOf($);return Z===Object.prototype||Z===null}function z9($,Z=0,Q={nodes:0}){if(Z>VQ||++Q.nodes>HQ)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 $)z9(X,Z+1,Q);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(FQ.has(X))I("hands_repl_invalid_json");z9(J,Z+1,Q)}}function o8($){return typeof $==="string"&&Object.hasOwn(UQ,$)}function R1($){if(!$.endsWith("[]"))return null;let Z=$.slice(0,-2);return o8(Z)?Z:null}function GQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function E1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function zQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function X8(){return Object.freeze({$handsRepl:"undefined"})}function S1($){if(!G9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:G9.from($).toString("base64")})}function WQ($){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 Z=$.maxHandles??A1;if(!Number.isInteger(Z)||Z<3||Z>1e5)I("hands_repl_invalid_handle_limit");let Q=new Map,X=new WeakMap,J=$.createOpaqueId??_1,Y=(K,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(K);if(W)return W;if(Q.size>=Z)I("hands_repl_handle_limit");let U="";for(let C=0;C<16;C+=1){let A=`hands_${J()}`;if(YQ.test(A)&&!Q.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:K});Q.set(U,{kind:K,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(K,j),j},z=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),F=(K)=>{if(!z0(K)||Object.keys(K).length!==3||K.$handsRepl!=="handle"||typeof K.id!=="string"||!YQ.test(K.id)||!o8(K.kind))I("hands_repl_invalid_handle");let L=Q.get(K.id);if(!L||L.kind!==K.kind)I("hands_repl_unknown_handle");return L},G=(K,L=0,W=new Set)=>{if(L>VQ)I("hands_repl_json_too_complex");if(K===void 0)return X8();if(K===null||typeof K==="boolean"||typeof K==="string")return K;if(typeof K==="number"){if(!Number.isFinite(K))I("hands_repl_non_json_result");return K}if(Array.isArray(K)){if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{return K.map((U)=>G(U,L+1,W))}finally{W.delete(K)}}if(!z0(K))I("hands_repl_non_json_result");if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{let U=Object.create(null);for(let j of Object.keys(K)){let O=Object.getOwnPropertyDescriptor(K,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(K)}},V=(K,L)=>{if(L==="void")return X8();if(L==="json")return G(K);if(L==="bytes")return S1(K);let W=R1(L);if(W){if(!Array.isArray(K))I("hands_repl_expected_target_list");if(W==="context"&&K.some((U)=>U!==$.context))I("hands_repl_foreign_context");return K.map((U)=>Y(W,U))}if(K===null||K===void 0)return X8();if(!o8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&K!==$.context)I("hands_repl_foreign_context");return Y(L,K)},B=(K)=>{if(z0(K)&&K.$handsRepl==="handle")return F(K).target;if(GQ(K))return G9.from(K.base64,"base64");if(E1(K))return;if(zQ(K))I("hands_repl_route_fulfill_only");if(Array.isArray(K))return K.map(B);if(!z0(K))return K;let L=Object.create(null);for(let[W,U]of Object.entries(K))L[W]=B(U);return L};return Object.freeze({roots:z,dispatch:async(K)=>{if(!z0(K)||typeof K.type!=="string")I("hands_repl_invalid_request");if(K.type==="a11y"){let T=K.target===void 0?Q.get(z.page.id):F(K.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(K.type==="view"){if(z9(K.source),K.options!==void 0)z9(K.options);let T=GQ(K.source)?G9.from(K.source.base64,"base64"):K.source;if($.privateProfile&&!G9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,K.options))}if(K.type!=="call")I("hands_repl_invalid_request");if(typeof K.method!=="string"||K.method.length===0||K.method.length>128)I("hands_repl_invalid_method");if(FQ.has(K.method))I("hands_repl_forbidden_method");let L=F(K.target),W=K.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(z9(W),L.kind==="page"&&K.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(K.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(K.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(K.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=K.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 V([$.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"||!x1.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 m=Reflect.get(L.target,"all");if(typeof m!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(m,L.target,[]);if(!Array.isArray(E)||E.length>HQ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let m of S){let E=Reflect.get(m,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,m,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&P1(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 m=await Reflect.apply(S,L.target,[I1]);if(!z0(m)||typeof m.password!=="boolean"||typeof m.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&m.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&m.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=UQ[L.kind][K.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"&&K.method==="contexts")return[z.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(K.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(K.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,[]),m=Array.isArray(S)?S[0]:void 0,E=k0(m)?Reflect.get(m,"viewportSize"):void 0;if(typeof E!=="function")return X8();return V(await Reflect.apply(E,m,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,K.method);return V(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,K.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!zQ(T))I("hands_repl_invalid_route_handler");z9(T.options);let S=B(T.options),m=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),m],N=await Reflect.apply(j,L.target,E);return V(N,U.returns)}let O=W.map(B);if(K.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"||!G9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},m=O[T];O[T]=Array.isArray(m)?await Promise.all(m.map(S)):await S(m)}if(K.method==="goto")await $.beforeNavigation?.();let C=$.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"}[K.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;C?.(P,k0(S)?S:void 0)}return V(A,U.returns)}})}import{isIP as jQ}from"net";import{Resolver as w1}from"dns/promises";import{isIP as Y8}from"net";var b1=[["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 r8($){if(Y8($)!==4)return null;let Z=$.split(".");if(Z.length!==4)return null;let Q=0;for(let X of Z){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Q=Q*256+J}return Q>>>0}function k1($,Z,Q){let X=r8(Z);if(X===null)return!1;let J=Q===0?0:4294967295<<32-Q>>>0;return($&J)>>>0===(X&J)>>>0}function BQ($){let Z=r8($);if(Z===null)return!0;return b1.some(([Q,X])=>k1(Z,Q,X))}function f1($){if(Y8($)!==6)return null;let Z=$.toLowerCase(),Q=Z.indexOf("%");if(Q>=0)Z=Z.slice(0,Q);let X=[],J=Z.lastIndexOf(":"),Y=J>=0?Z.slice(J+1):"";if(Y.includes(".")){let K=r8(Y);if(K===null)return null;X=[K>>>16&65535,K&65535],Z=Z.slice(0,J+1)+"0:0"}let z=Z.split("::");if(z.length>2)return null;let F=(K)=>{if(K==="")return[];let L=[];for(let W of K.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=F(z[0]??"");if(G===null)return null;if(z.length===1){let K=G;if(K.length!==8)return null;return X.length>0?K.slice(0,6).concat(X):K}let V=F(z[1]??"");if(V===null)return null;let B=8-G.length-V.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),V);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function m1($,Z){return`${$>>8&255}.${$&255}.${Z>>8&255}.${Z&255}`}function y1($){let Z=f1($);if(Z===null)return!0;let[Q,X,J]=Z;if((Q&57344)!==8192)return!0;if(Q===8193&&(X&65024)===0)return!0;if(Q===8193&&X===3512)return!0;if(Q===16383&&(X&61440)===0)return!0;if(Q===8194)return BQ(m1(X,J));return!1}function LQ($){return $.replace(/^\[|\]$/g,"")}function J8($){let Z=LQ($.trim()),Q=Y8(Z);if(Q===4)return BQ(Z);if(Q===6)return y1(Z);return!0}function NQ($){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 MQ=5000;function g1($){return async(Z,Q)=>{if(Q?.aborted)throw Error("aborted");let X=new w1({timeout:MQ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Q?.addEventListener("abort",J,{once:!0});try{let[Y,z]=await Promise.allSettled([X.resolve4(Z),X.resolve6(Z)]),F=[...Y.status==="fulfilled"?Y.value:[],...z.status==="fulfilled"?z.value:[]];if(F.length>0)return F;let G=[Y,z].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(NQ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Q?.removeEventListener("abort",J)}}}var h1=g1();async function v1($,Z,Q,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,z,F=Z($,J.signal);F.catch(()=>{});try{return await Promise.race([F,new Promise((G,V)=>{if(Y=setTimeout(()=>V(new DOMException("DNS lookup timed out","TimeoutError")),Q),X)z=()=>V(Error("aborted")),X.addEventListener("abort",z,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&z)X.removeEventListener("abort",z);J.abort()}}async function b5($,Z=h1,Q){let X=LQ($);if(Y8(X))return J8(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await v1(X,Z,MQ,Q)}catch(Y){return{ok:!1,reason:Q?.aborted?Q.reason instanceof Error&&Q.reason.name==="TimeoutError"?"dns_timeout":"aborted":NQ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(J8))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var c1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function t8($){return $.length<=253&&c1.test($.toLowerCase())}function d1($,Z){let Q=$.trim().toLowerCase();if(!t8(Q))return!1;if(Q.startsWith("*.")){let X=Q.slice(2);return Z===X||Z.endsWith(`.${X}`)}return Q===Z}function p1($){let Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Z)return null;let Q=Z.slice(1).map(Number);return Q.some((X)=>X>255)?null:Q}function e8($,Z=[]){let Q=(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),z=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${z>>8}.${z&255}`};return Z.some((X)=>Q(X)===Q($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Z=p1($);if(Z){let[Y,z,F]=Z;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&z>=64&&z<=127||Y===169&&z===254||Y===172&&z>=16&&z<=31||Y===192&&(z===168||z===0&&(F===0||F===2)||z===88&&F===99)||Y===198&&(z===18||z===19||z===51&&F===100)||Y===203&&z===0&&F===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Q=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Q){let Y=parseInt(Q[1],16),z=parseInt(Q[2],16);return l0(`${Y>>8}.${Y&255}.${z>>8}.${z&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 S9($,Z){let Q;try{Q=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Q.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Q.protocol))return{allowed:!1,url:$,host:Q.hostname||null,reason:"unsupported_protocol"};let X=Q.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Z.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(F)=>({allowed:!1,url:$,host:X,reason:F});if(Q.username||Q.password)return J("invalid_url");if(Z.mode==="public_web"){let F=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!jQ(X)||Boolean(jQ(X)&&J8(X));return{allowed:!F,url:$,host:X,reason:F?"private_network":"public_web"}}let Y=Number(Q.port||(["https:","wss:"].includes(Q.protocol)?443:80));if(Z.deniedPorts?.includes(Y)||e8(X,Z.deniedHosts))return J("destination_not_allowed");let z=l0(X);if(z==="private"||["local","internal","arpa"].some((F)=>X===F||X.endsWith(`.${F}`)))return J("private_network");if(z==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Z.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Z.allowedDomains.some((F)=>d1(F,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import CQ from"child_process";import{accessSync as l1,constants as s1,readFileSync as n1,statSync as OQ}from"fs";import{createRequire as DQ}from"module";import{homedir as $$}from"os";import{dirname as i1,isAbsolute as Z$,join as s0,resolve as a1,win32 as o1}from"path";var G8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:TQ.dependencies["playwright-core"],browser:"chromium"}),_Q=["/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"],Q$=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function r1($=process.env){let Z=[$.ProgramFiles??"C:\\Program Files",$["ProgramFiles(x86)"]??"C:\\Program Files (x86)"],Q=$.LOCALAPPDATA?[$.LOCALAPPDATA]:[],X=(J,...Y)=>J.map((z)=>o1.join(z,...Y));return[...X([...Z,...Q],"Google","Chrome","Application","chrome.exe"),...X(Z,"Microsoft","Edge","Application","msedge.exe"),...X([...Z,...Q],"BraveSoftware","Brave-Browser","Application","brave.exe")]}function w9($){try{return l1($,s1.X_OK),Z$($)&&OQ($).isFile()}catch{return!1}}function X$($,Z=process.platform){let Q=Z==="darwin"?_Q:Z==="linux"?Q$:Z==="win32"?r1():null;return Q?($??Q).find(w9)??null:null}function t1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Z=[];CQ.spawn=new Proxy(CQ.spawn,{apply(Q,X,J){let Y=Reflect.apply(Q,X,J),z=J[1],F=J[2]?.stdio;if(Array.isArray(z)&&z.includes("--remote-debugging-pipe")&&Array.isArray(F)&&F[3]==="pipe"&&F[4]==="pipe")Z.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Z})}async function z8($){if(t1(),$!==void 0){if(!Z$($))throw Error("hands_browser_driver_path_must_be_absolute");let X=s0($,"package.json"),J=JSON.parse(n1(X,"utf8"));if(J.name!==G8.driver)throw Error("hands_browser_wrong_driver");let Y=DQ(X)($),z=Y.default?.chromium??Y.chromium;if(!z)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:z}}let[Z,Q]=await Promise.all([import("./index-7f2kwwen.js"),import("./package-smk3nqjs.js").then((m)=>u1(m.default,1))]);return{version:Q.default.version,chromium:Z.chromium}}var e1=($,Z=G8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Z}),$7=($)=>$.loadDriver?.()??z8($.driverModuleDirectory),Z7={"1.60.0":"1223"};function u5(){let $=process.platform,Z=Z7[G8.driverVersion];if(!Z||$!=="linux"&&$!=="darwin"&&$!=="win32")return!1;let Q=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Q("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?s0(i1(DQ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?a1(Q("INIT_CWD")||process.cwd(),X):s0($==="darwin"?s0($$(),"Library","Caches"):$==="win32"?process.env.LOCALAPPDATA||s0($$(),"AppData","Local"):process.env.XDG_CACHE_HOME||s0($$(),".cache"),"ms-playwright");return OQ(s0(J,`chromium-${Z}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function K9($={}){return AQ($,G8.driverVersion)}async function J$($,Z={}){if($.driverVersion!=="1.61.1"||!Z$($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return AQ({...Z,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function AQ($,Z){let Q=(G)=>e1(G,Z),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin"&&X!=="win32")return Q("unsupported_platform");let J;try{J=await $7($)}catch{return Q("driver_missing")}if(J.version!==Z)return Q("driver_version_mismatch");let Y=(G,V)=>({status:"resolved",executablePath:G,source:V,driverVersion:J.version});if($.executablePath!==void 0)return w9($.executablePath)?Y($.executablePath,"configured"):Q("executable_missing");let z=J.chromium.executablePath();if(w9(z))return Y(z,"managed");let F=$.allowSystemBrowser===!0?X$($.systemCandidates,X):null;return F?Y(F,"system"):Q("executable_missing")}var B7=["/usr/local/bin/chromium",...Q$];function L7($,Z=wQ()){return X$($??(Z==="linux"?B7:void 0),Z)}async function N7(){try{return(await z8()).chromium}catch{return F7(import.meta.url)("playwright-core").chromium}}var M7=1048576,j7=105000,q7=20000,IQ=5000,C7=2000,T7=1000,O7=30000,RQ=81920,D7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function _7($,Z){let Q=new URL($.url()),X={...await $.allHeaders(),host:Q.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 F=(Q.protocol==="https:"?H7:V7)(Q,{method:$.method(),headers:X,agent:!1,lookup:(V,B,H)=>{let K=n0.isIP(Z);if(B.all)H(null,[{address:Z,family:K}]);else H(null,Z,K)}},(V)=>{let B=[],H=0;V.on("data",(K)=>{if(H+=K.length,H>33554432)F.destroy(Error("hands_browser_response_too_large"));else B.push(K)}),V.on("error",Y),V.on("end",()=>{let K={};for(let[L,W]of Object.entries(V.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))K[L]=Array.isArray(W)?W.join(`
305
+ `.trim();import{Buffer as G9}from"buffer";import{randomUUID as _1}from"crypto";class KQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var FQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),YQ=/^hands_[A-Za-z0-9_-]{8,128}$/,A1=2048,VQ=32,HQ=1e4,x1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function P1($){let Z=$.split("+"),Q=(Z.pop()??"").replace(/^Key/,"").toLowerCase();if(Q==="f12")return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Q))return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Z.includes("Shift")&&Q==="c")return!0;return Z.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Q)}var I1=($)=>{let Z=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Z&&!/^(https?:|about:blank)/i.test(Z.href))}},UQ={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 KQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Z=Object.getPrototypeOf($);return Z===Object.prototype||Z===null}function z9($,Z=0,Q={nodes:0}){if(Z>VQ||++Q.nodes>HQ)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 $)z9(X,Z+1,Q);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(FQ.has(X))I("hands_repl_invalid_json");z9(J,Z+1,Q)}}function o8($){return typeof $==="string"&&Object.hasOwn(UQ,$)}function R1($){if(!$.endsWith("[]"))return null;let Z=$.slice(0,-2);return o8(Z)?Z:null}function GQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function E1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function zQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function X8(){return Object.freeze({$handsRepl:"undefined"})}function S1($){if(!G9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:G9.from($).toString("base64")})}function WQ($){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 Z=$.maxHandles??A1;if(!Number.isInteger(Z)||Z<3||Z>1e5)I("hands_repl_invalid_handle_limit");let Q=new Map,X=new WeakMap,J=$.createOpaqueId??_1,Y=(K,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(K);if(W)return W;if(Q.size>=Z)I("hands_repl_handle_limit");let U="";for(let C=0;C<16;C+=1){let A=`hands_${J()}`;if(YQ.test(A)&&!Q.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:K});Q.set(U,{kind:K,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(K,j),j},z=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),F=(K)=>{if(!z0(K)||Object.keys(K).length!==3||K.$handsRepl!=="handle"||typeof K.id!=="string"||!YQ.test(K.id)||!o8(K.kind))I("hands_repl_invalid_handle");let L=Q.get(K.id);if(!L||L.kind!==K.kind)I("hands_repl_unknown_handle");return L},G=(K,L=0,W=new Set)=>{if(L>VQ)I("hands_repl_json_too_complex");if(K===void 0)return X8();if(K===null||typeof K==="boolean"||typeof K==="string")return K;if(typeof K==="number"){if(!Number.isFinite(K))I("hands_repl_non_json_result");return K}if(Array.isArray(K)){if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{return K.map((U)=>G(U,L+1,W))}finally{W.delete(K)}}if(!z0(K))I("hands_repl_non_json_result");if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{let U=Object.create(null);for(let j of Object.keys(K)){let O=Object.getOwnPropertyDescriptor(K,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(K)}},V=(K,L)=>{if(L==="void")return X8();if(L==="json")return G(K);if(L==="bytes")return S1(K);let W=R1(L);if(W){if(!Array.isArray(K))I("hands_repl_expected_target_list");if(W==="context"&&K.some((U)=>U!==$.context))I("hands_repl_foreign_context");return K.map((U)=>Y(W,U))}if(K===null||K===void 0)return X8();if(!o8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&K!==$.context)I("hands_repl_foreign_context");return Y(L,K)},B=(K)=>{if(z0(K)&&K.$handsRepl==="handle")return F(K).target;if(GQ(K))return G9.from(K.base64,"base64");if(E1(K))return;if(zQ(K))I("hands_repl_route_fulfill_only");if(Array.isArray(K))return K.map(B);if(!z0(K))return K;let L=Object.create(null);for(let[W,U]of Object.entries(K))L[W]=B(U);return L};return Object.freeze({roots:z,dispatch:async(K)=>{if(!z0(K)||typeof K.type!=="string")I("hands_repl_invalid_request");if(K.type==="a11y"){let T=K.target===void 0?Q.get(z.page.id):F(K.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(K.type==="view"){if(z9(K.source),K.options!==void 0)z9(K.options);let T=GQ(K.source)?G9.from(K.source.base64,"base64"):K.source;if($.privateProfile&&!G9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,K.options))}if(K.type!=="call")I("hands_repl_invalid_request");if(typeof K.method!=="string"||K.method.length===0||K.method.length>128)I("hands_repl_invalid_method");if(FQ.has(K.method))I("hands_repl_forbidden_method");let L=F(K.target),W=K.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(z9(W),L.kind==="page"&&K.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(K.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(K.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(K.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=K.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 V([$.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"||!x1.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 m=Reflect.get(L.target,"all");if(typeof m!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(m,L.target,[]);if(!Array.isArray(E)||E.length>HQ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let m of S){let E=Reflect.get(m,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,m,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&P1(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 m=await Reflect.apply(S,L.target,[I1]);if(!z0(m)||typeof m.password!=="boolean"||typeof m.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&m.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&m.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=UQ[L.kind][K.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"&&K.method==="contexts")return[z.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(K.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(K.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,[]),m=Array.isArray(S)?S[0]:void 0,E=k0(m)?Reflect.get(m,"viewportSize"):void 0;if(typeof E!=="function")return X8();return V(await Reflect.apply(E,m,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,K.method);return V(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,K.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!zQ(T))I("hands_repl_invalid_route_handler");z9(T.options);let S=B(T.options),m=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),m],N=await Reflect.apply(j,L.target,E);return V(N,U.returns)}let O=W.map(B);if(K.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"||!G9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},m=O[T];O[T]=Array.isArray(m)?await Promise.all(m.map(S)):await S(m)}if(K.method==="goto")await $.beforeNavigation?.();let C=$.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"}[K.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;C?.(P,k0(S)?S:void 0)}return V(A,U.returns)}})}import{isIP as jQ}from"net";import{Resolver as w1}from"dns/promises";import{isIP as Y8}from"net";var b1=[["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 r8($){if(Y8($)!==4)return null;let Z=$.split(".");if(Z.length!==4)return null;let Q=0;for(let X of Z){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Q=Q*256+J}return Q>>>0}function k1($,Z,Q){let X=r8(Z);if(X===null)return!1;let J=Q===0?0:4294967295<<32-Q>>>0;return($&J)>>>0===(X&J)>>>0}function BQ($){let Z=r8($);if(Z===null)return!0;return b1.some(([Q,X])=>k1(Z,Q,X))}function f1($){if(Y8($)!==6)return null;let Z=$.toLowerCase(),Q=Z.indexOf("%");if(Q>=0)Z=Z.slice(0,Q);let X=[],J=Z.lastIndexOf(":"),Y=J>=0?Z.slice(J+1):"";if(Y.includes(".")){let K=r8(Y);if(K===null)return null;X=[K>>>16&65535,K&65535],Z=Z.slice(0,J+1)+"0:0"}let z=Z.split("::");if(z.length>2)return null;let F=(K)=>{if(K==="")return[];let L=[];for(let W of K.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=F(z[0]??"");if(G===null)return null;if(z.length===1){let K=G;if(K.length!==8)return null;return X.length>0?K.slice(0,6).concat(X):K}let V=F(z[1]??"");if(V===null)return null;let B=8-G.length-V.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),V);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function m1($,Z){return`${$>>8&255}.${$&255}.${Z>>8&255}.${Z&255}`}function y1($){let Z=f1($);if(Z===null)return!0;let[Q,X,J]=Z;if((Q&57344)!==8192)return!0;if(Q===8193&&(X&65024)===0)return!0;if(Q===8193&&X===3512)return!0;if(Q===16383&&(X&61440)===0)return!0;if(Q===8194)return BQ(m1(X,J));return!1}function LQ($){return $.replace(/^\[|\]$/g,"")}function J8($){let Z=LQ($.trim()),Q=Y8(Z);if(Q===4)return BQ(Z);if(Q===6)return y1(Z);return!0}function NQ($){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 MQ=5000;function g1($){return async(Z,Q)=>{if(Q?.aborted)throw Error("aborted");let X=new w1({timeout:MQ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Q?.addEventListener("abort",J,{once:!0});try{let[Y,z]=await Promise.allSettled([X.resolve4(Z),X.resolve6(Z)]),F=[...Y.status==="fulfilled"?Y.value:[],...z.status==="fulfilled"?z.value:[]];if(F.length>0)return F;let G=[Y,z].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(NQ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Q?.removeEventListener("abort",J)}}}var h1=g1();async function v1($,Z,Q,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,z,F=Z($,J.signal);F.catch(()=>{});try{return await Promise.race([F,new Promise((G,V)=>{if(Y=setTimeout(()=>V(new DOMException("DNS lookup timed out","TimeoutError")),Q),X)z=()=>V(Error("aborted")),X.addEventListener("abort",z,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&z)X.removeEventListener("abort",z);J.abort()}}async function b5($,Z=h1,Q){let X=LQ($);if(Y8(X))return J8(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await v1(X,Z,MQ,Q)}catch(Y){return{ok:!1,reason:Q?.aborted?Q.reason instanceof Error&&Q.reason.name==="TimeoutError"?"dns_timeout":"aborted":NQ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(J8))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var c1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function t8($){return $.length<=253&&c1.test($.toLowerCase())}function d1($,Z){let Q=$.trim().toLowerCase();if(!t8(Q))return!1;if(Q.startsWith("*.")){let X=Q.slice(2);return Z===X||Z.endsWith(`.${X}`)}return Q===Z}function p1($){let Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Z)return null;let Q=Z.slice(1).map(Number);return Q.some((X)=>X>255)?null:Q}function e8($,Z=[]){let Q=(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),z=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${z>>8}.${z&255}`};return Z.some((X)=>Q(X)===Q($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Z=p1($);if(Z){let[Y,z,F]=Z;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&z>=64&&z<=127||Y===169&&z===254||Y===172&&z>=16&&z<=31||Y===192&&(z===168||z===0&&(F===0||F===2)||z===88&&F===99)||Y===198&&(z===18||z===19||z===51&&F===100)||Y===203&&z===0&&F===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Q=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Q){let Y=parseInt(Q[1],16),z=parseInt(Q[2],16);return l0(`${Y>>8}.${Y&255}.${z>>8}.${z&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 S9($,Z){let Q;try{Q=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Q.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Q.protocol))return{allowed:!1,url:$,host:Q.hostname||null,reason:"unsupported_protocol"};let X=Q.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Z.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(F)=>({allowed:!1,url:$,host:X,reason:F});if(Q.username||Q.password)return J("invalid_url");if(Z.mode==="public_web"){let F=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!jQ(X)||Boolean(jQ(X)&&J8(X));return{allowed:!F,url:$,host:X,reason:F?"private_network":"public_web"}}let Y=Number(Q.port||(["https:","wss:"].includes(Q.protocol)?443:80));if(Z.deniedPorts?.includes(Y)||e8(X,Z.deniedHosts))return J("destination_not_allowed");let z=l0(X);if(z==="private"||["local","internal","arpa"].some((F)=>X===F||X.endsWith(`.${F}`)))return J("private_network");if(z==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Z.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Z.allowedDomains.some((F)=>d1(F,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import CQ from"child_process";import{accessSync as l1,constants as s1,readFileSync as n1,statSync as OQ}from"fs";import{createRequire as DQ}from"module";import{homedir as $$}from"os";import{dirname as i1,isAbsolute as Z$,join as s0,resolve as a1,win32 as o1}from"path";var G8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:TQ.dependencies["playwright-core"],browser:"chromium"}),_Q=["/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"],Q$=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function r1($=process.env){let Z=[$.ProgramFiles??"C:\\Program Files",$["ProgramFiles(x86)"]??"C:\\Program Files (x86)"],Q=$.LOCALAPPDATA?[$.LOCALAPPDATA]:[],X=(J,...Y)=>J.map((z)=>o1.join(z,...Y));return[...X([...Z,...Q],"Google","Chrome","Application","chrome.exe"),...X(Z,"Microsoft","Edge","Application","msedge.exe"),...X([...Z,...Q],"BraveSoftware","Brave-Browser","Application","brave.exe")]}function w9($){try{return l1($,s1.X_OK),Z$($)&&OQ($).isFile()}catch{return!1}}function X$($,Z=process.platform){let Q=Z==="darwin"?_Q:Z==="linux"?Q$:Z==="win32"?r1():null;return Q?($??Q).find(w9)??null:null}function t1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Z=[];CQ.spawn=new Proxy(CQ.spawn,{apply(Q,X,J){let Y=Reflect.apply(Q,X,J),z=J[1],F=J[2]?.stdio;if(Array.isArray(z)&&z.includes("--remote-debugging-pipe")&&Array.isArray(F)&&F[3]==="pipe"&&F[4]==="pipe")Z.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Z})}async function z8($){if(t1(),$!==void 0){if(!Z$($))throw Error("hands_browser_driver_path_must_be_absolute");let X=s0($,"package.json"),J=JSON.parse(n1(X,"utf8"));if(J.name!==G8.driver)throw Error("hands_browser_wrong_driver");let Y=DQ(X)($),z=Y.default?.chromium??Y.chromium;if(!z)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:z}}let[Z,Q]=await Promise.all([import("./index-m32pjcjr.js"),import("./package-04cf0m62.js").then((m)=>u1(m.default,1))]);return{version:Q.default.version,chromium:Z.chromium}}var e1=($,Z=G8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Z}),$7=($)=>$.loadDriver?.()??z8($.driverModuleDirectory),Z7={"1.60.0":"1223"};function u5(){let $=process.platform,Z=Z7[G8.driverVersion];if(!Z||$!=="linux"&&$!=="darwin"&&$!=="win32")return!1;let Q=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Q("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?s0(i1(DQ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?a1(Q("INIT_CWD")||process.cwd(),X):s0($==="darwin"?s0($$(),"Library","Caches"):$==="win32"?process.env.LOCALAPPDATA||s0($$(),"AppData","Local"):process.env.XDG_CACHE_HOME||s0($$(),".cache"),"ms-playwright");return OQ(s0(J,`chromium-${Z}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function K9($={}){return AQ($,G8.driverVersion)}async function J$($,Z={}){if($.driverVersion!=="1.61.1"||!Z$($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return AQ({...Z,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function AQ($,Z){let Q=(G)=>e1(G,Z),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin"&&X!=="win32")return Q("unsupported_platform");let J;try{J=await $7($)}catch{return Q("driver_missing")}if(J.version!==Z)return Q("driver_version_mismatch");let Y=(G,V)=>({status:"resolved",executablePath:G,source:V,driverVersion:J.version});if($.executablePath!==void 0)return w9($.executablePath)?Y($.executablePath,"configured"):Q("executable_missing");let z=J.chromium.executablePath();if(w9(z))return Y(z,"managed");let F=$.allowSystemBrowser===!0?X$($.systemCandidates,X):null;return F?Y(F,"system"):Q("executable_missing")}var B7=["/usr/local/bin/chromium",...Q$];function L7($,Z=wQ()){return X$($??(Z==="linux"?B7:void 0),Z)}async function N7(){try{return(await z8()).chromium}catch{return F7(import.meta.url)("playwright-core").chromium}}var M7=1048576,j7=105000,q7=20000,IQ=5000,C7=2000,T7=1000,O7=30000,RQ=81920,D7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function _7($,Z){let Q=new URL($.url()),X={...await $.allHeaders(),host:Q.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 F=(Q.protocol==="https:"?H7:V7)(Q,{method:$.method(),headers:X,agent:!1,lookup:(V,B,H)=>{let K=n0.isIP(Z);if(B.all)H(null,[{address:Z,family:K}]);else H(null,Z,K)}},(V)=>{let B=[],H=0;V.on("data",(K)=>{if(H+=K.length,H>33554432)F.destroy(Error("hands_browser_response_too_large"));else B.push(K)}),V.on("error",Y),V.on("end",()=>{let K={};for(let[L,W]of Object.entries(V.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))K[L]=Array.isArray(W)?W.join(`
306
306
  `):W;J({status:V.statusCode??502,headers:K,body:Buffer.concat(B)})})}),G=setTimeout(()=>F.destroy(Error("hands_browser_fetch_timeout")),O7);F.once("close",()=>clearTimeout(G)),F.on("error",Y),F.end($.postDataBuffer()??void 0)})}async function A7($,Z,Q=()=>{},X={lookup:(J)=>K7(J,{all:!0}),fetch:_7}){let J=new WeakSet,Y=new WeakMap,z=(F)=>{let G=Y.get(F);if(G)return G;let V=(async()=>{if(!$.newCDPSession)return;let B=await $.newCDPSession(F),H=new Map;B.on("Network.loadingFinished",({requestId:K})=>H.delete(K)),B.on("Network.loadingFailed",({requestId:K})=>H.delete(K)),B.on("Fetch.requestPaused",async(K)=>{let L=K.networkId??K.requestId,W=K.redirectedRequestId?(H.get(L)??0)+1:0;H.set(L,W);let U=S9(K.request.url,Z),j=Z.mode==="enforce"&&Boolean(K.redirectedRequestId)&&U.host!==null&&!n0.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)Q(O),await B.send("Fetch.failRequest",{requestId:K.requestId,errorReason:"BlockedByClient"});else await B.send("Fetch.continueRequest",{requestId:K.requestId})}catch{await B.send("Fetch.failRequest",{requestId:K.requestId,errorReason:"Failed"}).catch(()=>{})}}),await B.send("Network.enable"),await B.send("Fetch.enable",{patterns:[{urlPattern:"*",requestStage:"Request"}]}),J.add(F)})();return Y.set(F,V),V};return await $.route("**/*",async(F)=>{let G=F.request().url(),V=S9(G,Z);if(V.allowed&&Z.mode==="public_web"){await F.continue();return}let B=F.request();if(V.allowed&&V.host&&n0.isIP(V.host)&&B.isNavigationRequest?.()){let H=B.frame();if(J.has(H.page())&&H===H.page().mainFrame()){await F.continue();return}}if(V.allowed&&(Z.mode==="off"||V.reason==="local_document")){await F.continue();return}if(V.allowed&&V.host)try{let H=V.host,K=l0(H),L,W=await(async()=>{if(K!=="hostname")return[{address:H,family:n0.isIP(H)}];if(V.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!n0.isIP(U)||Z.mode==="enforce"&&e8(U,Z.deniedHosts)||(V.reason==="loopback"?j!=="loopback":j!=="public")}))V={...V,allowed:!1,reason:"private_network"};else{let U=await X.fetch(F.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=S9(j,Z);V=O.allowed?{...O,allowed:!1,reason:"redirect_not_supported"}:O}else{await F.fulfill(U);return}}}catch{await F.abort("failed");return}Q(V),await F.abort("blockedbyclient")}),await $.routeWebSocket("**/*",async(F)=>{let G=S9(F.url(),Z);if(Z.mode==="enforce"&&G.allowed&&(!G.host||!n0.isIP(G.host)))G={...G,allowed:!1,reason:"destination_not_allowed"};if(G.allowed){F.connectToServer();return}Q(G),await F.close({code:1008,reason:"Reason egress policy denied"})}),Z.mode==="off"?void 0:{preparePage:z}}async function bQ($,Z=wQ(),Q){if(Q){let J=await J$(Q,{platform:Z,systemCandidates:$});return J.status==="resolved"?J.executablePath:null}if($!==void 0){let J=L7($,Z);if(J)return J}let X=await K9({platform:Z,systemCandidates:$,allowSystemBrowser:!0});return X.status==="resolved"?X.executablePath:null}function EQ($,Z){if(!$)throw Error("hands_repl_workspace_required");let Q=G$($),X=F9($),J=z$(X,F9(X,Z)),z=J!==".."&&!J.startsWith(`..${K$}`)&&!PQ(J)?F9(Q,J):F9(Q,Z);if(b0(F9(X,Z))||b0(z))throw Error("hands_repl_protected_path");let F=(W)=>{let U=z$(Q,W);return U!==""&&U!==".."&&!U.startsWith(`..${K$}`)&&!PQ(U)},G=G$(z);if(b0(G))throw Error("hands_repl_protected_path");if(!F(z)||!F(G))throw Error("hands_repl_file_outside_workspace");let V=z$(Q,z).split(K$),B=[Q,...V.map((W,U)=>F9(Q,...V.slice(0,U+1)))],H=B.map((W)=>xQ(W));if(H.some((W)=>W.isSymbolicLink()))throw Error("hands_repl_file_symlink");let K=H[H.length-1];if(!K.isFile()||K.nlink!==1||K.size>16777216)throw Error("hands_repl_file_not_regular_or_too_large");let L=Y7(z,Y$.O_RDONLY|Y$.O_NOFOLLOW|Y$.O_NONBLOCK);try{let W=J7(L);if(W.dev!==K.dev||W.ino!==K.ino||!W.isFile())throw Error("hands_repl_file_changed");for(let C=0;C<B.length;C++){let A=xQ(B[C]);if(A.dev!==H[C].dev||A.ino!==H[C].ino||A.isSymbolicLink())throw Error("hands_repl_file_changed")}if(!F(G$(z)))throw Error("hands_repl_file_outside_workspace");let U=Buffer.alloc(16777217),j=0;while(j<U.length){let C=G7(L,U,j,U.length-j,null);if(!C)break;j+=C}if(j===U.length)throw Error("hands_repl_file_too_large");let O=U.subarray(0,j);return{name:U7(z),mimeType:D7[W7(z).toLowerCase()]??"application/octet-stream",buffer:O}}finally{X7(L)}}function V9($,Z){$.end(`${JSON.stringify(Z)}
307
307
  `)}function K8($){try{z7($)}catch{}}async function kQ($){if($.managedBrowser&&$.driverModuleDirectory!==void 0)throw Error("hands_browser_ambiguous_driver_configuration");let Z=$.launch||$.targetContext?null:$.managedBrowser?await J$($.managedBrowser,{executablePath:$.browserExecutablePath}):await K9({executablePath:$.browserExecutablePath,driverModuleDirectory:$.driverModuleDirectory});if(Z?.status==="unavailable")throw Error(`hands_browser_${Z.reason}`);let Q=Z?.status==="resolved"?Z.executablePath:$.browserExecutablePath;if(!Q||!w9(Q))throw Error("hands_browser_unavailable");let X=$.launch??(async(N)=>($.targetContext?await N7():(await z8($.managedBrowser?.driverModuleDirectory??$.driverModuleDirectory)).chromium).launch(N)),J=[],Y={},z=null,F=null,G=null,V=null,B=!1,H=null,K=new Map,L=new WeakMap,W=null,U=()=>{if(B)throw Error("hands_repl_stopped");if(V)throw V},j=(N)=>{let M=L.get(N);if(M)return M;let D=Promise.resolve().then(()=>N.close()).then(()=>{K.delete(N)});return L.set(N,D),D},O=async()=>{let N=[...K.entries()].reverse(),M=W??=performance.now()+T7,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[_,y]of k.entries()){if(y.status!=="rejected")continue;let c=y.reason instanceof Error&&["Error","TimeoutError","ProtocolError"].includes(y.reason.name)?y.reason.name:"unknown";f.push(Error(`hands_repl_close_failed: ${N[_][1]}: ${c}`))}if(f.length)throw AggregateError(f,"hands_repl_stop_unconfirmed")},C=(N,M)=>{if(K.set(N,M),B||V)j(N).catch(()=>{return}),U();return N},A=async()=>{let N=await X({executablePath:Q,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{C(N,"browser"),M=$.targetContext??C(await N.newContext({viewport:{width:1440,height:900},screen:{width:1440,height:900},serviceWorkers:"block",acceptDownloads:!1}),"context");let D=await A7(M,$.networkPolicy??{mode:"off"},$.onEgressDenied);if(U(),D){let b=M.newPage.bind(M);M.newPage=async()=>{let h=await b();return await D.preparePage(h),h}}let k=M.pages()[0]??await M.newPage();await D?.preparePage(k),U();let f=async(b=k)=>{let h=b;if(typeof h.ariaSnapshot==="function")return h.ariaSnapshot({timeout:1e4});return k.locator("body").innerText({timeout:1e4})},_=async(b,h={})=>{let d=h&&typeof h==="object"&&!Array.isArray(h)?h:{},n,G0="image/png";if(Buffer.isBuffer(b)||b instanceof Uint8Array)n=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)))n=Buffer.from(b.replace(/^data:[^,]*,/,""),"base64");else if(typeof b==="string"){let T0=EQ($.workspaceRoot,b);n=T0.buffer,G0=T0.mimeType}else throw Error("view() needs a Buffer, a base64 string, or a path to an image file");if(n.length===0)throw Error("view(): the image is empty");let M0=String(d.label??"").replace(/[\r\n>]+/g," ").trim().slice(0,120),U0=Number(d.maxWidth)||1024,W0=Number(d.quality)||72,g0=$.targetContext?await N.newPage():await M.newPage();try{let T0=`data:${G0};base64,${n.toString("base64")}`;for(let t=0;t<5;t+=1){let j0=await g0.evaluate(async(B0)=>{let q0=new Image;q0.src=B0.url,await q0.decode();let h0=Math.min(1,B0.maxWidth/q0.naturalWidth),Y0=document.createElement("canvas");Y0.width=Math.max(1,Math.round(q0.naturalWidth*h0)),Y0.height=Math.max(1,Math.round(q0.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(q0,0,0,Y0.width,Y0.height),{data:Y0.toDataURL("image/jpeg",B0.q/100).split(",")[1]??"",width:Y0.width,height:Y0.height,sourceWidth:q0.naturalWidth,sourceHeight:q0.naturalHeight}},{url:T0,maxWidth:U0,q:W0}),e0=Buffer.from(j0.data,"base64");if(e0.length<=RQ){let B0=M0||"image";return`<<<ARA_VIEW_IMAGE ${j0.data} image/jpeg ${B0}>>>
308
308
  Viewing ${B0} (${j0.sourceWidth}x${j0.sourceHeight} source, sent at ${j0.width}x${j0.height}, ${Math.round(e0.length/1024)}KB).`}if(U0>640)U0=Math.round(U0*0.75);else W0=Math.max(30,W0-15)}throw Error(`view(): could not reduce the image under ${Math.round(RQ/1024)}KB`)}finally{await g0.close().catch(()=>{return})}},y=WQ({browser:$.targetContext?.browser()??N,context:M,page:k,a11y:f,view:_,readWorkspaceFile:(b)=>EQ($.workspaceRoot,b),privateProfile:$.privateProfile,beforeNavigation:$.beforeNavigation,recording:$.recording,screenshotExport:$.screenshotExport,actionRecorder:()=>{let b=J,h=Y;return(d,n)=>{if(b.length<SQ)b.push(d);if(n)h.page=n}}}),c=async(b)=>{U();let h=C(await N.newContext({serviceWorkers:"block",acceptDownloads:!1}),"context");try{await h.route("**/*",(n)=>n.abort()),U(),await h.routeWebSocket("**/*",(n)=>n.close({code:1008,reason:"Reason evaluator network denied"})),U(),await h.exposeBinding("__araHandsRpc",async(n,G0)=>$.onBrowserOperation?$.onBrowserOperation(b,()=>y.dispatch(G0)):y.dispatch(G0)),U();let d=await h.newPage();return U(),await d.goto("data:text/html,<title>Reason Hands evaluator</title>"),U(),await d.evaluate(`(${XQ})(${JSON.stringify(y.roots)})`),{context:h,page:d,runId:b}}catch(d){throw await j(h).catch(()=>{return}),d}},u=await c(),r={browser:N,context:M,page:k,evaluator:u,async captureProgressFrame(b){return _(await b.screenshot({type:"jpeg",quality:65,timeout:2000}),{label:"Screen after browser action"})},async resetEvaluator(b){await j(r.evaluator.context),r.evaluator=await c(b)}};return U(),r}catch(D){throw await O().catch(()=>{return}),D}},R=async()=>{if(U(),z)return z;if(!G){F=A();let N;G=Promise.race([F,new Promise((M,D)=>{N=setTimeout(()=>D(Error("hands_browser_unavailable: startup timed out")),q7)})]).then((M)=>{return U(),z=M,M}).catch(async()=>{V=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")),IQ)})])}catch{V=Error("hands_browser_unavailable: startup cleanup unconfirmed")}finally{if(M)clearTimeout(M)}throw V}).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 u=await w.evaluator.page.evaluate(`(${JQ})(${JSON.stringify({code:N})})`);if(typeof u!=="string")throw Error("hands_repl_invalid_evaluator_output");let r=k.page;if(D&&r&&!u.includes("<<<ARA_VIEW_IMAGE")){let b=()=>w.captureProgressFrame(r);try{let h=await($.onBrowserOperation?$.onBrowserOperation(M,b):b());return k.automaticProgressImage=!0,`${u}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ik as w}from"./vm-hands-entry-lite-zjfr0zh8.js";var S="inference.custom.v1",K=32768,P=67108864,Q=16384,T=204800,z=600000,U=["content-type","anthropic-version","user-agent"],L=w.enum(["openai-completions","openai-responses","anthropic-messages"]),V=new Set(U),W=w.record(w.string(),w.string().max(2048)).refine((j)=>Object.keys(j).every((A)=>V.has(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)),"Only non-secret custom endpoint request headers are permitted");function F(j){try{let A=new URL(j);return["http:","https:"].includes(A.protocol)&&!A.username&&!A.password&&!A.search&&!A.hash?A:null}catch{return null}}function X(j,A){let B=F(j.baseUrl),H=F(A.baseUrl),D=F(j.url);if(!B||!H||!D||j.method!=="POST"||A.execution!=="device")return!1;let I=(J)=>J.origin+J.pathname.replace(/\/+$/,"");if(I(B)!==I(H)||D.origin!==B.origin)return!1;let O=A.api==="openai-completions"?"/chat/completions":A.api==="openai-responses"?"/responses":"/v1/messages";return D.pathname===B.pathname.replace(/\/+$/,"")+O}var b=w.object({baseUrl:w.string().max(2048),url:w.string().max(4096),method:w.literal("POST"),body:w.string().refine((j)=>new TextEncoder().encode(j).byteLength<=T).optional(),headers:W,credentialOrganizationId:w.string().uuid(),accountKey:w.string().min(1).max(256).optional()}).strict().refine((j)=>L.options.some((A)=>X(j,{baseUrl:j.baseUrl,api:A,execution:"device"})),"Invalid custom endpoint inference URL"),k=w.object({status:w.number().int().min(200).max(599),statusText:w.string().max(256).refine((j)=>!/[\r\n\0]/.test(j)),headers:w.record(w.string(),w.string().max(4096)).refine((j)=>Object.keys(j).every((A)=>["content-type","retry-after","x-request-id","request-id"].includes(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)))}).strict(),y=w.union([w.object({eof:w.literal(!0)}).strict(),w.object({eof:w.literal(!1),data:w.string().max(Math.ceil(K/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((j)=>j.length>0&&j.length*3/4-(j.endsWith("==")?2:j.endsWith("=")?1:0)<=K)}).strict()]),M=w.object({bytes:w.number().int().min(0).max(P),chunks:w.number().int().min(0).max(Q)}).strict(),p=w.object({apiKey:w.string().min(1).max(16384).refine((j)=>!/[\r\n\0]/.test(j)),api:L}).strict(),Y=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function c(j){return typeof j==="string"&&Y.includes(j)}var Z="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",G={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${Z}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."},q="Local custom endpoints require a session on your connected computer. This custom endpoint's Execution location is Your computer, so Reason cloud never calls it. Connect your computer with the Reason desktop app or CLI and run this session there, or set the endpoint's Execution location to Reason cloud with a public https Base URL in Models, or choose another model.";function _(j){return typeof j==="string"&&j.startsWith("Local custom endpoints require a session on your connected computer.")}var $=new Set(Object.values(G));function h(j){return Object.hasOwn(G,j)?G[j]:null}function v(j){return typeof j==="string"&&($.has(j)||_(j))}var N="returned HTTP 403: its firewall blocked Reason cloud",x=/^Your model endpoint \S+ (?:returned HTTP 40[34]|returned HTTP 403: its firewall blocked Reason cloud|was unreachable: it refused the connection)\.$/,C=/Attention Required! \| Cloudflare|Sorry, you have been blocked|cf-error-details/i;function n(j,A,B){if(!/^[a-z0-9.-]+$/i.test(j))return null;if(A==="connection_refused")return`Your model endpoint ${j} was unreachable: it refused the connection.`;if(A===403&&B&&C.test(B))return`Your model endpoint ${j} ${N}.`;return A===403||A===404?`Your model endpoint ${j} returned HTTP ${A}.`:null}function E(j){return typeof j==="string"&&x.test(j)}function d(j){return E(j)&&j.includes(N)}
2
+ import{jk as w}from"./vm-hands-entry-lite-8pgggvbb.js";var S="inference.custom.v1",K=32768,P=67108864,Q=16384,T=204800,z=600000,U=["content-type","anthropic-version","user-agent"],L=w.enum(["openai-completions","openai-responses","anthropic-messages"]),V=new Set(U),W=w.record(w.string(),w.string().max(2048)).refine((j)=>Object.keys(j).every((A)=>V.has(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)),"Only non-secret custom endpoint request headers are permitted");function F(j){try{let A=new URL(j);return["http:","https:"].includes(A.protocol)&&!A.username&&!A.password&&!A.search&&!A.hash?A:null}catch{return null}}function X(j,A){let B=F(j.baseUrl),H=F(A.baseUrl),D=F(j.url);if(!B||!H||!D||j.method!=="POST"||A.execution!=="device")return!1;let I=(J)=>J.origin+J.pathname.replace(/\/+$/,"");if(I(B)!==I(H)||D.origin!==B.origin)return!1;let O=A.api==="openai-completions"?"/chat/completions":A.api==="openai-responses"?"/responses":"/v1/messages";return D.pathname===B.pathname.replace(/\/+$/,"")+O}var b=w.object({baseUrl:w.string().max(2048),url:w.string().max(4096),method:w.literal("POST"),body:w.string().refine((j)=>new TextEncoder().encode(j).byteLength<=T).optional(),headers:W,credentialOrganizationId:w.string().uuid(),accountKey:w.string().min(1).max(256).optional()}).strict().refine((j)=>L.options.some((A)=>X(j,{baseUrl:j.baseUrl,api:A,execution:"device"})),"Invalid custom endpoint inference URL"),k=w.object({status:w.number().int().min(200).max(599),statusText:w.string().max(256).refine((j)=>!/[\r\n\0]/.test(j)),headers:w.record(w.string(),w.string().max(4096)).refine((j)=>Object.keys(j).every((A)=>["content-type","retry-after","x-request-id","request-id"].includes(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)))}).strict(),y=w.union([w.object({eof:w.literal(!0)}).strict(),w.object({eof:w.literal(!1),data:w.string().max(Math.ceil(K/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((j)=>j.length>0&&j.length*3/4-(j.endsWith("==")?2:j.endsWith("=")?1:0)<=K)}).strict()]),M=w.object({bytes:w.number().int().min(0).max(P),chunks:w.number().int().min(0).max(Q)}).strict(),p=w.object({apiKey:w.string().min(1).max(16384).refine((j)=>!/[\r\n\0]/.test(j)),api:L}).strict(),Y=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function c(j){return typeof j==="string"&&Y.includes(j)}var Z="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",G={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${Z}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."},q="Local custom endpoints require a session on your connected computer. This custom endpoint's Execution location is Your computer, so Reason cloud never calls it. Connect your computer with the Reason desktop app or CLI and run this session there, or set the endpoint's Execution location to Reason cloud with a public https Base URL in Models, or choose another model.";function _(j){return typeof j==="string"&&j.startsWith("Local custom endpoints require a session on your connected computer.")}var $=new Set(Object.values(G));function h(j){return Object.hasOwn(G,j)?G[j]:null}function v(j){return typeof j==="string"&&($.has(j)||_(j))}var N="returned HTTP 403: its firewall blocked Reason cloud",x=/^Your model endpoint \S+ (?:returned HTTP 40[34]|returned HTTP 403: its firewall blocked Reason cloud|was unreachable: it refused the connection)\.$/,C=/Attention Required! \| Cloudflare|Sorry, you have been blocked|cf-error-details/i;function n(j,A,B){if(!/^[a-z0-9.-]+$/i.test(j))return null;if(A==="connection_refused")return`Your model endpoint ${j} was unreachable: it refused the connection.`;if(A===403&&B&&C.test(B))return`Your model endpoint ${j} ${N}.`;return A===403||A===404?`Your model endpoint ${j} returned HTTP ${A}.`:null}function E(j){return typeof j==="string"&&x.test(j)}function d(j){return E(j)&&j.includes(N)}
3
3
  export{S as gd,K as hd,P as id,Q as jd,T as kd,z as ld,U as md,X as nd,b as od,k as pd,y as qd,M as rd,p as sd,Y as td,c as ud,q as vd,_ as wd,h as xd,v as yd,n as zd,E as Ad,d as Bd};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ek as l}from"./vm-hands-entry-lite-51hmj6am.js";import{execFile as zj,spawn as I}from"child_process";var Cj="h264_ws_v1",kj="video",h=["smooth","sharp","data_saver","balanced"];var Yj="video_presets";var V=8388608,Y=65536,Lj="control",Aj="v1",d=200;function s(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q,J=(Q)=>typeof Q==="string"&&Q.length>0&&Q.length<=d;if(Object.keys(j).length!==2||!J(j.user_id)||!J(j.name))return null;return{user_id:j.user_id,name:j.name}}var xj="windows",Mj="v1",A=200,o=(q)=>typeof q==="string"&&h.includes(q);function fj(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q;if(Object.keys(j).length!==2||j.format!=="h264_ws_v1"||!o(j.preset))return null;return{format:"h264_ws_v1",preset:j.preset}}var $={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class U extends Error{constructor(q){super(q);this.name="DisplayVideoProtocolError"}}var e=new TextEncoder,jj=new TextDecoder("utf-8",{fatal:!0});function H(q,j){if(j.byteLength+1>V)throw new U("message_too_large");let J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,j.byteLength+1),Q.setUint8(4,q),J.set(j,5),J}function R(q){let j=e.encode(q);if(j.byteLength>Y)throw new U("text_too_large");return j}function f(q,j){if(!Number.isInteger(q)||q<0||q>65535)throw new U(`invalid_${j}`);return q}function qj(q){if(!Number.isFinite(q))throw new U("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(q)))}function hj(q){switch(q.type){case"hello":{let j=R(q.codec),J=new Uint8Array(6+j.byteLength),Q=new DataView(J.buffer);return Q.setUint16(0,f(q.width,"width")),Q.setUint16(2,f(q.height,"height")),Q.setUint8(4,Math.max(1,Math.min(240,Math.round(q.fps)))),Q.setUint8(5,h.indexOf(q.preset)),J.set(j,6),H($.hello,J)}case"frame":{let j=new Uint8Array(13+q.data.byteLength),J=new DataView(j.buffer);return J.setUint8(0,q.key?1:0),J.setUint32(1,q.seq>>>0),J.setBigUint64(5,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,13),H($.frame,j)}case"stats":return H($.stats,R(JSON.stringify(q.stats)));case"pong":case"ping":{let j=new Uint8Array(8);return new DataView(j.buffer).setFloat64(0,q.token),H(q.type==="ping"?$.ping:$.pong,j)}case"serverClipboard":return H($.serverClipboard,R(q.text));case"clientClipboard":return H($.clientClipboard,R(q.text));case"error":return H($.error,R(q.code));case"pointer":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint16(0,f(q.x,"x")),J.setUint16(2,f(q.y,"y")),J.setUint8(4,q.buttons&255),H($.pointer,j)}case"key":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint8(0,q.down?1:0),J.setUint32(1,q.keysym>>>0),H($.key,j)}case"config":return H($.config,Uint8Array.of(h.indexOf(q.preset)));case"keyframeRequest":return H($.keyframeRequest,new Uint8Array(0));case"audioHello":{let j=R(q.codec),J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,q.sampleRate>>>0),Q.setUint8(4,q.channels&255),J.set(j,5),H($.audioHello,J)}case"audio":{let j=new Uint8Array(8+q.data.byteLength);return new DataView(j.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,8),H($.audio,j)}case"control":return H($.control,R(JSON.stringify(q.control)));case"windows":{let j=q.bounds.slice(0,A),J=new Uint8Array(j.length*16),Q=new DataView(J.buffer);return j.forEach((Z,z)=>{[Z.x,Z.y,Z.width,Z.height].forEach((G,F)=>Q.setInt32(z*16+F*4,qj(G)))}),H($.windows,J)}case"audioEnable":return H($.audioEnable,Uint8Array.of(q.on?1:0));case"ack":{let j=new Uint8Array(4);return new DataView(j.buffer).setUint32(0,q.seq>>>0),H($.ack,j)}}}function T(q){let j=h[q];if(!j)throw new U("invalid_preset");return j}function C(q,j){if(q.byteLength!==j)throw new U("invalid_length")}function k(q){if(q.byteLength>Y)throw new U("text_too_large");try{return jj.decode(q)}catch{throw new U("invalid_text")}}function Jj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_stats")}let J=j;if(!J||typeof J!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((Z)=>typeof J[Z]!=="number"||!Number.isFinite(J[Z])))throw new U("invalid_stats");return{fps:J.fps,kbps:J.kbps,dropped:J.dropped,restarts:J.restarts,queued_bytes:J.queued_bytes}}function Qj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_control")}let J=j;if(!J||typeof J!=="object"||typeof J.you!=="boolean"||typeof J.same_user!=="boolean")throw new U("invalid_control");let Q=J.holder===null?null:s(J.holder);if(Q===null&&J.holder!==null)throw new U("invalid_control");return{holder:Q,you:J.you,same_user:J.same_user}}function Zj(q,j){let J=new DataView(j.buffer,j.byteOffset,j.byteLength);switch(q){case $.hello:if(j.byteLength<6)throw new U("invalid_length");return{type:"hello",width:J.getUint16(0),height:J.getUint16(2),fps:J.getUint8(4),preset:T(J.getUint8(5)),codec:k(j.subarray(6))};case $.frame:if(j.byteLength<14)throw new U("invalid_length");if(J.getUint8(0)>1)throw new U("invalid_frame_flags");return{type:"frame",key:J.getUint8(0)===1,seq:J.getUint32(1),captureMicros:Number(J.getBigUint64(5)),data:j.subarray(13)};case $.stats:return{type:"stats",stats:Jj(j)};case $.ping:case $.pong:return C(j,8),{type:q===$.ping?"ping":"pong",token:J.getFloat64(0)};case $.serverClipboard:return{type:"serverClipboard",text:k(j)};case $.clientClipboard:return{type:"clientClipboard",text:k(j)};case $.error:return{type:"error",code:k(j)};case $.pointer:return C(j,5),{type:"pointer",x:J.getUint16(0),y:J.getUint16(2),buttons:J.getUint8(4)};case $.key:if(C(j,5),J.getUint8(0)>1)throw new U("invalid_key_flags");return{type:"key",down:J.getUint8(0)===1,keysym:J.getUint32(1)};case $.config:return C(j,1),{type:"config",preset:T(J.getUint8(0))};case $.keyframeRequest:return C(j,0),{type:"keyframeRequest"};case $.audioHello:if(j.byteLength<5)throw new U("invalid_length");return{type:"audioHello",sampleRate:J.getUint32(0),channels:J.getUint8(4),codec:k(j.subarray(5))};case $.audio:if(j.byteLength<9)throw new U("invalid_length");return{type:"audio",captureMicros:Number(J.getBigUint64(0)),data:j.subarray(8)};case $.audioEnable:if(C(j,1),J.getUint8(0)>1)throw new U("invalid_audio_flags");return{type:"audioEnable",on:J.getUint8(0)===1};case $.control:return{type:"control",control:Qj(j)};case $.windows:{if(j.byteLength%16!==0||j.byteLength>A*16)throw new U("invalid_length");let Q=[];for(let Z=0;Z<j.byteLength;Z+=16)Q.push({x:J.getInt32(Z),y:J.getInt32(Z+4),width:J.getInt32(Z+8),height:J.getInt32(Z+12)});return{type:"windows",bounds:Q}}case $.ack:return C(j,4),{type:"ack",seq:J.getUint32(0)};default:return null}}class $j{buffer=new Uint8Array(0);push(q){let j=new Uint8Array(this.buffer.byteLength+q.byteLength);j.set(this.buffer),j.set(q,this.buffer.byteLength);let J=[],Q=0;while(j.byteLength-Q>=4){let Z=new DataView(j.buffer,j.byteOffset+Q,4).getUint32(0);if(Z<1||Z>V)throw new U("invalid_message_length");if(j.byteLength-Q-4<Z)break;let z=j[Q+4],G=j.slice(Q+5,Q+4+Z),F=Zj(z,G);if(F)J.push(F);Q+=4+Z}return this.buffer=j.slice(Q),J}}var t="/usr/bin/osascript",Gj=5000,Kj=1048576,Uj=String.raw`
2
+ import{Gk as l}from"./vm-hands-entry-lite-g87z5eb6.js";import{execFile as zj,spawn as I}from"child_process";var Cj="h264_ws_v1",kj="video",h=["smooth","sharp","data_saver","balanced"];var Yj="video_presets";var V=8388608,Y=65536,Lj="control",Aj="v1",d=200;function s(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q,J=(Q)=>typeof Q==="string"&&Q.length>0&&Q.length<=d;if(Object.keys(j).length!==2||!J(j.user_id)||!J(j.name))return null;return{user_id:j.user_id,name:j.name}}var xj="windows",Mj="v1",A=200,o=(q)=>typeof q==="string"&&h.includes(q);function fj(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q;if(Object.keys(j).length!==2||j.format!=="h264_ws_v1"||!o(j.preset))return null;return{format:"h264_ws_v1",preset:j.preset}}var $={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class U extends Error{constructor(q){super(q);this.name="DisplayVideoProtocolError"}}var e=new TextEncoder,jj=new TextDecoder("utf-8",{fatal:!0});function H(q,j){if(j.byteLength+1>V)throw new U("message_too_large");let J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,j.byteLength+1),Q.setUint8(4,q),J.set(j,5),J}function R(q){let j=e.encode(q);if(j.byteLength>Y)throw new U("text_too_large");return j}function f(q,j){if(!Number.isInteger(q)||q<0||q>65535)throw new U(`invalid_${j}`);return q}function qj(q){if(!Number.isFinite(q))throw new U("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(q)))}function hj(q){switch(q.type){case"hello":{let j=R(q.codec),J=new Uint8Array(6+j.byteLength),Q=new DataView(J.buffer);return Q.setUint16(0,f(q.width,"width")),Q.setUint16(2,f(q.height,"height")),Q.setUint8(4,Math.max(1,Math.min(240,Math.round(q.fps)))),Q.setUint8(5,h.indexOf(q.preset)),J.set(j,6),H($.hello,J)}case"frame":{let j=new Uint8Array(13+q.data.byteLength),J=new DataView(j.buffer);return J.setUint8(0,q.key?1:0),J.setUint32(1,q.seq>>>0),J.setBigUint64(5,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,13),H($.frame,j)}case"stats":return H($.stats,R(JSON.stringify(q.stats)));case"pong":case"ping":{let j=new Uint8Array(8);return new DataView(j.buffer).setFloat64(0,q.token),H(q.type==="ping"?$.ping:$.pong,j)}case"serverClipboard":return H($.serverClipboard,R(q.text));case"clientClipboard":return H($.clientClipboard,R(q.text));case"error":return H($.error,R(q.code));case"pointer":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint16(0,f(q.x,"x")),J.setUint16(2,f(q.y,"y")),J.setUint8(4,q.buttons&255),H($.pointer,j)}case"key":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint8(0,q.down?1:0),J.setUint32(1,q.keysym>>>0),H($.key,j)}case"config":return H($.config,Uint8Array.of(h.indexOf(q.preset)));case"keyframeRequest":return H($.keyframeRequest,new Uint8Array(0));case"audioHello":{let j=R(q.codec),J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,q.sampleRate>>>0),Q.setUint8(4,q.channels&255),J.set(j,5),H($.audioHello,J)}case"audio":{let j=new Uint8Array(8+q.data.byteLength);return new DataView(j.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,8),H($.audio,j)}case"control":return H($.control,R(JSON.stringify(q.control)));case"windows":{let j=q.bounds.slice(0,A),J=new Uint8Array(j.length*16),Q=new DataView(J.buffer);return j.forEach((Z,z)=>{[Z.x,Z.y,Z.width,Z.height].forEach((G,F)=>Q.setInt32(z*16+F*4,qj(G)))}),H($.windows,J)}case"audioEnable":return H($.audioEnable,Uint8Array.of(q.on?1:0));case"ack":{let j=new Uint8Array(4);return new DataView(j.buffer).setUint32(0,q.seq>>>0),H($.ack,j)}}}function T(q){let j=h[q];if(!j)throw new U("invalid_preset");return j}function C(q,j){if(q.byteLength!==j)throw new U("invalid_length")}function k(q){if(q.byteLength>Y)throw new U("text_too_large");try{return jj.decode(q)}catch{throw new U("invalid_text")}}function Jj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_stats")}let J=j;if(!J||typeof J!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((Z)=>typeof J[Z]!=="number"||!Number.isFinite(J[Z])))throw new U("invalid_stats");return{fps:J.fps,kbps:J.kbps,dropped:J.dropped,restarts:J.restarts,queued_bytes:J.queued_bytes}}function Qj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_control")}let J=j;if(!J||typeof J!=="object"||typeof J.you!=="boolean"||typeof J.same_user!=="boolean")throw new U("invalid_control");let Q=J.holder===null?null:s(J.holder);if(Q===null&&J.holder!==null)throw new U("invalid_control");return{holder:Q,you:J.you,same_user:J.same_user}}function Zj(q,j){let J=new DataView(j.buffer,j.byteOffset,j.byteLength);switch(q){case $.hello:if(j.byteLength<6)throw new U("invalid_length");return{type:"hello",width:J.getUint16(0),height:J.getUint16(2),fps:J.getUint8(4),preset:T(J.getUint8(5)),codec:k(j.subarray(6))};case $.frame:if(j.byteLength<14)throw new U("invalid_length");if(J.getUint8(0)>1)throw new U("invalid_frame_flags");return{type:"frame",key:J.getUint8(0)===1,seq:J.getUint32(1),captureMicros:Number(J.getBigUint64(5)),data:j.subarray(13)};case $.stats:return{type:"stats",stats:Jj(j)};case $.ping:case $.pong:return C(j,8),{type:q===$.ping?"ping":"pong",token:J.getFloat64(0)};case $.serverClipboard:return{type:"serverClipboard",text:k(j)};case $.clientClipboard:return{type:"clientClipboard",text:k(j)};case $.error:return{type:"error",code:k(j)};case $.pointer:return C(j,5),{type:"pointer",x:J.getUint16(0),y:J.getUint16(2),buttons:J.getUint8(4)};case $.key:if(C(j,5),J.getUint8(0)>1)throw new U("invalid_key_flags");return{type:"key",down:J.getUint8(0)===1,keysym:J.getUint32(1)};case $.config:return C(j,1),{type:"config",preset:T(J.getUint8(0))};case $.keyframeRequest:return C(j,0),{type:"keyframeRequest"};case $.audioHello:if(j.byteLength<5)throw new U("invalid_length");return{type:"audioHello",sampleRate:J.getUint32(0),channels:J.getUint8(4),codec:k(j.subarray(5))};case $.audio:if(j.byteLength<9)throw new U("invalid_length");return{type:"audio",captureMicros:Number(J.getBigUint64(0)),data:j.subarray(8)};case $.audioEnable:if(C(j,1),J.getUint8(0)>1)throw new U("invalid_audio_flags");return{type:"audioEnable",on:J.getUint8(0)===1};case $.control:return{type:"control",control:Qj(j)};case $.windows:{if(j.byteLength%16!==0||j.byteLength>A*16)throw new U("invalid_length");let Q=[];for(let Z=0;Z<j.byteLength;Z+=16)Q.push({x:J.getInt32(Z),y:J.getInt32(Z+4),width:J.getInt32(Z+8),height:J.getInt32(Z+12)});return{type:"windows",bounds:Q}}case $.ack:return C(j,4),{type:"ack",seq:J.getUint32(0)};default:return null}}class $j{buffer=new Uint8Array(0);push(q){let j=new Uint8Array(this.buffer.byteLength+q.byteLength);j.set(this.buffer),j.set(q,this.buffer.byteLength);let J=[],Q=0;while(j.byteLength-Q>=4){let Z=new DataView(j.buffer,j.byteOffset+Q,4).getUint32(0);if(Z<1||Z>V)throw new U("invalid_message_length");if(j.byteLength-Q-4<Z)break;let z=j[Q+4],G=j.slice(Q+5,Q+4+Z),F=Zj(z,G);if(F)J.push(F);Q+=4+Z}return this.buffer=j.slice(Q),J}}var t="/usr/bin/osascript",Gj=5000,Kj=1048576,Uj=String.raw`
3
3
  ObjC.import("CoreGraphics");
4
4
  ObjC.import("ApplicationServices");
5
5
  ObjC.import("AppKit");
@@ -109,4 +109,4 @@ function run() {
109
109
  `);X>=0;X=B.indexOf(`
110
110
  `)){let S=B.slice(0,X);if(B=B.slice(X+1),!S.startsWith("c "))continue;let O=S.slice(2);if(O.length>Math.ceil(Y/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(O)){K({reason:"display_protocol"});return}let _=Buffer.from(O,"base64");if(_.byteLength<=Y)q.clipboard(_.toString("utf8"));if(z)return}if(B.length>Math.ceil(Y/3)*4+2)K({reason:"display_protocol"})}),G.once("error",()=>W("Reason could not watch this Mac's desktop clipboard.")),G.once("exit",()=>{if(!z)W("Reason could not watch this Mac's desktop clipboard.")})};return J.stdout.on("data",(B)=>{if(z||Z===null)return;Z+=B.toString("utf8");let N=Z.indexOf(`
111
111
  `);if(N<0){if(Z.length>4096)K({reason:"display_protocol"});return}let X=y(Z.slice(0,N));if(Z=null,!X)K({reason:"display_protocol"});else if(!X.screen||!X.accessibility)W(j.length>0?"Reason's background worker needs Screen Recording and Accessibility on this Mac (its own Reason entry in System Settings > Privacy & Security, not the Reason app's): run `reason permissions allow` on this Mac.":"Allow Screen Recording and Accessibility for this Mac's Reason worker, then restart it.");else i(),q.ready({width:X.width,height:X.height})}),J.stdin.on("error",()=>{return}),J.once("error",()=>W("Reason could not start this Mac's desktop input.")),J.once("exit",()=>{if(Z!==null)W("Reason could not start this Mac's desktop input.");else K({reason:"display_closed"})}),{pointer:(B,N,X)=>L(Q.pointer(B,N,X)),key:(B,N)=>L(Q.key(B,N)),clipboard:(B)=>L([`c ${Buffer.from(B,"utf8").toString("base64")}`]),close(){z=!0,F()}}}
112
- export{Cj as Qj,kj as Rj,h as Sj,Yj as Tj,Y as Uj,Lj as Vj,Aj as Wj,s as Xj,xj as Yj,Mj as Zj,fj as _j,hj as $j,$j as ak,y as bk,Sj as ck,_j as dk,Hj as ek,Tj as fk,a as gk,Vj as hk};
112
+ export{Cj as Rj,kj as Sj,h as Tj,Yj as Uj,Y as Vj,Lj as Wj,Aj as Xj,s as Yj,xj as Zj,Mj as _j,fj as $j,hj as ak,$j as bk,y as ck,Sj as dk,_j as ek,Hj as fk,Tj as gk,a as hk,Vj as ik};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Df as jJ,Oe as _J,We as gJ,Xe as OJ,Ye as RJ,Ze as IJ}from"./vm-hands-entry-lite-02zaqpgh.js";import{createHash as m,randomBytes as WJ}from"crypto";import{closeSync as MJ,fsyncSync as TJ,mkdirSync as aJ,openSync as DJ,renameSync as nJ,rmSync as tJ,statSync as qJ,writeSync as xJ,constants as y}from"fs";import{join as t}from"path";var eJ=1;var e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function FJ(J){if(J.environment!==void 0||J.payload.environment!==void 0)throw new F("vm_hands_bind_invalid","bind carries a plaintext environment");if(J.payload.vm_hands_env_deferred===!0&&J.environment_sealed!==void 0)throw new F("vm_hands_bind_invalid","split bind carries an environment");return J.environment_sealed!==void 0}function AJ(J,Q){let{payload:$,authority:z}=J;if(!$||typeof $!=="object"||Array.isArray($)||!z||typeof z!=="object"||Array.isArray(z)||!Q.deviceId||!Q.rootId||$.run_id!==Q.runId||$.device_id!==Q.deviceId||z.device_id!==Q.deviceId||$.root_id!==Q.rootId||Q.snapshotId!==void 0&&$.snapshot_id!==Q.snapshotId)throw new F("vm_hands_env_invalid","environment does not match this Hands");return $}function SJ(J){if(J.capability!=="hands.connect")throw new F("vm_hands_bind_invalid","not a hands.connect claim");let Q=J.payload;return{kind:"vm_hands.bind",v:1,bind_id:J.attempt_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,run_id:J.run_id,session_id:typeof Q.workspace_id==="string"&&e.test(Q.workspace_id)?Q.workspace_id:J.run_id,brain_generation:Q.target_generation,fence_id:Q.target_fence_id,lease_until:J.lease_until,policy:{agent_profile:"",confinement_key:String(Q.hands_confinement??""),browser_egress:Q.browser_egress??null,policy_digest:Q.vm_hands_policy_digest},cwd:typeof Q.cwd==="string"?Q.cwd:"",claim:J,env:FJ(J)?J.environment_sealed:null,workspace_deferred:JQ(J)}}function JQ(J){let Q=J.payload[OJ];if(Q===void 0)return!1;if(Q!==!0||J.payload.vm_hands_env_deferred!==!0||J.environment_sealed!==void 0)throw new F("vm_hands_bind_invalid","a pre-bind must be environment-less");return!0}class F extends Error{code;constructor(J,Q){super(Q);this.code=J}}var I=(J)=>Buffer.from(J instanceof Uint8Array?J:new Uint8Array(J)).toString("base64url"),b=(J)=>new Uint8Array(Buffer.from(J,"base64url"));function c(J){if(J===null||typeof J!=="object")return JSON.stringify(J);if(Array.isArray(J))return`[${J.map(c).join(",")}]`;return`{${Object.keys(J).sort().map((Q)=>`${JSON.stringify(Q)}:${c(J[Q])}`).join(",")}}`}async function SQ(J){let Q=await crypto.subtle.importKey("pkcs8",b(J.device_key.pkcs8),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),$=b(J.device_key.spki),z=await crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!1,["deriveKey"]),L=new Uint8Array(await crypto.subtle.exportKey("spki",z.publicKey)),U=m("sha256").update($).digest("base64url");return{signing:{privateKey:Q},agreement:z,signingSpki:$,agreementSpki:L,fingerprint:U}}var QQ=4;class ZQ{init;keys;hooks;options;identity="identity_free";lastBrainGeneration=new Map;bound=new Map;binding=new Map;unbinding=new Set;servedRun=!1;commandsSinceVerified=!1;bootKillPending=!1;unverified=new Set;unverifiedTeardowns=new Map;grants=new Map;structural=Promise.resolve();exclusive(J){let Q=this.structural.then(J,J);return this.structural=Q.catch(()=>{return}),Q}constructor(J,Q,$,z){this.init=J;this.keys=Q;this.hooks=$;this.options=z;if(!e.test(J.workspace_id)&&!/^ws-[a-z0-9]{8,64}$/.test(J.workspace_id))throw new F("vm_hands_layout_invalid","bad workspace id");if(!Number.isSafeInteger(J.instance_generation)||J.instance_generation<1)throw new F("vm_hands_layout_invalid","bad generation")}get phase(){if(this.identity==="identity_free")return"identity_free";if(this.unbinding.size)return"unbinding";return this.bound.size||this.binding.size?"bound":"registered"}isBoundRun(J){for(let Q of this.bound.values())if(Q.runId===J)return!0;return!1}bindIdForRun(J){for(let Q of this.bound.values())if(Q.runId===J)return Q.bindId;return null}get liveBindIds(){return[...new Set([...this.bound.keys(),...this.binding.keys(),...this.unbinding])]}async environmentInstalled(J,Q,$){for(let z=Date.now()+Q;;){let L=this.bound.get(J);if(!L)return!1;if(L.envInstalled)return!0;if(Date.now()>=z||$?.aborted)return!1;await new Promise((U)=>setTimeout(U,25))}}opServed(){this.commandsSinceVerified=!0}canSpawn(J){for(let Q of this.bound.values())if(Q.runId===J)return Q.envInstalled;return!1}async registerFrame(J){if(this.identity!=="identity_free")throw new F("vm_hands_register_twice","already registered");if(typeof J!=="string"||J.length<16||J.length>256)throw new F("vm_hands_challenge_invalid","bad register challenge");let Q={challenge:J,t:"register",v:eJ,workspace_id:this.init.workspace_id,instance_generation:this.init.instance_generation,credential:this.init.credential,device_public_key:I(this.keys.signingSpki),env_public_key:I(this.keys.agreementSpki),key_fingerprint:this.keys.fingerprint,manifest_digest:this.init.manifest_digest,nonce:I(WJ(32)),timestamp_ms:(this.options.now??Date.now)(),vm_hands_attest_hold:!0},$=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new TextEncoder().encode(c(Q)));return{...Q,device_signature:I($)}}async helloFrame(J,Q){if(this.identity==="identity_free")throw new F("vm_hands_not_registered","hello before register");let $=String((this.options.now??Date.now)()),z=I(WJ(32)),L=jJ({method:"GET",pathAndQuery:_J,timestamp:$,nonce:z,challenge:J,bodySha256:m("sha256").update("").digest("hex")}),U=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new Uint8Array(L)));return{t:"hello",timestamp:$,nonce:z,signature:I($Q(U)),...Q?{vm_hands_previous_connection:Q}:{}}}registered(){if(this.identity!=="identity_free")throw new F("vm_hands_register_unexpected","registered twice");this.identity="registered"}async bind(J){if(this.identity!=="registered")throw new F("vm_hands_not_registered","bind before register");if(J.kind!=="vm_hands.bind"||J.v!==1)throw new F("vm_hands_bind_invalid","bad bind");for(let $ of[J.bind_id,J.attempt_id,J.run_id,J.session_id,J.fence_id])if(!e.test($))throw new F("vm_hands_bind_invalid","bad id");if(!Number.isSafeInteger(J.brain_generation)||J.brain_generation<=(this.lastBrainGeneration.get(J.run_id)??0))throw new F("vm_hands_generation_stale","brain generation not strictly higher");if(J.env&&(J.env.aad!==J.bind_id||J.env.alg!=="ECDH-P256+A256GCM"))throw new F("vm_hands_bind_invalid","bad env envelope");if(!/^[0-9a-f]{64}$/.test(J.policy.policy_digest))throw new F("vm_hands_bind_invalid","bad policy or nonce");if(m("sha256").update(c({hands_confinement:J.policy.confinement_key||null,browser_egress:J.policy.browser_egress??null})).digest("hex")!==J.policy.policy_digest)throw new F("vm_hands_policy_mismatch","policy digest does not match the claim");if(this.liveBindIds.includes(J.bind_id)||[...this.bound.values()].some(($)=>$.runId===J.run_id)||[...this.binding.values()].includes(J.run_id))throw new F("vm_hands_busy","this run already holds a bind here");if(this.liveBindIds.length>=QQ)throw new F("vm_hands_busy","every bind slot is held");if(this.grants.size)throw new F("vm_hands_busy","a bind waits for its workspace beside the setup");if(J.workspace_deferred&&(this.liveBindIds.length||this.commandsSinceVerified))throw new F("vm_hands_prebind_unsafe","a pre-bind needs a VM that served nothing since its last full kill");if(this.lastBrainGeneration.set(J.run_id,J.brain_generation),this.binding.set(J.bind_id,J.run_id),J.workspace_deferred){let $,z,L=new Promise((U,N)=>{$=U,z=N});L.catch(()=>{return}),this.grants.set(J.bind_id,{promise:L,resolve:$,reject:z})}return this.exclusive(()=>this.setUp(J))}async setUp(J){let Q=[...this.bound.keys()],$=null,z=!1,L=this.grants.get(J.bind_id);try{if(L&&(Q.length||this.commandsSinceVerified))throw new F("vm_hands_prebind_unsafe","a pre-bind needs a VM that served nothing since its last full kill");if(Q.length===0){if(this.bootKillPending&&!this.servedRun){try{await this.hooks.killProbe()}catch{throw new F("vm_hands_kill_unverified","the boot's scoped kill did not verify")}this.bootKillPending=!1}if(this.commandsSinceVerified)await this.hooks.killAndVerifyPayload(),this.unverified.clear(),this.commandsSinceVerified=!1;else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({own:!0}),this.unverified.clear()}else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({keep:Q}),this.unverified.clear();this.servedRun=!0,z=!0;let{launchId:U,applied:N,readyData:O}=await this.hooks.startExecutor({bindId:J.bind_id,sessionId:J.session_id,policyDigest:J.policy.policy_digest,confinementKey:J.policy.confinement_key,browserEgress:J.policy.browser_egress,cwd:J.cwd,claim:J.claim,...L?{workspaceGrant:L.promise}:{}}),T=this.hooks.restatLayout();this.hooks.verifyMounts?.();let D=null,A=null;if(J.env){let w=J.claim?.owner??{},v=AJ(await this.openSealed(J.env,J.bind_id),{runId:J.run_id,deviceId:typeof w.device_id==="string"?w.device_id:"",rootId:J.claim?.root_id??""});this.commandsSinceVerified=!0,D=this.hooks.installEnvironment(J.bind_id,v),A=typeof v.snapshot_id==="string"&&v.snapshot_id?v.snapshot_id:null,$=this.writeJobEnvRootOnly(J.bind_id,v)}if(this.unbinding.has(J.bind_id))throw new F("vm_hands_bind_lost","unbound while binding");return this.bound.set(J.bind_id,{bindId:J.bind_id,runId:J.run_id,sessionId:J.session_id,brainGeneration:J.brain_generation,policyDigest:J.policy.policy_digest,launchId:U,envInstalled:D!==null,rootId:J.claim?.root_id??"",envDirectory:$}),this.binding.delete(J.bind_id),this.grants.delete(J.bind_id),{bind_id:J.bind_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,launch_id:U,snapshot_revision:D,snapshot_id:A,layout:T,...O?{ready_data:O}:{},policy_digest:m("sha256").update(c({hands_confinement:N.hands_confinement??null,browser_egress:N.browser_egress??null})).digest("hex")}}catch(U){if($)KJ($);if(z){let O=[...this.bound.keys()];await this.hooks.killAndVerifyPayload({bindId:J.bind_id,keep:O,own:!0}).catch(()=>{this.unverified.add(J.bind_id)})}this.binding.delete(J.bind_id),this.grants.delete(J.bind_id);let N=U&&typeof U==="object"&&"code"in U&&typeof U.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(U.code)?U.code:"vm_hands_bind_failed";throw U instanceof F?U:new F(N,"executor refused the bind")}}grantWorkspace(J){let Q=this.grants.get(J);if(!Q)throw new F("vm_hands_not_binding","no pre-bind waits for a workspace grant");Q.resolve()}abandonWorkspaceGrant(J){this.grants.get(J)?.reject(new F("vm_hands_bind_lost","the pre-bind ended before its workspace grant"))}async deliverEnvironment(J){let Q=this.bound.get(J.attemptId);if(!Q||this.unbinding.has(J.attemptId))throw new F("vm_hands_not_bound","environment delivered while not bound");if(!e.test(J.attemptId)||typeof J.snapshotId!=="string"||!J.snapshotId||J.snapshotId.length>128||J.snapshotId.includes("/"))throw new F("vm_hands_env_invalid","bad snapshot id");let $=`${J.attemptId}/${J.snapshotId}`;if(J.sealed?.alg!=="ECDH-P256+A256GCM"||J.sealed.aad!==$)throw new F("vm_hands_env_invalid","bad env envelope");let z=AJ(await this.openSealed(J.sealed,$),{runId:Q.runId,deviceId:J.deviceId,rootId:Q.rootId,snapshotId:J.snapshotId});this.commandsSinceVerified=!0;let L=this.hooks.installEnvironment(Q.bindId,z);if(Q.envInstalled=!0,Q.envDirectory)KJ(Q.envDirectory);return Q.envDirectory=null,Q.envDirectory=this.writeJobEnvRootOnly(`${Q.bindId}-r${L}`,z),{snapshot_id:J.snapshotId,installed_revision:L,installed:!0}}async attestFrame(J,Q){if(this.identity==="identity_free")throw new F("vm_hands_not_registered","attest before register");if(!J||J.length>65536)throw new F("vm_hands_attest_invalid","no probe script");return this.exclusive(async()=>{if(this.liveBindIds.length)throw new F("vm_hands_attest_invalid","attest beside a bind");let $=await this.hooks.runProbe({nonce:Q,script:J});try{await this.hooks.killProbe()}catch{this.bootKillPending=!0}return{t:"attest",nonce:Q,exit_code:$.exitCode,markers:$.markers,proof_dir_inode:$.proofDirInode,script_sha256:m("sha256").update(J).digest("hex")}})}executorExited(J){return this.hooks.executorExited?.(J)??new Promise(()=>{})}async boundRefused(J){await this.unbind(J)}async unbind(J){let Q=this.bound.get(J)??null;if(this.unbinding.add(J),this.bound.delete(J),this.abandonWorkspaceGrant(J),Q)try{this.hooks.freezeBind?.(J)}catch{}return this.exclusive(()=>this.tearDown(J,Q))}async retryUnbind(J){if(!this.unverifiedTeardowns.has(J))throw new F("vm_hands_unbind_unknown","no unverified unbind of this bind");return this.exclusive(async()=>{if(!this.unverifiedTeardowns.has(J))throw new F("vm_hands_unbind_unknown","no unverified unbind of this bind");return this.tearDown(J,this.unverifiedTeardowns.get(J)??null,!0)})}async tearDown(J,Q,$=!1){try{this.bound.delete(J);let z=[...this.bound.keys()].filter((U)=>U!==J),L=!z.length&&($||!this.commandsSinceVerified);try{await this.hooks.killAndVerifyPayload(z.length?{bindId:J,keep:z}:L?{bindId:J,own:!0}:void 0)}catch(U){if(this.unverified.add(J),!this.unverifiedTeardowns.has(J))this.unverifiedTeardowns.set(J,Q);throw U}if(this.unverified.delete(J),!z.length&&!$)this.unverified.clear(),this.commandsSinceVerified=!1;if(Q?.envDirectory)KJ(Q.envDirectory);return this.unverifiedTeardowns.delete(J),{bind_id:Q?J:null,killed_verified:!0,shredded:!0,srt_fallbacks:z.length||$?null:this.hooks.takeSrtFallbacks?.()??null}}finally{this.unbinding.delete(J)}}async openSealed(J,Q){let $=()=>{throw new F("vm_hands_env_invalid","env did not decrypt")},z=await crypto.subtle.importKey("spki",b(J.epk),{name:"ECDH",namedCurve:"P-256"},!1,[]).catch($),L=await crypto.subtle.deriveKey({name:"ECDH",public:z},this.keys.agreement.privateKey,{name:"AES-GCM",length:256},!1,["decrypt"]),U=await crypto.subtle.decrypt({name:"AES-GCM",iv:b(J.iv),additionalData:new TextEncoder().encode(Q)},L,b(J.ct)).catch($),N=JSON.parse(new TextDecoder().decode(U));if(!N||typeof N!=="object"||Array.isArray(N))throw new F("vm_hands_env_invalid","env not an object");return N}writeJobEnvRootOnly(J,Q){let $=t(this.options.envRoot,`bind-${J}`);aJ($,{mode:448});let z=qJ($);if(!z.isDirectory()||(z.mode&63)!==0||z.uid!==(process.getuid?.()??-1))throw new F("vm_hands_env_dir_unsafe","env directory is not root's 0700");let L=Q.variables&&typeof Q.variables==="object"?Q.variables:{},U=Object.entries(L).filter(([T,D])=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(T)&&typeof D==="string").map(([T,D])=>`export ${T}='${String(D).replaceAll("'","'\\''")}'`).join(`
3
+ `)+`
4
+ `,N=t($,`.job.env.${WJ(8).toString("hex")}`),O=DJ(N,y.O_WRONLY|y.O_CREAT|y.O_EXCL|y.O_NOFOLLOW,384);try{xJ(O,U),TJ(O)}finally{MJ(O)}return nJ(N,t($,"job.env")),$}}function KJ(J){try{let Q=t(J,"job.env"),$=qJ(Q).size,z=DJ(Q,y.O_WRONLY|y.O_NOFOLLOW);try{xJ(z,Buffer.alloc($)),TJ(z)}finally{MJ(z)}}catch{}tJ(J,{recursive:!0,force:!0})}function $Q(J){if(J.length!==64)throw new F("vm_hands_signature_invalid","unexpected ECDSA signature length");let Q=(L)=>{let U=0;while(U<L.length-1&&L[U]===0)U++;let N=L.subarray(U),O=N[0]&128?Uint8Array.of(0,...N):N;return Uint8Array.of(2,O.length,...O)},$=Q(J.subarray(0,32)),z=Q(J.subarray(32));return Uint8Array.of(48,$.length+z.length,...$,...z)}import{randomUUID as zQ}from"crypto";var XQ="/app/local-runtime/session?register=vm_hands_v1",YQ="/app/local-runtime",wJ=25000,hJ=20000,GQ=1e4,yJ=5000,kJ=new Set(["pty.start","jobs.control","preview.serve.v1","display.stream.v1"]),PJ=75000,WQ=2000,KQ=1e4,FQ=new Set(["vm_hands_no_register","vm_hands_register_failed"]),PQ=3,CQ=20000,NQ=250,UQ=2000;function fJ(J){let Q=Math.min(NQ*2**(J-1),UQ);return Math.round(Q/2+Math.random()*Q/2)}var EQ=5000;function BQ(J){return J>=500||J===408||J===429}var JJ=20000;function HJ(J,Q){return typeof J==="string"&&/^[A-Za-z0-9._:-]{1,160}$/.test(J)?J:Q}class V extends Error{}var LQ=64,VJ=[1000,2000,4000,8000,15000,30000,60000,120000];function mJ(J){let Q=J&&typeof J==="object"&&"code"in J?J.code:null;return typeof Q==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(Q)?Q:"vm_hands_unbind_failed"}function AQ(J,Q,$,z,L){let U=$.turn.claim.attempt_id,N=J.healing??=new Set;if(N.has(U))return;N.add(U);let O=$.turn.claim.operation_id;(async()=>{for(let[T,D]of VJ.entries()){if(z.aborted)return;if(await new Promise((A)=>{let w=setTimeout(A,D);w.unref?.(),z.addEventListener("abort",()=>{clearTimeout(w),A()},{once:!0})}),z.aborted)return;try{let A=await Q.retryUnbind(U);L("vm_hands.unbind_healed",{operation_id:O,attempt:T+1}),J.receipts.push({...$,unbound:A}),J.flushReceipts?.();return}catch(A){let w=mJ(A);if(L("vm_hands.unbind_unverified",{operation_id:O,code:w,attempt:T+1}),w==="vm_hands_unbind_unknown")return}}L("vm_hands.unbind_heal_exhausted",{operation_id:O,attempts:VJ.length})})().finally(()=>N.delete(U))}async function bJ(J,Q){let $=[...J.modelOps.get(Q)??[]];for(let z of $)z.abort.abort();await Promise.race([Promise.all($.map((z)=>z.settled)),new Promise((z)=>setTimeout(z,yJ))])}async function _Q(J){let Q=[...J.personTerminals];for(let $ of Q)$.abort.abort();if(Q.length)await Promise.race([Promise.all(Q.map(($)=>$.settled)),new Promise(($)=>setTimeout($,yJ))]);return Q.length}async function p(J,Q,$){return await bJ(J,$),Q.unbind($)}function QJ(J){for(let Q of J.outbox?.splice(0)??[])Q.reject(Error("vm_hands_attempt_ended"))}var vJ=15000,OQ=1e4,jQ=1000;async function vQ(J){let Q=Date.now(),$={deviceId:null,connection:null,turns:new Map,lostAt:0,receipts:[],attest:"pending",attestWaiters:[],modelOps:new Map,personTerminals:new Set,bindsStarting:0},z=J.log??(()=>{}),L=async(O)=>{for(let[T,D]of[...$.turns]){$.turns.delete(T),J.onTurn?.(T,null),QJ(D);let A=await p($,J.agent,T).catch(()=>null);if(A)$.receipts.push({turn:D,failure:"vm_hands_bind_lost",unbound:A});z("vm_hands.bound_dropped",{reason:O})}},U=0,N=0;try{for(let O=0;!J.signal.aborted;O++){let T=await MQ(J,$).catch((A)=>{if(A instanceof F&&$.deviceId===null&&A.code==="vm_hands_no_session"&&Date.now()-Q<KQ)return{closeCode:0,closeReason:"vm_hands_no_session"};if(A instanceof F&&$.deviceId===null&&FQ.has(A.code)&&U<PQ&&Date.now()-Q<CQ)return U++,N=fJ(U),z("vm_hands.register_retry",{attempt:U,code:A.code,delay_ms:N}),{closeCode:0,closeReason:"vm_hands_register_retry"};if(A instanceof F&&$.deviceId===null)throw A;return{closeCode:0,closeReason:A instanceof Error?A.message:String(A)}});if(z("vm_hands.session_closed",{close_code:T.closeCode,reason:T.closeReason.slice(0,120),registered:$.deviceId!==null}),T.closeCode===4401||$.attest==="refused")return;if(J.signal.aborted)return;if($.turns.size&&Date.now()-$.lostAt>=PJ)await L("reconnect_deadline");if($.served)$.served=!1,O=0;let D=T.closeReason==="drain_reconnect"?0:T.closeReason==="vm_hands_register_retry"?N:T.closeReason==="vm_hands_no_session"?Math.min(250*2**Math.min(O,5),2000):$.turns.size?Math.min(250*2**Math.min(O,5),5000,Math.max(0,$.lostAt+PJ-Date.now())):Math.min(500*2**O,30000);if(await new Promise((A)=>setTimeout(A,D)),$.turns.size&&Date.now()-$.lostAt>=PJ)await L("reconnect_deadline")}}finally{await L("session_ended")}}async function MQ(J,Q){let $=Q.deviceId,z=J.log??(()=>{}),L=$?`/app/local-runtime/session?device_id=${encodeURIComponent($)}`:XQ,U=`${J.apiOrigin.replace(/^http/,"ws")}${L}`,N=new WebSocket(U),O=0,T="",D=new Map,A=[],w=null,v=new Promise((Z)=>{N.onclose=(Y)=>{O=Y.code,T=Y.reason;for(let X of D.values())X.reject(new V(`session closed ${Y.code}`));for(let X of Q.attestWaiters.splice(0))X(!1);D.clear(),Z()}});N.onmessage=(Z)=>{let Y;try{Y=JSON.parse(String(Z.data))}catch{N.close(4400);return}if(Y.t==="res"){let X=Y;D.get(X.id)?.resolve({status:X.status,body:X.body}),D.delete(X.id);return}if(Y.t==="reconnect"){let X=Math.max(0,Math.min(Number(Y.after_ms)||0,jQ));z("vm_hands.drain_reconnect",{after_ms:X}),setTimeout(()=>{try{N.close(4001,"drain_reconnect")}catch{}},X).unref?.();return}if(!w?.(Y))A.push(Y)};let l=(Z,Y)=>new Promise((X,K)=>{let C=A.findIndex((B)=>Z.includes(B.t));if(C>=0){X(A.splice(C,1)[0]);return}let E=setTimeout(()=>{w=null,K(new F("vm_hands_no_register",`no ${Z.join("/")} in ${Y} ms`))},Y);w=(B)=>{if(!Z.includes(B.t))return!1;return clearTimeout(E),w=null,X(B),!0}}),u=(Z)=>N.send(JSON.stringify(Z)),k=(Z,Y)=>new Promise((X,K)=>{if(N.readyState!==WebSocket.OPEN){K(new V("session closed"));return}let C=zQ(),E=typeof Y.wait_ms==="number"?Y.wait_ms:0,B=setTimeout(()=>{if(!D.delete(C))return;K(new V(`no answer to ${Z.split("/").pop()} in ${E+vJ} ms`)),N.close(4000,"request_timeout")},E+vJ);D.set(C,{reject:(G)=>{clearTimeout(B),K(G)},resolve:({status:G,body:W})=>{clearTimeout(B);let P=null;try{P=W?JSON.parse(W):null}catch{}X({status:G,json:P})}}),u({t:"req",id:C,path:`${YQ}${Z}`,body:JSON.stringify(Y)})}),CJ=()=>N.close(1001,"stopping");J.signal.addEventListener("abort",CJ,{once:!0});let ZJ,o=new Map,d=new Map,$J=!1,zJ=new Set,XJ=new Set,YJ=Promise.resolve(),NJ=()=>{r().catch(()=>{return})},i=!1;try{await new Promise((G,W)=>{let P=setTimeout(()=>W(Error("session open timeout")),OQ);N.onopen=()=>{clearTimeout(P),z("vm_hands.ws_open",{}),G()},N.onerror=()=>{clearTimeout(P),W(Error("session socket error"))}});let Z=await l(["challenge"],5000);z("vm_hands.challenge",{});let Y=[],X=null,K;if($){u(await J.agent.helloFrame(Z.challenge,Q.connection));let G=await l(["ready"],1e4);if(typeof G.vm_hands_connection==="string")Q.connection=G.vm_hands_connection;if(K={device_id:$,...G.cadence?{cadence:G.cadence}:{}},typeof G.vm_hands_probe_script==="string"){if(X=G.vm_hands_probe_script,i=!0,J.agent.phase==="registered"&&!Q.turns.size)Q.attest="pending"}Q.served=!0,z("vm_hands.reconnected",{device_id:$});let W=Array.isArray(G.vm_hands_binds)?G.vm_hands_binds:G.vm_hands_bind?[G.vm_hands_bind]:[];for(let[P,M]of[...Q.turns]){if(W.some((x)=>x&&x.operation_id===M.claim.operation_id&&x.attempt_id===M.claim.attempt_id)){Y.push(M),z("vm_hands.bound_resumed",{operation_id:M.claim.operation_id});continue}Q.turns.delete(P),J.onTurn?.(P,null),QJ(M);let q=await p(Q,J.agent,P).catch((x)=>s(x,M,"vm_hands_bind_lost"));if(q)Q.receipts.push({turn:M,failure:"vm_hands_bind_lost",unbound:q});z("vm_hands.bound_dropped",{reason:"not_named_on_reconnect"})}}else{u(await J.agent.registerFrame(Z.challenge)),z("vm_hands.register_sent",{});let G=await Promise.race([l(["registered","register_refused"],1e4),v.then(()=>{throw new F(T==="register_failed"?"vm_hands_register_failed":"vm_hands_register_closed","session closed before the register was answered")})]);if(G.t==="register_refused")throw new F(G.code,"register refused");J.agent.registered();let W=G;if(K=W,Q.deviceId=W.device_id,typeof W.vm_hands_connection==="string")Q.connection=W.vm_hands_connection;if(typeof W.vm_hands_probe_script==="string"){if(X=W.vm_hands_probe_script,i=!0,J.agent.phase==="registered"&&!Q.turns.size)Q.attest="pending"}Q.served=!0,z("vm_hands.registered",{device_id:K.device_id})}let C=async()=>{let G=await k("/heartbeat",await J.heartbeat());if(G.status>=300)throw Error(`heartbeat ${G.status}`)};await C();let E=K.cadence?.presence_interval_ms??30000;if(ZJ=setInterval(()=>{C().catch(()=>N.close())},E),X&&Q.attest!=="accepted"&&J.agent.phase==="registered"&&!Q.turns.size)pJ(X,Z.challenge);let B=(G,W)=>{d.set(G,W().catch(async(P)=>{if(await UJ(P,G),P instanceof V)N.close();else await r().catch(()=>{return})}).finally(()=>{d.delete(G)}))};Q.flushReceipts=NJ;try{await r();for(let G of Y)G.flush=()=>EJ(G),G.flush(),B(G.claim.attempt_id,()=>BJ(G));while(!J.signal.aborted&&N.readyState===WebSocket.OPEN){let G=await k("/operations/claim",{wait_ms:Math.min(K.cadence?.claim_wait_ms??wJ,wJ)});if(G.status===204||!G.json)continue;if(G.status>=300)throw Error(`claim ${G.status}`);let W=G.json;if(W.capability==="hands.connect"){if(d.has(W.attempt_id)){h({claim:W,eventSeq:0}).complete("failed",{error_code:"vm_hands_busy"}).catch(()=>{return});continue}B(W.attempt_id,()=>lJ(W))}else oJ(W).catch(()=>{return})}}catch(G){await UJ(G,null)}}finally{if(ZJ)clearInterval(ZJ);J.signal.removeEventListener("abort",CJ);for(let Z of Q.turns.values())Z.flush=null;if(Q.flushReceipts===NJ)Q.flushReceipts=null;N.close(),await v,await Promise.all([...d.values()]);for(let Z of J.agent.liveBindIds){if(Q.turns.has(Z))continue;let Y=o.get(Z),X=Y?{...Y,eventSeq:Y.eventSeq+1}:null,K=await p(Q,J.agent,Z).catch((C)=>X?s(C,X,"vm_hands_bind_lost"):null);if(K&&X)Q.receipts.push({turn:X,failure:"vm_hands_bind_lost",unbound:K});z("vm_hands.bound_dropped",{reason:"bound_after_loss"})}for(let Z of zJ)Z.abort()}return{closeCode:O,closeReason:T};async function UJ(Z,Y){if(Z instanceof V){if(!$J&&Q.turns.size)Q.lostAt=Date.now();$J=!0}else{let X=Y!==null?[Y]:[...new Set([...Q.turns.keys(),...J.agent.liveBindIds])];if(Y===null)$J=!0;for(let K of X){let C=Q.turns.get(K);if(Q.turns.delete(K),C)QJ(C),J.onTurn?.(K,null);if(J.agent.liveBindIds.includes(K)){let E=o.get(K)??C,B=E?{...E,eventSeq:E.eventSeq+1}:null,G=await p(Q,J.agent,K).catch((W)=>B?s(W,B,"vm_hands_bind_lost"):null);if(G&&B)Q.receipts.push({turn:B,failure:"vm_hands_bind_lost",unbound:G})}}}z("vm_hands.session_lost",{error:Z instanceof Error?Z.message:String(Z),bound_kept:Q.turns.size})}function h(Z){let Y=Z.claim,X={attempt_id:Y.attempt_id,attempt_token:Y.attempt_token},K=encodeURIComponent(Y.operation_id);return{fence:X,op:K,complete:(E,B={})=>k(`/operations/${K}/complete`,{...X,status:E,...B}),emit:(E,B)=>{let G=(Z.chain??Promise.resolve()).catch(()=>{return}).then(()=>C(E,B));return Z.chain=G,G}};async function C(E,B){let G=Z.eventSeq,W=(x)=>k(`/operations/${K}/events`,{...X,event_seq_start:x,events:[{kind:E,payload:{sequence:x,capability:String(Y.capability??"hands.connect"),data:B}}]}),P=G,M=await W(P),q=M.status===409?M.json?.expected_event_seq:void 0;if(typeof q==="number"&&q===G+1)M={status:200,json:{duplicate:!0}};else if(typeof q==="number"&&q>=0&&q!==G)P=q,M=await W(P);if(M.status<300)Z.eventSeq=P+1;return M}}function cJ(Z){return(Y,X)=>new Promise((K,C)=>{if(Q.turns.get(Z.claim.attempt_id)!==Z){C(Error("vm_hands_attempt_ended"));return}if(Z.outbox??=[],Z.outbox.length>=LQ){C(Error("vm_hands_outbox_full"));return}Z.outbox.push({kind:Y,data:X,resolve:K,reject:C}),Z.flush?.()})}function EJ(Z){if(XJ.has(Z))return;XJ.add(Z),(async()=>{try{while(Z.outbox?.length&&Q.turns.get(Z.claim.attempt_id)===Z&&N.readyState===WebSocket.OPEN){let Y=Z.outbox[0],X;try{X=await h(Z).emit(Y.kind,Y.data)}catch(K){if(K instanceof V)return;X={status:500}}if(Z.outbox.shift(),X.status<300)Y.resolve();else Y.reject(Error(`${Y.kind} refused ${X.status}`))}}finally{XJ.delete(Z)}})()}async function pJ(Z,Y){try{let X=await J.agent.attestFrame(Z,Y);if(N.readyState!==WebSocket.OPEN)return;u(X);let K=await l(["attested","attest_refused"],15000);Q.attest=K.t==="attested"?"accepted":"refused";for(let C of Q.attestWaiters.splice(0))C(Q.attest==="accepted");if(z("vm_hands.attest",{result:Q.attest,exit_code:X.exit_code,...K.t==="attest_refused"?{code:String(K.code??"")}:{}}),Q.attest==="refused")N.close(4401,"attest_refused")}catch(X){z("vm_hands.attest_failed",{code:X instanceof F?X.code:"probe_error"});for(let K of Q.attestWaiters.splice(0))K(!1);if(Q.attest!=="accepted")N.close(4000,"attest_unanswered")}}async function lJ(Z){let Y=i&&Q.attest==="pending",X=Z.vm_hands_attest,K=X;if(Q.attest==="refused"){z("vm_hands.claim_attest_refused",{said:typeof X==="string"?X.slice(0,16):typeof X,local:Q.attest}),await h({claim:Z,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(K==="accepted"){if(!Y&&Q.attest!=="accepted"){Q.attest="accepted";for(let _ of Q.attestWaiters.splice(0))_(!0)}}else if(K!=="pending"||!Y&&Q.attest!=="accepted"){z("vm_hands.claim_attest_refused",{said:typeof X==="string"?X.slice(0,16):typeof X,local:Q.attest}),await h({claim:Z,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(Q.attest!=="accepted"){let _=Date.parse(Z.lease_until)-Date.now()-5000,H=Math.max(0,Math.min(JJ,Number.isFinite(_)?_:JJ));if(!await new Promise((n)=>{let sJ=setTimeout(()=>n(!1),H);Q.attestWaiters.push((rJ)=>{clearTimeout(sJ),n(rJ)})})){await h({claim:Z,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}}let C={claim:Z,eventSeq:0},{complete:E,emit:B}=h(C),G;try{if(Z.capability!=="hands.connect")throw new F("vm_hands_bind_invalid","not hands.connect");G=!FJ(Z)}catch(_){z("vm_hands.bind_refused",{code:_ instanceof F?_.code:"unexpected"}),await E("failed",{error_code:_ instanceof F?_.code:"vm_hands_bind_invalid"});return}let W,P=null,M=!1;Q.bindsStarting++;try{let _=await _Q(Q);if(_)z("vm_hands.person_terminals_closed",{count:_});let H=SJ(Z),a=J.agent.bind(H);if(H.workspace_deferred)M=!0,P=uJ(C,()=>M);W=await a}catch(_){z("vm_hands.bind_refused",{code:_ instanceof F?_.code:"unexpected"}),await E("failed",{error_code:_ instanceof F?_.code:"vm_hands_bind_failed"});return}finally{M=!1,Q.bindsStarting--}let q=P?await P:-1,x={...W.ready_data??J.readyData({launchId:W.launch_id,claim:Z})};if(G)delete x.environment_installed;let GJ=!G&&W.snapshot_revision!==null&&W.snapshot_id!==null?{environment_installed:{snapshot_id:W.snapshot_id,installed_revision:W.snapshot_revision}}:{};o.set(Z.attempt_id,{claim:Z,launchId:W.launch_id,readyData:x,eventSeq:C.eventSeq,ackSeq:-1});let g={...x,...GJ,vm_hands:{layout:W.layout,policy_digest:W.policy_digest,launch_id:W.launch_id}},f=Date.now()+EQ,R=1,j=await B("hands.ready",g);while(BQ(j.status)&&!J.signal.aborted){let _=fJ(R);if(Date.now()+_>=f)break;await new Promise((H)=>setTimeout(H,_)),R++,j=await B("hands.ready",g)}if(R>1)z("vm_hands.ready_retried",{attempts:R,status_class:`${Math.floor(j.status/100)}xx`});if(o.delete(Z.attempt_id),j.status>=300){await bJ(Q,Z.attempt_id),await J.agent.boundRefused(Z.attempt_id),await E("failed",{error_code:HJ(j.json?.error,"vm_hands_probe_failed")});return}let S={claim:Z,launchId:W.launch_id,readyData:x,eventSeq:C.eventSeq,ackSeq:q};Q.turns.set(Z.attempt_id,S),S.flush=()=>EJ(S),J.onTurn?.(Z.attempt_id,cJ(S)),await BJ(S)}async function uJ(Z,Y){let{fence:X,op:K}=h(Z),C=Z.claim.attempt_id,E=-1;try{for(;;){let B=await k(`/operations/${K}/heartbeat`,{...X,control_ack_seq:E,wait_ms:hJ});if(!Y())return E;if(B.status>=300)return J.agent.abandonWorkspaceGrant(C),E;let G=(B.json?.controls??[]).slice().sort((W,P)=>W.seq-P.seq);for(let W of G){if(W.seq<=E)continue;if(E=W.seq,W.kind===RJ)return z("vm_hands.workspace_granted",{}),J.agent.grantWorkspace(C),E;return z("vm_hands.workspace_grant_abandoned",{control:/^[a-z][a-z0-9._-]{0,63}$/.test(W.kind)?W.kind:"other"}),J.agent.abandonWorkspaceGrant(C),E}}}catch{return J.agent.abandonWorkspaceGrant(C),E}}async function BJ(Z){let{fence:Y,op:X}=h(Z),K=null,C=null,E=J.agent.executorExited(Z.claim.attempt_id).then((B)=>{return C=B,null});J:for(;;){let B=await Promise.race([E,k(`/operations/${X}/heartbeat`,{...Y,control_ack_seq:Z.ackSeq,wait_ms:hJ})]);if(!B){K="vm_hands_executor_exited",z("vm_hands.executor_exited",{reason:C});break}if(B.status>=300)break;let G=(B.json?.controls??[]).slice().sort((W,P)=>W.seq-P.seq);for(let W of G){if(W.seq<=Z.ackSeq)continue;if(W.kind==="operation.cancel"||W.kind==="cancel"){Z.ackSeq=W.seq;break J}if(W.kind===gJ)try{await iJ(Z,W.payload??{})}catch(P){if(P instanceof V)throw P;K=P instanceof F?P.code:"environment_unavailable";let M=P&&typeof P==="object"&&"code"in P&&typeof P.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(P.code)?P.code:null;z("vm_hands.environment_refused",{code:K,cause:M});break J}Z.ackSeq=W.seq}}await dJ(Z,K)}async function oJ(Z){let Y=Z,X={claim:Y,eventSeq:0},{complete:K,emit:C,fence:E,op:B}={...h(X)},G=Z.vm_hands_origin==="person"?"person":"model",W=String(Z.capability??"");if(!J.executeOp){await K("failed",{error_code:"vm_hands_op_unsupported"});return}if(Z.vm_hands_attest==="accepted"&&Q.attest==="pending"&&!(i&&Q.attest==="pending")){Q.attest="accepted";for(let j of Q.attestWaiters.splice(0))j(!0)}if(Q.attest!=="accepted"){let j=Date.parse(String(Z.lease_until??""))-Date.now()-5000,S=Q.attest==="refused"?0:Math.max(0,Math.min(JJ,Number.isFinite(j)?j:JJ));if(!(S>0&&await new Promise((H)=>{let a=setTimeout(()=>H(!1),S);Q.attestWaiters.push((n)=>{clearTimeout(a),H(n)})}))){await K("failed",{error_code:"vm_hands_unattested"});return}}let P=J.agent.bindIdForRun(Y.run_id);if(G==="model"&&P===null){await K("failed",{error_code:"vm_hands_not_bound"});return}let M=W==="pty.start"&&G==="person"&&!Z.authority;if(M&&(J.agent.liveBindIds.length>0||Q.bindsStarting>0)){await K("failed",{error_code:"vm_hands_bound"});return}if(kJ.has(W)&&!M&&J.agent.liveBindIds.length===0){await K("failed",{error_code:"vm_hands_not_bound"});return}if(G==="model"&&P||kJ.has(W)&&!M)J.agent.opServed();let q=new AbortController;zJ.add(q);let x,GJ=new Promise((j)=>{x=j}),g={abort:q,settled:GJ};if(M)Q.personTerminals.add(g);if(G==="model"&&P){let j=Q.modelOps.get(P)??new Set;j.add(g),Q.modelOps.set(P,j),await J.agent.environmentInstalled(P,WQ,q.signal)}let f=-1,R=setInterval(()=>{k(`/operations/${B}/heartbeat`,{...E,control_ack_seq:f,wait_ms:0}).then((j)=>{if(j.status>=300){q.abort();return}let S=j.json?.controls??[];for(let _ of S)if(f=Math.max(f,_.seq),_.kind==="operation.cancel"||_.kind==="cancel")q.abort()},()=>q.abort())},GQ);try{let j=await J.executeOp({kind:G,claim:Z,...G==="model"&&P?{bindId:P}:{},signal:q.signal,emit:async(_)=>{await C(_.kind,_.data??{})}}),S=await K(j.status,{...j.result?{result:j.result}:{},...j.error_code?{error_code:HJ(j.error_code,"vm_hands_op_failed")}:{}});z("vm_hands.op",{capability:W,kind:G,status:j.status,code:j.error_code??null,...S.status>=300?{complete_status:S.status,complete_error:String(S.json?.error??"").slice(0,64)}:{}})}finally{if(clearInterval(R),zJ.delete(q),P)Q.modelOps.get(P)?.delete(g);Q.personTerminals.delete(g),x()}}async function dJ(Z,Y){let X=Z.claim.attempt_id;if(Q.turns.get(X)===Z)Q.turns.delete(X);J.onTurn?.(X,null),QJ(Z);let K=await p(Q,J.agent,X).catch((C)=>s(C,Z,Y));if(!K)return;Q.receipts.push({turn:Z,failure:Y,unbound:K}),await r()}function s(Z,Y,X){let K=mJ(Z);return z("vm_hands.unbind_unverified",{operation_id:Y.claim.operation_id,code:K,attempt:0}),h(Y).emit(IJ,{code:K}).catch(()=>{return}),AQ(Q,J.agent,{turn:Y,failure:X},J.signal,z),null}function r(){return YJ=YJ.then(LJ,LJ),YJ}async function LJ(){while(Q.receipts.length){let{turn:Z,failure:Y,unbound:X}=Q.receipts[0],{complete:K,emit:C}=h(Z);try{if(await C("hands.stopped",{...Z.readyData,reason_code:Y?"failed":"cancelled",killed_verified:X.killed_verified,shredded:X.shredded,...X.srt_fallbacks?{vm_hands_srt_fallbacks:X.srt_fallbacks}:{}}),Y)await K("failed",{error_code:Y});else await K("cancelled",{error_code:"driver_stopped"})}catch(E){if(E instanceof V)return}Q.receipts.shift()}}async function iJ(Z,Y){let{fence:X,op:K}=h(Z),C=Y.snapshot_id;if(Y.version!==1||typeof C!=="string"||Object.keys(Y).length!==2)throw new F("vm_hands_env_invalid","invalid environment delivery");let E=await k(`/operations/${K}/environment`,{...X,snapshot_id:C}),B=E.json?.environment_sealed;if(E.status!==200||!B||E.json?.payload!==void 0)throw new F("vm_hands_env_invalid","environment not delivered sealed");let G=await J.agent.deliverEnvironment({attemptId:Z.claim.attempt_id,snapshotId:C,deviceId:Q.deviceId??"",sealed:B});if((await k(`/operations/${K}/environment-ack`,{...X,...G})).status>=300)throw new F("vm_hands_env_ack_refused","environment ack refused")}}
5
+ export{SQ as xa,ZQ as ya,vQ as za};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Sd as ae,Ud as ne}from"./vm-hands-entry-lite-6wsa0qrb.js";import{vf as be}from"./vm-hands-entry-lite-5n4vsm6b.js";import{$f as z,Tf as C,Uf as ie,Wf as M,Xf as Oe,_f as Y,ag as v,jg as O,kg as Be}from"./vm-hands-entry-lite-vj9h1knv.js";import{Rg as Se}from"./vm-hands-entry-lite-fb5dzy9x.js";import{Gi as se}from"./vm-hands-entry-lite-7a01dgje.js";import{fj as J}from"./vm-hands-entry-lite-wc6skbhf.js";import{lj as x}from"./vm-hands-entry-lite-fyvgav60.js";import{ck as Ne,dk as oe}from"./vm-hands-entry-lite-1gxktkpe.js";import{jk as ye,pk as Ie}from"./vm-hands-entry-lite-rd0ak4ye.js";import{wk as xe}from"./vm-hands-entry-lite-r8qg3wp1.js";import{Ek as p}from"./vm-hands-entry-lite-51hmj6am.js";import{spawn as S,spawnSync as pt}from"child_process";import{createHash as ft,randomUUID as Te}from"crypto";import{closeSync as mt,copyFileSync as de,existsSync as q,fstatSync as _t,mkdirSync as pe,openSync as ht,readdirSync as D,readFileSync as j,readlinkSync as wt,renameSync as ve,rmSync as gt,statSync as bt,writeFileSync as xt}from"fs";import{connect as St}from"net";import{tmpdir as F,userInfo as Re}from"os";import{basename as fe,delimiter as yt,dirname as B,join as f}from"path";var Z=`import { spawn, execFileSync } from "node:child_process";
2
+ import{Sd as ae,Ud as ne}from"./vm-hands-entry-lite-73akm1q1.js";import{wf as be}from"./vm-hands-entry-lite-02zaqpgh.js";import{$f as Y,Uf as C,Vf as ie,Xf as M,Yf as Oe,ag as z,bg as v,kg as O,lg as Be}from"./vm-hands-entry-lite-w844s03h.js";import{Sg as Se}from"./vm-hands-entry-lite-hfv2tsm9.js";import{Hi as se}from"./vm-hands-entry-lite-vvv3m6wy.js";import{gj as J}from"./vm-hands-entry-lite-wxzh22y4.js";import{mj as x}from"./vm-hands-entry-lite-5x04hakp.js";import{dk as Ne,ek as oe}from"./vm-hands-entry-lite-ebgackey.js";import{kk as ye,qk as Ie}from"./vm-hands-entry-lite-p1s0xyc2.js";import{xk as xe}from"./vm-hands-entry-lite-fb02h1zm.js";import{Gk as p}from"./vm-hands-entry-lite-g87z5eb6.js";import{spawn as S,spawnSync as pt}from"child_process";import{createHash as ft,randomUUID as Te}from"crypto";import{closeSync as mt,copyFileSync as de,existsSync as q,fstatSync as _t,mkdirSync as pe,openSync as ht,readdirSync as D,readFileSync as j,readlinkSync as wt,renameSync as ve,rmSync as gt,statSync as bt,writeFileSync as xt}from"fs";import{connect as St}from"net";import{tmpdir as F,userInfo as Re}from"os";import{basename as fe,delimiter as yt,dirname as B,join as f}from"path";var Z=`import { spawn, execFileSync } from "node:child_process";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var n=Object.create;var{getPrototypeOf:o,defineProperty:e,getOwnPropertyNames:k,getOwnPropertyDescriptor:p}=Object,l=Object.prototype.hasOwnProperty;function m(a){return this[a]}var q,r,u=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var h=b?q??=new WeakMap:r??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?n(o(a)):{};let f=b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c;for(let g of k(a))if(!l.call(f,g))e(f,g,{get:m.bind(a,g),enumerable:!0});if(d)h.set(a,f);return f},v=(a)=>{var b=(j??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of k(a))if(!l.call(b,d))e(b,d,{get:m.bind(a,d),enumerable:!(c=p(a,d))||c.enumerable})}return j.set(a,b),b},j,w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=(a)=>a;function t(a,b){this[a]=s.bind(null,b)}var x=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:t.bind(b,c)})};var y=(a,b)=>()=>(a&&(b=a(a=0)),b);var z=import.meta.require;
3
- export{u as Fk,v as Gk,w as Hk,x as Ik,y as Jk,z as Kk};
3
+ export{u as Hk,v as Ik,w as Jk,x as Kk,y as Lk,z as Mk};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Ek as D}from"./vm-hands-entry-lite-8e932j3c.js";import{Fk as M}from"./vm-hands-entry-lite-88h9vwrv.js";import{execFileSync as A}from"child_process";import{realpathSync as U,statSync as F}from"fs";import{tmpdir as j}from"os";import{createRequire as I}from"module";import{win32 as Z}from"path";var J=["/bin/bash","/usr/bin/bash"],u="Git Bash was not found. Install Git for Windows (https://git-scm.com/download/win), then run `reason connect`.";function k(K){try{return F(K).isFile()}catch{return!1}}var q=(K)=>[Z.join(K,"bin","bash.exe"),Z.join(K,"usr","bin","bash.exe")];function O(K,Q){let L=Z.normalize(K).toLowerCase(),Y=(Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows").toLowerCase();return L.startsWith(Z.join(Y,"system32").toLowerCase()+"\\")||L.startsWith(Z.join(Y,"sysnative").toLowerCase()+"\\")||L.includes("\\windowsapps\\")}function C(K=process.env,Q=k){let L=[];for(let Y of(K.PATH??K.Path??"").split(";"))if(Y&&Z.isAbsolute(Y))L.push(Z.join(Y,"git.exe"));for(let Y of[K.ProgramW6432,K.ProgramFiles,K["ProgramFiles(x86)"]])if(Y)L.push(Z.join(Y,"Git","cmd","git.exe"));if(K.LOCALAPPDATA)L.push(Z.join(K.LOCALAPPDATA,"Programs","Git","cmd","git.exe"));return L.find(Q)??null}var T;function w(K=process.platform){if(K!=="win32")return"git";return T??=C(),T}function P(K){let Q=process.platform==="win32"?C(K):"git";if(!Q)return null;try{return A(Q,["--exec-path"],{encoding:"utf8",timeout:5000,windowsHide:!0,stdio:["ignore","pipe","ignore"],env:K}).trim()||null}catch{return null}}function G(K=process.env,Q=P,L=k){let Y=[],H=Q(K);if(H)Y.push(...q(Z.resolve(H,"..","..","..")));for(let $ of[K.ProgramW6432,K.ProgramFiles,K["ProgramFiles(x86)"]])if($)Y.push(...q(Z.join($,"Git")));if(K.LOCALAPPDATA)Y.push(...q(Z.join(K.LOCALAPPDATA,"Programs","Git")));for(let $ of(K.PATH??K.Path??"").split(";"))if($&&Z.isAbsolute($))Y.push(Z.join($,"bash.exe"));return Y.find(($)=>!O($,K)&&L($))??null}var z;function W(K=process.platform){if(K!=="win32")return J.find(k)??null;return z??=G(),z}function f(K=process.platform){let Q=W(K);if(!Q)throw Error(K==="win32"?u:"bash_unavailable");return Q}function h(K=process.platform){return U(K==="win32"?j():"/tmp")}function X(K=process.platform,Q=process.env){if(K!=="win32")return"/usr/bin:/bin";let L=Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows";return[Z.join(L,"System32"),L,Z.join(L,"System32","Wbem"),Z.join(L,"System32","WindowsPowerShell","v1.0")].join(";")}function _(K,Q=process.platform){if(Q!=="win32"||/[\\/]/.test(K))return K;let L=/\.exe$/i.test(K)?K:`${K}.exe`,Y=X(Q).split(";");return Z.join(L.toLowerCase()==="powershell.exe"?Y[3]:Y[0],L)}function v(K=process.platform,Q=process.env){if(K!=="win32")return{PATH:X(K)};let L=Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows";return{PATH:X(K,Q),SystemRoot:L,WINDIR:L}}function c(K=process.platform){return K==="win32"?{windowsHide:!0}:{detached:!0}}var V;function N(){if(V===void 0)V=D(M)(I(import.meta.url));return V}function p(K,Q=process.platform){let L=K.pid;if(Q!=="win32"||L===void 0)return;let Y=N();if(Y?.track(L))K.once("close",()=>Y.release(L))}function l(K,Q="SIGTERM",L=process.platform){if(L!=="win32"){process.kill(-K,Q);return}if(Q===0){process.kill(K,0);return}if(N()?.terminate(K))return;A(_("taskkill",L),["/PID",String(K),"/T","/F"],{stdio:"ignore",timeout:1e4,windowsHide:!0})}function d(K,Q=63,L=process.platform){return L==="win32"||K.uid===process.getuid?.()&&(K.mode&Q)===0}var x=/^(?:con|prn|aux|nul|com[0-9\u00b9\u00b2\u00b3]|lpt[0-9\u00b9\u00b2\u00b3]|conin\$|conout\$)(?:\..*)?$|:|[. ]$/i;function s(K){return K!=="."&&K!==".."&&x.test(K)}
3
+ export{u as rk,w as sk,W as tk,f as uk,h as vk,X as wk,_ as xk,v as yk,c as zk,p as Ak,l as Bk,d as Ck,s as Dk};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  class o extends Error{code;constructor(a,r){super(r);this.code=a;this.name="LocalCapabilityError"}}
3
- export{o as Ek};
3
+ export{o as Gk};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Vi as I}from"./vm-hands-entry-lite-sex82vb1.js";import{Ak as g,sk as R,vk as U,yk as C,zk as O}from"./vm-hands-entry-lite-r8qg3wp1.js";import{spawn as S}from"child_process";import{existsSync as x,mkdirSync as T,readFileSync as w,writeFileSync as E}from"fs";import{homedir as H}from"os";import{basename as L,delimiter as D,join as G,win32 as $}from"path";var N=process.platform==="win32"?U("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",b=N.split(D),_=5000,j=65536,k=new Set(["zsh","bash"]),f=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],P=(z,J)=>new Promise((B,Q)=>{let K;try{K=S(z,[...J],{...C(),stdio:["ignore","pipe","ignore"]}),O(K)}catch(X){Q(X);return}let W=[],V=0,Z=null,q=(X)=>{Z??=Error(X);try{if(K.pid!==void 0)g(K.pid,"SIGKILL")}catch{}},F=setTimeout(()=>q("login_shell_timeout"),_);K.stdout?.on("data",(X)=>{if(V+=X.length,V>j)q("login_shell_output_too_large");else W.push(X)}),K.once("error",(X)=>{clearTimeout(F),Q(X)}),K.once("close",(X)=>{if(clearTimeout(F),Z)Q(Z);else if(X!==0)Q(Error("login_shell_exit_nonzero"));else B(Buffer.concat(W).toString("utf8"))})});function v(z){return typeof z==="string"&&z.startsWith("/")&&!z.includes("\x00")&&k.has(L(z))}function M(z){let J=new Set,B=[];for(let Q of z){if(J.has(Q))continue;J.add(Q),B.push(Q)}return B}function A(z,J=process.platform){let B=J==="win32",Q=z.split(`
2
+ import{Wi as I}from"./vm-hands-entry-lite-mft9ke08.js";import{Ak as O,Bk as g,tk as R,wk as U,zk as C}from"./vm-hands-entry-lite-fb02h1zm.js";import{spawn as S}from"child_process";import{existsSync as x,mkdirSync as T,readFileSync as w,writeFileSync as E}from"fs";import{homedir as H}from"os";import{basename as L,delimiter as D,join as G,win32 as $}from"path";var N=process.platform==="win32"?U("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",b=N.split(D),_=5000,j=65536,k=new Set(["zsh","bash"]),f=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],P=(z,J)=>new Promise((B,Q)=>{let K;try{K=S(z,[...J],{...C(),stdio:["ignore","pipe","ignore"]}),O(K)}catch(X){Q(X);return}let W=[],V=0,Z=null,q=(X)=>{Z??=Error(X);try{if(K.pid!==void 0)g(K.pid,"SIGKILL")}catch{}},F=setTimeout(()=>q("login_shell_timeout"),_);K.stdout?.on("data",(X)=>{if(V+=X.length,V>j)q("login_shell_output_too_large");else W.push(X)}),K.once("error",(X)=>{clearTimeout(F),Q(X)}),K.once("close",(X)=>{if(clearTimeout(F),Z)Q(Z);else if(X!==0)Q(Error("login_shell_exit_nonzero"));else B(Buffer.concat(W).toString("utf8"))})});function v(z){return typeof z==="string"&&z.startsWith("/")&&!z.includes("\x00")&&k.has(L(z))}function M(z){let J=new Set,B=[];for(let Q of z){if(J.has(Q))continue;J.add(Q),B.push(Q)}return B}function A(z,J=process.platform){let B=J==="win32",Q=z.split(`
3
3
  `).at(-1)??"",K=[];for(let W of Q.split(B?";":":")){let V=W.trim();if(B?!$.isAbsolute(V):!V.startsWith("/"))continue;if(V.includes("\x00"))continue;if(I(V))continue;K.push(V)}return M(K)}function y(z){let J=z?.home??H(),B=z?.directoryExists??x,Q=f.map((K)=>G(J,...K)).filter((K)=>{try{return B(K)}catch{return!1}});return M([...Q,...process.platform==="win32"?A(process.env.PATH??process.env.Path??""):[],...b]).join(D)}async function d(z){let J=z?.shell??process.env.SHELL,B=()=>({path:y({home:z?.home,directoryExists:z?.directoryExists}),source:"fallback"});if(process.platform==="win32"||!v(J))return B();let Q;try{Q=await(z?.runLoginShell??P)(J,["-lic",'printf %s "$PATH"'])}catch{return B()}if(Buffer.byteLength(Q,"utf8")>j)return B();let K=A(Q);if(K.length===0)return B();return{path:M([...K,...b]).join(":"),source:"login_shell"}}function n(z){let J=null;return()=>{return J??=d(z),J}}function Y(z){if(z===void 0||z.includes("\x00")||Buffer.byteLength(z,"utf8")>32768)return;return z}function r(z){let J=z.source??process.env,B={HOME:z.home,PATH:z.path??N,TMPDIR:z.temporaryDirectory,SHELL:Y(J.SHELL)??"/bin/zsh",LANG:Y(J.LANG)??"C.UTF-8",LC_ALL:Y(J.LC_ALL)??Y(J.LANG)??"C.UTF-8"},Q=Y(J.LC_CTYPE),K=Y(J.TERM),W=Y(J.COLORTERM);if(Q)B.LC_CTYPE=Q;if(K)B.TERM=K;if(W)B.COLORTERM=W;if(process.platform==="win32"){for(let V of h){let Z=Y(J[V]);if(Z)B[V]=Z}B.TEMP=B.TMP=z.temporaryDirectory,B.SHELL=R()??B.SHELL,B.PATH=m(B.PATH)}return B}function m(z,J=G(H(),".reason","python3")){let B=(W)=>z.split($.delimiter).filter((V)=>V&&!/[\\/]WindowsApps[\\/]?$/i.test(V)).map((V)=>$.join(V,W)).find((V)=>x(V)),Q=B("python.exe");if(B("python3.exe")||!Q)return z;let K=`#!/bin/sh
4
4
  exec "${Q.replaceAll("\\","/")}" "$@"
5
5
  `;try{let W=G(J,"python3");if(!x(W)||w(W,"utf8")!==K)T(J,{recursive:!0}),E(W,K)}catch{return z}return[J,z].join($.delimiter)}var h=["SystemRoot","SystemDrive","windir","ComSpec","PATHEXT","USERPROFILE","USERNAME","USERDOMAIN","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","CommonProgramFiles","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","OS"];
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{lj as J}from"./vm-hands-entry-lite-fyvgav60.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
2
+ import{mj as J}from"./vm-hands-entry-lite-5x04hakp.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
3
3
  `)){let j=I.split(":");if(j.length<7||Number(j[2])!==q||!/^\d+$/.test(j[2])||!/^\d+$/.test(j[3]))continue;let x=j[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(j[0])||!M(x)||Q(x)!==x||x==="/")return null;return{username:j[0],uid:q,gid:Number(j[3]),home:x}}return null}function b(q={}){let B="value"in q?q.value:process.env[W];if(G=null,B===void 0||B==="")return null;let I=q.platform??process.platform,j="euid"in q?q.euid:process.geteuid?.(),x=/^[1-9]\d{0,9}$/.test(B)?Number(B):NaN,C=I==="linux"&&j===0&&Number.isSafeInteger(x)?X(x,(q.passwd??(()=>L("/etc/passwd","utf8")))()):null;if(!C||C.gid===0)throw Error("worker_desktop_user_invalid");return G=C,C}function k(){return G}function y(){return G?.home??J()}
4
- export{W as Og,X as Pg,b as Qg,k as Rg,y as Sg};
4
+ export{W as Pg,X as Qg,b as Rg,k as Sg,y as Tg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Pj as $}from"./vm-hands-entry-lite-ew076kpd.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
3
- export{O as Lj,Z as Mj,S as Nj,k as Oj};
2
+ import{Qj as $}from"./vm-hands-entry-lite-8q63t2c0.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
3
+ export{O as Mj,Z as Nj,S as Oj,k as Pj};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var p={REASON_API_KEY:"ARA_API_KEY",REASON_API_URL:"ARA_API_URL",REASON_CLI_CHANNEL:"ARA_CLI_CHANNEL",REASON_CLI_LAUNCHER_PATH:"ARA_CLI_LAUNCHER_PATH",REASON_MANAGED_RUNTIME_ROOT:"ARA_MANAGED_RUNTIME_ROOT",REASON_INSTALL_ALIAS_PATH:"ARA_INSTALL_ALIAS_PATH",REASON_INSTALL_DIR:"ARA_INSTALL_DIR",REASON_INSTALL_METHOD:"ARA_INSTALL_METHOD",REASON_INSTALL_PINNED_VERSION:"ARA_INSTALL_PINNED_VERSION",REASON_INSTALL_UPGRADE:"ARA_INSTALL_UPGRADE"},z=Object.values(p),x=new Set;function B(k,j){let q=k[j];if(q?.trim())return q;let w=k[p[j]];if(w?.trim())x.add(p[j]);return w}function D(k,j){return{[k]:j,[p[k]]:j}}
3
- export{B as Ci,D as Di};
3
+ export{B as Di,D as Ei};