@reason-machines/cli-linux-arm64 0.2.565 → 0.2.567

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 (123) hide show
  1. package/bin/reason +1 -1
  2. package/bin/vm-hands/agent-network-0sng03r6.js +2 -0
  3. package/bin/vm-hands/api-credentials-h4neeejt.js +2 -0
  4. package/bin/vm-hands/api-mr6xds10.js +2 -0
  5. package/bin/vm-hands/{ask-relay-v5btnjvb.js → ask-relay-c0v30hh6.js} +2 -2
  6. package/bin/vm-hands/connect-cli-jc4m755k.js +2 -0
  7. package/bin/vm-hands/credentials-nfx99zxr.js +2 -0
  8. package/bin/vm-hands/custom-endpoint-device-5047vdn3.js +2 -0
  9. package/bin/vm-hands/desktop-account-d1g1m6yb.js +2 -0
  10. package/bin/vm-hands/desktop-components-7ngf8byq.js +2 -0
  11. package/bin/vm-hands/desktop-delegate-4hb0163k.js +2 -0
  12. package/bin/vm-hands/device-workspace-8941tdsy.js +2 -0
  13. package/bin/vm-hands/{fsevents-ezcg3e40.js → fsevents-e57jgcfe.js} +1 -1
  14. package/bin/vm-hands/hands-worker-source-8a4kh44t.js +2 -0
  15. package/bin/vm-hands/{index-w92ys6ra.js → index-y21r07rf.js} +8 -8
  16. package/bin/vm-hands/install-receipt-rckwjqmt.js +2 -0
  17. package/bin/vm-hands/local-automation-3mdhfw08.js +2 -0
  18. package/bin/vm-hands/local-capabilities-6e0gkrqq.js +2 -0
  19. package/bin/vm-hands/local-desktop-users-hkdfxqtj.js +2 -0
  20. package/bin/vm-hands/local-display-mac-gsh74khc.js +2 -0
  21. package/bin/vm-hands/local-display-session-r6s0wghh.js +2 -0
  22. package/bin/vm-hands/local-display-video-61peg1pj.js +2 -0
  23. package/bin/vm-hands/local-managed-process-p8xd7m5f.js +2 -0
  24. package/bin/vm-hands/local-pty-session-w0yhjdvz.js +2 -0
  25. package/bin/vm-hands/managed-runtime-4s8q8r7f.js +2 -0
  26. package/bin/vm-hands/{network-auto-update-3m94436w.js → network-auto-update-wep7067g.js} +2 -2
  27. package/bin/vm-hands/network-contract-ht0psj5j.js +2 -0
  28. package/bin/vm-hands/{network-sign-in-xm79s170.js → network-sign-in-rdnerhpz.js} +2 -2
  29. package/bin/vm-hands/package-3rv6jngd.js +2 -0
  30. package/bin/vm-hands/permissions-mmg1gbdx.js +2 -0
  31. package/bin/vm-hands/reason-hands-protocol-9r62swp0.js +2 -0
  32. package/bin/vm-hands/serve-service-k3mpxpj6.js +2 -0
  33. package/bin/vm-hands/{status-89999mdn.js → status-2s3zjapg.js} +5 -5
  34. package/bin/vm-hands/version-41q9twfs.js +2 -0
  35. package/bin/vm-hands/{vm-hands-entry-lite-pg7nnyc6.js → vm-hands-entry-lite-04nx5y4f.js} +2 -2
  36. package/bin/vm-hands/{vm-hands-entry-lite-1xhpn3hw.js → vm-hands-entry-lite-07wr95rz.js} +3 -3
  37. package/bin/vm-hands/{vm-hands-entry-lite-33at6g06.js → vm-hands-entry-lite-0xfme8gg.js} +2 -2
  38. package/bin/vm-hands/{vm-hands-entry-lite-xfak34av.js → vm-hands-entry-lite-1as6h9ed.js} +4 -4
  39. package/bin/vm-hands/{vm-hands-entry-lite-gxf2r5en.js → vm-hands-entry-lite-1cdtev4n.js} +1 -1
  40. package/bin/vm-hands/{vm-hands-entry-lite-fn2805g8.js → vm-hands-entry-lite-1sy80ca9.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-yg4dk99m.js → vm-hands-entry-lite-2927z566.js} +1 -1
  42. package/bin/vm-hands/{vm-hands-entry-lite-ngn4tafr.js → vm-hands-entry-lite-298kzt93.js} +70 -70
  43. package/bin/vm-hands/{vm-hands-entry-lite-3q2ng4e9.js → vm-hands-entry-lite-3594pdj0.js} +2 -2
  44. package/bin/vm-hands/{vm-hands-entry-lite-7r27208j.js → vm-hands-entry-lite-3r063pb4.js} +2 -2
  45. package/bin/vm-hands/{vm-hands-entry-lite-2qfmabqn.js → vm-hands-entry-lite-4kb5rq3d.js} +3 -3
  46. package/bin/vm-hands/{vm-hands-entry-lite-bsk184m7.js → vm-hands-entry-lite-6g9we34r.js} +3 -3
  47. package/bin/vm-hands/{vm-hands-entry-lite-s93f3pbv.js → vm-hands-entry-lite-732hnx41.js} +3 -3
  48. package/bin/vm-hands/vm-hands-entry-lite-7aeqbfc8.js +3 -0
  49. package/bin/vm-hands/{vm-hands-entry-lite-y0jtj8zz.js → vm-hands-entry-lite-8twdd0ff.js} +1 -1
  50. package/bin/vm-hands/{vm-hands-entry-lite-432khjd5.js → vm-hands-entry-lite-9gn7k5rp.js} +5 -5
  51. package/bin/vm-hands/{vm-hands-entry-lite-t43bz0ey.js → vm-hands-entry-lite-ax2w9ywb.js} +3 -3
  52. package/bin/vm-hands/{vm-hands-entry-lite-1eyg750p.js → vm-hands-entry-lite-b3mfma12.js} +4 -4
  53. package/bin/vm-hands/{vm-hands-entry-lite-qjrgvdbj.js → vm-hands-entry-lite-bbjsnjct.js} +21 -21
  54. package/bin/vm-hands/{vm-hands-entry-lite-zp7chzcc.js → vm-hands-entry-lite-bc9zq8gx.js} +1 -1
  55. package/bin/vm-hands/{vm-hands-entry-lite-ngry8nkq.js → vm-hands-entry-lite-bqs4pkyb.js} +4 -4
  56. package/bin/vm-hands/{vm-hands-entry-lite-zpvr7wc6.js → vm-hands-entry-lite-bt6skt4h.js} +2 -2
  57. package/bin/vm-hands/{vm-hands-entry-lite-q62g6sx0.js → vm-hands-entry-lite-chve4vmh.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-rqfhfp09.js → vm-hands-entry-lite-crjaacc2.js} +2 -2
  59. package/bin/vm-hands/{vm-hands-entry-lite-gcqqnnze.js → vm-hands-entry-lite-cy8yc9gb.js} +19 -19
  60. package/bin/vm-hands/{vm-hands-entry-lite-ncyrz48z.js → vm-hands-entry-lite-dfphra23.js} +3 -3
  61. package/bin/vm-hands/{vm-hands-entry-lite-a3gq377t.js → vm-hands-entry-lite-dh87ysh2.js} +2 -2
  62. package/bin/vm-hands/{vm-hands-entry-lite-sz7z1qby.js → vm-hands-entry-lite-dtw6cj95.js} +2 -2
  63. package/bin/vm-hands/{vm-hands-entry-lite-tnj3483k.js → vm-hands-entry-lite-dzdjwa06.js} +1 -1
  64. package/bin/vm-hands/{vm-hands-entry-lite-chq0qx9f.js → vm-hands-entry-lite-g0bpdyfz.js} +2 -2
  65. package/bin/vm-hands/{vm-hands-entry-lite-rxydyqke.js → vm-hands-entry-lite-h7f5a5mb.js} +2 -2
  66. package/bin/vm-hands/{vm-hands-entry-lite-13nx02p7.js → vm-hands-entry-lite-hh0kba1y.js} +4 -4
  67. package/bin/vm-hands/{vm-hands-entry-lite-fccn6s4j.js → vm-hands-entry-lite-hpe54h0b.js} +2 -2
  68. package/bin/vm-hands/{vm-hands-entry-lite-kbnxk71q.js → vm-hands-entry-lite-hpw27zfb.js} +2 -2
  69. package/bin/vm-hands/{vm-hands-entry-lite-284z7ct8.js → vm-hands-entry-lite-kankyeep.js} +2 -2
  70. package/bin/vm-hands/{vm-hands-entry-lite-dy204qh4.js → vm-hands-entry-lite-n5jyzccm.js} +4 -4
  71. package/bin/vm-hands/{vm-hands-entry-lite-88dxn9b5.js → vm-hands-entry-lite-peyr9y6z.js} +2 -2
  72. package/bin/vm-hands/{vm-hands-entry-lite-cmmb9k3g.js → vm-hands-entry-lite-r131db1f.js} +2 -2
  73. package/bin/vm-hands/{vm-hands-entry-lite-pt19vacn.js → vm-hands-entry-lite-rmcdfbkk.js} +24 -24
  74. package/bin/vm-hands/{vm-hands-entry-lite-1b21avcs.js → vm-hands-entry-lite-sb1xtqxr.js} +2 -2
  75. package/bin/vm-hands/{vm-hands-entry-lite-b1vanmtv.js → vm-hands-entry-lite-sxnvhzy5.js} +4 -4
  76. package/bin/vm-hands/{vm-hands-entry-lite-cc8hwgxc.js → vm-hands-entry-lite-t2rhwchw.js} +3 -3
  77. package/bin/vm-hands/{vm-hands-entry-lite-sh4mqy93.js → vm-hands-entry-lite-t3k90kdn.js} +3 -3
  78. package/bin/vm-hands/{vm-hands-entry-lite-t86kt9jz.js → vm-hands-entry-lite-tv5mcw97.js} +6 -6
  79. package/bin/vm-hands/{vm-hands-entry-lite-12ck5swp.js → vm-hands-entry-lite-tzv8s0e7.js} +1 -1
  80. package/bin/vm-hands/{vm-hands-entry-lite-6vnjgy77.js → vm-hands-entry-lite-vedb5r12.js} +4 -4
  81. package/bin/vm-hands/{vm-hands-entry-lite-jj7873n8.js → vm-hands-entry-lite-vha0pf8k.js} +2 -2
  82. package/bin/vm-hands/{vm-hands-entry-lite-fxptf351.js → vm-hands-entry-lite-vvhfaxpd.js} +5 -5
  83. package/bin/vm-hands/{vm-hands-entry-lite-3gc2bn5a.js → vm-hands-entry-lite-wtjqjvea.js} +2 -2
  84. package/bin/vm-hands/{vm-hands-entry-lite-34b4tws6.js → vm-hands-entry-lite-xd393rm3.js} +6 -6
  85. package/bin/vm-hands/{vm-hands-entry-lite-z65xva21.js → vm-hands-entry-lite-ys4jhf7n.js} +2 -2
  86. package/bin/vm-hands/{vm-hands-entry-lite-af45ma9p.js → vm-hands-entry-lite-zaj1vnnd.js} +9 -9
  87. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  88. package/bin/vm-hands/{vm-hands-executor-kyb5t371.js → vm-hands-executor-31ea40aw.js} +4 -4
  89. package/bin/vm-hands/{vm-hands-op-runner-gkt79hcp.js → vm-hands-op-runner-6r390v3d.js} +1 -1
  90. package/bin/vm-hands/{vm-hands-runtime-tdr6j55n.js → vm-hands-runtime-z9m50n9p.js} +3 -3
  91. package/bin/vm-hands/worker-preview-readiness-w4zy5g2p.js +2 -0
  92. package/bin/vm-hands/worker-sandbox-2trfs79b.js +2 -0
  93. package/package.json +1 -1
  94. package/bin/vm-hands/agent-network-mnv1fm1c.js +0 -2
  95. package/bin/vm-hands/api-credentials-082cnpn9.js +0 -2
  96. package/bin/vm-hands/api-sq672f51.js +0 -2
  97. package/bin/vm-hands/connect-cli-rxb3qtra.js +0 -2
  98. package/bin/vm-hands/credentials-sk4sag42.js +0 -2
  99. package/bin/vm-hands/custom-endpoint-device-3jscber1.js +0 -2
  100. package/bin/vm-hands/desktop-account-xma0330a.js +0 -2
  101. package/bin/vm-hands/desktop-components-099xyxmz.js +0 -2
  102. package/bin/vm-hands/desktop-delegate-tch2qzx0.js +0 -2
  103. package/bin/vm-hands/device-workspace-4bj43nxq.js +0 -2
  104. package/bin/vm-hands/hands-worker-source-8pe7yv0m.js +0 -2
  105. package/bin/vm-hands/install-receipt-68xxg7hn.js +0 -2
  106. package/bin/vm-hands/local-automation-7pjd5nc1.js +0 -2
  107. package/bin/vm-hands/local-capabilities-ha0ey4zh.js +0 -2
  108. package/bin/vm-hands/local-desktop-users-jpf0resr.js +0 -2
  109. package/bin/vm-hands/local-display-mac-h5yz0ydd.js +0 -2
  110. package/bin/vm-hands/local-display-session-0mkswxgk.js +0 -2
  111. package/bin/vm-hands/local-display-video-c3fk87c5.js +0 -2
  112. package/bin/vm-hands/local-managed-process-ahr2jync.js +0 -2
  113. package/bin/vm-hands/local-pty-session-tqn2xmph.js +0 -2
  114. package/bin/vm-hands/managed-runtime-shzb3tr3.js +0 -2
  115. package/bin/vm-hands/network-contract-nkwcf4r9.js +0 -2
  116. package/bin/vm-hands/package-9w0mmxb5.js +0 -2
  117. package/bin/vm-hands/permissions-scffy1px.js +0 -2
  118. package/bin/vm-hands/reason-hands-protocol-pck5har9.js +0 -2
  119. package/bin/vm-hands/serve-service-grp91ybk.js +0 -2
  120. package/bin/vm-hands/version-wyshazh7.js +0 -2
  121. package/bin/vm-hands/vm-hands-entry-lite-997y1m1r.js +0 -3
  122. package/bin/vm-hands/worker-preview-readiness-h96yr4wf.js +0 -2
  123. package/bin/vm-hands/worker-sandbox-6kkhvryn.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{D,Dn,ds,Pr,ps,hs}from"./vm-hands-entry-lite-13nx02p7.js";import{wc,bc,A,Zo}from"./vm-hands-entry-lite-6vnjgy77.js";import{Ue}from"./vm-hands-entry-lite-chq0qx9f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as xt,spawn as _e}from"child_process";import{existsSync as vt}from"fs";import{connect as Et}from"net";function dt(){let e=new Set,t=null,s=(n)=>({holder:t?.viewer??null,you:t===n,same_user:Boolean(t?.viewer&&n.viewer&&t.viewer.user_id===n.viewer.user_id)}),i=()=>{for(let n of e)n.notify(s(n))};return{join(n){return e.add(n),n.notify(s(n)),()=>{if(!e.delete(n))return;if(t!==n)return;t=null,i()}},claim(n){if(t===n||!e.has(n))return;t=n,i()}}}var Ce=dt();import{spawn as pt}from"child_process";import{existsSync as ft}from"fs";import{connect as mt}from"net";import{join as j}from"path";var ze="reason_desktop",N={sampleRate:48000,channels:2,codec:"opus"},ht=5000,yt=107,gt=262144,Vo=(e)=>j(e,"native"),Kt=(e)=>`unix:${e}`;function he(e,t=1000){if(!ft(e))return Promise.resolve(!1);return new Promise((s)=>{let i=mt({path:e}),n=(l)=>{i.destroy(),s(l)};i.setTimeout(t,()=>n(!1)),i.once("error",()=>n(!1)),i.once("close",()=>n(!1)),i.once("connect",()=>n(!0))})}async function _c(e,t){if(!t)return null;let s=Vo(e);if(Buffer.byteLength(s)>yt||/["'\\\s]/.test(s))return null;try{if(await he(s))return s;let i=pt(t,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${j(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${s}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${ze} rate=${N.sampleRate} channels=${N.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:e,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:e,PULSE_RUNTIME_PATH:j(e,"runtime"),PULSE_STATE_PATH:j(e,"state")}});Ue(i.pid);let n=!1;i.once("error",()=>{n=!0}),i.once("exit",()=>{n=!0}),i.unref();let l=Date.now()+ht;while(Date.now()<l){if(await he(s))return s;if(n)return await he(s)?s:null;await new Promise((c)=>setTimeout(c,50))}if(!n)i.kill("SIGKILL");return null}catch{return null}}function Oe(){let{sampleRate:e,channels:t}=N;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(e),"-channels",String(t),"-fragment_size",String(e*t*2/50),"-i",`${ze}.monitor`,"-vn","-ac",String(t),"-ar",String(e),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var bt=[79,103,103,83],wt=Buffer.from("OpusHead"),_t=Buffer.from("OpusTags"),Be=(e,t)=>e.byteLength>=t.byteLength&&t.every((s,i)=>e[i]===s);class ye extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class ge{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(e){let t=new Uint8Array(this.buffer.byteLength+e.byteLength);t.set(this.buffer),t.set(e,this.buffer.byteLength);let s=[],i=0;while(t.byteLength-i>=27){if(bt.some((b,f)=>t[i+f]!==b)||t[i+4]!==0)throw new ye("invalid_page");let n=(t[i+5]&1)!==0,l=t[i+26];if(t.byteLength-i<27+l)break;let c=t.subarray(i+27,i+27+l),h=c.reduce((b,f)=>b+f,0),g=27+l+h;if(t.byteLength-i<g)break;if(!n&&this.partialBytes>0)this.resetPartial();let m=n&&this.partialBytes===0,p=i+27+l,w=p;for(let b of c){if(p+=b,b===255)continue;if(this.appendPartial(t.subarray(w,p),m),w=p,!m){let f=this.takePartial();if(f.byteLength>0&&!Be(f,wt)&&!Be(f,_t))s.push(f)}m=!1,this.resetPartial()}if(w<p)this.appendPartial(t.subarray(w,p),m);i+=g}return this.buffer=t.slice(i),s}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>gt)throw new ye("packet_too_large");this.partial.push(e.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let e=new Uint8Array(this.partialBytes),t=0;for(let s of this.partial)e.set(s,t),t+=s.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as kt}from"child_process";var Ve=1048576,St=String.raw`
