@reason-machines/cli-linux-x64 0.2.494 → 0.2.496

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 (101) hide show
  1. package/bin/reason +1 -1
  2. package/bin/vm-hands/api-c5b67kgx.js +2 -0
  3. package/bin/vm-hands/api-credentials-t0eyqvyb.js +2 -0
  4. package/bin/vm-hands/connect-cli-v2desvzn.js +2 -0
  5. package/bin/vm-hands/credentials-drj5ktpt.js +2 -0
  6. package/bin/vm-hands/custom-endpoint-device-389h3q6n.js +2 -0
  7. package/bin/vm-hands/desktop-account-tjf36aya.js +2 -0
  8. package/bin/vm-hands/{fsevents-wa96aeq8.js → fsevents-s0cwdhcq.js} +1 -1
  9. package/bin/vm-hands/hands-worker-source-wrj180b5.js +2 -0
  10. package/bin/vm-hands/{index-tpxh1rhj.js → index-w9sxzata.js} +7 -7
  11. package/bin/vm-hands/install-receipt-9bv4vth9.js +2 -0
  12. package/bin/vm-hands/local-automation-r8799erc.js +2 -0
  13. package/bin/vm-hands/local-capabilities-3e80wdfw.js +2 -0
  14. package/bin/vm-hands/local-desktop-users-tqagws7p.js +2 -0
  15. package/bin/vm-hands/local-display-mac-w792g9g3.js +2 -0
  16. package/bin/vm-hands/local-display-session-k3nbmz44.js +2 -0
  17. package/bin/vm-hands/local-display-video-wymf2q2t.js +2 -0
  18. package/bin/vm-hands/local-managed-process-knn335hh.js +2 -0
  19. package/bin/vm-hands/local-pty-session-rdv5wv5g.js +2 -0
  20. package/bin/vm-hands/managed-runtime-ajjy7qxf.js +2 -0
  21. package/bin/vm-hands/network-contract-h6s7ptm5.js +2 -0
  22. package/bin/vm-hands/package-yy8qcwwn.js +2 -0
  23. package/bin/vm-hands/permissions-x0d6x75e.js +2 -0
  24. package/bin/vm-hands/{reason-hands-protocol-7ck7a2ba.js → reason-hands-protocol-vw2dbdse.js} +1 -1
  25. package/bin/vm-hands/serve-service-gs1056pz.js +2 -0
  26. package/bin/vm-hands/{status-zmw3r5r6.js → status-x99x0y2e.js} +1 -1
  27. package/bin/vm-hands/version-qztzqxab.js +2 -0
  28. package/bin/vm-hands/{vm-hands-entry-lite-gfrp4eht.js → vm-hands-entry-lite-13rapgf5.js} +2 -2
  29. package/bin/vm-hands/{vm-hands-entry-lite-ytxa5cq0.js → vm-hands-entry-lite-1g1v87ky.js} +3 -3
  30. package/bin/vm-hands/{vm-hands-entry-lite-bveg8vsa.js → vm-hands-entry-lite-2dx4pnz7.js} +2 -2
  31. package/bin/vm-hands/{vm-hands-entry-lite-35rmpfdk.js → vm-hands-entry-lite-2jadtgms.js} +1 -1
  32. package/bin/vm-hands/{vm-hands-entry-lite-myb9bjy9.js → vm-hands-entry-lite-2zq8s2sr.js} +4 -4
  33. package/bin/vm-hands/{vm-hands-entry-lite-nnzqx15h.js → vm-hands-entry-lite-3gztfxwt.js} +13 -13
  34. package/bin/vm-hands/{vm-hands-entry-lite-smx6w8h0.js → vm-hands-entry-lite-4egbv7sp.js} +6 -6
  35. package/bin/vm-hands/{vm-hands-entry-lite-hy242z2t.js → vm-hands-entry-lite-64z2tjpg.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-hza7bvk8.js → vm-hands-entry-lite-6kq28jjd.js} +1 -1
  37. package/bin/vm-hands/{vm-hands-entry-lite-gn2rg810.js → vm-hands-entry-lite-6x1an7es.js} +3 -3
  38. package/bin/vm-hands/{vm-hands-entry-lite-xkba45hh.js → vm-hands-entry-lite-7777m86y.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-4e32vgs8.js → vm-hands-entry-lite-7yyx4qf9.js} +20 -20
  40. package/bin/vm-hands/{vm-hands-entry-lite-tbawqj1n.js → vm-hands-entry-lite-87vmbt38.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-vtbw3evj.js → vm-hands-entry-lite-8qhz89mt.js} +3 -3
  42. package/bin/vm-hands/{vm-hands-entry-lite-vezfnqf1.js → vm-hands-entry-lite-9wa2y4x0.js} +5 -5
  43. package/bin/vm-hands/{vm-hands-entry-lite-g27kmejx.js → vm-hands-entry-lite-a1xa7s06.js} +3 -3
  44. package/bin/vm-hands/vm-hands-entry-lite-b7zgdjf9.js +2 -0
  45. package/bin/vm-hands/{vm-hands-entry-lite-ya9p67x3.js → vm-hands-entry-lite-dw558ggz.js} +1 -1
  46. package/bin/vm-hands/{vm-hands-entry-lite-pk8fxewf.js → vm-hands-entry-lite-e4c6z5t3.js} +1 -1
  47. package/bin/vm-hands/{vm-hands-entry-lite-633mzx27.js → vm-hands-entry-lite-f62fvme8.js} +1 -1
  48. package/bin/vm-hands/{vm-hands-entry-lite-0tzzctxx.js → vm-hands-entry-lite-f69t48dj.js} +2 -2
  49. package/bin/vm-hands/{vm-hands-entry-lite-9r4d4mx1.js → vm-hands-entry-lite-gc7550c0.js} +1 -1
  50. package/bin/vm-hands/{vm-hands-entry-lite-55xh3ezr.js → vm-hands-entry-lite-h1gpv5px.js} +2 -2
  51. package/bin/vm-hands/{vm-hands-entry-lite-ss5n593s.js → vm-hands-entry-lite-ht7fk059.js} +5 -5
  52. package/bin/vm-hands/{vm-hands-entry-lite-v3ga0xcz.js → vm-hands-entry-lite-jc8dwrgp.js} +6 -6
  53. package/bin/vm-hands/vm-hands-entry-lite-jr2jmk4v.js +52 -0
  54. package/bin/vm-hands/{vm-hands-entry-lite-kgf255a9.js → vm-hands-entry-lite-jsbjsdgn.js} +3 -3
  55. package/bin/vm-hands/vm-hands-entry-lite-krm8w7wp.js +3 -0
  56. package/bin/vm-hands/{vm-hands-entry-lite-sk9jyg5p.js → vm-hands-entry-lite-n4xgpgkw.js} +2 -2
  57. package/bin/vm-hands/{vm-hands-entry-lite-hxhd7btg.js → vm-hands-entry-lite-nqdstx24.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-0ybetwry.js → vm-hands-entry-lite-nwwa0k2s.js} +1 -1
  59. package/bin/vm-hands/{vm-hands-entry-lite-27z324rk.js → vm-hands-entry-lite-p629s0jp.js} +3 -3
  60. package/bin/vm-hands/{vm-hands-entry-lite-ytdg3zx5.js → vm-hands-entry-lite-pfjesssg.js} +2 -2
  61. package/bin/vm-hands/{vm-hands-entry-lite-dxkxgqyy.js → vm-hands-entry-lite-pr1t5d93.js} +2 -2
  62. package/bin/vm-hands/{vm-hands-entry-lite-1qjw1rt2.js → vm-hands-entry-lite-psywfz8m.js} +4 -4
  63. package/bin/vm-hands/{vm-hands-entry-lite-hff5yfen.js → vm-hands-entry-lite-sqqw5ftm.js} +19 -19
  64. package/bin/vm-hands/{vm-hands-entry-lite-y7z8pfgt.js → vm-hands-entry-lite-swrymqj9.js} +2 -2
  65. package/bin/vm-hands/{vm-hands-entry-lite-p7m36kw7.js → vm-hands-entry-lite-tebh7dcm.js} +3 -3
  66. package/bin/vm-hands/{vm-hands-entry-lite-whdnstpa.js → vm-hands-entry-lite-w0pegc58.js} +4 -4
  67. package/bin/vm-hands/{vm-hands-entry-lite-6nhbph7w.js → vm-hands-entry-lite-w14a2f89.js} +3 -3
  68. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  69. package/bin/vm-hands/{vm-hands-executor-f9mnj5vh.js → vm-hands-executor-f986qmnd.js} +2 -2
  70. package/bin/vm-hands/{vm-hands-op-runner-fxb4977p.js → vm-hands-op-runner-bss4cb7g.js} +1 -1
  71. package/bin/vm-hands/{vm-hands-runtime-471q11j3.js → vm-hands-runtime-qzw9ndeb.js} +3 -3
  72. package/bin/vm-hands/worker-preview-readiness-m2dn9mmn.js +2 -0
  73. package/bin/vm-hands/worker-sandbox-k4cfh0ya.js +2 -0
  74. package/package.json +1 -1
  75. package/bin/vm-hands/api-9ett3970.js +0 -2
  76. package/bin/vm-hands/api-credentials-pcn0yerk.js +0 -2
  77. package/bin/vm-hands/connect-cli-naectjzw.js +0 -2
  78. package/bin/vm-hands/credentials-snvdd3wy.js +0 -2
  79. package/bin/vm-hands/custom-endpoint-device-v82y34dy.js +0 -2
  80. package/bin/vm-hands/desktop-account-c35292yy.js +0 -2
  81. package/bin/vm-hands/hands-worker-source-pd1m7s16.js +0 -2
  82. package/bin/vm-hands/install-receipt-n79tzg6r.js +0 -2
  83. package/bin/vm-hands/local-automation-826fbrc0.js +0 -2
  84. package/bin/vm-hands/local-capabilities-xkq59r1s.js +0 -2
  85. package/bin/vm-hands/local-desktop-users-mhhw7e7q.js +0 -2
  86. package/bin/vm-hands/local-display-mac-73yk1493.js +0 -2
  87. package/bin/vm-hands/local-display-session-csergvtt.js +0 -2
  88. package/bin/vm-hands/local-display-video-amgnx87w.js +0 -2
  89. package/bin/vm-hands/local-managed-process-djnpyxga.js +0 -2
  90. package/bin/vm-hands/local-pty-session-h88gf14w.js +0 -2
  91. package/bin/vm-hands/managed-runtime-3edzgtm8.js +0 -2
  92. package/bin/vm-hands/network-contract-gg5ztcdt.js +0 -2
  93. package/bin/vm-hands/package-0nbmep23.js +0 -2
  94. package/bin/vm-hands/permissions-e81yz7xe.js +0 -2
  95. package/bin/vm-hands/serve-service-k0vta12g.js +0 -2
  96. package/bin/vm-hands/version-s2brry6v.js +0 -2
  97. package/bin/vm-hands/vm-hands-entry-lite-1ymtsqqk.js +0 -52
  98. package/bin/vm-hands/vm-hands-entry-lite-5g508mhr.js +0 -2
  99. package/bin/vm-hands/vm-hands-entry-lite-ytazq3rk.js +0 -3
  100. package/bin/vm-hands/worker-preview-readiness-y992mb4a.js +0 -2
  101. package/bin/vm-hands/worker-sandbox-y62j1dkh.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{S,zt,Mn,Ge,$n,Bn}from"./vm-hands-entry-lite-whdnstpa.js";import{Xn}from"./vm-hands-entry-lite-ss5n593s.js";import{Gn}from"./vm-hands-entry-lite-vtbw3evj.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as qe}from"child_process";import{existsSync as ws}from"fs";import{connect as xs}from"net";function pn(){let e=new Set,t=null,n=(s)=>({holder:t?.viewer??null,you:t===s,same_user:Boolean(t?.viewer&&s.viewer&&t.viewer.user_id===s.viewer.user_id)}),o=()=>{for(let s of e)s.notify(n(s))};return{join(s){return e.add(s),s.notify(n(s)),()=>{if(!e.delete(s))return;if(t!==s)return;t=null,o()}},claim(s){if(t===s||!e.has(s))return;t=s,o()}}}var ut=pn();import{createHash as St}from"crypto";import{once as Sn}from"events";import{createWriteStream as vn,existsSync as mr,mkdirSync as gr,mkdtempSync as hr,readFileSync as le,readdirSync as br,renameSync as yr,realpathSync as En,rmSync as Pn,statSync as Ne,writeFileSync as wr}from"fs";import{delimiter as _r,dirname as vt,join as b}from"path";import{finished as Cn}from"stream/promises";var We="omljlfpmafedpplnpkkahegadhkimdje",lo="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var O={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},H={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${O.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${O.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${O.obu.version}/open-browser-use-chrome-extension-${O.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as fn}from"module";import{join as mn}from"path";var gn=30000,hn=1048576;function Te(){return process.env.SystemRoot??"C:\\Windows"}function bn(){return mn(Te(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var yn=String.raw`
2
+ import{S,zt,$n,Ge,Bn,Fn}from"./vm-hands-entry-lite-w0pegc58.js";import{Yn}from"./vm-hands-entry-lite-ht7fk059.js";import{Kn}from"./vm-hands-entry-lite-8qhz89mt.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as qe}from"child_process";import{existsSync as ws}from"fs";import{connect as xs}from"net";function pn(){let e=new Set,t=null,n=(s)=>({holder:t?.viewer??null,you:t===s,same_user:Boolean(t?.viewer&&s.viewer&&t.viewer.user_id===s.viewer.user_id)}),o=()=>{for(let s of e)s.notify(n(s))};return{join(s){return e.add(s),s.notify(n(s)),()=>{if(!e.delete(s))return;if(t!==s)return;t=null,o()}},claim(s){if(t===s||!e.has(s))return;t=s,o()}}}var ut=pn();import{createHash as St}from"crypto";import{once as Sn}from"events";import{createWriteStream as vn,existsSync as mr,mkdirSync as gr,mkdtempSync as hr,readFileSync as le,readdirSync as br,renameSync as yr,realpathSync as En,rmSync as Pn,statSync as Ne,writeFileSync as wr}from"fs";import{delimiter as _r,dirname as vt,join as b}from"path";import{finished as Cn}from"stream/promises";var We="omljlfpmafedpplnpkkahegadhkimdje",uo="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var O={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},H={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${O.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${O.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${O.obu.version}/open-browser-use-chrome-extension-${O.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as fn}from"module";import{join as mn}from"path";var gn=30000,hn=1048576;function Te(){return process.env.SystemRoot??"C:\\Windows"}function bn(){return mn(Te(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var yn=String.raw`
3
3
  $ErrorActionPreference = "Stop"
4
4
  Add-Type -TypeDefinition @"
5
5
  using System;
@@ -69,7 +69,7 @@ while ($null -ne ($line = [Console]::In.ReadLine())) {
69
69
  `).join("")),t.stdin.writableLength>hn)d({reason:"input_backpressure"})},g=()=>{i=Me(...Oe("clipboard"),{env:Ae(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let p="";i.stdout?.on("data",(w)=>{if(s)return;p+=w.toString("ascii");for(let f=p.indexOf(`
70
70
  `);f>=0;f=p.indexOf(`
71
71
  `)){let M=p.slice(0,f).replace(/\r$/,"");if(p=p.slice(f+1),!M.startsWith("c "))continue;let E=M.slice(2);if(E.length>Math.ceil(S/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(E)){d({reason:"display_protocol"});return}let c=Buffer.from(E,"base64");if(c.byteLength<=S)e.clipboard(c.toString("utf8"));if(s)return}if(p.length>Math.ceil(S/3)*4+4)d({reason:"display_protocol"})}),i.once("error",()=>y("Reason could not watch this computer's desktop clipboard.")),i.once("exit",()=>{if(!s)y("Reason could not watch this computer's desktop clipboard.")})};return t.stdout.on("data",(p)=>{if(s||o===null)return;o+=p.toString("utf8");let w=o.indexOf(`
72
- `);if(w<0){if(o.length>4096)d({reason:"display_protocol"});return}let f=ht(o.slice(0,w).trim());if(o=null,!f)d({reason:"display_protocol"});else if(f.session===0)y("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else g(),e.ready({width:f.width,height:f.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>y("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)y("Reason could not start this computer's desktop input.");else d({reason:"display_closed"})}),{pointer:(p,w,f)=>h(n.pointer(p,w,f)),key:(p,w)=>h(n.key(p,w)),clipboard:(p)=>h([`c ${Buffer.from(p,"utf8").toString("base64")}`]),close(){s=!0,a()}}}var Tn=["none","standard","all"],ue="22.23.3",An={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},$e={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},Et="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Dt="chrome-win64/chrome.exe",W={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Ln={version:W.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},Le={version:W.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${W.version}/ffmpeg-${W.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},_t=`ffmpeg-${Le.version}-essentials_build/bin`,z="com.ifuryst.open_browser_use.extension",It="com.reasonmachines.browser_use.extension",Ft="/tmp/reason-browser-use",Ue=["tint2","picom","xterm","pcmanfm"],Pt=["fonts-droid-fallback"],Ct=["pulseaudio"],Rt=["tigervnc-standalone-server"],Un=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...Pt,"galculator","chromium","ffmpeg","tmux",...Ct,...Rt,...Ue],Hn=new Set([...Ue,...Pt,...Ct,...Rt]),kt=Un.filter((e)=>e!=="chromium"&&!Hn.has(e)),Fn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],ce="/usr/bin/chromium",zn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function jn(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function K(e){return e==="win32-x64"||e==="win32-arm64"}function Be(e){return K(e)?`node-v${ue}-${e.replace("win32","win")}`:`node-v${ue}-${e}`}function de(e){return{node:{version:ue,url:`https://nodejs.org/dist/v${ue}/${Be(e)}${K(e)?".zip":".tar.gz"}`,sha256:An[e]},open_computer_use:{version:O.ocu.version,url:J.ocu.url,sha256:J.ocu.sha256},open_browser_use:{version:O.obu.version,url:J.obu.url,sha256:J.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:H.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${H.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:H.macArm64Sha256}}:K(e)?{chrome_for_testing:{version:H.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${H.version}/win64/chrome-win64.zip`,sha256:H.win64Sha256}}:{}}}function Vn(e){let t={extension:F};for(let[n,o]of Object.entries(de(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Mt(e){return b(e,".local","share","reason","desktop")}function Tr(e,t=Gn()){let n=Mt(t),o=(p)=>b(n,p,de(e)[p]?.version??""),s=o("open_computer_use"),i=o("open_browser_use"),a=e==="darwin-arm64",d=K(e),y=b(t,"Library","Application Support"),h=b(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:b(t,"AppData","Local"),"OpenBrowserUse"),g=a?b(y,"Google","Chrome","NativeMessagingHosts",`${z}.json`):d?b(h,"NativeMessagingHosts",`${z}.json`):b(t,".config","google-chrome","NativeMessagingHosts",`${z}.json`);return{root:n,automation:b(vt(n),"automation"),receipt:b(n,"receipt.json"),minimal:is(t),node:d?b(o("node"),Be(e),"node.exe"):b(o("node"),"bin","node"),ocuDir:s,ocu:b(s,$e[e].ocu),ocuApp:a?b(s,"dist","Open Computer Use.app"):null,obuDir:i,obu:b(i,"cli","open-browser-use.js"),nativeHost:b(i,$e[e].obu),extensionDir:a?b(y,"OpenBrowserUse","chrome-extension","release"):d?b(h,"chrome-extension","release"):b(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:g,nativeHostManifests:a?[g,b(y,"Google","ChromeForTesting","NativeMessagingHosts",`${z}.json`)]:d?[g]:[b(t,".config","chromium","NativeMessagingHosts",`${z}.json`),b(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${z}.json`)],browser:a?b(o("chrome_for_testing"),Et):d?b(o("chrome_for_testing"),Dt):ce,userChromeHost:a?b(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:a?b(y,"Google","Chrome","NativeMessagingHosts",`${It}.json`):null,ffmpegDir:b(n,"ffmpeg"),ffmpeg:a?b(n,"ffmpeg",W.version,"ffmpeg"):d?b(n,"ffmpeg",Le.version,_t,"ffmpeg.exe"):null,ffprobe:a?b(n,"ffprobe",Ln.version,"ffprobe"):d?b(n,"ffmpeg",Le.version,_t,"ffprobe.exe"):null}}function Wn(e){try{let t=JSON.parse(le(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((s)=>typeof s==="string")||!Tn.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((s)=>typeof s==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function A(e){try{return Ne(e).isFile()}catch{return!1}}function Tt(e){try{let t=Ne(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function Kn(e){try{return le(e,"utf8")}catch{return null}}function U(e){for(let t of zn){let n=b(t,e);try{let o=Ne(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function qn(e){try{let t=JSON.parse(le(b(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function Yn(e,t,n){let o=de(n)[e];if(!o)return!1;let s=K(n);if(e==="node")return A(s?b(t,Be(n),"node.exe"):b(t,"bin","node"));if(e==="chrome_for_testing")return A(b(t,s?Dt:Et));let i=$e[n][e==="open_computer_use"?"ocu":"obu"];return qn(t)===o.version&&A(b(t,i))&&(e==="open_computer_use"||A(b(t,"cli","open-browser-use.js")))}function Jn(e){return St("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function He(e){try{let t=JSON.parse(le(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Zn(e){let t=He(b(e.extensionDir,"manifest.json"));return t!==null&&t.version===O.obu.version&&typeof t.key==="string"&&Jn(t.key)===F}function Qn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===z&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${F}/`&&(t===void 0||e.path===t)}function es(e){return Zn(e)&&A(e.nativeHost)&&e.nativeHostManifests.every((t)=>Qn(He(t),e.nativeHost))}function ts(e){return`#!/bin/sh
72
+ `);if(w<0){if(o.length>4096)d({reason:"display_protocol"});return}let f=ht(o.slice(0,w).trim());if(o=null,!f)d({reason:"display_protocol"});else if(f.session===0)y("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else g(),e.ready({width:f.width,height:f.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>y("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)y("Reason could not start this computer's desktop input.");else d({reason:"display_closed"})}),{pointer:(p,w,f)=>h(n.pointer(p,w,f)),key:(p,w)=>h(n.key(p,w)),clipboard:(p)=>h([`c ${Buffer.from(p,"utf8").toString("base64")}`]),close(){s=!0,a()}}}var Rn=["none","standard","all"],ue="22.23.3",Mn={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},$e={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},Et="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Dt="chrome-win64/chrome.exe",W={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Tn={version:W.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},Le={version:W.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${W.version}/ffmpeg-${W.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},_t=`ffmpeg-${Le.version}-essentials_build/bin`,z="com.ifuryst.open_browser_use.extension",It="com.reasonmachines.browser_use.extension",Ft="/tmp/reason-browser-use",Ue=["tint2","picom","xterm","pcmanfm"],Pt=["fonts-droid-fallback"],Ct=["pulseaudio"],Rt=["tigervnc-standalone-server"],An=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...Pt,"galculator","chromium","ffmpeg","tmux",...Ct,...Rt,...Ue],Un=new Set([...Ue,...Pt,...Ct,...Rt]),kt=An.filter((e)=>e!=="chromium"&&!Un.has(e)),Hn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],ce="/usr/bin/chromium",zn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function jn(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function K(e){return e==="win32-x64"||e==="win32-arm64"}function Be(e){return K(e)?`node-v${ue}-${e.replace("win32","win")}`:`node-v${ue}-${e}`}function de(e){return{node:{version:ue,url:`https://nodejs.org/dist/v${ue}/${Be(e)}${K(e)?".zip":".tar.gz"}`,sha256:Mn[e]},open_computer_use:{version:O.ocu.version,url:J.ocu.url,sha256:J.ocu.sha256},open_browser_use:{version:O.obu.version,url:J.obu.url,sha256:J.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:H.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${H.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:H.macArm64Sha256}}:K(e)?{chrome_for_testing:{version:H.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${H.version}/win64/chrome-win64.zip`,sha256:H.win64Sha256}}:{}}}function Gn(e){let t={extension:F};for(let[n,o]of Object.entries(de(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Mt(e){return b(e,".local","share","reason","desktop")}function Tr(e,t=Kn()){let n=Mt(t),o=(p)=>b(n,p,de(e)[p]?.version??""),s=o("open_computer_use"),i=o("open_browser_use"),a=e==="darwin-arm64",d=K(e),y=b(t,"Library","Application Support"),h=b(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:b(t,"AppData","Local"),"OpenBrowserUse"),g=a?b(y,"Google","Chrome","NativeMessagingHosts",`${z}.json`):d?b(h,"NativeMessagingHosts",`${z}.json`):b(t,".config","google-chrome","NativeMessagingHosts",`${z}.json`);return{root:n,automation:b(vt(n),"automation"),receipt:b(n,"receipt.json"),minimal:is(t),node:d?b(o("node"),Be(e),"node.exe"):b(o("node"),"bin","node"),ocuDir:s,ocu:b(s,$e[e].ocu),ocuApp:a?b(s,"dist","Open Computer Use.app"):null,obuDir:i,obu:b(i,"cli","open-browser-use.js"),nativeHost:b(i,$e[e].obu),extensionDir:a?b(y,"OpenBrowserUse","chrome-extension","release"):d?b(h,"chrome-extension","release"):b(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:g,nativeHostManifests:a?[g,b(y,"Google","ChromeForTesting","NativeMessagingHosts",`${z}.json`)]:d?[g]:[b(t,".config","chromium","NativeMessagingHosts",`${z}.json`),b(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${z}.json`)],browser:a?b(o("chrome_for_testing"),Et):d?b(o("chrome_for_testing"),Dt):ce,userChromeHost:a?b(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:a?b(y,"Google","Chrome","NativeMessagingHosts",`${It}.json`):null,ffmpegDir:b(n,"ffmpeg"),ffmpeg:a?b(n,"ffmpeg",W.version,"ffmpeg"):d?b(n,"ffmpeg",Le.version,_t,"ffmpeg.exe"):null,ffprobe:a?b(n,"ffprobe",Tn.version,"ffprobe"):d?b(n,"ffmpeg",Le.version,_t,"ffprobe.exe"):null}}function Vn(e){try{let t=JSON.parse(le(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((s)=>typeof s==="string")||!Rn.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((s)=>typeof s==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function A(e){try{return Ne(e).isFile()}catch{return!1}}function Tt(e){try{let t=Ne(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function Wn(e){try{return le(e,"utf8")}catch{return null}}function U(e){for(let t of zn){let n=b(t,e);try{let o=Ne(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Xn(e){try{let t=JSON.parse(le(b(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function qn(e,t,n){let o=de(n)[e];if(!o)return!1;let s=K(n);if(e==="node")return A(s?b(t,Be(n),"node.exe"):b(t,"bin","node"));if(e==="chrome_for_testing")return A(b(t,s?Dt:Et));let i=$e[n][e==="open_computer_use"?"ocu":"obu"];return Xn(t)===o.version&&A(b(t,i))&&(e==="open_computer_use"||A(b(t,"cli","open-browser-use.js")))}function Jn(e){return St("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function He(e){try{let t=JSON.parse(le(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Zn(e){let t=He(b(e.extensionDir,"manifest.json"));return t!==null&&t.version===O.obu.version&&typeof t.key==="string"&&Jn(t.key)===F}function Qn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===z&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${F}/`&&(t===void 0||e.path===t)}function es(e){return Zn(e)&&A(e.nativeHost)&&e.nativeHostManifests.every((t)=>Qn(He(t),e.nativeHost))}function ts(e){return`#!/bin/sh
73
73
  # Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
74
74
  obu=${`'${e.replaceAll("'","'\\''")}'`}
75
75
  case "$1" in
@@ -77,7 +77,7 @@ case "$1" in
77
77
  mcp) shift; exec "$obu" mcp --socket-dir ${Ft} "$@" ;;
78
78
  esac
79
79
  exec "$obu" "$@"
80
- `}function ns(e){let t=He(e),n=t?.allowed_origins;return t!==null&&t.name===It&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${We}/`)&&typeof t.path==="string"&&Tt(t.path)}function ss(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Kn(e.userChromeHost)!==ts(e.nativeHost)||!Tt(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return ns(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var rs={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function x(e={}){let t=e.platform===void 0?jn():e.platform;if(!t)return null;let n=Tr(t,e.home),o=Wn(n.receipt),s=Vn(t),i=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(s).sort()),a=[],d=de(t);for(let c of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=d[c];if(!_)continue;let v=Yn(c,b(n.root,c,_.version),t),D=o?.pins[c],L=v&&D===s[c]?"ready":D!==void 0&&D!==s[c]?"outdated":"missing";a.push({name:c,state:L,detail:_.version})}let y=o?.pins.extension===F&&es(n);a.push({name:"browser_extension",state:y?"ready":"missing",detail:F});let h=U("Xvfb"),g=U("x11vnc"),p=U("openbox");if(K(t))a.push(yt()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),a.push(n.ffmpeg&&A(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){a.push(A(ce)?{name:"browser",state:"ready",detail:ce}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${ce}`});let c=h!==null&&g!==null&&p!==null;a.push({name:"display",state:c?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=Fn.filter((P)=>U(P)===null),v=(o?.missing_system_packages??kt).filter((P)=>kt.includes(P)),D=_.length===0&&v.length===0;a.push(D?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...v,..._])].join(" ")});let L=Ue.filter((P)=>U(P)===null);a.push(L.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:L.join(" ")})}let w=n.ffmpeg&&A(n.ffmpeg)?n.ffmpeg:U("ffmpeg"),f=!w?null:w===n.ffmpeg?n.ffprobe:b(vt(En(w)),"ffprobe"),M=i&&a.every((c)=>c.state==="ready"),E=(c)=>i&&a.every((_)=>!rs[c].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:M,features:{display:E("display"),computer:E("computer"),browser:E("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:w,ffprobe:f&&A(f)?f:null,userChrome:ss(n,i&&["node","open_browser_use"].every((c)=>a.find((_)=>_.name===c)?.state==="ready")),pulseaudio:U("pulseaudio"),xvnc:U("Xvnc"),xvfb:h,x11vnc:g,openbox:p,components:a}}function Ot(e){return os(e)?Xn():[]}function os(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===b(e.root,"ffmpeg",W.version,"ffmpeg")}async function po(e,t,n,o=fetch){try{let s=await o(e,{redirect:"follow"});if(!s.ok||!s.body)throw Error(`download failed (HTTP ${s.status}): ${e}`);let i=St("sha256"),a=vn(n,{mode:384});try{let y=s.body.getReader();for(let h=await y.read();!h.done;h=await y.read())if(i.update(h.value),!a.write(h.value))await Sn(a,"drain")}finally{a.end(),await Cn(a)}let d=i.digest("hex");if(d!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${d}`)}catch(s){throw Pn(n,{force:!0}),s}}function is(e){return b(Mt(e),"minimal.json")}import{spawn as as}from"child_process";import{existsSync as cs}from"fs";import{connect as us}from"net";import{join as pe}from"path";var $t="reason_desktop",Q={sampleRate:48000,channels:2,codec:"opus"},ls=5000,ds=107,ps=262144,Rn=(e)=>pe(e,"native"),Ve=(e)=>`unix:${e}`;function Fe(e,t=1000){if(!cs(e))return Promise.resolve(!1);return new Promise((n)=>{let o=us({path:e}),s=(i)=>{o.destroy(),n(i)};o.setTimeout(t,()=>s(!1)),o.once("error",()=>s(!1)),o.once("close",()=>s(!1)),o.once("connect",()=>s(!0))})}async function uo(e,t){if(!t)return null;let n=Rn(e);if(Buffer.byteLength(n)>ds||/["'\\\s]/.test(n))return null;try{if(await Fe(n))return n;let o=as(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:${pe(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${$t} rate=${Q.sampleRate} channels=${Q.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:pe(e,"runtime"),PULSE_STATE_PATH:pe(e,"state")}}),s=!1;o.once("error",()=>{s=!0}),o.once("exit",()=>{s=!0}),o.unref();let i=Date.now()+ls;while(Date.now()<i){if(await Fe(n))return n;if(s)return await Fe(n)?n:null;await new Promise((a)=>setTimeout(a,50))}if(!s)o.kill("SIGKILL");return null}catch{return null}}function Lt(){let{sampleRate:e,channels:t}=Q;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",`${$t}.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 fs=[79,103,103,83],ms=Buffer.from("OpusHead"),gs=Buffer.from("OpusTags"),At=(e,t)=>e.byteLength>=t.byteLength&&t.every((n,o)=>e[o]===n);class ze extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class je{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 n=[],o=0;while(t.byteLength-o>=27){if(fs.some((w,f)=>t[o+f]!==w)||t[o+4]!==0)throw new ze("invalid_page");let s=(t[o+5]&1)!==0,i=t[o+26];if(t.byteLength-o<27+i)break;let a=t.subarray(o+27,o+27+i),d=a.reduce((w,f)=>w+f,0),y=27+i+d;if(t.byteLength-o<y)break;if(!s&&this.partialBytes>0)this.resetPartial();let h=s&&this.partialBytes===0,g=o+27+i,p=g;for(let w of a){if(g+=w,w===255)continue;if(this.appendPartial(t.subarray(p,g),h),p=g,!h){let f=this.takePartial();if(f.byteLength>0&&!At(f,ms)&&!At(f,gs))n.push(f)}h=!1,this.resetPartial()}if(p<g)this.appendPartial(t.subarray(p,g),h);o+=y}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>ps)throw new ze("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 n of this.partial)e.set(n,t),t+=n.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as hs}from"child_process";var Nt=1048576,bs=String.raw`
80
+ `}function ns(e){let t=He(e),n=t?.allowed_origins;return t!==null&&t.name===It&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${We}/`)&&typeof t.path==="string"&&Tt(t.path)}function ss(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Wn(e.userChromeHost)!==ts(e.nativeHost)||!Tt(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return ns(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var rs={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function x(e={}){let t=e.platform===void 0?jn():e.platform;if(!t)return null;let n=Tr(t,e.home),o=Vn(n.receipt),s=Gn(t),i=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(s).sort()),a=[],d=de(t);for(let c of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=d[c];if(!_)continue;let v=qn(c,b(n.root,c,_.version),t),D=o?.pins[c],L=v&&D===s[c]?"ready":D!==void 0&&D!==s[c]?"outdated":"missing";a.push({name:c,state:L,detail:_.version})}let y=o?.pins.extension===F&&es(n);a.push({name:"browser_extension",state:y?"ready":"missing",detail:F});let h=U("Xvfb"),g=U("x11vnc"),p=U("openbox");if(K(t))a.push(yt()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),a.push(n.ffmpeg&&A(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){a.push(A(ce)?{name:"browser",state:"ready",detail:ce}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${ce}`});let c=h!==null&&g!==null&&p!==null;a.push({name:"display",state:c?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=Hn.filter((P)=>U(P)===null),v=(o?.missing_system_packages??kt).filter((P)=>kt.includes(P)),D=_.length===0&&v.length===0;a.push(D?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...v,..._])].join(" ")});let L=Ue.filter((P)=>U(P)===null);a.push(L.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:L.join(" ")})}let w=n.ffmpeg&&A(n.ffmpeg)?n.ffmpeg:U("ffmpeg"),f=!w?null:w===n.ffmpeg?n.ffprobe:b(vt(En(w)),"ffprobe"),M=i&&a.every((c)=>c.state==="ready"),E=(c)=>i&&a.every((_)=>!rs[c].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:M,features:{display:E("display"),computer:E("computer"),browser:E("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:w,ffprobe:f&&A(f)?f:null,userChrome:ss(n,i&&["node","open_browser_use"].every((c)=>a.find((_)=>_.name===c)?.state==="ready")),pulseaudio:U("pulseaudio"),xvnc:U("Xvnc"),xvfb:h,x11vnc:g,openbox:p,components:a}}function Ot(e){return os(e)?Yn():[]}function os(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===b(e.root,"ffmpeg",W.version,"ffmpeg")}async function ho(e,t,n,o=fetch){try{let s=await o(e,{redirect:"follow"});if(!s.ok||!s.body)throw Error(`download failed (HTTP ${s.status}): ${e}`);let i=St("sha256"),a=vn(n,{mode:384});try{let y=s.body.getReader();for(let h=await y.read();!h.done;h=await y.read())if(i.update(h.value),!a.write(h.value))await Sn(a,"drain")}finally{a.end(),await Cn(a)}let d=i.digest("hex");if(d!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${d}`)}catch(s){throw Pn(n,{force:!0}),s}}function is(e){return b(Mt(e),"minimal.json")}import{spawn as as}from"child_process";import{existsSync as cs}from"fs";import{connect as us}from"net";import{join as pe}from"path";var $t="reason_desktop",Q={sampleRate:48000,channels:2,codec:"opus"},ls=5000,ds=107,ps=262144,On=(e)=>pe(e,"native"),Ve=(e)=>`unix:${e}`;function Fe(e,t=1000){if(!cs(e))return Promise.resolve(!1);return new Promise((n)=>{let o=us({path:e}),s=(i)=>{o.destroy(),n(i)};o.setTimeout(t,()=>s(!1)),o.once("error",()=>s(!1)),o.once("close",()=>s(!1)),o.once("connect",()=>s(!0))})}async function po(e,t){if(!t)return null;let n=On(e);if(Buffer.byteLength(n)>ds||/["'\\\s]/.test(n))return null;try{if(await Fe(n))return n;let o=as(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:${pe(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${$t} rate=${Q.sampleRate} channels=${Q.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:pe(e,"runtime"),PULSE_STATE_PATH:pe(e,"state")}}),s=!1;o.once("error",()=>{s=!0}),o.once("exit",()=>{s=!0}),o.unref();let i=Date.now()+ls;while(Date.now()<i){if(await Fe(n))return n;if(s)return await Fe(n)?n:null;await new Promise((a)=>setTimeout(a,50))}if(!s)o.kill("SIGKILL");return null}catch{return null}}function Lt(){let{sampleRate:e,channels:t}=Q;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",`${$t}.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 fs=[79,103,103,83],ms=Buffer.from("OpusHead"),gs=Buffer.from("OpusTags"),At=(e,t)=>e.byteLength>=t.byteLength&&t.every((n,o)=>e[o]===n);class ze extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class je{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 n=[],o=0;while(t.byteLength-o>=27){if(fs.some((w,f)=>t[o+f]!==w)||t[o+4]!==0)throw new ze("invalid_page");let s=(t[o+5]&1)!==0,i=t[o+26];if(t.byteLength-o<27+i)break;let a=t.subarray(o+27,o+27+i),d=a.reduce((w,f)=>w+f,0),y=27+i+d;if(t.byteLength-o<y)break;if(!s&&this.partialBytes>0)this.resetPartial();let h=s&&this.partialBytes===0,g=o+27+i,p=g;for(let w of a){if(g+=w,w===255)continue;if(this.appendPartial(t.subarray(p,g),h),p=g,!h){let f=this.takePartial();if(f.byteLength>0&&!At(f,ms)&&!At(f,gs))n.push(f)}h=!1,this.resetPartial()}if(p<g)this.appendPartial(t.subarray(p,g),h);o+=y}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>ps)throw new ze("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 n of this.partial)e.set(n,t),t+=n.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as hs}from"child_process";var Nt=1048576,bs=String.raw`
81
81
  import gi, json, os, sys
82
82
  gi.require_version("Gtk", "3.0")
83
83
  from gi.repository import Gtk, Gdk, GLib
@@ -121,6 +121,6 @@ Gtk.main()
121
121
  `;function Ut(e,t){let n=hs("/usr/bin/python3",["-I","-u","-c",bs],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),o=!1,s=!0,i="",a=0,d=[],y=setTimeout(()=>g(),5000),h=()=>{o=!0,clearTimeout(y),d.length=0,n.kill("SIGKILL")},g=()=>{if(o)return;h(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},p=(w,f=32)=>{if(o)return;if(!s){w();return}if(a+=f,a>Nt)h(),t.end({reason:"input_backpressure"});else d.push({apply:w,bytes:f})};return n.stdout.on("data",(w)=>{if(o)return;i+=w.toString("ascii");for(let f=i.indexOf(`
122
122
  `);f>=0;f=i.indexOf(`
123
123
  `)){let M=i.slice(0,f);i=i.slice(f+1);let E;try{E=JSON.parse(M)}catch{g();return}if(E==="ready"||E==="ack"){clearTimeout(y),s=!1;while(!s&&!o&&d.length){let c=d.shift();a-=c.bytes,c.apply()}}else if(E&&typeof E==="object"&&"text"in E&&typeof E.text==="string"&&Buffer.byteLength(E.text)<=S)t.clipboard(E.text);else{g();return}if(o)return}if(i.length>S*6+32)g()}),n.stdin.on("error",g),n.once("error",g),n.once("exit",g),{apply:p,write(w){if(Buffer.byteLength(w)>S||w.includes("\x00")){g();return}let f=`${JSON.stringify(w)}
124
- `;p(()=>{if(s=!0,y=setTimeout(()=>g(),5000),n.stdin.write(f),n.stdin.writableLength>Nt)h(),t.end({reason:"input_backpressure"})},Buffer.byteLength(f))},close:h}}var X={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}},_s="avc1.4D002A",Bt={width:1920,height:1080},ks=262144,Ss=0.2,vs=250,Es=1e4,Ds=1024,Ke=1e4,Is=500,Ps=60,Cs=1e4,Rs=1000,Ht=1048576,Ms=-223,Ts=-308,On={kind:"mac_screen",sound:null},In={kind:"windows_screen",sound:null},Os,jt=()=>Os??=x()?.ffmpeg??null,me=(e,t,n)=>qe(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),As,Ye=()=>As??=Ot(x()),Gt=(e,t,n)=>{let[o,...s]=[...Ye(),e];return me(o,[...s,...t],n)},Vt=()=>nn?.videotoolbox?"h264_videotoolbox":"libx264",$s=()=>Math.round(performance.now()*1000),Xe=new Set,Wt=!1;function Jt(e){if(Xe.add(e),e.once("exit",()=>Xe.delete(e)),Wt)return;Wt=!0,process.once("exit",()=>{for(let t of Xe)try{t.kill("SIGKILL")}catch{}})}function Zt(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{}},Is);e.once("exit",()=>clearTimeout(t))}function Ls(e,t,n){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",n],size:t}}function Ns(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Us(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 Bs(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Qt=1700000;function en(e){return Math.min(1,Math.round(Math.sqrt(Qt/(e.width*e.height))*100)/100)}function Hs(e,t,n){let o=qe(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,en(n.size)))],{stdio:["ignore","pipe","ignore"]}),s=qe(e,t,{env:{},stdio:["pipe","pipe","ignore"]});o.stdout.pipe(s.stdin),s.stdin.on("error",()=>{});let i=()=>{if(o.exitCode===null&&o.signalCode===null)o.kill("SIGTERM")};return s.once("exit",i),s.once("error",i),o.once("exit",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),o.once("error",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),s}function Kt(e){let t=Math.min(1,Bt.width/e.width,Bt.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function fe(e,t,n,o="libx264"){let s=X[e],i=(p)=>Math.max(2,Math.floor(p/2)*2),a={width:i(n.width*s.scale),height:i(n.height*s.scale)},d=a.width!==t.size?.width||a.height!==t.size.height,y=Math.max(1,Math.round(s.kbps*2/s.fps)),h=["-g",String(s.fps*Ps)],g=o==="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",...h,"-b:v",`${s.kbps}k`,"-maxrate",`${s.kbps}k`,"-bufsize",`${y}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",s.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...s.threads?["-threads",String(s.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...h,"-crf",String(s.crf),"-maxrate",`${s.kbps}k`,"-bufsize",`${y}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...d?["-vf",`scale=${a.width}:${a.height}:flags=fast_bilinear`]:[],...g,"-flush_packets","1","-f","h264","pipe:1"]}class tn{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let n=new Uint8Array(this.buffer.byteLength+e.byteLength);n.set(this.buffer),n.set(e,this.buffer.byteLength),this.buffer=n;let o=[],s=this.scanned;while(s+3<this.buffer.byteLength){if(this.buffer[s]!==0||this.buffer[s+1]!==0||this.buffer[s+2]!==1){s++;continue}let i=this.buffer[s+3]&31,a=s>0&&this.buffer[s-1]===0?s-1:s;if(i===9&&a>0)o.push({data:this.buffer.slice(0,a),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(a),this.key=!1,this.micros=t,s-=a;if(i===5)this.key=!0;s+=3}return this.scanned=s,o}}function Fs(e,t){let n=xs({path:e}),o=Buffer.alloc(0),s="version",i=0,a=!1,d=[],y=0,h=!1,g=(c)=>{if(h)return;h=!0,n.destroy(),t.end(c)},p=()=>g({reason:"display_protocol"}),w=(c)=>{if(h)return;if(!a){if(y+=c.byteLength,y>Ht)g({reason:"input_backpressure"});else d.push(c);return}if(n.write(c),n.writableLength>Ht)g({reason:"input_backpressure"})},f=(c)=>{o=o.subarray(c)},M=()=>{switch(s){case"version":{if(o.byteLength<12)return!1;let c=/^RFB (\d{3})\.(\d{3})\n$/.exec(o.subarray(0,12).toString("latin1"));if(!c||Number(c[1])*1000+Number(c[2])<3007)return p(),!1;return f(12),n.write(`RFB 003.007
125
- `),s="security",!0}case"security":{if(o.byteLength<1)return!1;let c=o[0];if(c===0)return p(),!1;if(o.byteLength<1+c)return!1;if(!o.subarray(1,1+c).includes(1))return p(),!1;return f(1+c),n.write(Buffer.from([1,1])),s="init",!0}case"init":{if(o.byteLength<24)return!1;let c=o.readUInt32BE(20);if(c>65536)return p(),!1;if(o.byteLength<24+c)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(f(24+c),_.width===0||_.height===0)return p(),!1;s="messages";let v=Buffer.alloc(12);v.writeUInt8(2,0),v.writeUInt16BE(2,2),v.writeInt32BE(Ts,4),v.writeInt32BE(Ms,8),n.write(v),a=!0;for(let D of d)n.write(D);return d=[],y=0,t.ready(_),!h}case"skip":{let c=Math.min(i,o.byteLength);if(f(c),i-=c,i>0)return!1;return s="messages",!0}case"messages":{if(o.byteLength<1)return!1;switch(o[0]){case 1:{if(o.byteLength<6)return!1;let c=6+o.readUInt16BE(4)*6;if(o.byteLength<c)return!1;return f(c),!0}case 2:return f(1),!0;case 3:{if(o.byteLength<8)return!1;let c=o.readUInt32BE(4);if(c>S/2)return f(8),s="skip",i=c,!0;if(o.byteLength<8+c)return!1;let _=o.subarray(8,8+c).toString("latin1");return f(8+c),t.clipboard(_),!h}default:return p(),!1}}}},E=!1;return n.once("connect",()=>{E=!0}),n.on("data",(c)=>{if(h)return;o=o.byteLength?Buffer.concat([o,c]):c;while(!h&&M());}),n.once("error",()=>{if(!E)g({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>g({reason:"display_closed"})),{pointer(c,_,v){let D=Buffer.alloc(6);D.writeUInt8(5,0),D.writeUInt8(v&255,1),D.writeUInt16BE(c,2),D.writeUInt16BE(_,4),w(D)},key(c,_){let v=Buffer.alloc(8);v.writeUInt8(4,0),v.writeUInt8(c?1:0,1),v.writeUInt32BE(_>>>0,4),w(v)},clipboard(c){if(Array.from(c).some((D)=>D.codePointAt(0)>255)){g({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(c,"latin1"),v=Buffer.alloc(8);v.writeUInt8(6,0),v.writeUInt32BE(_.byteLength,4),w(Buffer.concat([v,_]))},close(){h=!0,n.destroy()}}}class Je{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,n,o){this.viewers.add(e),this.stop();let s;try{s=n()}catch{this.fail();return}Jt(s);let i={child:s,splitter:new tn};this.run=i;for(let d of[...this.viewers])d.started(t);s.stdout?.on("data",(d)=>{if(this.run!==i)return;for(let y of i.splitter.push(d,o()))for(let h of[...this.viewers])h.unit(y)});let a=()=>{if(this.run!==i)return;this.run=null,this.fail()};s.once("exit",a),s.once("error",a)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;Zt(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Xt=new WeakMap;function zs(e){let t=Xt.get(e);if(!t)Xt.set(e,t=new Je);return t}var ee=new Map;function Dn(e,t,n={}){let o=n.micros??$s,s=new Mn,i=t.request.preset,a=null,d=null,y=null,h=!1,g=null,p=!1,w=!1,f=null,M=0,E=0,c=!1,_=null,v=null,D=0,L=null,P=[],te=0,N=[],Ze=new Uint32Array(Ke+1),ge=0,he=null,be=0,q=0,ye=0,Qe=0,et=0,ne=null,we=0,j={frames:0,bytes:0,since:o()},G=[],Y=0,xe,_e=!1,rn=o(),R={},V=()=>Math.round((o()-rn)/1000),tt=n.control??ut,ke=null,Se=null,nt=0,ve=!1,st={pause(){if(!g?.running)return;g.stop(),ve=!0},adopt(u){let l=u!==null&&(u.width!==d?.width||u.height!==d?.height);if(l)d=u;if(!l&&!ve)return;if(ve=!1,g)ae();else Ie()}},on=(u)=>{if(!n.resizeDesktop||!a||"kind"in a||e.done)return;let l=a.display,m=()=>[...ee.get(l)??[]];nt++,n.resizeDesktop(a,u,()=>{for(let k of m())k.pause()}).then((k)=>{for(let I of m())I.adopt(k)})},T=(u)=>{let l=zt(u);return e.send(l),Qe+=l.byteLength,l.byteLength},se=(u)=>{if(e.done)return;if(e.open)T({type:"error",code:u});e.end({reason:u})},re=()=>Math.max(ks,X[i].kbps*1000/8*Ss),oe=()=>o()/1000,an=()=>{while(N.length>1&&N[0].atMs<oe()-Es)N.shift();return N[0]?.rttMs??null},rt=(u)=>{let l=an();if(l===null||P.length===0)return!1;let m=(l+vs)*u;return oe()-P[0].sentMs>m||te>m/1000*X[i].kbps*1000/8},cn=(u)=>{if(D===0)return;let l=Math.min(u,D-1);if(L!==null&&l<=L)return;L=l;let m=oe();while(P.length&&P[0].seq<=l){let k=P.shift();if(te-=k.bytes,k.seq!==l)continue;let I=Math.max(0,m-k.sentMs);while(N.length&&N.at(-1).rttMs>=I)N.pop();N.push({atMs:m,rttMs:I}),Ze[Math.min(Ke,Math.round(I))]++,ge++,he=Math.min(he??I,I)}},un=()=>{let u=0;for(let l=0;l<=Ke;l++)if(u+=Ze[l],u*2>=ge)return l;return 0},ln=()=>e.bufferedAmount<=re()/2&&!rt(0.5),ot=()=>{_e=!0,G=[],Y=0,g?.leave(Ee),g=null},it=(u)=>{if(e.done)return;if(u.key)R.first_key_ms??=V();if(!h){if(!g||G.length===0&&!u.key)return;if(G.push(u),Y+=u.data.byteLength,Y>re())ot();return}if(c){q++;return}if(e.bufferedAmount>re()||rt(1)){c=!0,q++,_=setInterval(()=>{if(e.done||!ln())return;if(_)clearInterval(_);_=null,c=!1,ae()},n.drainPollMs??25);return}if(!p){if(!u.key){q++;return}if(T({type:"hello",width:d.width,height:d.height,fps:X[i].fps,preset:i,codec:_s}),p=!0,R.first_frame_ms??=V(),!w&&a?.sound)T({type:"audioHello",...Q}),w=!0}let l=T({type:"frame",key:u.key,seq:D,captureMicros:u.micros,data:u.data});if(P.push({seq:D,sentMs:oe(),bytes:l}),te+=l,P.length>Ds)te-=P.shift().bytes;D++,be++,ne??=u.micros,we=u.micros,j.frames++,j.bytes+=l},Ee={started(u){i=u,p=!1,G=[],Y=0},unit:it,failed:()=>se("encoder_failed")},De=()=>{let u=(n.ffmpeg??jt)();if(!a||!d){se("encoder_failed");return}let[l,m]=[a,d],k="kind"in l&&l.kind==="simulator"?l.stream:null;if(!u&&!k){se("encoder_failed");return}if(g??="kind"in l&&l.kind==="mac_screen"?zs(n.spawn??Gt):new Je,R.encoder_ms===void 0)R.encoder_ms=V(),R.encoder_shared=g.running;g.start(Ee,i,()=>{let I=X[i].fps;if(k)return k(I,X[i].kbps,Qt);if("kind"in l&&l.kind==="simulator"){let C=Math.min(0.99,en(l.size)),B={width:l.size.width*C,height:l.size.height*C};return Hs(u,fe(i,Bs(Math.min(I,30)),B,(n.macEncoder??Vt)()),l)}if("kind"in l&&l.kind==="windows_screen")return(n.spawn??me)(u,fe(i,Us(I,m),Kt(m)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in l?(n.spawn??Gt)(u,fe(i,Ns(I),Kt(m),(n.macEncoder??Vt)()),{}):(n.spawn??me)(u,fe(i,Ls(I,m,l.display),m),{DISPLAY:l.display,XAUTHORITY:l.xauthority})},o)},ie=()=>{if(!f)return;Zt(f.child),f=null},dn=()=>{let u=(n.ffmpeg??jt)();if(f||e.done||!w||!a?.sound||!u)return;let l;try{l=(n.spawn??me)(u,Lt(),{PULSE_SERVER:Ve(a.sound)})}catch{return}Jt(l);let m={child:l,reader:new je};f=m,l.stdout?.on("data",(I)=>{if(f!==m||e.done)return;let C;try{C=m.reader.push(I)}catch{ie();return}let B=o();for(let Ce of C){if(e.bufferedAmount>re()){E++;continue}T({type:"audio",captureMicros:B,data:Ce}),M++}});let k=()=>{if(f===m)ie()};l.once("exit",k),l.once("error",k)},ae=()=>{if(!g||e.done)return;ye++,De()},Ie=()=>{if(e.done||!d)return;if(!h){if(g||_e)return;De(),xe=setTimeout(()=>{if(!h)ot()},Cs);return}if(clearTimeout(xe),R.encoder_early===void 0){if(R.encoder_early=g!==null,_e)R.hold_lapsed=!0}if(!g)De();let u=G;G=[],Y=0;for(let l of u)it(l);v??=setInterval(()=>{let l=o(),m=Math.max(0.001,(l-j.since)/1e6);T({type:"stats",stats:{fps:Math.round(j.frames/m*10)/10,kbps:Math.round(j.bytes*8/1000/m),dropped:q,restarts:ye,queued_bytes:e.bufferedAmount}}),j={frames:0,bytes:0,since:l}},Rs)};t.desktop.then((u)=>{if(e.done)return;a=u;let l={ready(m){d=m,R.desktop_ms??=V(),Ie()},clipboard(m){if(e.open&&Buffer.byteLength(m)<=S)T({type:"serverClipboard",text:m})},end(m){if("reason"in m&&e.open)T({type:"error",code:m.reason});e.end(m)}};if("kind"in u&&u.kind==="simulator")y=u.input,l.ready(u.points);else if("kind"in u&&u.kind==="windows_screen")y=(n.windowsInput??xt)(l);else if("kind"in u)y=(n.macInput??((m)=>Bn(m,Ye())))(l);else{let m=ee.get(u.display);if(!m)ee.set(u.display,m=new Set);m.add(st);let k=(n.linuxClipboard??Ut)(u,l),I=Fs(u.rfbSocket,{...l,clipboard:(C)=>{if(!k)l.clipboard(C)}});y=k?{pointer:(C,B,Ce)=>k.apply(()=>I.pointer(C,B,Ce)),key:(C,B)=>k.apply(()=>I.key(C,B)),clipboard:(C)=>k.write(C),close(){k.close(),I.close()}}:I}at()},(u)=>e.end({error:u}));function at(){if(Se||!t.viewerSameNetwork||!h||e.done||!a||!("kind"in a)||a.kind!=="mac_screen")return;Se=(n.macWindows??$n)((u)=>{if(e.open)T({type:"windows",bounds:u})})}let ct={viewer:t.viewer??null,notify(u){if(e.open)T({type:"control",control:u})}},Pe=(u)=>{if(!y)return;if(!a||!("kind"in a)||a.kind!=="simulator")tt.claim(ct);u(y)};return{opened(){R.relay_ms??=V()},received(u){et+=u.byteLength;let l;try{l=s.push(u)}catch{se("viewer_protocol");return}for(let m of l){if(e.done)return;switch(m.type){case"ping":T({type:"pong",token:m.token});break;case"pointer":Pe((k)=>k.pointer(m.x,m.y,m.buttons));break;case"key":Pe((k)=>k.key(m.down,m.keysym));break;case"clientClipboard":Pe((k)=>k.clipboard(m.text));break;case"config":if(m.preset!==i)i=m.preset,ae();break;case"keyframeRequest":if(p&&!c)ae();break;case"ack":cn(m.seq);break;case"audioEnable":if(m.on)dn();else ie();break;case"resize":on({width:m.width,height:m.height});break;default:break}}if(!h&&!e.done){if(h=!0,R.viewer_ms=V(),t.viewer)ke=tt.join(ct);Ie(),at()}},close(){if(a&&!("kind"in a)){let u=ee.get(a.display);if(u?.delete(st),u?.size===0)ee.delete(a.display)}if(ke?.(),ke=null,Se?.close(),_)clearInterval(_);if(v)clearInterval(v);clearTimeout(xe),g?.leave(Ee),ie(),y?.close()},summary:()=>({output_bytes:Qe,input_bytes:et,video:{preset:i,frames:be,dropped:q,restarts:ye,avg_fps:ne!==null&&we>ne?Math.round((be-1)/((we-ne)/1e6)*10)/10:0,min_rtt_ms:Math.round(he??0),p50_rtt_ms:ge?un():0,audio_packets:M,audio_dropped:E,resizes:nt,connect:R}})}}var qt=null,nn=null,js=null,Gs=null;function Vs(){let e=x();return e?.features.display?e.ffmpeg:null}function sn(e){return qt??=new Promise((t)=>{ys(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(n,o)=>{let s=(i)=>!n&&new RegExp(`^\\s*V\\S*\\s+${i}\\s`,"m").test(o);t(nn={x264:s("libx264"),videotoolbox:s("h264_videotoolbox")})})}),qt}var Yt=null;function Nn(){return Yt??=(async()=>{let e=[x()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&ws(n)));if(!e)return null;let t=await sn(e);return t.videotoolbox||t.x264?e:null})(),Yt}function Pr(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Vs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??sn)(n);if(e==="linux")return o.then((i)=>i.x264);if(e==="win32"){let i=t.windowsScreen?t.windowsScreen():Gs??=bt();return Promise.all([o,i]).then(([a,d])=>a.x264&&(d?.session??0)>0)}let s=t.macScreen?t.macScreen():js??=Ge(Ye());return Promise.all([o,s]).then(([i,a])=>(i.x264||i.videotoolbox)&&a?.screen===!0&&a.accessibility)}
126
- export{We,lo,F,Rn,Ve,uo,On,In,Dn,Nn,Pr,Ft,Tr,x,po};
124
+ `;p(()=>{if(s=!0,y=setTimeout(()=>g(),5000),n.stdin.write(f),n.stdin.writableLength>Nt)h(),t.end({reason:"input_backpressure"})},Buffer.byteLength(f))},close:h}}var X={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}},_s="avc1.4D002A",Bt={width:1920,height:1080},ks=262144,Ss=0.2,vs=250,Es=1e4,Ds=1024,Ke=1e4,Is=500,Ps=60,Cs=1e4,Rs=1000,Ht=1048576,Ms=-223,Ts=-308,In={kind:"mac_screen",sound:null},Dn={kind:"windows_screen",sound:null},Os,jt=()=>Os??=x()?.ffmpeg??null,me=(e,t,n)=>qe(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),As,Ye=()=>As??=Ot(x()),Gt=(e,t,n)=>{let[o,...s]=[...Ye(),e];return me(o,[...s,...t],n)},Vt=()=>nn?.videotoolbox?"h264_videotoolbox":"libx264",$s=()=>Math.round(performance.now()*1000),Xe=new Set,Wt=!1;function Jt(e){if(Xe.add(e),e.once("exit",()=>Xe.delete(e)),Wt)return;Wt=!0,process.once("exit",()=>{for(let t of Xe)try{t.kill("SIGKILL")}catch{}})}function Zt(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{}},Is);e.once("exit",()=>clearTimeout(t))}function Ls(e,t,n){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",n],size:t}}function Ns(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Us(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 Bs(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Qt=1700000;function en(e){return Math.min(1,Math.round(Math.sqrt(Qt/(e.width*e.height))*100)/100)}function Hs(e,t,n){let o=qe(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,en(n.size)))],{stdio:["ignore","pipe","ignore"]}),s=qe(e,t,{env:{},stdio:["pipe","pipe","ignore"]});o.stdout.pipe(s.stdin),s.stdin.on("error",()=>{});let i=()=>{if(o.exitCode===null&&o.signalCode===null)o.kill("SIGTERM")};return s.once("exit",i),s.once("error",i),o.once("exit",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),o.once("error",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),s}function Kt(e){let t=Math.min(1,Bt.width/e.width,Bt.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function fe(e,t,n,o="libx264"){let s=X[e],i=(p)=>Math.max(2,Math.floor(p/2)*2),a={width:i(n.width*s.scale),height:i(n.height*s.scale)},d=a.width!==t.size?.width||a.height!==t.size.height,y=Math.max(1,Math.round(s.kbps*2/s.fps)),h=["-g",String(s.fps*Ps)],g=o==="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",...h,"-b:v",`${s.kbps}k`,"-maxrate",`${s.kbps}k`,"-bufsize",`${y}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",s.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...s.threads?["-threads",String(s.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...h,"-crf",String(s.crf),"-maxrate",`${s.kbps}k`,"-bufsize",`${y}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...d?["-vf",`scale=${a.width}:${a.height}:flags=fast_bilinear`]:[],...g,"-flush_packets","1","-f","h264","pipe:1"]}class tn{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let n=new Uint8Array(this.buffer.byteLength+e.byteLength);n.set(this.buffer),n.set(e,this.buffer.byteLength),this.buffer=n;let o=[],s=this.scanned;while(s+3<this.buffer.byteLength){if(this.buffer[s]!==0||this.buffer[s+1]!==0||this.buffer[s+2]!==1){s++;continue}let i=this.buffer[s+3]&31,a=s>0&&this.buffer[s-1]===0?s-1:s;if(i===9&&a>0)o.push({data:this.buffer.slice(0,a),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(a),this.key=!1,this.micros=t,s-=a;if(i===5)this.key=!0;s+=3}return this.scanned=s,o}}function Fs(e,t){let n=xs({path:e}),o=Buffer.alloc(0),s="version",i=0,a=!1,d=[],y=0,h=!1,g=(c)=>{if(h)return;h=!0,n.destroy(),t.end(c)},p=()=>g({reason:"display_protocol"}),w=(c)=>{if(h)return;if(!a){if(y+=c.byteLength,y>Ht)g({reason:"input_backpressure"});else d.push(c);return}if(n.write(c),n.writableLength>Ht)g({reason:"input_backpressure"})},f=(c)=>{o=o.subarray(c)},M=()=>{switch(s){case"version":{if(o.byteLength<12)return!1;let c=/^RFB (\d{3})\.(\d{3})\n$/.exec(o.subarray(0,12).toString("latin1"));if(!c||Number(c[1])*1000+Number(c[2])<3007)return p(),!1;return f(12),n.write(`RFB 003.007
125
+ `),s="security",!0}case"security":{if(o.byteLength<1)return!1;let c=o[0];if(c===0)return p(),!1;if(o.byteLength<1+c)return!1;if(!o.subarray(1,1+c).includes(1))return p(),!1;return f(1+c),n.write(Buffer.from([1,1])),s="init",!0}case"init":{if(o.byteLength<24)return!1;let c=o.readUInt32BE(20);if(c>65536)return p(),!1;if(o.byteLength<24+c)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(f(24+c),_.width===0||_.height===0)return p(),!1;s="messages";let v=Buffer.alloc(12);v.writeUInt8(2,0),v.writeUInt16BE(2,2),v.writeInt32BE(Ts,4),v.writeInt32BE(Ms,8),n.write(v),a=!0;for(let D of d)n.write(D);return d=[],y=0,t.ready(_),!h}case"skip":{let c=Math.min(i,o.byteLength);if(f(c),i-=c,i>0)return!1;return s="messages",!0}case"messages":{if(o.byteLength<1)return!1;switch(o[0]){case 1:{if(o.byteLength<6)return!1;let c=6+o.readUInt16BE(4)*6;if(o.byteLength<c)return!1;return f(c),!0}case 2:return f(1),!0;case 3:{if(o.byteLength<8)return!1;let c=o.readUInt32BE(4);if(c>S/2)return f(8),s="skip",i=c,!0;if(o.byteLength<8+c)return!1;let _=o.subarray(8,8+c).toString("latin1");return f(8+c),t.clipboard(_),!h}default:return p(),!1}}}},E=!1;return n.once("connect",()=>{E=!0}),n.on("data",(c)=>{if(h)return;o=o.byteLength?Buffer.concat([o,c]):c;while(!h&&M());}),n.once("error",()=>{if(!E)g({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>g({reason:"display_closed"})),{pointer(c,_,v){let D=Buffer.alloc(6);D.writeUInt8(5,0),D.writeUInt8(v&255,1),D.writeUInt16BE(c,2),D.writeUInt16BE(_,4),w(D)},key(c,_){let v=Buffer.alloc(8);v.writeUInt8(4,0),v.writeUInt8(c?1:0,1),v.writeUInt32BE(_>>>0,4),w(v)},clipboard(c){if(Array.from(c).some((D)=>D.codePointAt(0)>255)){g({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(c,"latin1"),v=Buffer.alloc(8);v.writeUInt8(6,0),v.writeUInt32BE(_.byteLength,4),w(Buffer.concat([v,_]))},close(){h=!0,n.destroy()}}}class Je{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,n,o){this.viewers.add(e),this.stop();let s;try{s=n()}catch{this.fail();return}Jt(s);let i={child:s,splitter:new tn};this.run=i;for(let d of[...this.viewers])d.started(t);s.stdout?.on("data",(d)=>{if(this.run!==i)return;for(let y of i.splitter.push(d,o()))for(let h of[...this.viewers])h.unit(y)});let a=()=>{if(this.run!==i)return;this.run=null,this.fail()};s.once("exit",a),s.once("error",a)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;Zt(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Xt=new WeakMap;function zs(e){let t=Xt.get(e);if(!t)Xt.set(e,t=new Je);return t}var ee=new Map;function Nn(e,t,n={}){let o=n.micros??$s,s=new $n,i=t.request.preset,a=null,d=null,y=null,h=!1,g=null,p=!1,w=!1,f=null,M=0,E=0,c=!1,_=null,v=null,D=0,L=null,P=[],te=0,N=[],Ze=new Uint32Array(Ke+1),ge=0,he=null,be=0,q=0,ye=0,Qe=0,et=0,ne=null,we=0,j={frames:0,bytes:0,since:o()},G=[],Y=0,xe,_e=!1,rn=o(),R={},V=()=>Math.round((o()-rn)/1000),tt=n.control??ut,ke=null,Se=null,nt=0,ve=!1,st={pause(){if(!g?.running)return;g.stop(),ve=!0},adopt(u){let l=u!==null&&(u.width!==d?.width||u.height!==d?.height);if(l)d=u;if(!l&&!ve)return;if(ve=!1,g)ae();else Ie()}},on=(u)=>{if(!n.resizeDesktop||!a||"kind"in a||e.done)return;let l=a.display,m=()=>[...ee.get(l)??[]];nt++,n.resizeDesktop(a,u,()=>{for(let k of m())k.pause()}).then((k)=>{for(let I of m())I.adopt(k)})},T=(u)=>{let l=zt(u);return e.send(l),Qe+=l.byteLength,l.byteLength},se=(u)=>{if(e.done)return;if(e.open)T({type:"error",code:u});e.end({reason:u})},re=()=>Math.max(ks,X[i].kbps*1000/8*Ss),oe=()=>o()/1000,an=()=>{while(N.length>1&&N[0].atMs<oe()-Es)N.shift();return N[0]?.rttMs??null},rt=(u)=>{let l=an();if(l===null||P.length===0)return!1;let m=(l+vs)*u;return oe()-P[0].sentMs>m||te>m/1000*X[i].kbps*1000/8},cn=(u)=>{if(D===0)return;let l=Math.min(u,D-1);if(L!==null&&l<=L)return;L=l;let m=oe();while(P.length&&P[0].seq<=l){let k=P.shift();if(te-=k.bytes,k.seq!==l)continue;let I=Math.max(0,m-k.sentMs);while(N.length&&N.at(-1).rttMs>=I)N.pop();N.push({atMs:m,rttMs:I}),Ze[Math.min(Ke,Math.round(I))]++,ge++,he=Math.min(he??I,I)}},un=()=>{let u=0;for(let l=0;l<=Ke;l++)if(u+=Ze[l],u*2>=ge)return l;return 0},ln=()=>e.bufferedAmount<=re()/2&&!rt(0.5),ot=()=>{_e=!0,G=[],Y=0,g?.leave(Ee),g=null},it=(u)=>{if(e.done)return;if(u.key)R.first_key_ms??=V();if(!h){if(!g||G.length===0&&!u.key)return;if(G.push(u),Y+=u.data.byteLength,Y>re())ot();return}if(c){q++;return}if(e.bufferedAmount>re()||rt(1)){c=!0,q++,_=setInterval(()=>{if(e.done||!ln())return;if(_)clearInterval(_);_=null,c=!1,ae()},n.drainPollMs??25);return}if(!p){if(!u.key){q++;return}if(T({type:"hello",width:d.width,height:d.height,fps:X[i].fps,preset:i,codec:_s}),p=!0,R.first_frame_ms??=V(),!w&&a?.sound)T({type:"audioHello",...Q}),w=!0}let l=T({type:"frame",key:u.key,seq:D,captureMicros:u.micros,data:u.data});if(P.push({seq:D,sentMs:oe(),bytes:l}),te+=l,P.length>Ds)te-=P.shift().bytes;D++,be++,ne??=u.micros,we=u.micros,j.frames++,j.bytes+=l},Ee={started(u){i=u,p=!1,G=[],Y=0},unit:it,failed:()=>se("encoder_failed")},De=()=>{let u=(n.ffmpeg??jt)();if(!a||!d){se("encoder_failed");return}let[l,m]=[a,d],k="kind"in l&&l.kind==="simulator"?l.stream:null;if(!u&&!k){se("encoder_failed");return}if(g??="kind"in l&&l.kind==="mac_screen"?zs(n.spawn??Gt):new Je,R.encoder_ms===void 0)R.encoder_ms=V(),R.encoder_shared=g.running;g.start(Ee,i,()=>{let I=X[i].fps;if(k)return k(I,X[i].kbps,Qt);if("kind"in l&&l.kind==="simulator"){let C=Math.min(0.99,en(l.size)),B={width:l.size.width*C,height:l.size.height*C};return Hs(u,fe(i,Bs(Math.min(I,30)),B,(n.macEncoder??Vt)()),l)}if("kind"in l&&l.kind==="windows_screen")return(n.spawn??me)(u,fe(i,Us(I,m),Kt(m)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in l?(n.spawn??Gt)(u,fe(i,Ns(I),Kt(m),(n.macEncoder??Vt)()),{}):(n.spawn??me)(u,fe(i,Ls(I,m,l.display),m),{DISPLAY:l.display,XAUTHORITY:l.xauthority})},o)},ie=()=>{if(!f)return;Zt(f.child),f=null},dn=()=>{let u=(n.ffmpeg??jt)();if(f||e.done||!w||!a?.sound||!u)return;let l;try{l=(n.spawn??me)(u,Lt(),{PULSE_SERVER:Ve(a.sound)})}catch{return}Jt(l);let m={child:l,reader:new je};f=m,l.stdout?.on("data",(I)=>{if(f!==m||e.done)return;let C;try{C=m.reader.push(I)}catch{ie();return}let B=o();for(let Ce of C){if(e.bufferedAmount>re()){E++;continue}T({type:"audio",captureMicros:B,data:Ce}),M++}});let k=()=>{if(f===m)ie()};l.once("exit",k),l.once("error",k)},ae=()=>{if(!g||e.done)return;ye++,De()},Ie=()=>{if(e.done||!d)return;if(!h){if(g||_e)return;De(),xe=setTimeout(()=>{if(!h)ot()},Cs);return}if(clearTimeout(xe),R.encoder_early===void 0){if(R.encoder_early=g!==null,_e)R.hold_lapsed=!0}if(!g)De();let u=G;G=[],Y=0;for(let l of u)it(l);v??=setInterval(()=>{let l=o(),m=Math.max(0.001,(l-j.since)/1e6);T({type:"stats",stats:{fps:Math.round(j.frames/m*10)/10,kbps:Math.round(j.bytes*8/1000/m),dropped:q,restarts:ye,queued_bytes:e.bufferedAmount}}),j={frames:0,bytes:0,since:l}},Rs)};t.desktop.then((u)=>{if(e.done)return;a=u;let l={ready(m){d=m,R.desktop_ms??=V(),Ie()},clipboard(m){if(e.open&&Buffer.byteLength(m)<=S)T({type:"serverClipboard",text:m})},end(m){if("reason"in m&&e.open)T({type:"error",code:m.reason});e.end(m)}};if("kind"in u&&u.kind==="simulator")y=u.input,l.ready(u.points);else if("kind"in u&&u.kind==="windows_screen")y=(n.windowsInput??xt)(l);else if("kind"in u)y=(n.macInput??((m)=>Fn(m,Ye())))(l);else{let m=ee.get(u.display);if(!m)ee.set(u.display,m=new Set);m.add(st);let k=(n.linuxClipboard??Ut)(u,l),I=Fs(u.rfbSocket,{...l,clipboard:(C)=>{if(!k)l.clipboard(C)}});y=k?{pointer:(C,B,Ce)=>k.apply(()=>I.pointer(C,B,Ce)),key:(C,B)=>k.apply(()=>I.key(C,B)),clipboard:(C)=>k.write(C),close(){k.close(),I.close()}}:I}at()},(u)=>e.end({error:u}));function at(){if(Se||!t.viewerSameNetwork||!h||e.done||!a||!("kind"in a)||a.kind!=="mac_screen")return;Se=(n.macWindows??Bn)((u)=>{if(e.open)T({type:"windows",bounds:u})})}let ct={viewer:t.viewer??null,notify(u){if(e.open)T({type:"control",control:u})}},Pe=(u)=>{if(!y)return;if(!a||!("kind"in a)||a.kind!=="simulator")tt.claim(ct);u(y)};return{opened(){R.relay_ms??=V()},received(u){et+=u.byteLength;let l;try{l=s.push(u)}catch{se("viewer_protocol");return}for(let m of l){if(e.done)return;switch(m.type){case"ping":T({type:"pong",token:m.token});break;case"pointer":Pe((k)=>k.pointer(m.x,m.y,m.buttons));break;case"key":Pe((k)=>k.key(m.down,m.keysym));break;case"clientClipboard":Pe((k)=>k.clipboard(m.text));break;case"config":if(m.preset!==i)i=m.preset,ae();break;case"keyframeRequest":if(p&&!c)ae();break;case"ack":cn(m.seq);break;case"audioEnable":if(m.on)dn();else ie();break;case"resize":on({width:m.width,height:m.height});break;default:break}}if(!h&&!e.done){if(h=!0,R.viewer_ms=V(),t.viewer)ke=tt.join(ct);Ie(),at()}},close(){if(a&&!("kind"in a)){let u=ee.get(a.display);if(u?.delete(st),u?.size===0)ee.delete(a.display)}if(ke?.(),ke=null,Se?.close(),_)clearInterval(_);if(v)clearInterval(v);clearTimeout(xe),g?.leave(Ee),ie(),y?.close()},summary:()=>({output_bytes:Qe,input_bytes:et,video:{preset:i,frames:be,dropped:q,restarts:ye,avg_fps:ne!==null&&we>ne?Math.round((be-1)/((we-ne)/1e6)*10)/10:0,min_rtt_ms:Math.round(he??0),p50_rtt_ms:ge?un():0,audio_packets:M,audio_dropped:E,resizes:nt,connect:R}})}}var qt=null,nn=null,js=null,Gs=null;function Vs(){let e=x();return e?.features.display?e.ffmpeg:null}function sn(e){return qt??=new Promise((t)=>{ys(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(n,o)=>{let s=(i)=>!n&&new RegExp(`^\\s*V\\S*\\s+${i}\\s`,"m").test(o);t(nn={x264:s("libx264"),videotoolbox:s("h264_videotoolbox")})})}),qt}var Yt=null;function Ln(){return Yt??=(async()=>{let e=[x()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&ws(n)));if(!e)return null;let t=await sn(e);return t.videotoolbox||t.x264?e:null})(),Yt}function Pr(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Vs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??sn)(n);if(e==="linux")return o.then((i)=>i.x264);if(e==="win32"){let i=t.windowsScreen?t.windowsScreen():Gs??=bt();return Promise.all([o,i]).then(([a,d])=>a.x264&&(d?.session??0)>0)}let s=t.macScreen?t.macScreen():js??=Ge(Ye());return Promise.all([o,s]).then(([i,a])=>(i.x264||i.videotoolbox)&&a?.screen===!0&&a.accessibility)}
126
+ export{We,uo,F,On,Ve,po,In,Dn,Nn,Ln,Pr,Ft,Tr,x,ho};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{t,o,i,W,ee,s,n}from"./vm-hands-entry-lite-g27kmejx.js";var lt=32768,Lt=67108864,Cr=16384,E=204800,xn=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=ee(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function u(e){try{let r=new URL(e);return["http:","https:"].includes(r.protocol)&&!r.username&&!r.password&&!r.search&&!r.hash?r:null}catch{return null}}function Ar(e,r){let c=u(e.baseUrl),l=u(r.baseUrl),a=u(e.url);if(!c||!l||!a||e.method!=="POST"||r.execution!=="device")return!1;let d=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(d(c)!==d(l)||a.origin!==c.origin)return!1;let h=r.api==="openai-completions"?"/chat/completions":r.api==="openai-responses"?"/responses":"/v1/messages";return a.pathname===c.pathname.replace(/\/+$/,"")+h}var kn=i({baseUrl:t().max(2048),url:t().max(4096),method:n("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=E).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((r)=>Ar(e,{baseUrl:e.baseUrl,api:r,execution:"device"})),"Invalid custom endpoint inference URL"),x=i({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:ee(t(),t().max(4096)).refine((e)=>Object.keys(e).every((r)=>["content-type","retry-after","x-request-id","request-id"].includes(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)))}).strict(),D=W([i({eof:n(!0)}).strict(),i({eof:n(!1),data:t().max(Math.ceil(lt/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=lt)}).strict()]),y=i({bytes:o().int().min(0).max(Lt),chunks:o().int().min(0).max(Cr)}).strict(),Cn=i({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),S=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function An(e){return typeof e==="string"&&S.includes(e)}var O="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",g={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${O}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(g));export{lt,Lt,Cr,xn,Ar,kn,Cn,An};
2
+ import{t,o,i,W,ee,s,n}from"./vm-hands-entry-lite-a1xa7s06.js";var lt=32768,Lt=67108864,Cr=16384,E=204800,kn=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=ee(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function u(e){try{let r=new URL(e);return["http:","https:"].includes(r.protocol)&&!r.username&&!r.password&&!r.search&&!r.hash?r:null}catch{return null}}function Ar(e,r){let c=u(e.baseUrl),l=u(r.baseUrl),a=u(e.url);if(!c||!l||!a||e.method!=="POST"||r.execution!=="device")return!1;let d=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(d(c)!==d(l)||a.origin!==c.origin)return!1;let h=r.api==="openai-completions"?"/chat/completions":r.api==="openai-responses"?"/responses":"/v1/messages";return a.pathname===c.pathname.replace(/\/+$/,"")+h}var Cn=i({baseUrl:t().max(2048),url:t().max(4096),method:n("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=E).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((r)=>Ar(e,{baseUrl:e.baseUrl,api:r,execution:"device"})),"Invalid custom endpoint inference URL"),x=i({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:ee(t(),t().max(4096)).refine((e)=>Object.keys(e).every((r)=>["content-type","retry-after","x-request-id","request-id"].includes(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)))}).strict(),D=W([i({eof:n(!0)}).strict(),i({eof:n(!1),data:t().max(Math.ceil(lt/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=lt)}).strict()]),y=i({bytes:o().int().min(0).max(Lt),chunks:o().int().min(0).max(Cr)}).strict(),An=i({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),S=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function Pn(e){return typeof e==="string"&&S.includes(e)}var O="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",g={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${O}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(g));export{lt,Lt,Cr,kn,Ar,Cn,An,Pn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var Qt={name:"github-native-engineer-device-worker-production",version:"0.2.494",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@agentclientprotocol/sdk":"1.9.0","@anthropic-ai/sandbox-runtime":"^0.0.80","@earendil-works/pi-tui":"1.0.0","@reason/runtime-distribution":"workspace:*",diff:"8.0.4","open-browser-use-sdk":"0.1.42","playwright-core":"1.60.0",toml:"4.2.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
2
+ var Qt={name:"github-native-engineer-device-worker-production",version:"0.2.496",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@agentclientprotocol/sdk":"1.9.0","@anthropic-ai/sandbox-runtime":"^0.0.80","@earendil-works/pi-tui":"1.0.0","@reason/runtime-distribution":"workspace:*",diff:"8.0.4","open-browser-use-sdk":"0.1.42","playwright-core":"1.60.0",toml:"4.2.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
3
3
  export{Qt};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{Nt}from"./vm-hands-entry-lite-np07qyeq.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{fe,se,C}from"./vm-hands-entry-lite-tbawqj1n.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as h,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as A,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(A(A(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Ui(){z=!0}function j(){return z?c(A(re(process.execPath)),"runtime","srt"):void 0}function y(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!h(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!h(y()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??h,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??h;if(t==="win32")return(e.bash??fe)()&&o(y())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??Nt;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,M=!1,p=null,F=null;var m=null,P=null,_=null,E=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Hi(e){if(m!==null&&m!==e||M&&S!==null&&S!==e||P!==null&&P!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
2
+ import{Nt}from"./vm-hands-entry-lite-np07qyeq.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{fe,se,C}from"./vm-hands-entry-lite-87vmbt38.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as h,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as A,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(A(A(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Hi(){z=!0}function j(){return z?c(A(re(process.execPath)),"runtime","srt"):void 0}function y(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!h(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!h(y()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??h,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??h;if(t==="win32")return(e.bash??fe)()&&o(y())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??Nt;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,M=!1,p=null,F=null;var m=null,P=null,_=null,E=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function zi(e){if(m!==null&&m!==e||M&&S!==null&&S!==e||P!==null&&P!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
3
  `);p=e}function ur(e){if(p)return!1;if(!M){if(S=xe(e??{}),M=!0,S&&!e)Ce()}return S!==null}function he(){return ur()?S:null}var R=null,x=0;function I(e,t){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)D();let o=m??e.sandboxMode??he();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(P&&P!==o)D();return P=o,R??=(async()=>{let{SandboxManager:n}=await(e.loadSandboxRuntime??Y)();return await n.initialize(Ne(o,t)),n})().catch((n)=>{if(R=null,t)_=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(n).slice(0,500)})
4
4
  `);else b(`initialize_failed: ${String(n)}`);throw n instanceof r?n:new r("sandbox_unavailable","The confined execution sandbox failed to start.")}),R.then((n)=>{if(p)throw new r("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return n})}function O(){if(x-=1,x===0)for(let e of v.splice(0))e()}async function ye(e,t=!0,o,n){let i=n===void 0?1/0:Date.now()+n;await Q();let s=_e();if(t)await s;let a=JSON.stringify(e),l=!1,u=()=>{if(!l)return;l=!1;let d=(g.get(a)??1)-1;if(d>0)g.set(a,d);else g.delete(a)};try{for(;;){if(o?.aborted)throw new r("cancelled","Operation was cancelled.");if(Date.now()>=i)return!1;if(E){await E;continue}let d=g.keys().next().value;if(_??=d??a,_===a&&(d===void 0||d===a))break;if(!l){l=!0,g.set(a,(g.get(a)??0)+1);continue}if(x===0&&d===a){Pe();continue}await new Promise((f)=>{if(v.push(f),o?.addEventListener("abort",()=>f(),{once:!0}),i!==1/0)setTimeout(f,Math.max(0,i-Date.now())).unref?.()})}return x+=1,!0}finally{if(l&&x===0)for(let d of v.splice(0))d();u()}}function Pe(){return E??=Me().finally(()=>{E=null}),E}function Ee(e,t,o=process.env){let n=o.USERPROFILE?w.resolve(o.USERPROFILE).toLowerCase():null,i=w.resolve(e).toLowerCase(),s=n!==null&&i.startsWith(`${n}\\`),a=t?q(o).filter((l)=>l.toLowerCase()===i||l.toLowerCase().startsWith(`${i}\\`)):[];return{denyRead:[],allowRead:[e],allowWrite:t?[e]:[],denyWrite:t?a:s?[]:[e]}}function q(e,t=process.execPath){let o=new Map;for(let n of[...(e.PATH??e.Path??"").split(";"),w.dirname(t)]){if(!n||!w.isAbsolute(n))continue;let i=w.resolve(n);if(!o.has(i.toLowerCase()))o.set(i.toLowerCase(),i)}return[...o.values()]}function Re(e=process.env,t=process.execPath){let o=[e.SystemRoot,e.ProgramFiles,e["ProgramFiles(x86)"],e.ProgramW6432,e.ProgramData,e.USERPROFILE].filter((n)=>!!n).map((n)=>w.resolve(n).toLowerCase());return q(e,t).filter((n)=>{let i=n.toLowerCase();return!o.some((s)=>i===s||i.startsWith(`${s}\\`))})}var U=null,H=null;function Q(e=y()){return H??=(async()=>{let t;try{t=JSON.parse((await V(e,["status"])).stdout).user?.user?.sid}catch{return null}if(typeof t!=="string"||!/^S-1-[0-9-]+$/.test(t))return null;if(!await new Promise((n)=>{let i=J(C("icacls"),[e,"/grant",`*${t}:(RX)`],{stdio:"ignore",windowsHide:!0,timeout:30000});i.on("error",()=>n(!1)),i.on("close",(s)=>n(s===0))}))process.stderr.write(`Reason worker: could not let the Windows sandbox user run srt-win.exe
5
5
  `);return t})(),H}function V(e,t,o){return new Promise((n)=>{let i=J(e,t,{stdio:["pipe","pipe","ignore"],windowsHide:!0,timeout:120000}),s="";i.stdout?.setEncoding("utf8").on("data",(a)=>{s+=a}),i.on("error",()=>n({status:null,stdout:s})),i.on("close",(a)=>n({status:a,stdout:s})),i.stdin?.end(o??"")})}function _e(e=y()){return U??=(async()=>{let t=Re();if(t.length===0)return;let o=await Q(e),n=o?await V(e,["acl","stamp","--holder-pid",String(process.ppid),"--sandbox-user-sid",o],JSON.stringify({denyRead:[],denyWrite:t})):null;if(!n||n.status!==0&&n.status!==2)b(`program_folder_deny_failed: ${n?`exit ${n.status}`:"no sandbox user"}`),process.stderr.write(`Reason worker: could not deny the Windows sandbox writes to PATH folders (${n?`exit ${n.status}`:"no sandbox user"}); confined commands are off
6
- `)})(),U}var Ae=`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 Me(){let e=R;if(R=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!ur())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!h(y()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function hn(e=h,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"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 ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:y()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function zi(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),x+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??hn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
- export{Ui,Hi,ur,hn,zi};
6
+ `)})(),U}var Ae=`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 Me(){let e=R;if(R=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!ur())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!h(y()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function hn(e=h,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"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 ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:y()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function qi(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),x+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??hn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
+ export{Hi,zi,ur,hn,qi};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class ft extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function Ao(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
- export{ft,Ao};
2
+ var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class ft extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function Po(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
+ export{ft,Po};