2
+ import{D,On,ps,Pr,hs,fs}from"./vm-hands-entry-lite-hh0kba1y.js";import{wc,bc,A,Qo}from"./vm-hands-entry-lite-vedb5r12.js";import{Ue}from"./vm-hands-entry-lite-g0bpdyfz.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as xt,spawn as _e}from"child_process";import{existsSync as vt}from"fs";import{connect as Et}from"net";function dt(){let e=new Set,t=null,s=(n)=>({holder:t?.viewer??null,you:t===n,same_user:Boolean(t?.viewer&&n.viewer&&t.viewer.user_id===n.viewer.user_id)}),i=()=>{for(let n of e)n.notify(s(n))};return{join(n){return e.add(n),n.notify(s(n)),()=>{if(!e.delete(n))return;if(t!==n)return;t=null,i()}},claim(n){if(t===n||!e.has(n))return;t=n,i()}}}var Ce=dt();import{spawn as pt}from"child_process";import{existsSync as ft}from"fs";import{connect as mt}from"net";import{join as j}from"path";var ze="reason_desktop",N={sampleRate:48000,channels:2,codec:"opus"},ht=5000,yt=107,gt=262144,Go=(e)=>j(e,"native"),Kt=(e)=>`unix:${e}`;function he(e,t=1000){if(!ft(e))return Promise.resolve(!1);return new Promise((s)=>{let i=mt({path:e}),n=(l)=>{i.destroy(),s(l)};i.setTimeout(t,()=>n(!1)),i.once("error",()=>n(!1)),i.once("close",()=>n(!1)),i.once("connect",()=>n(!0))})}async function _c(e,t){if(!t)return null;let s=Go(e);if(Buffer.byteLength(s)>yt||/["'\\\s]/.test(s))return null;try{if(await he(s))return s;let i=pt(t,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${j(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${s}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${ze} rate=${N.sampleRate} channels=${N.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:e,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:e,PULSE_RUNTIME_PATH:j(e,"runtime"),PULSE_STATE_PATH:j(e,"state")}});Ue(i.pid);let n=!1;i.once("error",()=>{n=!0}),i.once("exit",()=>{n=!0}),i.unref();let l=Date.now()+ht;while(Date.now()<l){if(await he(s))return s;if(n)return await he(s)?s:null;await new Promise((c)=>setTimeout(c,50))}if(!n)i.kill("SIGKILL");return null}catch{return null}}function Oe(){let{sampleRate:e,channels:t}=N;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(e),"-channels",String(t),"-fragment_size",String(e*t*2/50),"-i",`${ze}.monitor`,"-vn","-ac",String(t),"-ar",String(e),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var bt=[79,103,103,83],wt=Buffer.from("OpusHead"),_t=Buffer.from("OpusTags"),Be=(e,t)=>e.byteLength>=t.byteLength&&t.every((s,i)=>e[i]===s);class ye extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class ge{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(e){let t=new Uint8Array(this.buffer.byteLength+e.byteLength);t.set(this.buffer),t.set(e,this.buffer.byteLength);let s=[],i=0;while(t.byteLength-i>=27){if(bt.some((b,f)=>t[i+f]!==b)||t[i+4]!==0)throw new ye("invalid_page");let n=(t[i+5]&1)!==0,l=t[i+26];if(t.byteLength-i<27+l)break;let c=t.subarray(i+27,i+27+l),h=c.reduce((b,f)=>b+f,0),g=27+l+h;if(t.byteLength-i<g)break;if(!n&&this.partialBytes>0)this.resetPartial();let m=n&&this.partialBytes===0,p=i+27+l,w=p;for(let b of c){if(p+=b,b===255)continue;if(this.appendPartial(t.subarray(w,p),m),w=p,!m){let f=this.takePartial();if(f.byteLength>0&&!Be(f,wt)&&!Be(f,_t))s.push(f)}m=!1,this.resetPartial()}if(w<p)this.appendPartial(t.subarray(w,p),m);i+=g}return this.buffer=t.slice(i),s}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>gt)throw new ye("packet_too_large");this.partial.push(e.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let e=new Uint8Array(this.partialBytes),t=0;for(let s of this.partial)e.set(s,t),t+=s.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as kt}from"child_process";var Ve=1048576,St=String.raw`
3
3
  import gi, json, os, sys
4
4
  gi.require_version("Gtk", "3.0")
5
5
  from gi.repository import Gtk, Gdk, GLib
@@ -43,6 +43,6 @@ Gtk.main()
43
43
  `;function Ne(e,t){let s=kt("/usr/bin/python3",["-I","-u","-c",St],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),i=!1,n=!0,l="",c=0,h=[],g=setTimeout(()=>p(),5000),m=()=>{i=!0,clearTimeout(g),h.length=0,s.kill("SIGKILL")},p=()=>{if(i)return;m(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},w=(b,f=32)=>{if(i)return;if(!n){b();return}if(c+=f,c>Ve)m(),t.end({reason:"input_backpressure"});else h.push({apply:b,bytes:f})};return s.stdout.on("data",(b)=>{if(i)return;l+=b.toString("ascii");for(let f=l.indexOf(`
44
44
  `);f>=0;f=l.indexOf(`
45
45
  `)){let T=l.slice(0,f);l=l.slice(f+1);let x;try{x=JSON.parse(T)}catch{p();return}if(x==="ready"||x==="ack"){clearTimeout(g),n=!1;while(!n&&!i&&h.length){let d=h.shift();c-=d.bytes,d.apply()}}else if(x&&typeof x==="object"&&"text"in x&&typeof x.text==="string"&&Buffer.byteLength(x.text)<=D)t.clipboard(x.text);else{p();return}if(i)return}if(l.length>D*6+32)p()}),s.stdin.on("error",p),s.once("error",p),s.once("exit",p),{apply:w,write(b){if(Buffer.byteLength(b)>D||b.includes("\x00")){p();return}let f=`${JSON.stringify(b)}
46
- `;w(()=>{if(n=!0,g=setTimeout(()=>p(),5000),s.stdin.write(f),s.stdin.writableLength>Ve)m(),t.end({reason:"input_backpressure"})},Buffer.byteLength(f))},close:m}}var z={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},Dt="avc1.4D002A",Ge={width:1920,height:1080},Mt=262144,Pt=0.2,It=250,Lt=1e4,At=1024,be=1e4,Rt=500,Tt=60,Ct=1e4,Bt=1000,Fe=1048576,Ut=-223,zt=-308,Go={kind:"mac_screen",sound:null},Ko={kind:"windows_screen",sound:null},Ot,He=()=>Ot??=A()?.ffmpeg??null,Z=(e,t,s)=>_e(e,t,{env:s,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Vt,ke=()=>Vt??=Zo(A()),$e=(e,t,s)=>{let[i,...n]=[...ke(),e];return Z(i,[...n,...t],s)},Ke=()=>nt?.videotoolbox?"h264_videotoolbox":"libx264",Nt=()=>Math.round(performance.now()*1000),we=new Set,qe=!1;function Je(e){if(we.add(e),e.once("exit",()=>we.delete(e)),qe)return;qe=!0,process.once("exit",()=>{for(let t of we)try{t.kill("SIGKILL")}catch{}})}function Ze(e){try{e.stdout?.destroy()}catch{}if(e.exitCode!==null||e.signalCode!==null)return;try{e.kill("SIGTERM")}catch{return}let t=setTimeout(()=>{if(e.exitCode===null&&e.signalCode===null)try{e.kill("SIGKILL")}catch{}},Rt);e.once("exit",()=>clearTimeout(t))}function Gt(e,t,s){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",s],size:t}}function Ft(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Ht(e,t){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(e),"-offset_x","0","-offset_y","0","-video_size",`${t.width}x${t.height}`,"-i","desktop"],size:t}}function $t(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Qe=1700000;function et(e){return Math.min(1,Math.round(Math.sqrt(Qe/(e.width*e.height))*100)/100)}function qt(e,t,s){let i=_e(s.axe,["stream-video","--udid",s.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,et(s.size)))],{stdio:["ignore","pipe","ignore"]}),n=_e(e,t,{env:{},stdio:["pipe","pipe","ignore"]});i.stdout.pipe(n.stdin),n.stdin.on("error",()=>{});let l=()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGTERM")};return n.once("exit",l),n.once("error",l),i.once("exit",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),i.once("error",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),n}function We(e){let t=Math.min(1,Ge.width/e.width,Ge.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function J(e,t,s,i="libx264"){let n=z[e],l=(w)=>Math.max(2,Math.floor(w/2)*2),c={width:l(s.width*n.scale),height:l(s.height*n.scale)},h=c.width!==t.size?.width||c.height!==t.size.height,g=Math.max(1,Math.round(n.kbps*2/n.fps)),m=["-g",String(n.fps*Tt)],p=i==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...m,"-b:v",`${n.kbps}k`,"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",n.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...n.threads?["-threads",String(n.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...m,"-crf",String(n.crf),"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...h?["-vf",`scale=${c.width}:${c.height}:flags=fast_bilinear`]:[],...p,"-flush_packets","1","-f","h264","pipe:1"]}class tt{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let s=new Uint8Array(this.buffer.byteLength+e.byteLength);s.set(this.buffer),s.set(e,this.buffer.byteLength),this.buffer=s;let i=[],n=this.scanned;while(n+3<this.buffer.byteLength){if(this.buffer[n]!==0||this.buffer[n+1]!==0||this.buffer[n+2]!==1){n++;continue}let l=this.buffer[n+3]&31,c=n>0&&this.buffer[n-1]===0?n-1:n;if(l===9&&c>0)i.push({data:this.buffer.slice(0,c),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(c),this.key=!1,this.micros=t,n-=c;if(l===5)this.key=!0;n+=3}return this.scanned=n,i}}function Wt(e,t){let s=Et({path:e}),i=Buffer.alloc(0),n="version",l=0,c=!1,h=[],g=0,m=!1,p=(d)=>{if(m)return;m=!0,s.destroy(),t.end(d)},w=()=>p({reason:"display_protocol"}),b=(d)=>{if(m)return;if(!c){if(g+=d.byteLength,g>Fe)p({reason:"input_backpressure"});else h.push(d);return}if(s.write(d),s.writableLength>Fe)p({reason:"input_backpressure"})},f=(d)=>{i=i.subarray(d)},T=()=>{switch(n){case"version":{if(i.byteLength<12)return!1;let d=/^RFB (\d{3})\.(\d{3})\n$/.exec(i.subarray(0,12).toString("latin1"));if(!d||Number(d[1])*1000+Number(d[2])<3007)return w(),!1;return f(12),s.write(`RFB 003.007
47
- `),n="security",!0}case"security":{if(i.byteLength<1)return!1;let d=i[0];if(d===0)return w(),!1;if(i.byteLength<1+d)return!1;if(!i.subarray(1,1+d).includes(1))return w(),!1;return f(1+d),s.write(Buffer.from([1,1])),n="init",!0}case"init":{if(i.byteLength<24)return!1;let d=i.readUInt32BE(20);if(d>65536)return w(),!1;if(i.byteLength<24+d)return!1;let S={width:i.readUInt16BE(0),height:i.readUInt16BE(2)};if(f(24+d),S.width===0||S.height===0)return w(),!1;n="messages";let _=Buffer.alloc(12);_.writeUInt8(2,0),_.writeUInt16BE(2,2),_.writeInt32BE(zt,4),_.writeInt32BE(Ut,8),s.write(_),c=!0;for(let v of h)s.write(v);return h=[],g=0,t.ready(S),!m}case"skip":{let d=Math.min(l,i.byteLength);if(f(d),l-=d,l>0)return!1;return n="messages",!0}case"messages":{if(i.byteLength<1)return!1;switch(i[0]){case 1:{if(i.byteLength<6)return!1;let d=6+i.readUInt16BE(4)*6;if(i.byteLength<d)return!1;return f(d),!0}case 2:return f(1),!0;case 3:{if(i.byteLength<8)return!1;let d=i.readUInt32BE(4);if(d>D/2)return f(8),n="skip",l=d,!0;if(i.byteLength<8+d)return!1;let S=i.subarray(8,8+d).toString("latin1");return f(8+d),t.clipboard(S),!m}default:return w(),!1}}}},x=!1;return s.once("connect",()=>{x=!0}),s.on("data",(d)=>{if(m)return;i=i.byteLength?Buffer.concat([i,d]):d;while(!m&&T());}),s.once("error",()=>{if(!x)p({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),s.once("close",()=>p({reason:"display_closed"})),{pointer(d,S,_){let v=Buffer.alloc(6);v.writeUInt8(5,0),v.writeUInt8(_&255,1),v.writeUInt16BE(d,2),v.writeUInt16BE(S,4),b(v)},key(d,S){let _=Buffer.alloc(8);_.writeUInt8(4,0),_.writeUInt8(d?1:0,1),_.writeUInt32BE(S>>>0,4),b(_)},clipboard(d){if(Array.from(d).some((v)=>v.codePointAt(0)>255)){p({reason:"clipboard_unicode_unsupported"});return}let S=Buffer.from(d,"latin1"),_=Buffer.alloc(8);_.writeUInt8(6,0),_.writeUInt32BE(S.byteLength,4),b(Buffer.concat([_,S]))},close(){m=!0,s.destroy()}}}class Se{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,s,i){this.viewers.add(e),this.stop();let n;try{n=s()}catch{this.fail();return}Je(n);let l={child:n,splitter:new tt};this.run=l;for(let h of[...this.viewers])h.started(t);n.stdout?.on("data",(h)=>{if(this.run!==l)return;for(let g of l.splitter.push(h,i()))for(let m of[...this.viewers])m.unit(g)});let c=()=>{if(this.run!==l)return;this.run=null,this.fail()};n.once("exit",c),n.once("error",c)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;Ze(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Xe=new WeakMap;function Xt(e){let t=Xe.get(e);if(!t)Xe.set(e,t=new Se);return t}var G=new Map;function Jo(e,t,s={}){let i=s.micros??Nt,n=new ds,l=t.request.preset,c=null,h=null,g=null,m=!1,p=null,w=!1,b=!1,f=null,T=0,x=0,d=!1,S=null,_=null,v=0,Q=null,I=[],F=0,L=[],xe=new Uint32Array(be+1),ee=0,te=null,ne=0,O=0,re=0,ve=0,Ee=0,H=null,ie=0,C={frames:0,bytes:0,since:i()},B=[],V=0,se,oe=!1,it=i(),M={},U=()=>Math.round((i()-it)/1000),De=s.control??Ce,ae=null,le=null,Me=0,ue=!1,Pe={pause(){if(!p?.running)return;p.stop(),ue=!0},adopt(o){let a=o!==null&&(o.width!==h?.width||o.height!==h?.height);if(a)h=o;if(!a&&!ue)return;if(ue=!1,p)Y();else pe()}},st=(o)=>{if(!s.resizeDesktop||!c||"kind"in c||e.done)return;let a=c.display,u=()=>[...G.get(a)??[]];Me++,s.resizeDesktop(c,o,()=>{for(let y of u())y.pause()}).then((y)=>{for(let k of u())k.adopt(y)})},P=(o)=>{let a=Dn(o);return e.send(a),ve+=a.byteLength,a.byteLength},K=(o)=>{if(e.done)return;if(e.open)P({type:"error",code:o});e.end({reason:o})},q=()=>Math.max(Mt,z[l].kbps*1000/8*Pt),W=()=>i()/1000,ot=()=>{while(L.length>1&&L[0].atMs<W()-Lt)L.shift();return L[0]?.rttMs??null},Ie=(o)=>{let a=ot();if(a===null||I.length===0)return!1;let u=(a+It)*o;return W()-I[0].sentMs>u||F>u/1000*z[l].kbps*1000/8},at=(o)=>{if(v===0)return;let a=Math.min(o,v-1);if(Q!==null&&a<=Q)return;Q=a;let u=W();while(I.length&&I[0].seq<=a){let y=I.shift();if(F-=y.bytes,y.seq!==a)continue;let k=Math.max(0,u-y.sentMs);while(L.length&&L.at(-1).rttMs>=k)L.pop();L.push({atMs:u,rttMs:k}),xe[Math.min(be,Math.round(k))]++,ee++,te=Math.min(te??k,k)}},lt=()=>{let o=0;for(let a=0;a<=be;a++)if(o+=xe[a],o*2>=ee)return a;return 0},ut=()=>e.bufferedAmount<=q()/2&&!Ie(0.5),Le=()=>{oe=!0,B=[],V=0,p?.leave(ce),p=null},Ae=(o)=>{if(e.done)return;if(o.key)M.first_key_ms??=U();if(!m){if(!p||B.length===0&&!o.key)return;if(B.push(o),V+=o.data.byteLength,V>q())Le();return}if(d){O++;return}if(e.bufferedAmount>q()||Ie(1)){d=!0,O++,S=setInterval(()=>{if(e.done||!ut())return;if(S)clearInterval(S);S=null,d=!1,Y()},s.drainPollMs??25);return}if(!w){if(!o.key){O++;return}if(P({type:"hello",width:h.width,height:h.height,fps:z[l].fps,preset:l,codec:Dt}),w=!0,M.first_frame_ms??=U(),!b&&c?.sound)P({type:"audioHello",...N}),b=!0}let a=P({type:"frame",key:o.key,seq:v,captureMicros:o.micros,data:o.data});if(I.push({seq:v,sentMs:W(),bytes:a}),F+=a,I.length>At)F-=I.shift().bytes;v++,ne++,H??=o.micros,ie=o.micros,C.frames++,C.bytes+=a},ce={started(o){l=o,w=!1,B=[],V=0},unit:Ae,failed:()=>K("encoder_failed")},de=()=>{let o=(s.ffmpeg??He)();if(!c||!h){K("encoder_failed");return}let[a,u]=[c,h],y="kind"in a&&a.kind==="simulator"?a.stream:null;if(!o&&!y){K("encoder_failed");return}if(p??="kind"in a&&a.kind==="mac_screen"?Xt(s.spawn??$e):new Se,M.encoder_ms===void 0)M.encoder_ms=U(),M.encoder_shared=p.running;p.start(ce,l,()=>{let k=z[l].fps;if(y)return y(k,z[l].kbps,Qe);if("kind"in a&&a.kind==="simulator"){let E=Math.min(0.99,et(a.size)),R={width:a.size.width*E,height:a.size.height*E};return qt(o,J(l,$t(Math.min(k,30)),R,(s.macEncoder??Ke)()),a)}if("kind"in a&&a.kind==="windows_screen")return(s.spawn??Z)(o,J(l,Ht(k,u),We(u)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in a?(s.spawn??$e)(o,J(l,Ft(k),We(u),(s.macEncoder??Ke)()),{}):(s.spawn??Z)(o,J(l,Gt(k,u,a.display),u),{DISPLAY:a.display,XAUTHORITY:a.xauthority})},i)},X=()=>{if(!f)return;Ze(f.child),f=null},ct=()=>{let o=(s.ffmpeg??He)();if(f||e.done||!b||!c?.sound||!o)return;let a;try{a=(s.spawn??Z)(o,Oe(),{PULSE_SERVER:Kt(c.sound)})}catch{return}Je(a);let u={child:a,reader:new ge};f=u,a.stdout?.on("data",(k)=>{if(f!==u||e.done)return;let E;try{E=u.reader.push(k)}catch{X();return}let R=i();for(let me of E){if(e.bufferedAmount>q()){x++;continue}P({type:"audio",captureMicros:R,data:me}),T++}});let y=()=>{if(f===u)X()};a.once("exit",y),a.once("error",y)},Y=()=>{if(!p||e.done)return;re++,de()},pe=()=>{if(e.done||!h)return;if(!m){if(p||oe)return;de(),se=setTimeout(()=>{if(!m)Le()},Ct);return}if(clearTimeout(se),M.encoder_early===void 0){if(M.encoder_early=p!==null,oe)M.hold_lapsed=!0}if(!p)de();let o=B;B=[],V=0;for(let a of o)Ae(a);_??=setInterval(()=>{let a=i(),u=Math.max(0.001,(a-C.since)/1e6);P({type:"stats",stats:{fps:Math.round(C.frames/u*10)/10,kbps:Math.round(C.bytes*8/1000/u),dropped:O,restarts:re,queued_bytes:e.bufferedAmount}}),C={frames:0,bytes:0,since:a}},Bt)};t.desktop.then((o)=>{if(e.done)return;c=o;let a={ready(u){h=u,M.desktop_ms??=U(),pe()},clipboard(u){if(e.open&&Buffer.byteLength(u)<=D)P({type:"serverClipboard",text:u})},end(u){if("reason"in u&&e.open)P({type:"error",code:u.reason});e.end(u)}};if("kind"in o&&o.kind==="simulator")g=o.input,a.ready(o.points);else if("kind"in o&&o.kind==="windows_screen")g=(s.windowsInput??bc)(a);else if("kind"in o)g=(s.macInput??((u)=>hs(u,ke())))(a);else{let u=G.get(o.display);if(!u)G.set(o.display,u=new Set);u.add(Pe);let y=(s.linuxClipboard??Ne)(o,a),k=Wt(o.rfbSocket,{...a,clipboard:(E)=>{if(!y)a.clipboard(E)}});g=y?{pointer:(E,R,me)=>y.apply(()=>k.pointer(E,R,me)),key:(E,R)=>y.apply(()=>k.key(E,R)),clipboard:(E)=>y.write(E),close(){y.close(),k.close()}}:k}Re()},(o)=>e.end({error:o}));function Re(){if(le||!t.viewerSameNetwork||!m||e.done||!c||!("kind"in c)||c.kind!=="mac_screen")return;le=(s.macWindows??ps)((o)=>{if(e.open)P({type:"windows",bounds:o})})}let Te={viewer:t.viewer??null,notify(o){if(e.open)P({type:"control",control:o})}},fe=(o)=>{if(!g)return;if(!c||!("kind"in c)||c.kind!=="simulator")De.claim(Te);o(g)};return{opened(){M.relay_ms??=U()},received(o){Ee+=o.byteLength;let a;try{a=n.push(o)}catch{K("viewer_protocol");return}for(let u of a){if(e.done)return;switch(u.type){case"ping":P({type:"pong",token:u.token});break;case"pointer":fe((y)=>y.pointer(u.x,u.y,u.buttons));break;case"key":fe((y)=>y.key(u.down,u.keysym));break;case"clientClipboard":fe((y)=>y.clipboard(u.text));break;case"config":if(u.preset!==l)l=u.preset,Y();break;case"keyframeRequest":if(w&&!d)Y();break;case"ack":at(u.seq);break;case"audioEnable":if(u.on)ct();else X();break;case"resize":st({width:u.width,height:u.height});break;default:break}}if(!m&&!e.done){if(m=!0,M.viewer_ms=U(),t.viewer)ae=De.join(Te);pe(),Re()}},close(){if(c&&!("kind"in c)){let o=G.get(c.display);if(o?.delete(Pe),o?.size===0)G.delete(c.display)}if(ae?.(),ae=null,le?.close(),S)clearInterval(S);if(_)clearInterval(_);clearTimeout(se),p?.leave(ce),X(),g?.close()},summary:()=>({output_bytes:ve,input_bytes:Ee,video:{preset:l,frames:ne,dropped:O,restarts:re,avg_fps:H!==null&&ie>H?Math.round((ne-1)/((ie-H)/1e6)*10)/10:0,min_rtt_ms:Math.round(te??0),p50_rtt_ms:ee?lt():0,audio_packets:T,audio_dropped:x,resizes:Me,connect:M}})}}var Ye=null,nt=null,Yt=null,jt=null;function Zt(){let e=A();return e?.features.display?e.ffmpeg:null}function rt(e){return Ye??=new Promise((t)=>{xt(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(s,i)=>{let n=(l)=>!s&&new RegExp(`^\\s*V\\S*\\s+${l}\\s`,"m").test(i);t(nt={x264:n("libx264"),videotoolbox:n("h264_videotoolbox")})})}),Ye}var je=null;function Xo(){return je??=(async()=>{let e=[A()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((s)=>Boolean(s&&vt(s)));if(!e)return null;let t=await rt(e);return t.videotoolbox||t.x264?e:null})(),je}function Jt(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let s=(t.ffmpeg??Zt)();if(!s)return Promise.resolve(!1);let i=(t.encoders??rt)(s);if(e==="linux")return i.then((l)=>l.x264);if(e==="win32"){let l=t.windowsScreen?t.windowsScreen():jt??=wc();return Promise.all([i,l]).then(([c,h])=>c.x264&&(h?.session??0)>0)}let n=t.macScreen?t.macScreen():Yt??=Pr(ke());return Promise.all([i,n]).then(([l,c])=>(l.x264||l.videotoolbox)&&c?.screen===!0&&c.accessibility)}
48
- export{Vo,Kt,_c,Go,Ko,Jo,Xo,Jt};
46
+ `;w(()=>{if(n=!0,g=setTimeout(()=>p(),5000),s.stdin.write(f),s.stdin.writableLength>Ve)m(),t.end({reason:"input_backpressure"})},Buffer.byteLength(f))},close:m}}var z={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},Dt="avc1.4D002A",Ge={width:1920,height:1080},Mt=262144,Pt=0.2,It=250,Lt=1e4,At=1024,be=1e4,Rt=500,Tt=60,Ct=1e4,Bt=1000,Fe=1048576,Ut=-223,zt=-308,Ko={kind:"mac_screen",sound:null},Jo={kind:"windows_screen",sound:null},Ot,He=()=>Ot??=A()?.ffmpeg??null,Z=(e,t,s)=>_e(e,t,{env:s,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Vt,ke=()=>Vt??=Qo(A()),$e=(e,t,s)=>{let[i,...n]=[...ke(),e];return Z(i,[...n,...t],s)},Ke=()=>nt?.videotoolbox?"h264_videotoolbox":"libx264",Nt=()=>Math.round(performance.now()*1000),we=new Set,qe=!1;function Je(e){if(we.add(e),e.once("exit",()=>we.delete(e)),qe)return;qe=!0,process.once("exit",()=>{for(let t of we)try{t.kill("SIGKILL")}catch{}})}function Ze(e){try{e.stdout?.destroy()}catch{}if(e.exitCode!==null||e.signalCode!==null)return;try{e.kill("SIGTERM")}catch{return}let t=setTimeout(()=>{if(e.exitCode===null&&e.signalCode===null)try{e.kill("SIGKILL")}catch{}},Rt);e.once("exit",()=>clearTimeout(t))}function Gt(e,t,s){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",s],size:t}}function Ft(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Ht(e,t){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(e),"-offset_x","0","-offset_y","0","-video_size",`${t.width}x${t.height}`,"-i","desktop"],size:t}}function $t(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Qe=1700000;function et(e){return Math.min(1,Math.round(Math.sqrt(Qe/(e.width*e.height))*100)/100)}function qt(e,t,s){let i=_e(s.axe,["stream-video","--udid",s.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,et(s.size)))],{stdio:["ignore","pipe","ignore"]}),n=_e(e,t,{env:{},stdio:["pipe","pipe","ignore"]});i.stdout.pipe(n.stdin),n.stdin.on("error",()=>{});let l=()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGTERM")};return n.once("exit",l),n.once("error",l),i.once("exit",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),i.once("error",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),n}function We(e){let t=Math.min(1,Ge.width/e.width,Ge.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function J(e,t,s,i="libx264"){let n=z[e],l=(w)=>Math.max(2,Math.floor(w/2)*2),c={width:l(s.width*n.scale),height:l(s.height*n.scale)},h=c.width!==t.size?.width||c.height!==t.size.height,g=Math.max(1,Math.round(n.kbps*2/n.fps)),m=["-g",String(n.fps*Tt)],p=i==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...m,"-b:v",`${n.kbps}k`,"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",n.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...n.threads?["-threads",String(n.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...m,"-crf",String(n.crf),"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...h?["-vf",`scale=${c.width}:${c.height}:flags=fast_bilinear`]:[],...p,"-flush_packets","1","-f","h264","pipe:1"]}class tt{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let s=new Uint8Array(this.buffer.byteLength+e.byteLength);s.set(this.buffer),s.set(e,this.buffer.byteLength),this.buffer=s;let i=[],n=this.scanned;while(n+3<this.buffer.byteLength){if(this.buffer[n]!==0||this.buffer[n+1]!==0||this.buffer[n+2]!==1){n++;continue}let l=this.buffer[n+3]&31,c=n>0&&this.buffer[n-1]===0?n-1:n;if(l===9&&c>0)i.push({data:this.buffer.slice(0,c),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(c),this.key=!1,this.micros=t,n-=c;if(l===5)this.key=!0;n+=3}return this.scanned=n,i}}function Wt(e,t){let s=Et({path:e}),i=Buffer.alloc(0),n="version",l=0,c=!1,h=[],g=0,m=!1,p=(d)=>{if(m)return;m=!0,s.destroy(),t.end(d)},w=()=>p({reason:"display_protocol"}),b=(d)=>{if(m)return;if(!c){if(g+=d.byteLength,g>Fe)p({reason:"input_backpressure"});else h.push(d);return}if(s.write(d),s.writableLength>Fe)p({reason:"input_backpressure"})},f=(d)=>{i=i.subarray(d)},T=()=>{switch(n){case"version":{if(i.byteLength<12)return!1;let d=/^RFB (\d{3})\.(\d{3})\n$/.exec(i.subarray(0,12).toString("latin1"));if(!d||Number(d[1])*1000+Number(d[2])<3007)return w(),!1;return f(12),s.write(`RFB 003.007
47
+ `),n="security",!0}case"security":{if(i.byteLength<1)return!1;let d=i[0];if(d===0)return w(),!1;if(i.byteLength<1+d)return!1;if(!i.subarray(1,1+d).includes(1))return w(),!1;return f(1+d),s.write(Buffer.from([1,1])),n="init",!0}case"init":{if(i.byteLength<24)return!1;let d=i.readUInt32BE(20);if(d>65536)return w(),!1;if(i.byteLength<24+d)return!1;let S={width:i.readUInt16BE(0),height:i.readUInt16BE(2)};if(f(24+d),S.width===0||S.height===0)return w(),!1;n="messages";let _=Buffer.alloc(12);_.writeUInt8(2,0),_.writeUInt16BE(2,2),_.writeInt32BE(zt,4),_.writeInt32BE(Ut,8),s.write(_),c=!0;for(let v of h)s.write(v);return h=[],g=0,t.ready(S),!m}case"skip":{let d=Math.min(l,i.byteLength);if(f(d),l-=d,l>0)return!1;return n="messages",!0}case"messages":{if(i.byteLength<1)return!1;switch(i[0]){case 1:{if(i.byteLength<6)return!1;let d=6+i.readUInt16BE(4)*6;if(i.byteLength<d)return!1;return f(d),!0}case 2:return f(1),!0;case 3:{if(i.byteLength<8)return!1;let d=i.readUInt32BE(4);if(d>D/2)return f(8),n="skip",l=d,!0;if(i.byteLength<8+d)return!1;let S=i.subarray(8,8+d).toString("latin1");return f(8+d),t.clipboard(S),!m}default:return w(),!1}}}},x=!1;return s.once("connect",()=>{x=!0}),s.on("data",(d)=>{if(m)return;i=i.byteLength?Buffer.concat([i,d]):d;while(!m&&T());}),s.once("error",()=>{if(!x)p({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),s.once("close",()=>p({reason:"display_closed"})),{pointer(d,S,_){let v=Buffer.alloc(6);v.writeUInt8(5,0),v.writeUInt8(_&255,1),v.writeUInt16BE(d,2),v.writeUInt16BE(S,4),b(v)},key(d,S){let _=Buffer.alloc(8);_.writeUInt8(4,0),_.writeUInt8(d?1:0,1),_.writeUInt32BE(S>>>0,4),b(_)},clipboard(d){if(Array.from(d).some((v)=>v.codePointAt(0)>255)){p({reason:"clipboard_unicode_unsupported"});return}let S=Buffer.from(d,"latin1"),_=Buffer.alloc(8);_.writeUInt8(6,0),_.writeUInt32BE(S.byteLength,4),b(Buffer.concat([_,S]))},close(){m=!0,s.destroy()}}}class Se{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,s,i){this.viewers.add(e),this.stop();let n;try{n=s()}catch{this.fail();return}Je(n);let l={child:n,splitter:new tt};this.run=l;for(let h of[...this.viewers])h.started(t);n.stdout?.on("data",(h)=>{if(this.run!==l)return;for(let g of l.splitter.push(h,i()))for(let m of[...this.viewers])m.unit(g)});let c=()=>{if(this.run!==l)return;this.run=null,this.fail()};n.once("exit",c),n.once("error",c)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;Ze(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Xe=new WeakMap;function Xt(e){let t=Xe.get(e);if(!t)Xe.set(e,t=new Se);return t}var G=new Map;function Xo(e,t,s={}){let i=s.micros??Nt,n=new ps,l=t.request.preset,c=null,h=null,g=null,m=!1,p=null,w=!1,b=!1,f=null,T=0,x=0,d=!1,S=null,_=null,v=0,Q=null,I=[],F=0,L=[],xe=new Uint32Array(be+1),ee=0,te=null,ne=0,O=0,re=0,ve=0,Ee=0,H=null,ie=0,C={frames:0,bytes:0,since:i()},B=[],V=0,se,oe=!1,it=i(),M={},U=()=>Math.round((i()-it)/1000),De=s.control??Ce,ae=null,le=null,Me=0,ue=!1,Pe={pause(){if(!p?.running)return;p.stop(),ue=!0},adopt(o){let a=o!==null&&(o.width!==h?.width||o.height!==h?.height);if(a)h=o;if(!a&&!ue)return;if(ue=!1,p)Y();else pe()}},st=(o)=>{if(!s.resizeDesktop||!c||"kind"in c||e.done)return;let a=c.display,u=()=>[...G.get(a)??[]];Me++,s.resizeDesktop(c,o,()=>{for(let y of u())y.pause()}).then((y)=>{for(let k of u())k.adopt(y)})},P=(o)=>{let a=On(o);return e.send(a),ve+=a.byteLength,a.byteLength},K=(o)=>{if(e.done)return;if(e.open)P({type:"error",code:o});e.end({reason:o})},q=()=>Math.max(Mt,z[l].kbps*1000/8*Pt),W=()=>i()/1000,ot=()=>{while(L.length>1&&L[0].atMs<W()-Lt)L.shift();return L[0]?.rttMs??null},Ie=(o)=>{let a=ot();if(a===null||I.length===0)return!1;let u=(a+It)*o;return W()-I[0].sentMs>u||F>u/1000*z[l].kbps*1000/8},at=(o)=>{if(v===0)return;let a=Math.min(o,v-1);if(Q!==null&&a<=Q)return;Q=a;let u=W();while(I.length&&I[0].seq<=a){let y=I.shift();if(F-=y.bytes,y.seq!==a)continue;let k=Math.max(0,u-y.sentMs);while(L.length&&L.at(-1).rttMs>=k)L.pop();L.push({atMs:u,rttMs:k}),xe[Math.min(be,Math.round(k))]++,ee++,te=Math.min(te??k,k)}},lt=()=>{let o=0;for(let a=0;a<=be;a++)if(o+=xe[a],o*2>=ee)return a;return 0},ut=()=>e.bufferedAmount<=q()/2&&!Ie(0.5),Le=()=>{oe=!0,B=[],V=0,p?.leave(ce),p=null},Ae=(o)=>{if(e.done)return;if(o.key)M.first_key_ms??=U();if(!m){if(!p||B.length===0&&!o.key)return;if(B.push(o),V+=o.data.byteLength,V>q())Le();return}if(d){O++;return}if(e.bufferedAmount>q()||Ie(1)){d=!0,O++,S=setInterval(()=>{if(e.done||!ut())return;if(S)clearInterval(S);S=null,d=!1,Y()},s.drainPollMs??25);return}if(!w){if(!o.key){O++;return}if(P({type:"hello",width:h.width,height:h.height,fps:z[l].fps,preset:l,codec:Dt}),w=!0,M.first_frame_ms??=U(),!b&&c?.sound)P({type:"audioHello",...N}),b=!0}let a=P({type:"frame",key:o.key,seq:v,captureMicros:o.micros,data:o.data});if(I.push({seq:v,sentMs:W(),bytes:a}),F+=a,I.length>At)F-=I.shift().bytes;v++,ne++,H??=o.micros,ie=o.micros,C.frames++,C.bytes+=a},ce={started(o){l=o,w=!1,B=[],V=0},unit:Ae,failed:()=>K("encoder_failed")},de=()=>{let o=(s.ffmpeg??He)();if(!c||!h){K("encoder_failed");return}let[a,u]=[c,h],y="kind"in a&&a.kind==="simulator"?a.stream:null;if(!o&&!y){K("encoder_failed");return}if(p??="kind"in a&&a.kind==="mac_screen"?Xt(s.spawn??$e):new Se,M.encoder_ms===void 0)M.encoder_ms=U(),M.encoder_shared=p.running;p.start(ce,l,()=>{let k=z[l].fps;if(y)return y(k,z[l].kbps,Qe);if("kind"in a&&a.kind==="simulator"){let E=Math.min(0.99,et(a.size)),R={width:a.size.width*E,height:a.size.height*E};return qt(o,J(l,$t(Math.min(k,30)),R,(s.macEncoder??Ke)()),a)}if("kind"in a&&a.kind==="windows_screen")return(s.spawn??Z)(o,J(l,Ht(k,u),We(u)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in a?(s.spawn??$e)(o,J(l,Ft(k),We(u),(s.macEncoder??Ke)()),{}):(s.spawn??Z)(o,J(l,Gt(k,u,a.display),u),{DISPLAY:a.display,XAUTHORITY:a.xauthority})},i)},X=()=>{if(!f)return;Ze(f.child),f=null},ct=()=>{let o=(s.ffmpeg??He)();if(f||e.done||!b||!c?.sound||!o)return;let a;try{a=(s.spawn??Z)(o,Oe(),{PULSE_SERVER:Kt(c.sound)})}catch{return}Je(a);let u={child:a,reader:new ge};f=u,a.stdout?.on("data",(k)=>{if(f!==u||e.done)return;let E;try{E=u.reader.push(k)}catch{X();return}let R=i();for(let me of E){if(e.bufferedAmount>q()){x++;continue}P({type:"audio",captureMicros:R,data:me}),T++}});let y=()=>{if(f===u)X()};a.once("exit",y),a.once("error",y)},Y=()=>{if(!p||e.done)return;re++,de()},pe=()=>{if(e.done||!h)return;if(!m){if(p||oe)return;de(),se=setTimeout(()=>{if(!m)Le()},Ct);return}if(clearTimeout(se),M.encoder_early===void 0){if(M.encoder_early=p!==null,oe)M.hold_lapsed=!0}if(!p)de();let o=B;B=[],V=0;for(let a of o)Ae(a);_??=setInterval(()=>{let a=i(),u=Math.max(0.001,(a-C.since)/1e6);P({type:"stats",stats:{fps:Math.round(C.frames/u*10)/10,kbps:Math.round(C.bytes*8/1000/u),dropped:O,restarts:re,queued_bytes:e.bufferedAmount}}),C={frames:0,bytes:0,since:a}},Bt)};t.desktop.then((o)=>{if(e.done)return;c=o;let a={ready(u){h=u,M.desktop_ms??=U(),pe()},clipboard(u){if(e.open&&Buffer.byteLength(u)<=D)P({type:"serverClipboard",text:u})},end(u){if("reason"in u&&e.open)P({type:"error",code:u.reason});e.end(u)}};if("kind"in o&&o.kind==="simulator")g=o.input,a.ready(o.points);else if("kind"in o&&o.kind==="windows_screen")g=(s.windowsInput??bc)(a);else if("kind"in o)g=(s.macInput??((u)=>fs(u,ke())))(a);else{let u=G.get(o.display);if(!u)G.set(o.display,u=new Set);u.add(Pe);let y=(s.linuxClipboard??Ne)(o,a),k=Wt(o.rfbSocket,{...a,clipboard:(E)=>{if(!y)a.clipboard(E)}});g=y?{pointer:(E,R,me)=>y.apply(()=>k.pointer(E,R,me)),key:(E,R)=>y.apply(()=>k.key(E,R)),clipboard:(E)=>y.write(E),close(){y.close(),k.close()}}:k}Re()},(o)=>e.end({error:o}));function Re(){if(le||!t.viewerSameNetwork||!m||e.done||!c||!("kind"in c)||c.kind!=="mac_screen")return;le=(s.macWindows??hs)((o)=>{if(e.open)P({type:"windows",bounds:o})})}let Te={viewer:t.viewer??null,notify(o){if(e.open)P({type:"control",control:o})}},fe=(o)=>{if(!g)return;if(!c||!("kind"in c)||c.kind!=="simulator")De.claim(Te);o(g)};return{opened(){M.relay_ms??=U()},received(o){Ee+=o.byteLength;let a;try{a=n.push(o)}catch{K("viewer_protocol");return}for(let u of a){if(e.done)return;switch(u.type){case"ping":P({type:"pong",token:u.token});break;case"pointer":fe((y)=>y.pointer(u.x,u.y,u.buttons));break;case"key":fe((y)=>y.key(u.down,u.keysym));break;case"clientClipboard":fe((y)=>y.clipboard(u.text));break;case"config":if(u.preset!==l)l=u.preset,Y();break;case"keyframeRequest":if(w&&!d)Y();break;case"ack":at(u.seq);break;case"audioEnable":if(u.on)ct();else X();break;case"resize":st({width:u.width,height:u.height});break;default:break}}if(!m&&!e.done){if(m=!0,M.viewer_ms=U(),t.viewer)ae=De.join(Te);pe(),Re()}},close(){if(c&&!("kind"in c)){let o=G.get(c.display);if(o?.delete(Pe),o?.size===0)G.delete(c.display)}if(ae?.(),ae=null,le?.close(),S)clearInterval(S);if(_)clearInterval(_);clearTimeout(se),p?.leave(ce),X(),g?.close()},summary:()=>({output_bytes:ve,input_bytes:Ee,video:{preset:l,frames:ne,dropped:O,restarts:re,avg_fps:H!==null&&ie>H?Math.round((ne-1)/((ie-H)/1e6)*10)/10:0,min_rtt_ms:Math.round(te??0),p50_rtt_ms:ee?lt():0,audio_packets:T,audio_dropped:x,resizes:Me,connect:M}})}}var Ye=null,nt=null,Yt=null,jt=null;function Zt(){let e=A();return e?.features.display?e.ffmpeg:null}function rt(e){return Ye??=new Promise((t)=>{xt(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(s,i)=>{let n=(l)=>!s&&new RegExp(`^\\s*V\\S*\\s+${l}\\s`,"m").test(i);t(nt={x264:n("libx264"),videotoolbox:n("h264_videotoolbox")})})}),Ye}var je=null;function Yo(){return je??=(async()=>{let e=[A()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((s)=>Boolean(s&&vt(s)));if(!e)return null;let t=await rt(e);return t.videotoolbox||t.x264?e:null})(),je}function Jt(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let s=(t.ffmpeg??Zt)();if(!s)return Promise.resolve(!1);let i=(t.encoders??rt)(s);if(e==="linux")return i.then((l)=>l.x264);if(e==="win32"){let l=t.windowsScreen?t.windowsScreen():jt??=wc();return Promise.all([i,l]).then(([c,h])=>c.x264&&(h?.session??0)>0)}let n=t.macScreen?t.macScreen():Yt??=Pr(ke());return Promise.all([i,n]).then(([l,c])=>(l.x264||l.videotoolbox)&&c?.screen===!0&&c.accessibility)}
48
+ export{Go,Kt,_c,Ko,Jo,Xo,Yo,Jt};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ui,zi,qi,Mn}from"./vm-hands-entry-lite-kbnxk71q.js";import{hc,fc,F,Ei,ki,jo,_r,Ho,xi,qt,_t,Uo,Wt,He,Vt,yt,yn,Ci,Ai,qo}from"./vm-hands-entry-lite-zp7chzcc.js";import{Un}from"./vm-hands-entry-lite-rxydyqke.js";import{gn}from"./vm-hands-entry-lite-a3gq377t.js";import{vt}from"./vm-hands-entry-lite-fccn6s4j.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
2
+ import{zi,qi,Wi,Bn}from"./vm-hands-entry-lite-hpw27zfb.js";import{hc,fc,F,ki,xi,Ho,_r,Uo,Ci,qt,_t,zo,Wt,He,Vt,yt,wn,Ai,Pi,Wo}from"./vm-hands-entry-lite-bc9zq8gx.js";import{zn}from"./vm-hands-entry-lite-h7f5a5mb.js";import{_n}from"./vm-hands-entry-lite-dh87ysh2.js";import{vt}from"./vm-hands-entry-lite-hpe54h0b.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
3
3
  const fail = (message, reasonCode) => { throw Object.assign(Error(message), {reasonCode}); };
4
4
  const read = (p, reasonCode, trim=true) => { try { const text=fs.readFileSync(p, "utf8"); return trim?text.trim():text; }
5
5
  catch { fail("memory_read", reasonCode); } };
@@ -309,7 +309,7 @@ function fileOperation(request) {
309
309
  });
310
310
  return { promise, cancel() {} };
311
311
  }
312
- `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as O}from"crypto";var q=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var an=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+an.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],b=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],E="^(?!(?:"+v.join("|")+")$)(?!(?:"+b.join("|")+"))"+t.slice(1),S="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+S+"|"+E.slice(1,-1)+")$",w=new RegExp(n);function fi(u){return w.test(u)}var dr=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),Re=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var U=2,H="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],R=d.join(":"),I=["/opt/homebrew/bin",...d].join(":"),A='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var P=String.raw`(function(anchor, pid, native) {
312
+ `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as O}from"crypto";var q=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var cn=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+cn.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],b=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],E="^(?!(?:"+v.join("|")+")$)(?!(?:"+b.join("|")+"))"+t.slice(1),S="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+S+"|"+E.slice(1,-1)+")$",w=new RegExp(n);function mi(u){return w.test(u)}var dr=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),Re=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var U=2,H="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],R=d.join(":"),I=["/opt/homebrew/bin",...d].join(":"),A='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var P=String.raw`(function(anchor, pid, native) {
313
313
  const token = native.identity(pid);
314
314
  const session = native.session(pid);
315
315
  if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
@@ -369,22 +369,22 @@ const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(r)};
369
369
  const sampleGuestMemory = ${o};
370
370
  const inspectMacPtyMember = ${P};
371
371
  const probeLinuxPtyLibrary = ${k};
372
- const windowsPtyApi = ${gn};
372
+ const windowsPtyApi = ${_n};
373
373
  const LINUX_PTY_EXEC_SOURCE = ${JSON.stringify(N)};
374
- const CLOSE_CODES = ${JSON.stringify(Ai)};
374
+ const CLOSE_CODES = ${JSON.stringify(Pi)};
375
375
  const SHA256_RE = /^[0-9a-f]{64}$/;
376
- const MAX_FRAME_BYTES = ${Ei};
377
- const MAX_INPUT_CHARS = ${ki};
378
- const MAX_STRUCTURED_INPUT_CHARS = ${jo};
376
+ const MAX_FRAME_BYTES = ${ki};
377
+ const MAX_INPUT_CHARS = ${xi};
378
+ const MAX_STRUCTURED_INPUT_CHARS = ${Ho};
379
379
  const MAX_OUTPUT_CHARS = ${_r};
380
- const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${qo};
381
- const MAX_ERROR_CHARS = ${Ho};
380
+ const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${Wo};
381
+ const MAX_ERROR_CHARS = ${Uo};
382
382
  const MAX_LEDGER_IDS = 16384;
383
383
  const MAX_CACHED_RESULTS = 256;
384
- const MAX_JOB_INPUT_CHARS = ${xi};
384
+ const MAX_JOB_INPUT_CHARS = ${Ci};
385
385
  const MAX_JOB_OUTPUT_CHARS = ${qt};
386
386
  const MAX_JOB_OUTPUT_CHUNKS = ${_t};
387
- const MAX_JOBS = ${Uo};
387
+ const MAX_JOBS = ${zo};
388
388
  const MAX_JOB_RECORD_BYTES = 262144;
389
389
  const MAX_JOB_JOURNAL_BYTES = MAX_JOBS * MAX_JOB_RECORD_BYTES;
390
390
  const MAX_JOB_CONTROL_FRAME_BYTES = ${Wt};
@@ -395,7 +395,7 @@ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
395
395
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
396
396
  const WINDOWS = process.platform === "win32";
397
397
  // Each Bash leader's tree on Windows, children that outlive it included (shared/windows-job-object.ts).
398
- const windowsJobs = WINDOWS ? ${Un}(require) : null;
398
+ const windowsJobs = WINDOWS ? ${zn}(require) : null;
399
399
  /** Windows has no POSIX owner or mode bits: the user's own profile folders are
400
400
  * private by their ACLs, and the worker runs as that ordinary user. */
401
401
  function ownedPrivately(stat, mask = 0o077) {
@@ -577,12 +577,12 @@ function validJobEnvSourcePath() {
577
577
  if (config.jobEnvSourcePath === undefined || config.jobEnvSourcePath === path.join(config.workRoot, "job.env")) return true;
578
578
  // A cloud workspace's job.env is in its Session's root-only control
579
579
  // directory (shared/device-workspace.ts), derived from the root alone.
580
- const cloud = new RegExp(${JSON.stringify(Mn.source)}).exec(config.workRoot);
580
+ const cloud = new RegExp(${JSON.stringify(Bn.source)}).exec(config.workRoot);
581
581
  if (process.platform === "linux" && cloud) {
582
582
  const workspaceId = cloud[3];
583
- const owner = (new RegExp(${JSON.stringify(zi.source)}).exec(workspaceId) || [])[1]
584
- ?? (new RegExp(${JSON.stringify(qi.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
- return config.jobEnvSourcePath === ${JSON.stringify(Ui)} + "/" + owner + "/job.env";
583
+ const owner = (new RegExp(${JSON.stringify(qi.source)}).exec(workspaceId) || [])[1]
584
+ ?? (new RegExp(${JSON.stringify(Wi.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
+ return config.jobEnvSourcePath === ${JSON.stringify(zi)} + "/" + owner + "/job.env";
586
586
  }
587
587
  // Personal Cloud controls are root-owned and outside the writable grant.
588
588
  // Admit only the same canonical session, never a caller-selected private path.
@@ -2347,7 +2347,7 @@ function windowsPtyOperation(request, managed) {
2347
2347
  try {
2348
2348
  if (pty.activeProcesses() > 0) pty.terminate();
2349
2349
  for (const startedAt = Date.now(); pty.activeProcesses() > 0;) {
2350
- if (Date.now() - startedAt > ${yn}) throw new Error("pty_cleanup_timeout");
2350
+ if (Date.now() - startedAt > ${wn}) throw new Error("pty_cleanup_timeout");
2351
2351
  await new Promise((resolve) => setTimeout(resolve, 20));
2352
2352
  }
2353
2353
  pty.close();
@@ -2795,7 +2795,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
2795
2795
  const { members, empty } = native.session(anchor, device);
2796
2796
  try {
2797
2797
  if (empty && exitCode !== null && subreaper) break;
2798
- if (Date.now() - startedAt > ${yn}) throw new Error("pty_cleanup_timeout");
2798
+ if (Date.now() - startedAt > ${wn}) throw new Error("pty_cleanup_timeout");
2799
2799
  for (const token of members) {
2800
2800
  if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
2801
2801
  const id = native.identityKey(token);
@@ -2811,7 +2811,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
2811
2811
  controlReleased = true;
2812
2812
  let exitTimer;
2813
2813
  try { await Promise.race([child.exited, new Promise((_, reject) => {
2814
- exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${Ci});
2814
+ exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${Ai});
2815
2815
  })]); } finally { clearTimeout(exitTimer); }
2816
2816
  if (timedOut) finish("timeout", 124);
2817
2817
  else if (cancelled) finish("cancelled", 130);
@@ -4176,5 +4176,5 @@ void startJobControl().then(() => {
4176
4176
  try { loadJobs(); prepareRequestJournal(); } catch { process.exit(44); }
4177
4177
  if (validPrivateJob) markReady(); else connect();
4178
4178
  }, () => process.exit(45));
4179
- `.trimStart();var T=O("sha256").update(nl,"utf8").digest("hex"),Ro={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
- export{an,fi,dr,Re,U,H,nl,T,Ro};
4179
+ `.trimStart();var T=O("sha256").update(nl,"utf8").digest("hex"),To={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
+ export{cn,mi,dr,Re,U,H,nl,T,To};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{te}from"./vm-hands-entry-lite-kbnxk71q.js";var pc=32;var hc="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",fc=262144;var F=2,Ei=33554432,ki=200000,jo=4000000,_r=240000;var Ho=2000;var xi=16384,qt=32768,_t=128,Uo=64,Wt=2097152,_n=1,He=16384,Vt=32768,zo=8388608,yt=1000,yn=2500,Ci=2000,wn=yn+Ci,R=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,h=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Ai={text_only:4430,invalid_json:4431,invalid_cancel_request:4432,invalid_sdk_response:4433,claim_required:4434,invalid_claim:4435,executor_mismatch:4436,stale_generation:4437,fence_conflict:4438,frame_too_large:4439,result_too_large:4440,progress_too_large:4441,terminal_cleanup_started:4442,job_journal_unavailable:4443},V=new Map(Object.entries(Ai).map(([t,n])=>[n,t]));var N=["cancelled","command_failed","duplicate_request_id","duplicate_result_evicted","invalid_repl_response","invalid_request","process_group_cleanup_unconfirmed","repl_failed","result_too_large","repl_response_too_large","repl_transport_failed","request_ledger_full","request_journal_unavailable","request_outcome_uncertain","maintenance_held","request_not_found","resume_digest_mismatch","spawn_failed","stale_generation","timeout"],I=new Set(N),qo=16384,y=["maintenance_held","invalid_job_request","jobs_disabled","job_not_found","job_conflict","job_capacity","job_journal_unavailable","job_not_running","job_lease_expired","job_input_sequence","job_input_backpressure","stale_generation","pty_unsupported","job_mode_mismatch"];class r extends Error{code;constructor(t){super(t);this.name="HandsProtocolError",this.code=t}}function m(t){return new TextEncoder().encode(t).byteLength}function a(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function i(t,n){let e=new Set(n);return Object.keys(t).every((s)=>e.has(s))}function nt(t){return typeof t==="string"&&R.test(t)}function Ee(t){return Number.isSafeInteger(t)&&Number(t)>=1}function ce(t){return typeof t==="string"&&h.test(t)}function it(t){return typeof t==="string"&&t.startsWith("pty-")&&ce(t.slice(4))}function p(t){return[t.cols,t.rows].every((n)=>Number.isSafeInteger(n)&&Number(n)>=1&&Number(n)<=yt)}function _(t){if(typeof t!=="string"||t.length>Math.ceil(He/3)*4||t.length%4!==0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return-1;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;if(n&&"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[t.length-n-1])&(n===2?15:3))return-1;let s=t.length/4*3-n;return s<=He?s:-1}function l(t){if(m(t)>Ei)throw new r("frame_too_large");try{return JSON.parse(t)}catch{throw new r("invalid_json")}}function Pi(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","jobId","action","input"])||n.type!=="job"||n.version!==F||!Ee(n.generation)||!nt(n.id)||!nt(n.jobId)||!a(n.input))throw new r("invalid_job_request");let e=n.input,s=Number.isSafeInteger(e.leaseExpiresAtMs)&&Number(e.leaseExpiresAtMs)>0,d=Number.isSafeInteger(e.sequence)&&Number(e.sequence)>=1;if(!(n.action==="start"?e.mode==="pty"?i(e,["mode","cols","rows","leaseExpiresAtMs"])&&it(n.jobId)&&p(e)&&s:i(e,["script","leaseExpiresAtMs"])&&typeof e.script==="string"&&e.script.length<=ki&&s:n.action==="inspect"?i(e,["after"])&&Number.isSafeInteger(e.after)&&Number(e.after)>=0:n.action==="input"?"dataBase64"in e?i(e,["sequence","dataBase64"])&&it(n.jobId)&&d&&_(e.dataBase64)>0:i(e,["sequence","data","eof"])&&d&&typeof e.data==="string"&&e.data.length<=xi&&typeof e.eof==="boolean":n.action==="resize"?i(e,["sequence","cols","rows"])&&it(n.jobId)&&d&&p(e):n.action==="renew"?i(e,["leaseExpiresAtMs"])&&s:n.action==="cancel"&&i(e,[])))throw new r("invalid_job_request");return n}function Ri(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","ok","job","error"])||n.type!=="job_result"||n.version!==F||!Ee(n.generation)||!nt(n.id))throw new r("invalid_job_result");if(n.ok===!1&&n.job===void 0&&typeof n.error==="string"&&y.some((o)=>o===n.error))return n;let e=n.job;if(n.ok!==!0||n.error!==void 0||!a(e)||!i(e,["jobId","state","startedAtMs","finishedAtMs","leaseExpiresAtMs","exitCode","inputSequence","output","firstCursor","nextCursor","truncated","process","environmentRevision","environmentSnapshotId","pty"])||!nt(e.jobId)||!["starting","running","exited","cancelled","expired","uncertain"].includes(String(e.state))||!Number.isSafeInteger(e.startedAtMs)||Number(e.startedAtMs)<1||!Number.isSafeInteger(e.leaseExpiresAtMs)||Number(e.leaseExpiresAtMs)<1||e.finishedAtMs!==null&&(!Number.isSafeInteger(e.finishedAtMs)||Number(e.finishedAtMs)<Number(e.startedAtMs))||e.exitCode!==null&&(!Number.isSafeInteger(e.exitCode)||Number(e.exitCode)<0||Number(e.exitCode)>255)||!Number.isSafeInteger(e.inputSequence)||Number(e.inputSequence)<0||!Number.isSafeInteger(e.firstCursor)||Number(e.firstCursor)<1||!Number.isSafeInteger(e.nextCursor)||Number(e.nextCursor)<Number(e.firstCursor)-1||typeof e.truncated!=="boolean"||!Array.isArray(e.output)||e.output.length>_t)throw new r("invalid_job_result");if(e.environmentRevision===void 0!==(e.environmentSnapshotId===void 0)||e.environmentRevision!==void 0&&(!Number.isSafeInteger(e.environmentRevision)||Number(e.environmentRevision)<1||!ce(e.environmentSnapshotId)))throw new r("invalid_job_result");let s=Number(e.firstCursor)-1,d=0;for(let o of e.output){if(!a(o)||!i(o,["cursor","stream","text"])||!Number.isSafeInteger(o.cursor)||Number(o.cursor)<=s||Number(o.cursor)>Number(e.nextCursor)||!["stdout","stderr"].includes(String(o.stream))||typeof o.text!=="string")throw new r("invalid_job_result");d+=o.text.length,s=Number(o.cursor)}if(d>qt)throw new r("invalid_job_result");let c=e.state==="starting"||e.state==="running";if(c&&(e.finishedAtMs!==null||e.exitCode!==null)||!c&&e.finishedAtMs===null||e.state==="uncertain"&&e.exitCode!==null||e.state==="exited"&&e.exitCode===null||e.state==="cancelled"&&e.exitCode!==130||e.state==="expired"&&e.exitCode!==124)throw new r("invalid_job_result");if(e.process!==void 0){let o=e.process;if(!a(o)||!i(o,["pid","processGroupId","executorLaunchId"])||!Number.isSafeInteger(o.pid)||Number(o.pid)<1||o.processGroupId!==o.pid||!ce(o.executorLaunchId)||!["starting","running"].includes(String(e.state)))throw new r("invalid_job_result")}if(e.pty!==void 0){let o=e.pty;if(!a(o)||!i(o,["version","cols","rows","output","cleanup"])||o.version!==_n||!it(e.jobId)||!p(o)||e.output.length!==0||!Array.isArray(o.output)||o.output.length>_t||(c?o.cleanup!=="pending":e.state==="uncertain"?o.cleanup!=="unconfirmed":o.cleanup!=="confirmed")||e.state==="running"&&(e.process===void 0||e.environmentRevision===void 0))throw new r("invalid_job_result");let g=Number(e.firstCursor)-1,b=0;for(let u of o.output){if(!a(u)||!i(u,["cursor","dataBase64"])||!Number.isSafeInteger(u.cursor)||Number(u.cursor)<=g||Number(u.cursor)>Number(e.nextCursor))throw new r("invalid_job_result");let f=_(u.dataBase64);if(f<=0||(b+=f)>Vt)throw new r("invalid_job_result");g=Number(u.cursor)}}return n}function Wo(t){if(m(t)>Wt)throw new r("frame_too_large");let n=l(t);if(!a(n)||!i(n,["version","sessionId","operationId","runId","deviceId","rootId","workspace","binding","targetRevision","rootGrantRevision","generation","fenceId","executorLaunchId","job"])||n.version!==_n||![n.sessionId,n.operationId,n.runId].every(nt)||![n.deviceId,n.rootId,n.fenceId,n.executorLaunchId].every(ce)||!Ee(n.generation)||!Number.isSafeInteger(n.rootGrantRevision)||Number(n.rootGrantRevision)<1||!["workspace_source","mcp_control"].includes(String(n.binding))||!Number.isSafeInteger(n.targetRevision)||Number(n.targetRevision)<0||n.binding==="workspace_source"&&n.targetRevision!==0||!a(n.workspace))throw new r("invalid_pty_receipt");if(!te(n.workspace))throw new r("invalid_pty_receipt");let e=Ri(JSON.stringify({type:"job_result",version:F,generation:n.generation,id:n.operationId,ok:!0,job:n.job}));if(!e.ok||!e.job.pty||e.job.pty.output.length!==0||e.job.process&&e.job.process.executorLaunchId!==n.executorLaunchId)throw new r("invalid_pty_receipt");return n}export{pc,hc,fc,F,Ei,ki,jo,_r,Ho,xi,qt,_t,Uo,Wt,_n,He,Vt,zo,yt,yn,Ci,wn,Ai,qo,nt,Ee,ce,it,Pi,Ri,Wo};
2
+ import{te}from"./vm-hands-entry-lite-hpw27zfb.js";var pc=32;var hc="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",fc=262144;var F=2,ki=33554432,xi=200000,Ho=4000000,_r=240000;var Uo=2000;var Ci=16384,qt=32768,_t=128,zo=64,Wt=2097152,yn=1,He=16384,Vt=32768,qo=8388608,yt=1000,wn=2500,Ai=2000,bn=wn+Ai,R=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,h=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Pi={text_only:4430,invalid_json:4431,invalid_cancel_request:4432,invalid_sdk_response:4433,claim_required:4434,invalid_claim:4435,executor_mismatch:4436,stale_generation:4437,fence_conflict:4438,frame_too_large:4439,result_too_large:4440,progress_too_large:4441,terminal_cleanup_started:4442,job_journal_unavailable:4443},V=new Map(Object.entries(Pi).map(([t,n])=>[n,t]));var N=["cancelled","command_failed","duplicate_request_id","duplicate_result_evicted","invalid_repl_response","invalid_request","process_group_cleanup_unconfirmed","repl_failed","result_too_large","repl_response_too_large","repl_transport_failed","request_ledger_full","request_journal_unavailable","request_outcome_uncertain","maintenance_held","request_not_found","resume_digest_mismatch","spawn_failed","stale_generation","timeout"],I=new Set(N),Wo=16384,y=["maintenance_held","invalid_job_request","jobs_disabled","job_not_found","job_conflict","job_capacity","job_journal_unavailable","job_not_running","job_lease_expired","job_input_sequence","job_input_backpressure","stale_generation","pty_unsupported","job_mode_mismatch"];class r extends Error{code;constructor(t){super(t);this.name="HandsProtocolError",this.code=t}}function m(t){return new TextEncoder().encode(t).byteLength}function a(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function i(t,n){let e=new Set(n);return Object.keys(t).every((s)=>e.has(s))}function nt(t){return typeof t==="string"&&R.test(t)}function Ee(t){return Number.isSafeInteger(t)&&Number(t)>=1}function ce(t){return typeof t==="string"&&h.test(t)}function it(t){return typeof t==="string"&&t.startsWith("pty-")&&ce(t.slice(4))}function p(t){return[t.cols,t.rows].every((n)=>Number.isSafeInteger(n)&&Number(n)>=1&&Number(n)<=yt)}function _(t){if(typeof t!=="string"||t.length>Math.ceil(He/3)*4||t.length%4!==0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return-1;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;if(n&&"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[t.length-n-1])&(n===2?15:3))return-1;let s=t.length/4*3-n;return s<=He?s:-1}function l(t){if(m(t)>ki)throw new r("frame_too_large");try{return JSON.parse(t)}catch{throw new r("invalid_json")}}function Ri(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","jobId","action","input"])||n.type!=="job"||n.version!==F||!Ee(n.generation)||!nt(n.id)||!nt(n.jobId)||!a(n.input))throw new r("invalid_job_request");let e=n.input,s=Number.isSafeInteger(e.leaseExpiresAtMs)&&Number(e.leaseExpiresAtMs)>0,d=Number.isSafeInteger(e.sequence)&&Number(e.sequence)>=1;if(!(n.action==="start"?e.mode==="pty"?i(e,["mode","cols","rows","leaseExpiresAtMs"])&&it(n.jobId)&&p(e)&&s:i(e,["script","leaseExpiresAtMs"])&&typeof e.script==="string"&&e.script.length<=xi&&s:n.action==="inspect"?i(e,["after"])&&Number.isSafeInteger(e.after)&&Number(e.after)>=0:n.action==="input"?"dataBase64"in e?i(e,["sequence","dataBase64"])&&it(n.jobId)&&d&&_(e.dataBase64)>0:i(e,["sequence","data","eof"])&&d&&typeof e.data==="string"&&e.data.length<=Ci&&typeof e.eof==="boolean":n.action==="resize"?i(e,["sequence","cols","rows"])&&it(n.jobId)&&d&&p(e):n.action==="renew"?i(e,["leaseExpiresAtMs"])&&s:n.action==="cancel"&&i(e,[])))throw new r("invalid_job_request");return n}function Ti(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","ok","job","error"])||n.type!=="job_result"||n.version!==F||!Ee(n.generation)||!nt(n.id))throw new r("invalid_job_result");if(n.ok===!1&&n.job===void 0&&typeof n.error==="string"&&y.some((o)=>o===n.error))return n;let e=n.job;if(n.ok!==!0||n.error!==void 0||!a(e)||!i(e,["jobId","state","startedAtMs","finishedAtMs","leaseExpiresAtMs","exitCode","inputSequence","output","firstCursor","nextCursor","truncated","process","environmentRevision","environmentSnapshotId","pty"])||!nt(e.jobId)||!["starting","running","exited","cancelled","expired","uncertain"].includes(String(e.state))||!Number.isSafeInteger(e.startedAtMs)||Number(e.startedAtMs)<1||!Number.isSafeInteger(e.leaseExpiresAtMs)||Number(e.leaseExpiresAtMs)<1||e.finishedAtMs!==null&&(!Number.isSafeInteger(e.finishedAtMs)||Number(e.finishedAtMs)<Number(e.startedAtMs))||e.exitCode!==null&&(!Number.isSafeInteger(e.exitCode)||Number(e.exitCode)<0||Number(e.exitCode)>255)||!Number.isSafeInteger(e.inputSequence)||Number(e.inputSequence)<0||!Number.isSafeInteger(e.firstCursor)||Number(e.firstCursor)<1||!Number.isSafeInteger(e.nextCursor)||Number(e.nextCursor)<Number(e.firstCursor)-1||typeof e.truncated!=="boolean"||!Array.isArray(e.output)||e.output.length>_t)throw new r("invalid_job_result");if(e.environmentRevision===void 0!==(e.environmentSnapshotId===void 0)||e.environmentRevision!==void 0&&(!Number.isSafeInteger(e.environmentRevision)||Number(e.environmentRevision)<1||!ce(e.environmentSnapshotId)))throw new r("invalid_job_result");let s=Number(e.firstCursor)-1,d=0;for(let o of e.output){if(!a(o)||!i(o,["cursor","stream","text"])||!Number.isSafeInteger(o.cursor)||Number(o.cursor)<=s||Number(o.cursor)>Number(e.nextCursor)||!["stdout","stderr"].includes(String(o.stream))||typeof o.text!=="string")throw new r("invalid_job_result");d+=o.text.length,s=Number(o.cursor)}if(d>qt)throw new r("invalid_job_result");let c=e.state==="starting"||e.state==="running";if(c&&(e.finishedAtMs!==null||e.exitCode!==null)||!c&&e.finishedAtMs===null||e.state==="uncertain"&&e.exitCode!==null||e.state==="exited"&&e.exitCode===null||e.state==="cancelled"&&e.exitCode!==130||e.state==="expired"&&e.exitCode!==124)throw new r("invalid_job_result");if(e.process!==void 0){let o=e.process;if(!a(o)||!i(o,["pid","processGroupId","executorLaunchId"])||!Number.isSafeInteger(o.pid)||Number(o.pid)<1||o.processGroupId!==o.pid||!ce(o.executorLaunchId)||!["starting","running"].includes(String(e.state)))throw new r("invalid_job_result")}if(e.pty!==void 0){let o=e.pty;if(!a(o)||!i(o,["version","cols","rows","output","cleanup"])||o.version!==yn||!it(e.jobId)||!p(o)||e.output.length!==0||!Array.isArray(o.output)||o.output.length>_t||(c?o.cleanup!=="pending":e.state==="uncertain"?o.cleanup!=="unconfirmed":o.cleanup!=="confirmed")||e.state==="running"&&(e.process===void 0||e.environmentRevision===void 0))throw new r("invalid_job_result");let g=Number(e.firstCursor)-1,b=0;for(let u of o.output){if(!a(u)||!i(u,["cursor","dataBase64"])||!Number.isSafeInteger(u.cursor)||Number(u.cursor)<=g||Number(u.cursor)>Number(e.nextCursor))throw new r("invalid_job_result");let f=_(u.dataBase64);if(f<=0||(b+=f)>Vt)throw new r("invalid_job_result");g=Number(u.cursor)}}return n}function Vo(t){if(m(t)>Wt)throw new r("frame_too_large");let n=l(t);if(!a(n)||!i(n,["version","sessionId","operationId","runId","deviceId","rootId","workspace","binding","targetRevision","rootGrantRevision","generation","fenceId","executorLaunchId","job"])||n.version!==yn||![n.sessionId,n.operationId,n.runId].every(nt)||![n.deviceId,n.rootId,n.fenceId,n.executorLaunchId].every(ce)||!Ee(n.generation)||!Number.isSafeInteger(n.rootGrantRevision)||Number(n.rootGrantRevision)<1||!["workspace_source","mcp_control"].includes(String(n.binding))||!Number.isSafeInteger(n.targetRevision)||Number(n.targetRevision)<0||n.binding==="workspace_source"&&n.targetRevision!==0||!a(n.workspace))throw new r("invalid_pty_receipt");if(!te(n.workspace))throw new r("invalid_pty_receipt");let e=Ti(JSON.stringify({type:"job_result",version:F,generation:n.generation,id:n.operationId,ok:!0,job:n.job}));if(!e.ok||!e.job.pty||e.job.pty.output.length!==0||e.job.process&&e.job.process.executorLaunchId!==n.executorLaunchId)throw new r("invalid_pty_receipt");return n}export{pc,hc,fc,F,ki,xi,Ho,_r,Uo,Ci,qt,_t,zo,Wt,yn,He,Vt,qo,yt,wn,Ai,bn,Pi,Wo,nt,Ee,ce,it,Ri,Ti,Vo};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{Ft}from"./vm-hands-entry-lite-s93f3pbv.js";import{ln}from"./vm-hands-entry-lite-q62g6sx0.js";import{Y,Ye,B}from"./vm-hands-entry-lite-pg7nnyc6.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as k,spawnSync as N}from"child_process";import{existsSync as S,mkdtempSync as z,readFileSync as j,readdirSync as we,realpathSync as Se,rmSync as q,statSync as Q}from"fs";import{platform as W,tmpdir as V}from"os";import{dirname as A,join as u,win32 as x}from"path";import{fileURLToPath as be,pathToFileURL as F}from"url";var xe=["bwrap","socat","rg"],he=2000,I=20000,ye=3,O=4000,Pe=new Set([".git",".hg",".svn","node_modules"]),Ee=["runAsHostUid","sysrq-trigger"],Z=u(A(A(be(import.meta.url))),"packages","sandbox-runtime"),Re=u(Z,"src","index.ts"),ee=!1;function cr(){ee=!0}function ne(){return ee?u(A(Se(process.execPath)),"runtime","srt"):void 0}function Ae(){let e=u(ne()??Z,"vendor","srt-win");return u(e,process.arch,"srt-win.exe")}var Da="confined commands need the Windows sandbox: run `reason connect` and approve the Windows prompt.";function tn(e=Ae()){let n=N(e,["status"],{encoding:"utf8",timeout:15000,windowsHide:!0});try{let o=JSON.parse(n.stdout??"");return n.status===0&&o.user?.user?.exists===!0&&o.user.cred_present===!0}catch{return!1}}function Oa(e=Ae()){let n=N(e,["install"],{stdio:["ignore","ignore","ignore"],timeout:120000,windowsHide:!0});return n.status===0?"installed":n.status===10?"cancelled":"failed"}async function te(){let e=ne();if(e&&process.platform==="linux"&&!S(u(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!S(Ae()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=j(u(e,"sandbox-runtime.mjs"),"utf8");for(let s of Ee)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let t=(await import(e?F(u(e,"sandbox-runtime.mjs")).href:F(Re).href)).SandboxManager;if(!t||typeof t.initialize!=="function"||typeof t.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:t}}function _e(e={}){if((e.platformName??W())!=="linux")return!1;let o=e.fileExists??S,t=e.readFile??((i)=>j(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(t("/proc/1/cgroup"))}catch{return!1}}function re(e){return["/bin/true","/usr/bin/true"].find((n)=>e(n))??null}function Me(e,n){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",n]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",n]}function Ce(e,n){try{let o=N("bwrap",Me(e,n),{stdio:"ignore",timeout:he});return!o.error&&o.status===0}catch{return!1}}function ve(e){let n=e.platformName??W(),o=e.fileExists??S;if(n==="win32")return(e.bash??Y)()&&o(Ae())?m??"strict":null;if(n!=="linux")return null;let t=e.hasExecutable??ln;if(!xe.every((l)=>t(l)))return null;let i=re(o);if(!i)return null;let s=m??(e.containerized??_e({platformName:n})?"weak":"strict");return(e.probeNamespaces??((l)=>Ce(l,i)))(s)?s:null}var h=null,M=!1,p=null,U=null,H=null,m=null,y=null,_=null,P=null,C=[],b=new Map;function v(){throw g("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Na(e){if(m!==null&&m!==e||M&&h!==null&&h!==e||y!==null&&y!==e)v();m=e}function g(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
- `);p=e}function Xn(e){if(p)return!1;if(!M){if(h=ve(e??{}),M=!0,h&&!e)ue()}return h!==null}function De(){return Xn()?h:null}var E=null,w=0;function D(e,n){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)v();let o=m??e.sandboxMode??De();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(y&&y!==o)v();return y=o,E??=(async()=>{let{SandboxManager:t}=await(e.loadSandboxRuntime??te)();return await t.initialize(Ie(o,n)),t})().catch((t)=>{if(E=null,n)_=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(t).slice(0,500)})
2
+ import{Ft}from"./vm-hands-entry-lite-732hnx41.js";import{un}from"./vm-hands-entry-lite-chve4vmh.js";import{Y,Ye,B}from"./vm-hands-entry-lite-04nx5y4f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as k,spawnSync as N}from"child_process";import{existsSync as S,mkdtempSync as z,readFileSync as j,readdirSync as we,realpathSync as Se,rmSync as q,statSync as Q}from"fs";import{platform as W,tmpdir as V}from"os";import{dirname as A,join as u,win32 as x}from"path";import{fileURLToPath as be,pathToFileURL as F}from"url";var xe=["bwrap","socat","rg"],he=2000,I=20000,ye=3,O=4000,Pe=new Set([".git",".hg",".svn","node_modules"]),Ee=["runAsHostUid","sysrq-trigger"],Z=u(A(A(be(import.meta.url))),"packages","sandbox-runtime"),Re=u(Z,"src","index.ts"),ee=!1;function cr(){ee=!0}function ne(){return ee?u(A(Se(process.execPath)),"runtime","srt"):void 0}function Ae(){let e=u(ne()??Z,"vendor","srt-win");return u(e,process.arch,"srt-win.exe")}var Oa="confined commands need the Windows sandbox: run `reason connect` and approve the Windows prompt.";function tn(e=Ae()){let n=N(e,["status"],{encoding:"utf8",timeout:15000,windowsHide:!0});try{let o=JSON.parse(n.stdout??"");return n.status===0&&o.user?.user?.exists===!0&&o.user.cred_present===!0}catch{return!1}}function Na(e=Ae()){let n=N(e,["install"],{stdio:["ignore","ignore","ignore"],timeout:120000,windowsHide:!0});return n.status===0?"installed":n.status===10?"cancelled":"failed"}async function te(){let e=ne();if(e&&process.platform==="linux"&&!S(u(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!S(Ae()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=j(u(e,"sandbox-runtime.mjs"),"utf8");for(let s of Ee)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let t=(await import(e?F(u(e,"sandbox-runtime.mjs")).href:F(Re).href)).SandboxManager;if(!t||typeof t.initialize!=="function"||typeof t.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:t}}function _e(e={}){if((e.platformName??W())!=="linux")return!1;let o=e.fileExists??S,t=e.readFile??((i)=>j(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(t("/proc/1/cgroup"))}catch{return!1}}function re(e){return["/bin/true","/usr/bin/true"].find((n)=>e(n))??null}function Me(e,n){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",n]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",n]}function Ce(e,n){try{let o=N("bwrap",Me(e,n),{stdio:"ignore",timeout:he});return!o.error&&o.status===0}catch{return!1}}function ve(e){let n=e.platformName??W(),o=e.fileExists??S;if(n==="win32")return(e.bash??Y)()&&o(Ae())?m??"strict":null;if(n!=="linux")return null;let t=e.hasExecutable??un;if(!xe.every((l)=>t(l)))return null;let i=re(o);if(!i)return null;let s=m??(e.containerized??_e({platformName:n})?"weak":"strict");return(e.probeNamespaces??((l)=>Ce(l,i)))(s)?s:null}var h=null,M=!1,p=null,U=null,H=null,m=null,y=null,_=null,P=null,C=[],b=new Map;function v(){throw g("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function La(e){if(m!==null&&m!==e||M&&h!==null&&h!==e||y!==null&&y!==e)v();m=e}function g(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
+ `);p=e}function Yn(e){if(p)return!1;if(!M){if(h=ve(e??{}),M=!0,h&&!e)ue()}return h!==null}function De(){return Yn()?h:null}var E=null,w=0;function D(e,n){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)v();let o=m??e.sandboxMode??De();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(y&&y!==o)v();return y=o,E??=(async()=>{let{SandboxManager:t}=await(e.loadSandboxRuntime??te)();return await t.initialize(Ie(o,n)),t})().catch((t)=>{if(E=null,n)_=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(t).slice(0,500)})
4
4
  `);else g(`initialize_failed: ${String(t)}`);throw t instanceof r?t:new r("sandbox_unavailable","The confined execution sandbox failed to start.")}),E.then((t)=>{if(p)throw new r("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return t})}function T(){if(w-=1,w===0)for(let e of C.splice(0))e()}async function oe(e,n=!0,o,t){let i=t===void 0?1/0:Date.now()+t;await le();let s=ke();if(n)await s;let a=JSON.stringify(e),l=!1,c=()=>{if(!l)return;l=!1;let d=(b.get(a)??1)-1;if(d>0)b.set(a,d);else b.delete(a)};try{for(;;){if(o?.aborted)throw new r("cancelled","Operation was cancelled.");if(Date.now()>=i)return!1;if(P){await P;continue}let d=b.keys().next().value;if(_??=d??a,_===a&&(d===void 0||d===a))break;if(!l){l=!0,b.set(a,(b.get(a)??0)+1);continue}if(w===0&&d===a){ie();continue}await new Promise((f)=>{if(C.push(f),o?.addEventListener("abort",()=>f(),{once:!0}),i!==1/0)setTimeout(f,Math.max(0,i-Date.now())).unref?.()})}return w+=1,!0}finally{if(l&&w===0)for(let d of C.splice(0))d();c()}}function ie(){return P??=ce().finally(()=>{P=null}),P}function se(e,n,o=process.env){let t=o.USERPROFILE?x.resolve(o.USERPROFILE).toLowerCase():null,i=x.resolve(e).toLowerCase(),s=t!==null&&i.startsWith(`${t}\\`),a=n?ae(o).filter((l)=>l.toLowerCase()===i||l.toLowerCase().startsWith(`${i}\\`)):[];return{denyRead:[],allowRead:[e],allowWrite:n?[e]:[],denyWrite:n?a:s?[]:[e]}}function ae(e,n=process.execPath){let o=new Map;for(let t of[...(e.PATH??e.Path??"").split(";"),x.dirname(n)]){if(!t||!x.isAbsolute(t))continue;let i=x.resolve(t);if(!o.has(i.toLowerCase()))o.set(i.toLowerCase(),i)}return[...o.values()]}function Te(e=process.env,n=process.execPath){let o=[e.SystemRoot,e.ProgramFiles,e["ProgramFiles(x86)"],e.ProgramW6432,e.ProgramData,e.USERPROFILE].filter((t)=>!!t).map((t)=>x.resolve(t).toLowerCase());return ae(e,n).filter((t)=>{let i=t.toLowerCase();return!o.some((s)=>i===s||i.startsWith(`${s}\\`))})}var J=null,K=null;function le(e=Ae()){return K??=(async()=>{let n;try{n=JSON.parse((await de(e,["status"])).stdout).user?.user?.sid}catch{return null}if(typeof n!=="string"||!/^S-1-[0-9-]+$/.test(n))return null;if(!await new Promise((t)=>{let i=k(B("icacls"),[e,"/grant",`*${n}:(RX)`],{stdio:"ignore",windowsHide:!0,timeout:30000});i.on("error",()=>t(!1)),i.on("close",(s)=>t(s===0))}))process.stderr.write(`Reason worker: could not let the Windows sandbox user run srt-win.exe
5
5
  `);return n})(),K}function de(e,n,o){return new Promise((t)=>{let i=k(e,n,{stdio:["pipe","pipe","ignore"],windowsHide:!0,timeout:120000}),s="";i.stdout?.setEncoding("utf8").on("data",(a)=>{s+=a}),i.on("error",()=>t({status:null,stdout:s})),i.on("close",(a)=>t({status:a,stdout:s})),i.stdin?.end(o??"")})}function ke(e=Ae()){return J??=(async()=>{let n=Te();if(n.length===0)return;let o=await le(e),t=o?await de(e,["acl","stamp","--holder-pid",String(process.ppid),"--sandbox-user-sid",o],JSON.stringify({denyRead:[],denyWrite:n})):null;if(!t||t.status!==0&&t.status!==2)g(`program_folder_deny_failed: ${t?`exit ${t.status}`:"no sandbox user"}`),process.stderr.write(`Reason worker: could not deny the Windows sandbox writes to PATH folders (${t?`exit ${t.status}`:"no sandbox user"}); confined commands are off
6
- `)})(),J}var Ne=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function ce(){let e=E;if(E=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function ue(e={}){if(p)return!1;if(e.loadSandboxRuntime)return G(e.loadSandboxRuntime);if(!Xn())return!1;return U??=G(te),U}async function G(e){try{let{SandboxManager:n}=await e();if(process.platform==="win32"){if(!S(Ae()))g("dependencies_missing: srt-win.exe");return!p}let o=n.checkDependencies().errors;if(o.length>0)return g(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(n){return g(`load_failed: ${String(n)}`),!1}}async function La(e={}){if(!e.loadSandboxRuntime&&!e.sandboxMode){if(!await ue())return!1;return H??=X({}),H}return X(e)}async function X(e){let n=process.platform==="win32",o=z(u(V(),"reason-device-probe-"));try{let t=n?se(o,!1):void 0;if(t)await oe(t,!1);let i;try{i=await We(await D(e,t),o)}catch{return!1}finally{if(n)T()}if(!i)g("confined_command_failed");if(w===0)await(n?ie():ce());return i}finally{q(o,{recursive:!0,force:!0})}}async function We(e,n){let o=process.platform==="win32",t=o?"true":re(S);if(!t)return!1;try{let{argv:i,env:s}=await e.wrapWithSandboxArgv(fe([t]),Yn(),{filesystem:o?pe([],n):me({root:n,allowWrite:!1,temporaryDirectory:n,protectedPaths:[]})},void 0,n),[a,...l]=i;if(!a)return!1;return await Le(a,l,n,o?{env:s}:{})}catch{return!1}finally{try{e.cleanupAfterCommand()}catch{}}}function Le(e,n,o,t={}){return new Promise((i)=>{let s=!1,a,l=(f)=>{if(s)return;s=!0,clearTimeout(a),i(f)},c;try{c=(t.spawnChild??k)(e,n,{cwd:o,env:t.env??{PATH:Ft,HOME:o,TMPDIR:o},stdio:"ignore",windowsHide:!0})}catch{l(!1);return}c.once("error",()=>l(!1));let d=(f,R)=>l(f===0&&R===null);if(c.once("exit",d),c.once("close",d),c.exitCode!==null||c.signalCode!==null)d(c.exitCode,c.signalCode);if(s)return;a=setTimeout(()=>{l(!1);try{c.kill("SIGKILL")}catch{}},Math.min(t.timeoutMs??I,I))})}function Yn(e=S,n=W()){if(n==="win32")return Ye("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function fe(e){return e.map((n)=>`'${n.replaceAll("'","'\\''")}'`).join(" ")}function Fe(e,n,o=(t)=>we(t,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let t=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<O){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let c of l){if(s+=1,s>O)break;let d=u(a.path,c);if(n(d)){t.push(d);continue}if(a.depth+1<ye&&!Pe.has(c))i.push({path:d,depth:a.depth+1})}}return t}function me(e){let n=u(e.root,".git"),o=[];try{if(Q(n).isDirectory())o=[u(n,"config"),u(n,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function pe(e,n){let o=u(n,".git"),t=[];try{if(Q(o).isDirectory())t=[u(o,"config"),u(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...t]}}function Ie(e,n){if(n)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:n,windows:{srtWin:{path:Ae()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function $a(e){let n=e.createTemporaryDirectory??(()=>z(u(V(),"reason-device-"))),o=e.removeTemporaryDirectory??((t)=>q(t,{recursive:!0,force:!0}));return async(t,i,s)=>{let a=process.platform==="win32",l;if(a){let d=se(s.root,s.allowWrite);if(!await oe(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await D(e,d)}catch(f){throw T(),f}}else l=await D(e),w+=1;let c;try{c=n();let d=Fe(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ne:"")+fe([t,...i]),e.shell??Yn(),{filesystem:a?pe(d,s.root):me({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:c,protectedPaths:d})},s.signal,s.cwd)}catch(L){throw L instanceof r?L:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[R,...ge]=f.argv;if(!R)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(R,ge,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,c)})}finally{T();try{l.cleanupAfterCommand()}catch{}if(c!==void 0)o(c)}}}
7
- export{cr,Ae,Da,tn,Oa,Na,Xn,La,Yn,$a};
6
+ `)})(),J}var Ne=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function ce(){let e=E;if(E=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function ue(e={}){if(p)return!1;if(e.loadSandboxRuntime)return G(e.loadSandboxRuntime);if(!Yn())return!1;return U??=G(te),U}async function G(e){try{let{SandboxManager:n}=await e();if(process.platform==="win32"){if(!S(Ae()))g("dependencies_missing: srt-win.exe");return!p}let o=n.checkDependencies().errors;if(o.length>0)return g(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(n){return g(`load_failed: ${String(n)}`),!1}}async function $a(e={}){if(!e.loadSandboxRuntime&&!e.sandboxMode){if(!await ue())return!1;return H??=X({}),H}return X(e)}async function X(e){let n=process.platform==="win32",o=z(u(V(),"reason-device-probe-"));try{let t=n?se(o,!1):void 0;if(t)await oe(t,!1);let i;try{i=await We(await D(e,t),o)}catch{return!1}finally{if(n)T()}if(!i)g("confined_command_failed");if(w===0)await(n?ie():ce());return i}finally{q(o,{recursive:!0,force:!0})}}async function We(e,n){let o=process.platform==="win32",t=o?"true":re(S);if(!t)return!1;try{let{argv:i,env:s}=await e.wrapWithSandboxArgv(fe([t]),Zn(),{filesystem:o?pe([],n):me({root:n,allowWrite:!1,temporaryDirectory:n,protectedPaths:[]})},void 0,n),[a,...l]=i;if(!a)return!1;return await Le(a,l,n,o?{env:s}:{})}catch{return!1}finally{try{e.cleanupAfterCommand()}catch{}}}function Le(e,n,o,t={}){return new Promise((i)=>{let s=!1,a,l=(f)=>{if(s)return;s=!0,clearTimeout(a),i(f)},c;try{c=(t.spawnChild??k)(e,n,{cwd:o,env:t.env??{PATH:Ft,HOME:o,TMPDIR:o},stdio:"ignore",windowsHide:!0})}catch{l(!1);return}c.once("error",()=>l(!1));let d=(f,R)=>l(f===0&&R===null);if(c.once("exit",d),c.once("close",d),c.exitCode!==null||c.signalCode!==null)d(c.exitCode,c.signalCode);if(s)return;a=setTimeout(()=>{l(!1);try{c.kill("SIGKILL")}catch{}},Math.min(t.timeoutMs??I,I))})}function Zn(e=S,n=W()){if(n==="win32")return Ye("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function fe(e){return e.map((n)=>`'${n.replaceAll("'","'\\''")}'`).join(" ")}function Fe(e,n,o=(t)=>we(t,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let t=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<O){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let c of l){if(s+=1,s>O)break;let d=u(a.path,c);if(n(d)){t.push(d);continue}if(a.depth+1<ye&&!Pe.has(c))i.push({path:d,depth:a.depth+1})}}return t}function me(e){let n=u(e.root,".git"),o=[];try{if(Q(n).isDirectory())o=[u(n,"config"),u(n,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function pe(e,n){let o=u(n,".git"),t=[];try{if(Q(o).isDirectory())t=[u(o,"config"),u(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...t]}}function Ie(e,n){if(n)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:n,windows:{srtWin:{path:Ae()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Ma(e){let n=e.createTemporaryDirectory??(()=>z(u(V(),"reason-device-"))),o=e.removeTemporaryDirectory??((t)=>q(t,{recursive:!0,force:!0}));return async(t,i,s)=>{let a=process.platform==="win32",l;if(a){let d=se(s.root,s.allowWrite);if(!await oe(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await D(e,d)}catch(f){throw T(),f}}else l=await D(e),w+=1;let c;try{c=n();let d=Fe(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ne:"")+fe([t,...i]),e.shell??Zn(),{filesystem:a?pe(d,s.root):me({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:c,protectedPaths:d})},s.signal,s.cwd)}catch(L){throw L instanceof r?L:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[R,...ge]=f.argv;if(!R)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(R,ge,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,c)})}finally{T();try{l.cleanupAfterCommand()}catch{}if(c!==void 0)o(c)}}}
7
+ export{cr,Ae,Oa,tn,Na,La,Yn,$a,Zn,Ma};