@reason-machines/cli-linux-x64 0.2.416 → 0.2.419
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.
- package/THIRD_PARTY_NOTICES.txt +7 -8
- package/bin/reason +2 -2
- package/bin/runtime/srt/sandbox-runtime.mjs +52 -52
- package/bin/vm-hands/api-credentials-s4897qxy.js +2 -0
- package/bin/vm-hands/api-m73x3da5.js +2 -0
- package/bin/vm-hands/ask-relay-4kwcx2b7.js +8 -0
- package/bin/vm-hands/connect-cli-34b18gjs.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-j012b4bd.js +2 -0
- package/bin/vm-hands/desktop-account-0q0arpzk.js +2 -0
- package/bin/vm-hands/device-workspace-3jxhs54b.js +2 -0
- package/bin/vm-hands/hands-worker-source-y64axsw3.js +2 -0
- package/bin/vm-hands/index-194s4vz0.js +12818 -0
- package/bin/vm-hands/install-receipt-1g68b446.js +2 -0
- package/bin/vm-hands/local-automation-k2w46hn2.js +2 -0
- package/bin/vm-hands/local-capabilities-tdzbqmrb.js +2 -0
- package/bin/vm-hands/local-desktop-users-6thzvydd.js +2 -0
- package/bin/vm-hands/local-display-mac-59ma7sxa.js +2 -0
- package/bin/vm-hands/local-display-session-4833qq7h.js +2 -0
- package/bin/vm-hands/local-display-video-c1143mz6.js +2 -0
- package/bin/vm-hands/local-managed-process-mr0zpk7c.js +2 -0
- package/bin/vm-hands/local-pty-session-bwarwpsd.js +2 -0
- package/bin/vm-hands/managed-runtime-vz1wqwwg.js +2 -0
- package/bin/vm-hands/network-contract-gprc37sw.js +2 -0
- package/bin/vm-hands/package-ej9snd47.js +2 -0
- package/bin/vm-hands/permissions-7sfghef4.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-jsrkawe2.js +2 -0
- package/bin/vm-hands/serve-service-kngyzh74.js +2 -0
- package/bin/vm-hands/status-jz29fb95.js +96 -0
- package/bin/vm-hands/version-g29vt13t.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-0h4qmgm2.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-0k13wmzm.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-1exfjv79.js +52 -0
- package/bin/vm-hands/vm-hands-entry-lite-26q3hbdc.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-28s7v15d.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-2m5dwrdf.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-37hvds7z.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-3rqdzqhk.js +112 -0
- package/bin/vm-hands/vm-hands-entry-lite-4gh5kfr4.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-t7an5zg2.js → vm-hands-entry-lite-4k4h9rcq.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-6nwbqg37.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-m11j0f9q.js → vm-hands-entry-lite-6y6pz2yw.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-714wspqb.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-7zk0r3p9.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-9qep7pka.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-bdhjpv7g.js → vm-hands-entry-lite-agsp101y.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-am6kj1n1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-as1tkffn.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-bxt4n1nj.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-c2g3wmkp.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-d2w8tghq.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-d98m00b8.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-daxcxjze.js +344 -0
- package/bin/vm-hands/vm-hands-entry-lite-dcnyve97.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-e1b89x66.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ej5ffjck.js +105 -0
- package/bin/vm-hands/vm-hands-entry-lite-ejkba2nk.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-f3wh0dza.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-f5xb489y.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-feybcq63.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-fpp2bs9y.js +452 -0
- package/bin/vm-hands/{vm-hands-entry-lite-cs5t8eyd.js → vm-hands-entry-lite-fzkfajew.js} +9 -5
- package/bin/vm-hands/vm-hands-entry-lite-gt497d5x.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-gxper06w.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-j2ng164q.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-jp9q2vsx.js +127 -0
- package/bin/vm-hands/vm-hands-entry-lite-magmzx9c.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ntx8fdyq.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-pfzczmaa.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-pkc4ry5x.js +539 -0
- package/bin/vm-hands/vm-hands-entry-lite-pp7jfqzr.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-q8wkrzer.js +66 -0
- package/bin/vm-hands/vm-hands-entry-lite-s823n1q9.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-s9xf5z69.js +7 -0
- package/bin/vm-hands/vm-hands-entry-lite-tchc7z17.js +128 -0
- package/bin/vm-hands/vm-hands-entry-lite-tytfs183.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-v4jtxgaj.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-vgpt2n1v.js +11 -0
- package/bin/vm-hands/{vm-hands-entry-lite-9c95p6n9.js → vm-hands-entry-lite-vsa7t6m9.js} +54 -54
- package/bin/vm-hands/vm-hands-entry-lite-xp3qzxk5.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -3
- package/bin/vm-hands/vm-hands-executor-epyhpjv3.js +11 -0
- package/bin/vm-hands/vm-hands-op-runner-fn1qph82.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-8vt9etvv.js +4 -0
- package/bin/vm-hands/worker-preview-readiness-yfjgban2.js +2 -0
- package/bin/vm-hands/worker-sandbox-z0t69av8.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-cjv8m2zy.js +0 -2
- package/bin/vm-hands/api-credentials-m5akr9fv.js +0 -2
- package/bin/vm-hands/connect-cli-pcfvh00f.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-dkqb4rqy.js +0 -2
- package/bin/vm-hands/desktop-account-5v7x0ajx.js +0 -2
- package/bin/vm-hands/device-workspace-p9q9dckg.js +0 -2
- package/bin/vm-hands/fsevents-ekt70rcc.js +0 -2
- package/bin/vm-hands/hands-worker-source-cgrpm21b.js +0 -2
- package/bin/vm-hands/index-k8kcz8a3.js +0 -12818
- package/bin/vm-hands/install-receipt-7vt2y2vh.js +0 -2
- package/bin/vm-hands/local-automation-zj5h05b9.js +0 -2
- package/bin/vm-hands/local-capabilities-gkdh1z5z.js +0 -2
- package/bin/vm-hands/local-desktop-users-q886k0mm.js +0 -2
- package/bin/vm-hands/local-display-mac-w85956f1.js +0 -2
- package/bin/vm-hands/local-display-session-m6an1hqp.js +0 -2
- package/bin/vm-hands/local-pty-session-5f50sqq0.js +0 -2
- package/bin/vm-hands/managed-runtime-esfmzn6z.js +0 -2
- package/bin/vm-hands/network-contract-9x9kc5vv.js +0 -2
- package/bin/vm-hands/package-78fkast4.js +0 -2
- package/bin/vm-hands/permissions-bvfecyb8.js +0 -2
- package/bin/vm-hands/reason-hands-protocol-2tnghj3b.js +0 -2
- package/bin/vm-hands/serve-service-mr4mkymv.js +0 -2
- package/bin/vm-hands/status-7m9d0yek.js +0 -10
- package/bin/vm-hands/version-4bsjs55h.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-09m2cdkw.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-0xrsph3r.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-1cwqa4jr.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-1rrb66r9.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-1rtkf2xm.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-22kfyvnk.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-6aeea05q.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-6sgfhegd.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-7n60veqy.js +0 -458
- package/bin/vm-hands/vm-hands-entry-lite-88swf2qr.js +0 -6
- package/bin/vm-hands/vm-hands-entry-lite-89z488gz.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-8ns59paz.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-8t9xssf9.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-8vfd0kez.js +0 -250
- package/bin/vm-hands/vm-hands-entry-lite-907pa7f9.js +0 -65
- package/bin/vm-hands/vm-hands-entry-lite-9ay6f56v.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-ab2m9erf.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-b885gwfh.js +0 -7
- package/bin/vm-hands/vm-hands-entry-lite-ckv17tn8.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-dqd4p5kw.js +0 -105
- package/bin/vm-hands/vm-hands-entry-lite-enah5gv4.js +0 -14
- package/bin/vm-hands/vm-hands-entry-lite-eqgj4acy.js +0 -112
- package/bin/vm-hands/vm-hands-entry-lite-f5e3dbgk.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-gvwdy3rf.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-hj8n59y9.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-k278g9kj.js +0 -42
- package/bin/vm-hands/vm-hands-entry-lite-pgb514h0.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-pmcz7j7t.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-q0k6kx6d.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-qk4kexta.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-qy9xg6em.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-qysyf65v.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-sm5nkxpw.js +0 -540
- package/bin/vm-hands/vm-hands-entry-lite-t7n6t3j9.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-vq14wv7h.js +0 -52
- package/bin/vm-hands/vm-hands-entry-lite-vrqzr15t.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-zg36myyf.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-zjn2nsth.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-zybbbegw.js +0 -3
- package/bin/vm-hands/vm-hands-executor-a7aqej5n.js +0 -11
- package/bin/vm-hands/vm-hands-op-runner-k4n3zrqb.js +0 -2
- package/bin/vm-hands/vm-hands-runtime-z6ydmvqc.js +0 -4
- package/bin/vm-hands/worker-sandbox-smqj3mbe.js +0 -2
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{E}from"./vm-hands-entry-lite-pgb514h0.js";import{fe,Re,Kt,Jt,Oe}from"./vm-hands-entry-lite-9ay6f56v.js";import{spawn as y}from"child_process";import{existsSync as p,mkdirSync as T,readFileSync as _,writeFileSync as A}from"fs";import{homedir as m}from"os";import{basename as H,delimiter as g,join as f,win32 as u}from"path";var fr=process.platform==="win32"?Re("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",P=fr.split(g),R=5000,S=65536,O=new Set(["zsh","bash"]),b=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],x=(t,e)=>new Promise((n,r)=>{let o;try{o=y(t,[...e],{...Kt(),stdio:["ignore","pipe","ignore"]}),Jt(o)}catch(c){r(c);return}let i=[],s=0,a=null,L=(c)=>{a??=Error(c);try{if(o.pid!==void 0)Oe(o.pid,"SIGKILL")}catch{}},d=setTimeout(()=>L("login_shell_timeout"),R);o.stdout?.on("data",(c)=>{if(s+=c.length,s>S)L("login_shell_output_too_large");else i.push(c)}),o.once("error",(c)=>{clearTimeout(d),r(c)}),o.once("close",(c)=>{if(clearTimeout(d),a)r(a);else if(c!==0)r(Error("login_shell_exit_nonzero"));else n(Buffer.concat(i).toString("utf8"))})});function w(t){return typeof t==="string"&&t.startsWith("/")&&!t.includes("\x00")&&O.has(H(t))}function h(t){let e=new Set,n=[];for(let r of t){if(e.has(r))continue;e.add(r),n.push(r)}return n}function mr(t,e=process.platform){let n=e==="win32",r=t.split(`
|
|
3
|
-
`).at(-1)??"",o=[];for(let i of r.split(n?";":":")){let s=i.trim();if(n?!u.isAbsolute(s):!s.startsWith("/"))continue;if(s.includes("\x00"))continue;if(E(s))continue;o.push(s)}return h(o)}function ln(t){let e=t?.home??m(),n=t?.directoryExists??p,r=b.map((o)=>f(e,...o)).filter((o)=>{try{return n(o)}catch{return!1}});return h([...r,...process.platform==="win32"?mr(process.env.PATH??process.env.Path??""):[],...P]).join(g)}async function C(t){let e=t?.shell??process.env.SHELL,n=()=>({path:ln({home:t?.home,directoryExists:t?.directoryExists}),source:"fallback"});if(process.platform==="win32"||!w(e))return n();let r;try{r=await(t?.runLoginShell??x)(e,["-lic",'printf %s "$PATH"'])}catch{return n()}if(Buffer.byteLength(r,"utf8")>S)return n();let o=mr(r);if(o.length===0)return n();return{path:h([...o,...P]).join(":"),source:"login_shell"}}function $i(t){let e=null;return()=>(e??=C(t),e)}function l(t){if(t===void 0||t.includes("\x00")||Buffer.byteLength(t,"utf8")>32768)return;return t}function Me(t){let e=t.source??process.env,n={HOME:t.home,PATH:t.path??fr,TMPDIR:t.temporaryDirectory,SHELL:l(e.SHELL)??"/bin/zsh",LANG:l(e.LANG)??"C.UTF-8",LC_ALL:l(e.LC_ALL)??l(e.LANG)??"C.UTF-8"},r=l(e.LC_CTYPE),o=l(e.TERM),i=l(e.COLORTERM);if(r)n.LC_CTYPE=r;if(o)n.TERM=o;if(i)n.COLORTERM=i;if(process.platform==="win32"){for(let s of I){let a=l(e[s]);if(a)n[s]=a}n.TEMP=n.TMP=t.temporaryDirectory,n.SHELL=fe()??n.SHELL,n.PATH=un(n.PATH)}return n}function un(t,e=f(m(),".reason","python3")){let n=(i)=>t.split(u.delimiter).filter((s)=>s&&!/[\\/]WindowsApps[\\/]?$/i.test(s)).map((s)=>u.join(s,i)).find((s)=>p(s)),r=n("python.exe");if(n("python3.exe")||!r)return t;let o=`#!/bin/sh
|
|
4
|
-
exec "${r.replaceAll("\\","/")}" "$@"
|
|
5
|
-
`;try{let i=f(e,"python3");if(!p(i)||_(i,"utf8")!==o)T(e,{recursive:!0}),A(i,o)}catch{return t}return[e,t].join(u.delimiter)}var I=["SystemRoot","SystemDrive","windir","ComSpec","PATHEXT","USERPROFILE","USERNAME","USERDOMAIN","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","CommonProgramFiles","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","OS"];
|
|
6
|
-
export{fr,mr,ln,$i,Me,un};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{de,We,T}from"./vm-hands-entry-lite-8t9xssf9.js";import{execFileSync as p}from"child_process";import{existsSync as s,realpathSync as c}from"fs";import{userInfo as l}from"os";import{isAbsolute as u,join as t,normalize as f,parse as d}from"path";function a(){let r=f(l().homedir);if(!u(r)||r===d(r).root)throw Error("Could not resolve the canonical user home.");return r}function ne(r,n,e=a()){let i=T(n);if(n.kind==="managed"&&n.base){let o=c(e);return{anchor:o,boundary:t(o,n.base),path:t(o,i)}}if(n.kind==="root"&&We(n.path)){let o=c(e);return{anchor:o,boundary:t(o,de),path:t(o,i)}}return{anchor:r,boundary:r,path:t(r,i)}}function qt(r=a()){return t(r,".config")}function uo(){if(process.platform!=="darwin")return null;try{let r=p("/usr/bin/getconf",["DARWIN_USER_DIR"],{encoding:"utf8",timeout:5000}).trim();return u(r)?c(r):null}catch{return null}}function po(r=a()){let n=t(r,"Library","Application Support","Ara"),e=t(r,"Library","Application Support","Reason");return s(n)&&!s(e)?n:e}
|
|
3
|
-
export{a,ne,qt,uo,po};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var ue=".reason/workspace",Ee="workspace_base",J="sessions",xe="workspace_layout",de=".reason/workspace/sessions",zt=/^[0-9a-f]{8}$/;function We(t){if(!Z(t))return!1;let e=".reason/workspace/sessions/";if(!t.startsWith(e))return!1;let n=t.slice(e.length).split("/");return n.length===2&&zt.test(n[0])}var i=4096,S="workspaces/pi";function Z(t){if(typeof t!=="string"||!t||t.length>i)return!1;if(t.startsWith("/")||t.includes("\x00")||t.includes("\\"))return!1;return t.split("/").every((e)=>e!==""&&e!=="."&&e!=="..")}function T(t){if(t.kind==="root"){if(t.path===void 0)return".";if(!Z(t.path))throw Error("invalid_device_workspace_identity");return t.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(t.workspaceId)||t.workspaceId==="."||t.workspaceId==="..")throw Error("invalid_device_workspace_identity");let e=t.layout==="sessions"?"sessions":S;return`${t.base?`${t.base}/`:""}${e}/${t.workspaceId}/repo`}function H(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.kind==="root"&&Object.keys(e).length===1)return{kind:"root"};if(e.kind==="root"&&Object.keys(e).length===2&&Z(e.path))return{kind:"root",path:e.path};if(e.kind!=="managed"||typeof e.workspaceId!=="string"||Object.keys(e).length!==2+(e.base===void 0?0:1)+(e.layout===void 0?0:1)||e.base!==void 0&&e.base!==".reason/workspace"||e.layout!==void 0&&e.layout!=="sessions")return null;let n={kind:"managed",workspaceId:e.workspaceId,...e.base===".reason/workspace"?{base:".reason/workspace"}:{},...e.layout==="sessions"?{layout:"sessions"}:{}};try{return T(n),n}catch{return null}}var c="/home/runner";var Hr="/run/reason/sessions",O=/^(?:\/[A-Za-z0-9._-]+)+$/,qr=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,zr=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function a(t){return qr.exec(t)?.[1]??zr.exec(t)?.[1]??t}var Wt=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/;function _(t,e=c,n="sessions"){if(!O.test(e)||e.split("/").some((s)=>s==="."||s===".."))throw Error("invalid_cloud_payload_home");let r=`${e}/${T({kind:"managed",workspaceId:t,base:".reason/workspace",...n?{layout:n}:{}})}`,o=`${Hr}/${a(t)}`;return{home:e,root:r.slice(0,-5),checkout:r,control:o,jobEnv:`${o}/job.env`,cloudAccess:`${o}/cloud-access`,logs:`${o}/logs`,pin:`${o}/ws`}}function E(t){return Wt.exec(t.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function Wr(t){let e=Wt.exec(t.replace(/\/+$/,""));if(!e)return null;try{let n=_(e[3],e[1],E(t));return n.root===t.replace(/\/+$/,"")?n:null}catch{return null}}
|
|
3
|
-
export{ue,Ee,J,xe,de,zt,We,Z,T,H,Hr,qr,zr,Wt,Wr};
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{v,On,oo,Fr,In,ze,Dn,Nn}from"./vm-hands-entry-lite-eqgj4acy.js";import{Mn}from"./vm-hands-entry-lite-qk4kexta.js";import{kn}from"./vm-hands-entry-lite-f5e3dbgk.js";import{gt}from"./vm-hands-entry-lite-gvwdy3rf.js";import{vr}from"./vm-hands-entry-lite-1rtkf2xm.js";import{j}from"./vm-hands-entry-lite-q0k6kx6d.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as Cs,spawn as Ar}from"child_process";import{randomBytes as Ns}from"crypto";import{chmodSync as vs,existsSync as kr,lstatSync as Ls,mkdirSync as Ms,readFileSync as Qs,rmSync as Us,writeFileSync as at}from"fs";import{connect as Os}from"net";import{join as X}from"path";var St="./desktop-wallpaper-0pjhgyfk.jpg";var _t="./dock-browser-afp005mt.png";var wt="./dock-files-rywdm96b.png";var qt="./dock-terminal-s41cj1jp.png";var Et=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
|
|
3
|
-
# The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
|
|
4
|
-
# python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
|
|
5
|
-
# Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
|
|
6
|
-
import ctypes, sys
|
|
7
|
-
import gi
|
|
8
|
-
gi.require_version("GdkPixbuf", "2.0")
|
|
9
|
-
from gi.repository import GdkPixbuf
|
|
10
|
-
x = ctypes.cdll.LoadLibrary("libX11.so.6")
|
|
11
|
-
x.XOpenDisplay.restype = ctypes.c_void_p
|
|
12
|
-
x.XOpenDisplay.argtypes = [ctypes.c_char_p]
|
|
13
|
-
d = x.XOpenDisplay(None)
|
|
14
|
-
if not d: sys.exit("no display")
|
|
15
|
-
for name, res, args in [
|
|
16
|
-
("XDefaultScreen", ctypes.c_int, [ctypes.c_void_p]),
|
|
17
|
-
("XRootWindow", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_int]),
|
|
18
|
-
("XDisplayWidth", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
19
|
-
("XDisplayHeight", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
20
|
-
("XDefaultDepth", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
21
|
-
("XDefaultVisual", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_int]),
|
|
22
|
-
("XDefaultGC", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_int]),
|
|
23
|
-
("XCreatePixmap", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint]),
|
|
24
|
-
("XCreateImage", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_int, ctypes.c_int]),
|
|
25
|
-
("XPutImage", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_uint, ctypes.c_uint]),
|
|
26
|
-
("XInternAtom", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]),
|
|
27
|
-
("XChangeProperty", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int]),
|
|
28
|
-
("XSetWindowBackgroundPixmap", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong]),
|
|
29
|
-
("XClearWindow", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong]),
|
|
30
|
-
("XSetCloseDownMode", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
31
|
-
("XCloseDisplay", ctypes.c_int, [ctypes.c_void_p]),
|
|
32
|
-
]:
|
|
33
|
-
f = getattr(x, name); f.restype = res; f.argtypes = args
|
|
34
|
-
s = x.XDefaultScreen(d); root = x.XRootWindow(d, s)
|
|
35
|
-
w, h = x.XDisplayWidth(d, s), x.XDisplayHeight(d, s)
|
|
36
|
-
if x.XDefaultDepth(d, s) != 24: sys.exit("unsupported depth")
|
|
37
|
-
# Scale to cover the screen, then crop the centre.
|
|
38
|
-
src = GdkPixbuf.Pixbuf.new_from_file(sys.argv[1])
|
|
39
|
-
k = max(w / src.get_width(), h / src.get_height())
|
|
40
|
-
sw, sh = max(w, round(src.get_width() * k)), max(h, round(src.get_height() * k))
|
|
41
|
-
pb = src.scale_simple(sw, sh, GdkPixbuf.InterpType.BILINEAR).new_subpixbuf((sw - w) // 2, (sh - h) // 2, w, h).copy()
|
|
42
|
-
if pb.get_has_alpha(): pb = pb.composite_color_simple(w, h, GdkPixbuf.InterpType.NEAREST, 255, 1, 0, 0)
|
|
43
|
-
rgb, stride = pb.get_pixels(), pb.get_rowstride()
|
|
44
|
-
bgrx = bytearray(w * h * 4)
|
|
45
|
-
for y in range(h):
|
|
46
|
-
row = rgb[y * stride:y * stride + w * 3]; o = y * w * 4
|
|
47
|
-
bgrx[o:o + w * 4:4] = row[2::3]; bgrx[o + 1:o + w * 4:4] = row[1::3]; bgrx[o + 2:o + w * 4:4] = row[0::3]
|
|
48
|
-
buf = ctypes.create_string_buffer(bytes(bgrx), len(bgrx))
|
|
49
|
-
pix = x.XCreatePixmap(d, root, w, h, 24)
|
|
50
|
-
img = x.XCreateImage(d, x.XDefaultVisual(d, s), 24, 2, 0, buf, w, h, 32, 0) # ZPixmap
|
|
51
|
-
x.XPutImage(d, pix, x.XDefaultGC(d, s), img, 0, 0, 0, 0, w, h)
|
|
52
|
-
ref = ctypes.c_ulong(pix)
|
|
53
|
-
for atom in (b"_XROOTPMAP_ID", b"ESETROOT_PMAP_ID"):
|
|
54
|
-
x.XChangeProperty(d, root, x.XInternAtom(d, atom, 0), 20, 32, 0, ctypes.byref(ref), 1) # XA_PIXMAP, PropModeReplace
|
|
55
|
-
x.XSetWindowBackgroundPixmap(d, root, pix)
|
|
56
|
-
x.XClearWindow(d, root)
|
|
57
|
-
x.XSetCloseDownMode(d, 1) # RetainPermanent: the pixmap outlives this process
|
|
58
|
-
x.XCloseDisplay(d)
|
|
59
|
-
`;var oe=32,Dt=76;function Vr(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
-
<openbox_config xmlns="http://openbox.org/3.4/rc">
|
|
61
|
-
<theme><keepBorder>no</keepBorder></theme>
|
|
62
|
-
<applications>
|
|
63
|
-
<!-- Debian Chromium is "Chromium"; Chrome for Testing is "Chromium-browser". -->
|
|
64
|
-
<application class="Chromium*">
|
|
65
|
-
<decor>no</decor>
|
|
66
|
-
<position force="yes"><x>${oe}</x><y>${oe}</y></position>
|
|
67
|
-
<size><width>${e.width-oe*2}</width><height>${e.height-oe-Dt}</height></size>
|
|
68
|
-
</application>
|
|
69
|
-
</applications>
|
|
70
|
-
</openbox_config>`}var Kr=`# Remote sandbox dock \u2014 launcher icons only, centred, no panel fill
|
|
71
|
-
panel_items = L
|
|
72
|
-
panel_size = 100% 46
|
|
73
|
-
panel_margin = 0 10
|
|
74
|
-
panel_padding = 0 0 10
|
|
75
|
-
panel_position = bottom center horizontal
|
|
76
|
-
panel_shrink = 1
|
|
77
|
-
panel_background_id = 0
|
|
78
|
-
panel_layer = top
|
|
79
|
-
mouse_effects = 1
|
|
80
|
-
mouse_hover_icon_asb = 100 0 12
|
|
81
|
-
mouse_pressed_icon_asb = 100 0 -12
|
|
82
|
-
|
|
83
|
-
launcher_icon_size = 46
|
|
84
|
-
launcher_padding = 0 0 10
|
|
85
|
-
launcher_background_id = 0
|
|
86
|
-
launcher_tooltip = 1
|
|
87
|
-
|
|
88
|
-
launcher_item_app = /tmp/ara-chromium.desktop
|
|
89
|
-
launcher_item_app = /tmp/ara-terminal.desktop
|
|
90
|
-
launcher_item_app = /tmp/ara-files.desktop
|
|
91
|
-
`,Ir=`corner-radius = 12;
|
|
92
|
-
rounded-corners-exclude = [
|
|
93
|
-
"class_g = 'tint2'",
|
|
94
|
-
"window_type = 'dock'",
|
|
95
|
-
"window_type = 'desktop'"
|
|
96
|
-
];
|
|
97
|
-
backend = "xrender";
|
|
98
|
-
shadow = false;
|
|
99
|
-
fading = false;
|
|
100
|
-
vsync = false;
|
|
101
|
-
inactive-opacity = 1.0;
|
|
102
|
-
active-opacity = 1.0;
|
|
103
|
-
`,Zr="/tmp/ara-dock-browser.png",Yr=`[Desktop Entry]
|
|
104
|
-
Name=Chrome
|
|
105
|
-
Exec=chromium --no-sandbox %U
|
|
106
|
-
Icon=${Zr}
|
|
107
|
-
Type=Application
|
|
108
|
-
Categories=Network;WebBrowser;
|
|
109
|
-
`,zr=`[Desktop Entry]
|
|
110
|
-
Name=Terminal
|
|
111
|
-
Exec=bash -c "DISPLAY=:99 xterm -fa DejaVuSansMono -fs 11 -bg black -fg white"
|
|
112
|
-
Icon=/tmp/ara-dock-terminal.png
|
|
113
|
-
Type=Application
|
|
114
|
-
Categories=System;TerminalEmulator;
|
|
115
|
-
`,Hr=`[Desktop Entry]
|
|
116
|
-
Name=Files
|
|
117
|
-
Exec=bash -c "DISPLAY=:99 pcmanfm --no-desktop"
|
|
118
|
-
Icon=/tmp/ara-dock-files.png
|
|
119
|
-
Type=Application
|
|
120
|
-
Categories=System;FileManager;
|
|
121
|
-
`;var Tt={"wallpaper.jpg":St,"dock-browser.png":_t,"dock-terminal.png":qt,"dock-files.png":wt},en=Et,tn='set_wallpaper() { if command -v feh >/dev/null 2>&1; then feh --bg-fill "$1"; else python3 "$2" "$1"; fi; }';function Rt(e){let t=(p)=>p.replaceAll("DISPLAY=:99",`DISPLAY=${e.display}`).replaceAll("/tmp/ara-",`${e.root}/ara-`),n=new Set(e.absent??[]),o=Kr.split(`
|
|
122
|
-
`).filter((p)=>!(n.has("terminal")&&p.endsWith("/ara-terminal.desktop"))&&!(n.has("files")&&p.endsWith("/ara-files.desktop"))).join(`
|
|
123
|
-
`);return{files:{"openbox/rc.xml":Vr(e.screen),"tint2/tint2rc":t(o),"picom/picom.conf":Ir,...n.has("terminal")?{}:{"ara-terminal.desktop":t(zr)},...n.has("files")?{}:{"ara-files.desktop":t(Hr)},"ara-chromium.desktop":t(Yr).replace("chromium --no-sandbox %U",e.browserExec),"ara-set-root-wallpaper.py":en},start:['ticks() { line=$(cat "/proc/$1/stat" 2>/dev/null) || return 1; rest=${line##*) }; case $rest in Z*|X*) return 1;; esac; printf "%s" "$rest" | cut -d " " -f20; }','alive() { [ -f "$ROOT/$1.pid" ] || return 1; read -r pid start <"$ROOT/$1.pid"; current=$(ticks "$pid") || return 1; [ "$current" = "$start" ] && kill -0 "$pid" 2>/dev/null; }','launch() { name=$1; shift; "$@" 9>&- >"$ROOT/$name.log" 2>&1 & pid=$!; start=$(ticks "$pid"); printf "%s %s\\n" "$pid" "$start" >"$ROOT/$name.pid"; }',tn,'[ ! -f "$ROOT/ara-wallpaper.jpg" ] || set_wallpaper "$ROOT/ara-wallpaper.jpg" "$ROOT/ara-set-root-wallpaper.py" || true','if ! alive tint2 && command -v tint2 >/dev/null 2>&1; then launch tint2 tint2 -c "$ROOT/tint2/tint2rc"; fi','if ! alive picom && command -v picom >/dev/null 2>&1; then launch picom picom --config "$ROOT/picom/picom.conf"; fi']}}import{createHash as Ft}from"crypto";import{once as dn}from"events";import{createWriteStream as bn,existsSync as vo,mkdirSync as Lo,mkdtempSync as Mo,readFileSync as ye,readdirSync as Qo,renameSync as Uo,realpathSync as xn,rmSync as yn,statSync as Fe,writeFileSync as Oo}from"fs";import{delimiter as Jo,dirname as $t,join as g}from"path";import{finished as mn}from"stream/promises";var $e="omljlfpmafedpplnpkkahegadhkimdje",Fi="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var U={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"}},J={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var ie={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${U.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${U.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${U.obu.version}/open-browser-use-chrome-extension-${U.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as rn}from"module";import{join as nn}from"path";var sn=30000,on=1048576;function Ue(){return process.env.SystemRoot??"C:\\Windows"}function an(){return nn(Ue(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var pn=String.raw`
|
|
124
|
-
$ErrorActionPreference = "Stop"
|
|
125
|
-
Add-Type -TypeDefinition @"
|
|
126
|
-
using System;
|
|
127
|
-
using System.Runtime.InteropServices;
|
|
128
|
-
public static class ReasonInput {
|
|
129
|
-
[StructLayout(LayoutKind.Sequential)] public struct MOUSEINPUT { public int dx; public int dy; public int mouseData; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
|
|
130
|
-
[StructLayout(LayoutKind.Sequential)] public struct KEYBDINPUT { public ushort wVk; public ushort wScan; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
|
|
131
|
-
[StructLayout(LayoutKind.Explicit)] public struct UNION { [FieldOffset(0)] public MOUSEINPUT mi; [FieldOffset(0)] public KEYBDINPUT ki; }
|
|
132
|
-
[StructLayout(LayoutKind.Sequential)] public struct INPUT { public uint type; public UNION u; }
|
|
133
|
-
[DllImport("user32.dll")] static extern uint SendInput(uint count, INPUT[] inputs, int size);
|
|
134
|
-
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
|
|
135
|
-
[DllImport("user32.dll")] public static extern int GetSystemMetrics(int index);
|
|
136
|
-
[DllImport("user32.dll")] static extern uint MapVirtualKey(uint code, uint type);
|
|
137
|
-
[DllImport("user32.dll")] public static extern uint GetClipboardSequenceNumber();
|
|
138
|
-
static void Send(INPUT input) { SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT))); }
|
|
139
|
-
public static void Mouse(uint flags, int x, int y, int data) {
|
|
140
|
-
INPUT input = new INPUT(); input.type = 0;
|
|
141
|
-
input.u.mi.dx = x; input.u.mi.dy = y; input.u.mi.mouseData = data; input.u.mi.dwFlags = flags; Send(input);
|
|
142
|
-
}
|
|
143
|
-
public static void Key(ushort vk, ushort unit, uint flags) {
|
|
144
|
-
INPUT input = new INPUT(); input.type = 1;
|
|
145
|
-
input.u.ki.wVk = vk; input.u.ki.wScan = vk != 0 ? (ushort)MapVirtualKey(vk, 0) : unit; input.u.ki.dwFlags = flags; Send(input);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
"@
|
|
149
|
-
[void][ReasonInput]::SetProcessDPIAware()
|
|
150
|
-
$width = [ReasonInput]::GetSystemMetrics(0)
|
|
151
|
-
$height = [ReasonInput]::GetSystemMetrics(1)
|
|
152
|
-
$session = [Diagnostics.Process]::GetCurrentProcess().SessionId
|
|
153
|
-
[Console]::Out.WriteLine('{"session":' + $session + ',"width":' + $width + ',"height":' + $height + '}')
|
|
154
|
-
[Console]::Out.Flush()
|
|
155
|
-
$mode = "__MODE__"
|
|
156
|
-
if ($mode -eq "probe") { exit 0 }
|
|
157
|
-
if ($mode -eq "clipboard") {
|
|
158
|
-
# Only changes made during this pairing: never export the initial clipboard.
|
|
159
|
-
$parent = Get-Process -Id __PARENT__
|
|
160
|
-
$last = [ReasonInput]::GetClipboardSequenceNumber()
|
|
161
|
-
while (-not $parent.HasExited) {
|
|
162
|
-
Start-Sleep -Milliseconds 100
|
|
163
|
-
$count = [ReasonInput]::GetClipboardSequenceNumber()
|
|
164
|
-
if ($count -eq $last) { continue }
|
|
165
|
-
$last = $count
|
|
166
|
-
try { $text = Get-Clipboard -Raw } catch { continue }
|
|
167
|
-
if (-not $text) { continue }
|
|
168
|
-
$bytes = [Text.Encoding]::UTF8.GetBytes($text)
|
|
169
|
-
if ($bytes.Length -gt __MAX_TEXT_BYTES__) { continue }
|
|
170
|
-
[Console]::Out.WriteLine("c " + [Convert]::ToBase64String($bytes))
|
|
171
|
-
[Console]::Out.Flush()
|
|
172
|
-
}
|
|
173
|
-
exit 0
|
|
174
|
-
}
|
|
175
|
-
$scaleX = 65535.0 / [Math]::Max(1, $width - 1)
|
|
176
|
-
$scaleY = 65535.0 / [Math]::Max(1, $height - 1)
|
|
177
|
-
while ($null -ne ($line = [Console]::In.ReadLine())) {
|
|
178
|
-
$n = $line.Split(" ")
|
|
179
|
-
try {
|
|
180
|
-
switch ($n[0]) {
|
|
181
|
-
"p" { [ReasonInput]::Mouse(0x8001, [int]([int]$n[1] * $scaleX), [int]([int]$n[2] * $scaleY), 0) }
|
|
182
|
-
"b" { [ReasonInput]::Mouse([uint32]$n[1], 0, 0, [int]$n[2]) }
|
|
183
|
-
"k" { [ReasonInput]::Key([uint16]$n[1], [uint16]$n[2], [uint32]$n[3]) }
|
|
184
|
-
"c" { Set-Clipboard -Value ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($n[1]))) }
|
|
185
|
-
}
|
|
186
|
-
} catch { [Console]::Error.WriteLine("input: $_") }
|
|
187
|
-
}
|
|
188
|
-
`;function Oe(e){let t=pn.replace("__MODE__",e).replace("__PARENT__",String(process.pid)).replace("__MAX_TEXT_BYTES__",String(v));return[an(),["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(t,"utf16le").toString("base64")]]}var cn=["USERPROFILE","LOCALAPPDATA","APPDATA","TEMP","TMP","PSModuleAnalysisCachePath"];function Je(){let e=cn.flatMap((t)=>process.env[t]?[[t,process.env[t]]]:[]);return{...Object.fromEntries(e),SystemRoot:Ue(),windir:Ue()}}function Qt(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=="object")return null;let n=t,o=(s,i)=>typeof s==="number"&&Number.isSafeInteger(s)&&s>=i;return o(n.session,0)&&o(n.width,1)&&o(n.height,1)?{session:n.session,width:n.width,height:n.height}:null}function Ut(){return new Promise((e)=>{let t=Me(...Oe("probe"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0}),n="",o=setTimeout(()=>{t.kill("SIGKILL"),e(null)},sn);t.stdout.setEncoding("utf8").on("data",(s)=>{n+=s}),t.once("error",()=>{clearTimeout(o),e(null)}),t.once("close",()=>{clearTimeout(o),e(Qt(n.split(/\r?\n/)[0]??""))})})}var ae;function Ot(){if(ae!==void 0)return ae;if(process.platform!=="win32")return ae=!1;try{let e=rn(import.meta.url)("bun:ffi"),{symbols:t}=e.dlopen("kernel32.dll",{GetCurrentProcessId:{args:[],returns:e.FFIType.u32},ProcessIdToSessionId:{args:[e.FFIType.u32,e.FFIType.ptr],returns:e.FFIType.i32}}),n=new Uint32Array(1);return ae=t.ProcessIdToSessionId(t.GetCurrentProcessId(),n)!==0&&n[0]>0}catch{return ae=!1}}var kt=[{bit:1,down:2,up:4},{bit:2,down:32,up:64},{bit:4,down:8,up:16}],Xt=2048,Nt=4096,ln=[[8,Xt,120],[16,Xt,-120],[32,Nt,-120],[64,Nt,120]],vt=1,Le=2,un=4,fn=new Set([65505,65506]),Lt=new Set([65507,65508,65511,65512,65513,65514,65027,65515,65516]),Mt=new Map([[65505,[160,!1]],[65506,[161,!1]],[65507,[162,!1]],[65508,[163,!0]],[65511,[164,!1]],[65512,[165,!0]],[65513,[164,!1]],[65514,[165,!0]],[65027,[165,!0]],[65515,[91,!0]],[65516,[92,!0]],[65288,[8,!1]],[65289,[9,!1]],[65056,[9,!1]],[65293,[13,!1]],[65307,[27,!1]],[65535,[46,!0]],[65379,[45,!0]],[65360,[36,!0]],[65367,[35,!0]],[65365,[33,!0]],[65366,[34,!0]],[65361,[37,!0]],[65362,[38,!0]],[65363,[39,!0]],[65364,[40,!0]],[65383,[93,!0]],[65509,[20,!1]],[65299,[19,!1]],[65300,[145,!1]],[65377,[44,!0]],[65407,[144,!0]],[32,[32,!1]],[65421,[13,!0]],[65408,[32,!1]],[65450,[106,!1]],[65451,[107,!1]],[65452,[108,!1]],[65453,[109,!1]],[65454,[110,!1]],[65455,[111,!0]],[65429,[36,!1]],[65430,[37,!1]],[65431,[38,!1]],[65432,[39,!1]],[65433,[40,!1]],[65434,[33,!1]],[65435,[34,!1]],[65436,[35,!1]],[65438,[45,!1]],[65439,[46,!1]],...Array.from({length:10},(e,t)=>[65456+t,[96+t,!1]]),...Array.from({length:24},(e,t)=>[65470+t,[112+t,!1]])]);class Bt{x=-1;y=-1;mask=0;held=new Set;pressed=new Set;pointer(e,t,n){let o=[];if(e!==this.x||t!==this.y)this.x=e,this.y=t,o.push(`p ${e} ${t}`);for(let s of kt){let i=(this.mask&s.bit)!==0,p=(n&s.bit)!==0;if(i!==p)o.push(`b ${p?s.down:s.up} 0`)}for(let[s,i,p]of ln)if(!(this.mask&s)&&n&s)o.push(`b ${i} ${p}`);return this.mask=n,o}key(e,t){let n=e?0:Le;if(fn.has(t)||Lt.has(t))if(e)this.held.add(t);else this.held.delete(t);let o=Mt.get(t);if(o)return[`k ${o[0]} 0 ${n|(o[1]?vt:0)}`];let s=t<256?t:(t&4278190080)===16777216?t&16777215:0,i=String.fromCharCode(s),p=[...this.held].some((h)=>Lt.has(h)),l=/^[A-Za-z0-9]$/.test(i)?i.toUpperCase().charCodeAt(0):0;if(l&&(e?p:this.pressed.has(l))){if(e)this.pressed.add(l);else this.pressed.delete(l);return[`k ${l} 0 ${n}`]}if(s<33||s>=127&&s<160||s>65535||s>=55296&&s<57344)return[];return[`k 0 ${s} ${n|un}`]}release(){let e=kt.filter((t)=>this.mask&t.bit).map((t)=>`b ${t.up} 0`);for(let t of this.pressed)e.push(`k ${t} 0 ${Le}`);for(let t of this.held){let[n,o]=Mt.get(t);e.push(`k ${n} 0 ${Le|(o?vt:0)}`)}return this.mask=0,this.pressed.clear(),this.held.clear(),e}}function Jt(e){let t=Me(...Oe("input"),{env:Je(),stdio:["pipe","pipe","ignore"],windowsHide:!0}),n=new Bt,o="",s=!1,i=null,p=()=>{if(i?.kill("SIGKILL"),t.exitCode!==null||t.signalCode!==null)return;t.stdin.end(n.release().map((u)=>`${u}
|
|
189
|
-
`).join("")),setTimeout(()=>t.kill("SIGKILL"),2000).unref()},l=(u)=>{if(s)return;s=!0,p(),e.end(u)},h=(u)=>l({error:new r("display_unavailable",u)}),f=(u)=>{if(s||u.length===0)return;if(t.stdin.write(u.map((S)=>`${S}
|
|
190
|
-
`).join("")),t.stdin.writableLength>on)l({reason:"input_backpressure"})},x=()=>{i=Me(...Oe("clipboard"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let u="";i.stdout?.on("data",(S)=>{if(s)return;u+=S.toString("ascii");for(let y=u.indexOf(`
|
|
191
|
-
`);y>=0;y=u.indexOf(`
|
|
192
|
-
`)){let A=u.slice(0,y).replace(/\r$/,"");if(u=u.slice(y+1),!A.startsWith("c "))continue;let q=A.slice(2);if(q.length>Math.ceil(v/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(q)){l({reason:"display_protocol"});return}let c=Buffer.from(q,"base64");if(c.byteLength<=v)e.clipboard(c.toString("utf8"));if(s)return}if(u.length>Math.ceil(v/3)*4+4)l({reason:"display_protocol"})}),i.once("error",()=>h("Reason could not watch this computer's desktop clipboard.")),i.once("exit",()=>{if(!s)h("Reason could not watch this computer's desktop clipboard.")})};return t.stdout.on("data",(u)=>{if(s||o===null)return;o+=u.toString("utf8");let S=o.indexOf(`
|
|
193
|
-
`);if(S<0){if(o.length>4096)l({reason:"display_protocol"});return}let y=Qt(o.slice(0,S).trim());if(o=null,!y)l({reason:"display_protocol"});else if(y.session===0)h("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else x(),e.ready({width:y.width,height:y.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>h("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)h("Reason could not start this computer's desktop input.");else l({reason:"display_closed"})}),{pointer:(u,S,y)=>f(n.pointer(u,S,y)),key:(u,S)=>f(n.key(u,S)),clipboard:(u)=>f([`c ${Buffer.from(u,"utf8").toString("base64")}`]),close(){s=!0,p()}}}var hn=["none","standard","all"],xe="22.23.3",gn={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},je={"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"}},Gt="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Vt="chrome-win64/chrome.exe",Y={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Sn={version:Y.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},We={version:Y.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${Y.version}/ffmpeg-${Y.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},jt=`ffmpeg-${We.version}-essentials_build/bin`,G="com.ifuryst.open_browser_use.extension",Kt="com.reasonmachines.browser_use.extension",Ct="/tmp/reason-browser-use",Ge=["tint2","picom","xterm","pcmanfm"],It=["fonts-droid-fallback"],Zt=["pulseaudio"],_n=["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",...It,"galculator","chromium","ffmpeg","tmux",...Zt,...Ge],wn=new Set([...Ge,...It,...Zt]),Wt=_n.filter((e)=>e!=="chromium"&&!wn.has(e)),Pn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],be="/usr/bin/chromium",qn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function En(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 z(e){return e==="win32-x64"||e==="win32-arm64"}function Ve(e){return z(e)?`node-v${xe}-${e.replace("win32","win")}`:`node-v${xe}-${e}`}function me(e){return{node:{version:xe,url:`https://nodejs.org/dist/v${xe}/${Ve(e)}${z(e)?".zip":".tar.gz"}`,sha256:gn[e]},open_computer_use:{version:U.ocu.version,url:ie.ocu.url,sha256:ie.ocu.sha256},open_browser_use:{version:U.obu.version,url:ie.obu.url,sha256:ie.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:J.macArm64Sha256}}:z(e)?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/win64/chrome-win64.zip`,sha256:J.win64Sha256}}:{}}}function Tn(e){let t={extension:F};for(let[n,o]of Object.entries(me(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Yt(e){return g(e,".local","share","reason","desktop")}function yr(e,t=kn()){let n=Yt(t),o=(u)=>g(n,u,me(e)[u]?.version??""),s=o("open_computer_use"),i=o("open_browser_use"),p=e==="darwin-arm64",l=z(e),h=g(t,"Library","Application Support"),f=g(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:g(t,"AppData","Local"),"OpenBrowserUse"),x=p?g(h,"Google","Chrome","NativeMessagingHosts",`${G}.json`):l?g(f,"NativeMessagingHosts",`${G}.json`):g(t,".config","google-chrome","NativeMessagingHosts",`${G}.json`);return{root:n,automation:g($t(n),"automation"),receipt:g(n,"receipt.json"),minimal:$n(t),node:l?g(o("node"),Ve(e),"node.exe"):g(o("node"),"bin","node"),ocuDir:s,ocu:g(s,je[e].ocu),ocuApp:p?g(s,"dist","Open Computer Use.app"):null,obuDir:i,obu:g(i,"cli","open-browser-use.js"),nativeHost:g(i,je[e].obu),extensionDir:p?g(h,"OpenBrowserUse","chrome-extension","release"):l?g(f,"chrome-extension","release"):g(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:x,nativeHostManifests:p?[x,g(h,"Google","ChromeForTesting","NativeMessagingHosts",`${G}.json`)]:l?[x]:[g(t,".config","chromium","NativeMessagingHosts",`${G}.json`),g(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${G}.json`)],browser:p?g(o("chrome_for_testing"),Gt):l?g(o("chrome_for_testing"),Vt):be,userChromeHost:p?g(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:p?g(h,"Google","Chrome","NativeMessagingHosts",`${Kt}.json`):null,ffmpegDir:g(n,"ffmpeg"),ffmpeg:p?g(n,"ffmpeg",Y.version,"ffmpeg"):l?g(n,"ffmpeg",We.version,jt,"ffmpeg.exe"):null,ffprobe:p?g(n,"ffprobe",Sn.version,"ffprobe"):l?g(n,"ffmpeg",We.version,jt,"ffprobe.exe"):null}}function Rn(e){try{let t=JSON.parse(ye(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")||!hn.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 O(e){try{return Fe(e).isFile()}catch{return!1}}function zt(e){try{let t=Fe(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function An(e){try{return ye(e,"utf8")}catch{return null}}function W(e){for(let t of qn){let n=g(t,e);try{let o=Fe(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Xn(e){try{let t=JSON.parse(ye(g(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function Cn(e,t,n){let o=me(n)[e];if(!o)return!1;let s=z(n);if(e==="node")return O(s?g(t,Ve(n),"node.exe"):g(t,"bin","node"));if(e==="chrome_for_testing")return O(g(t,s?Vt:Gt));let i=je[n][e==="open_computer_use"?"ocu":"obu"];return Xn(t)===o.version&&O(g(t,i))&&(e==="open_computer_use"||O(g(t,"cli","open-browser-use.js")))}function vn(e){return Ft("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function Ke(e){try{let t=JSON.parse(ye(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Ln(e){let t=Ke(g(e.extensionDir,"manifest.json"));return t!==null&&t.version===U.obu.version&&typeof t.key==="string"&&vn(t.key)===F}function Qn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===G&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${F}/`&&(t===void 0||e.path===t)}function Un(e){return Ln(e)&&O(e.nativeHost)&&e.nativeHostManifests.every((t)=>Qn(Ke(t),e.nativeHost))}function Bn(e){return`#!/bin/sh
|
|
194
|
-
# Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
|
|
195
|
-
obu=${`'${e.replaceAll("'","'\\''")}'`}
|
|
196
|
-
case "$1" in
|
|
197
|
-
chrome-extension://*) exec "$obu" host --socket-dir ${Ct} ;;
|
|
198
|
-
mcp) shift; exec "$obu" mcp --socket-dir ${Ct} "$@" ;;
|
|
199
|
-
esac
|
|
200
|
-
exec "$obu" "$@"
|
|
201
|
-
`}function Jn(e){let t=Ke(e),n=t?.allowed_origins;return t!==null&&t.name===Kt&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${$e}/`)&&typeof t.path==="string"&&zt(t.path)}function jn(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||An(e.userChromeHost)!==Bn(e.nativeHost)||!zt(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return Jn(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var Wn={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 P(e={}){let t=e.platform===void 0?En():e.platform;if(!t)return null;let n=yr(t,e.home),o=Rn(n.receipt),s=Tn(t),i=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(s).sort()),p=[],l=me(t);for(let c of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=l[c];if(!_)continue;let E=Cn(c,g(n.root,c,_.version),t),D=o?.pins[c],N=E&&D===s[c]?"ready":D!==void 0&&D!==s[c]?"outdated":"missing";p.push({name:c,state:N,detail:_.version})}let h=o?.pins.extension===F&&Un(n);p.push({name:"browser_extension",state:h?"ready":"missing",detail:F});let f=W("Xvfb"),x=W("x11vnc"),u=W("openbox");if(z(t))p.push(Ot()?{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"}),p.push(n.ffmpeg&&O(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"){p.push(O(be)?{name:"browser",state:"ready",detail:be}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${be}`});let c=f!==null&&x!==null&&u!==null;p.push({name:"display",state:c?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=Pn.filter((k)=>W(k)===null),E=(o?.missing_system_packages??Wt).filter((k)=>Wt.includes(k)),D=_.length===0&&E.length===0;p.push(D?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...E,..._])].join(" ")});let N=Ge.filter((k)=>W(k)===null);p.push(N.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:N.join(" ")})}let S=n.ffmpeg&&O(n.ffmpeg)?n.ffmpeg:W("ffmpeg"),y=!S?null:S===n.ffmpeg?n.ffprobe:g($t(xn(S)),"ffprobe"),A=i&&p.every((c)=>c.state==="ready"),q=(c)=>i&&p.every((_)=>!Wn[c].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:A,features:{display:q("display"),computer:q("computer"),browser:q("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:S,ffprobe:y&&O(y)?y:null,userChrome:jn(n,i&&["node","open_browser_use"].every((c)=>p.find((_)=>_.name===c)?.state==="ready")),pulseaudio:W("pulseaudio"),xvfb:f,x11vnc:x,openbox:u,components:p}}function Ht(e){return Fn(e)?Mn():[]}function Fn(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===g(e.root,"ffmpeg",Y.version,"ffmpeg")}async function Ui(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=Ft("sha256"),p=bn(n,{mode:384});try{let h=s.body.getReader();for(let f=await h.read();!f.done;f=await h.read())if(i.update(f.value),!p.write(f.value))await dn(p,"drain")}finally{p.end(),await mn(p)}let l=i.digest("hex");if(l!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${l}`)}catch(s){throw yn(n,{force:!0}),s}}function $n(e){return g(Yt(e),"minimal.json")}import{execFile as os,spawn as rt}from"child_process";import{existsSync as is}from"fs";import{connect as as}from"net";function Gn(){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 er=Gn();import{spawn as Vn}from"child_process";import{existsSync as Kn}from"fs";import{connect as Zn}from"net";import{join as he}from"path";var rr="reason_desktop",pe={sampleRate:48000,channels:2,codec:"opus"},Yn=5000,zn=107,Hn=262144,Ye=(e)=>he(e,"native"),Qe=(e)=>`unix:${e}`;function Ie(e,t=1000){if(!Kn(e))return Promise.resolve(!1);return new Promise((n)=>{let o=Zn({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 nr(e,t){if(!t)return null;let n=Ye(e);if(Buffer.byteLength(n)>zn||/["'\\\s]/.test(n))return null;try{if(await Ie(n))return n;let o=Vn(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:${he(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${rr} rate=${pe.sampleRate} channels=${pe.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:he(e,"runtime"),PULSE_STATE_PATH:he(e,"state")}}),s=!1;o.once("error",()=>{s=!0}),o.once("exit",()=>{s=!0}),o.unref();let i=Date.now()+Yn;while(Date.now()<i){if(await Ie(n))return n;if(s)return await Ie(n)?n:null;await new Promise((p)=>setTimeout(p,50))}if(!s)o.kill("SIGKILL");return null}catch{return null}}function sr(){let{sampleRate:e,channels:t}=pe;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",`${rr}.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 es=[79,103,103,83],ts=Buffer.from("OpusHead"),rs=Buffer.from("OpusTags"),tr=(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 He{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(es.some((S,y)=>t[o+y]!==S)||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 p=t.subarray(o+27,o+27+i),l=p.reduce((S,y)=>S+y,0),h=27+i+l;if(t.byteLength-o<h)break;if(!s&&this.partialBytes>0)this.resetPartial();let f=s&&this.partialBytes===0,x=o+27+i,u=x;for(let S of p){if(x+=S,S===255)continue;if(this.appendPartial(t.subarray(u,x),f),u=x,!f){let y=this.takePartial();if(y.byteLength>0&&!tr(y,ts)&&!tr(y,rs))n.push(y)}f=!1,this.resetPartial()}if(u<x)this.appendPartial(t.subarray(u,x),f);o+=h}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>Hn)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 ns}from"child_process";var or=1048576,ss=String.raw`
|
|
202
|
-
import gi, json, os, sys
|
|
203
|
-
gi.require_version("Gtk", "3.0")
|
|
204
|
-
from gi.repository import Gtk, Gdk, GLib
|
|
205
|
-
if not Gtk.init_check()[0]:
|
|
206
|
-
sys.exit(1)
|
|
207
|
-
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
|
208
|
-
pending = b""
|
|
209
|
-
generation = 0
|
|
210
|
-
def send(value):
|
|
211
|
-
print(json.dumps(value, ensure_ascii=True), flush=True)
|
|
212
|
-
def changed(clipboard, event):
|
|
213
|
-
global generation
|
|
214
|
-
generation += 1
|
|
215
|
-
current = generation
|
|
216
|
-
def received(clipboard, text, unused):
|
|
217
|
-
if current == generation and text is not None and len(text.encode("utf-8")) <= ${v}:
|
|
218
|
-
send({"text": text})
|
|
219
|
-
clipboard.request_text(received, None)
|
|
220
|
-
# No request_text on startup: never share the pre-existing clipboard.
|
|
221
|
-
clipboard.connect("owner-change", changed)
|
|
222
|
-
def input_ready(fd, condition):
|
|
223
|
-
global pending
|
|
224
|
-
chunk = os.read(fd, 65536)
|
|
225
|
-
if not chunk:
|
|
226
|
-
Gtk.main_quit()
|
|
227
|
-
return False
|
|
228
|
-
pending += chunk
|
|
229
|
-
while b"\n" in pending:
|
|
230
|
-
line, pending = pending.split(b"\n", 1)
|
|
231
|
-
text = json.loads(line)
|
|
232
|
-
if not isinstance(text, str) or len(text.encode("utf-8")) > ${v} or "\x00" in text:
|
|
233
|
-
sys.exit(1)
|
|
234
|
-
clipboard.set_text(text, -1)
|
|
235
|
-
send("ack")
|
|
236
|
-
if len(pending) > ${v*6+2}:
|
|
237
|
-
sys.exit(1)
|
|
238
|
-
return True
|
|
239
|
-
GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
|
|
240
|
-
send("ready")
|
|
241
|
-
Gtk.main()
|
|
242
|
-
`;function ir(e,t){let n=ns("/usr/bin/python3",["-I","-u","-c",ss],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),o=!1,s=!0,i="",p=0,l=[],h=setTimeout(()=>x(),5000),f=()=>{o=!0,clearTimeout(h),l.length=0,n.kill("SIGKILL")},x=()=>{if(o)return;f(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},u=(S,y=32)=>{if(o)return;if(!s){S();return}if(p+=y,p>or)f(),t.end({reason:"input_backpressure"});else l.push({apply:S,bytes:y})};return n.stdout.on("data",(S)=>{if(o)return;i+=S.toString("ascii");for(let y=i.indexOf(`
|
|
243
|
-
`);y>=0;y=i.indexOf(`
|
|
244
|
-
`)){let A=i.slice(0,y);i=i.slice(y+1);let q;try{q=JSON.parse(A)}catch{x();return}if(q==="ready"||q==="ack"){clearTimeout(h),s=!1;while(!s&&!o&&l.length){let c=l.shift();p-=c.bytes,c.apply()}}else if(q&&typeof q==="object"&&"text"in q&&typeof q.text==="string"&&Buffer.byteLength(q.text)<=v)t.clipboard(q.text);else{x();return}if(o)return}if(i.length>v*6+32)x()}),n.stdin.on("error",x),n.once("error",x),n.once("exit",x),{apply:u,write(S){if(Buffer.byteLength(S)>v||S.includes("\x00")){x();return}let y=`${JSON.stringify(S)}
|
|
245
|
-
`;u(()=>{if(s=!0,h=setTimeout(()=>x(),5000),n.stdin.write(y),n.stdin.writableLength>or)f(),t.end({reason:"input_backpressure"})},Buffer.byteLength(y))},close:f}}var H={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}},ps="avc1.4D002A",ar={width:1920,height:1080},cs=262144,ls=0.2,fs=250,ds=1e4,bs=1024,et=1e4,xs=500,ys=60,ms=1e4,hs=1000,pr=1048576,hr={kind:"mac_screen",sound:null},gr={kind:"windows_screen",sound:null},gs,cr=()=>gs??=P()?.ffmpeg??null,Se=(e,t,n)=>rt(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Ss,nt=()=>Ss??=Ht(P()),lr=(e,t,n)=>{let[o,...s]=[...nt(),e];return Se(o,[...s,...t],n)},ur=()=>Dr?.videotoolbox?"h264_videotoolbox":"libx264",_s=()=>Math.round(performance.now()*1000),tt=new Set,fr=!1;function Sr(e){if(tt.add(e),e.once("exit",()=>tt.delete(e)),fr)return;fr=!0,process.once("exit",()=>{for(let t of tt)try{t.kill("SIGKILL")}catch{}})}function _r(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{}},xs);e.once("exit",()=>clearTimeout(t))}function ws(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 Ps(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function qs(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 Es(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var wr=1700000;function Pr(e){return Math.min(1,Math.round(Math.sqrt(wr/(e.width*e.height))*100)/100)}function Ds(e,t,n){let o=rt(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,Pr(n.size)))],{stdio:["ignore","pipe","ignore"]}),s=rt(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 dr(e){let t=Math.min(1,ar.width/e.width,ar.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function ge(e,t,n,o="libx264"){let s=H[e],i=(u)=>Math.max(2,Math.floor(u/2)*2),p={width:i(n.width*s.scale),height:i(n.height*s.scale)},l=p.width!==t.size?.width||p.height!==t.size.height,h=Math.max(1,Math.round(s.kbps*2/s.fps)),f=["-g",String(s.fps*ys)],x=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",...f,"-b:v",`${s.kbps}k`,"-maxrate",`${s.kbps}k`,"-bufsize",`${h}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",...f,"-crf",String(s.crf),"-maxrate",`${s.kbps}k`,"-bufsize",`${h}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...l?["-vf",`scale=${p.width}:${p.height}:flags=fast_bilinear`]:[],...x,"-flush_packets","1","-f","h264","pipe:1"]}class qr{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,p=s>0&&this.buffer[s-1]===0?s-1:s;if(i===9&&p>0)o.push({data:this.buffer.slice(0,p),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(p),this.key=!1,this.micros=t,s-=p;if(i===5)this.key=!0;s+=3}return this.scanned=s,o}}function Ts(e,t){let n=as({path:e}),o=Buffer.alloc(0),s="version",i=0,p=!1,l=[],h=0,f=!1,x=(c)=>{if(f)return;f=!0,n.destroy(),t.end(c)},u=()=>x({reason:"display_protocol"}),S=(c)=>{if(f)return;if(!p){if(h+=c.byteLength,h>pr)x({reason:"input_backpressure"});else l.push(c);return}if(n.write(c),n.writableLength>pr)x({reason:"input_backpressure"})},y=(c)=>{o=o.subarray(c)},A=()=>{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 u(),!1;return y(12),n.write(`RFB 003.007
|
|
246
|
-
`),s="security",!0}case"security":{if(o.byteLength<1)return!1;let c=o[0];if(c===0)return u(),!1;if(o.byteLength<1+c)return!1;if(!o.subarray(1,1+c).includes(1))return u(),!1;return y(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 u(),!1;if(o.byteLength<24+c)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(y(24+c),_.width===0||_.height===0)return u(),!1;s="messages",p=!0;for(let E of l)n.write(E);return l=[],h=0,t.ready(_),!f}case"skip":{let c=Math.min(i,o.byteLength);if(y(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 y(c),!0}case 2:return y(1),!0;case 3:{if(o.byteLength<8)return!1;let c=o.readUInt32BE(4);if(c>v/2)return y(8),s="skip",i=c,!0;if(o.byteLength<8+c)return!1;let _=o.subarray(8,8+c).toString("latin1");return y(8+c),t.clipboard(_),!f}default:return u(),!1}}}},q=!1;return n.once("connect",()=>{q=!0}),n.on("data",(c)=>{if(f)return;o=o.byteLength?Buffer.concat([o,c]):c;while(!f&&A());}),n.once("error",()=>{if(!q)x({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>x({reason:"display_closed"})),{pointer(c,_,E){let D=Buffer.alloc(6);D.writeUInt8(5,0),D.writeUInt8(E&255,1),D.writeUInt16BE(c,2),D.writeUInt16BE(_,4),S(D)},key(c,_){let E=Buffer.alloc(8);E.writeUInt8(4,0),E.writeUInt8(c?1:0,1),E.writeUInt32BE(_>>>0,4),S(E)},clipboard(c){if(Array.from(c).some((D)=>D.codePointAt(0)>255)){x({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(c,"latin1"),E=Buffer.alloc(8);E.writeUInt8(6,0),E.writeUInt32BE(_.byteLength,4),S(Buffer.concat([E,_]))},close(){f=!0,n.destroy()}}}class st{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}Sr(s);let i={child:s,splitter:new qr};this.run=i;for(let l of[...this.viewers])l.started(t);s.stdout?.on("data",(l)=>{if(this.run!==i)return;for(let h of i.splitter.push(l,o()))for(let f of[...this.viewers])f.unit(h)});let p=()=>{if(this.run!==i)return;this.run=null,this.fail()};s.once("exit",p),s.once("error",p)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;_r(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var br=new WeakMap;function Rs(e){let t=br.get(e);if(!t)br.set(e,t=new st);return t}function Er(e,t,n={}){let o=n.micros??_s,s=new In,i=t.request.preset,p=null,l=null,h=null,f=!1,x=null,u=!1,S=!1,y=null,A=0,q=0,c=!1,_=null,E=null,D=0,N=null,k=[],te=0,w=[],M=new Uint32Array(et+1),B=0,Pe=null,qe=0,re=0,Ee=0,lt=0,ut=0,ce=null,De=0,K={frames:0,bytes:0,since:o()},I=[],ne=0,Te,Re=!1,Nr=o(),C={},Z=()=>Math.round((o()-Nr)/1000),ft=n.control??er,Ae=null,ke=null,L=(b)=>{let d=Fr(b);return e.send(d),lt+=d.byteLength,d.byteLength},le=(b)=>{if(e.done)return;if(e.open)L({type:"error",code:b});e.end({reason:b})},ue=()=>Math.max(cs,H[i].kbps*1000/8*ls),fe=()=>o()/1000,Lr=()=>{while(w.length>1&&w[0].atMs<fe()-ds)w.shift();return w[0]?.rttMs??null},dt=(b)=>{let d=Lr();if(d===null||k.length===0)return!1;let m=(d+fs)*b;return fe()-k[0].sentMs>m||te>m/1000*H[i].kbps*1000/8},Mr=(b)=>{if(D===0)return;let d=Math.min(b,D-1);if(N!==null&&d<=N)return;N=d;let m=fe();while(k.length&&k[0].seq<=d){let T=k.shift();if(te-=T.bytes,T.seq!==d)continue;let R=Math.max(0,m-T.sentMs);while(w.length&&w.at(-1).rttMs>=R)w.pop();w.push({atMs:m,rttMs:R}),M[Math.min(et,Math.round(R))]++,B++,Pe=Math.min(Pe??R,R)}},Qr=()=>{let b=0;for(let d=0;d<=et;d++)if(b+=M[d],b*2>=B)return d;return 0},Ur=()=>e.bufferedAmount<=ue()/2&&!dt(0.5),bt=()=>{Re=!0,I=[],ne=0,x?.leave(Xe),x=null},xt=(b)=>{if(e.done)return;if(b.key)C.first_key_ms??=Z();if(!f){if(!x||I.length===0&&!b.key)return;if(I.push(b),ne+=b.data.byteLength,ne>ue())bt();return}if(c){re++;return}if(e.bufferedAmount>ue()||dt(1)){c=!0,re++,_=setInterval(()=>{if(e.done||!Ur())return;if(_)clearInterval(_);_=null,c=!1,Ne()},n.drainPollMs??25);return}if(!u){if(!b.key){re++;return}if(L({type:"hello",width:l.width,height:l.height,fps:H[i].fps,preset:i,codec:ps}),u=!0,C.first_frame_ms??=Z(),!S&&p?.sound)L({type:"audioHello",...pe}),S=!0}let d=L({type:"frame",key:b.key,seq:D,captureMicros:b.micros,data:b.data});if(k.push({seq:D,sentMs:fe(),bytes:d}),te+=d,k.length>bs)te-=k.shift().bytes;D++,qe++,ce??=b.micros,De=b.micros,K.frames++,K.bytes+=d},Xe={started(b){i=b,u=!1,I=[],ne=0},unit:xt,failed:()=>le("encoder_failed")},Ce=()=>{let b=(n.ffmpeg??cr)();if(!p||!l){le("encoder_failed");return}let[d,m]=[p,l],T="kind"in d&&d.kind==="simulator"?d.stream:null;if(!b&&!T){le("encoder_failed");return}if(x??="kind"in d&&d.kind==="mac_screen"?Rs(n.spawn??lr):new st,C.encoder_ms===void 0)C.encoder_ms=Z(),C.encoder_shared=x.running;x.start(Xe,i,()=>{let R=H[i].fps;if(T)return T(R,H[i].kbps,wr);if("kind"in d&&d.kind==="simulator"){let Q=Math.min(0.99,Pr(d.size)),se={width:d.size.width*Q,height:d.size.height*Q};return Ds(b,ge(i,Es(Math.min(R,30)),se,(n.macEncoder??ur)()),d)}if("kind"in d&&d.kind==="windows_screen")return(n.spawn??Se)(b,ge(i,qs(R,m),dr(m)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in d?(n.spawn??lr)(b,ge(i,Ps(R),dr(m),(n.macEncoder??ur)()),{}):(n.spawn??Se)(b,ge(i,ws(R,m,d.display),m),{DISPLAY:d.display,XAUTHORITY:d.xauthority})},o)},de=()=>{if(!y)return;_r(y.child),y=null},Or=()=>{let b=(n.ffmpeg??cr)();if(y||e.done||!S||!p?.sound||!b)return;let d;try{d=(n.spawn??Se)(b,sr(),{PULSE_SERVER:Qe(p.sound)})}catch{return}Sr(d);let m={child:d,reader:new He};y=m,d.stdout?.on("data",(R)=>{if(y!==m||e.done)return;let Q;try{Q=m.reader.push(R)}catch{de();return}let se=o();for(let Br of Q){if(e.bufferedAmount>ue()){q++;continue}L({type:"audio",captureMicros:se,data:Br}),A++}});let T=()=>{if(y===m)de()};d.once("exit",T),d.once("error",T)},Ne=()=>{if(!x||e.done)return;Ee++,Ce()},yt=()=>{if(e.done||!l)return;if(!f){if(x||Re)return;Ce(),Te=setTimeout(()=>{if(!f)bt()},ms);return}if(clearTimeout(Te),C.encoder_early===void 0){if(C.encoder_early=x!==null,Re)C.hold_lapsed=!0}if(!x)Ce();let b=I;I=[],ne=0;for(let d of b)xt(d);E??=setInterval(()=>{let d=o(),m=Math.max(0.001,(d-K.since)/1e6);L({type:"stats",stats:{fps:Math.round(K.frames/m*10)/10,kbps:Math.round(K.bytes*8/1000/m),dropped:re,restarts:Ee,queued_bytes:e.bufferedAmount}}),K={frames:0,bytes:0,since:d}},hs)};t.desktop.then((b)=>{if(e.done)return;p=b;let d={ready(m){l=m,C.desktop_ms??=Z(),yt()},clipboard(m){if(e.open&&Buffer.byteLength(m)<=v)L({type:"serverClipboard",text:m})},end(m){if("reason"in m&&e.open)L({type:"error",code:m.reason});e.end(m)}};if("kind"in b&&b.kind==="simulator")h=b.input,d.ready(b.points);else if("kind"in b&&b.kind==="windows_screen")h=(n.windowsInput??Jt)(d);else if("kind"in b)h=(n.macInput??((m)=>Nn(m,nt())))(d);else{let m=(n.linuxClipboard??ir)(b,d),T=Ts(b.rfbSocket,{...d,clipboard:(R)=>{if(!m)d.clipboard(R)}});h=m?{pointer:(R,Q,se)=>m.apply(()=>T.pointer(R,Q,se)),key:(R,Q)=>m.apply(()=>T.key(R,Q)),clipboard:(R)=>m.write(R),close(){m.close(),T.close()}}:T}mt()},(b)=>e.end({error:b}));function mt(){if(ke||!t.viewerSameNetwork||!f||e.done||!p||!("kind"in p)||p.kind!=="mac_screen")return;ke=(n.macWindows??Dn)((b)=>{if(e.open)L({type:"windows",bounds:b})})}let ht={viewer:t.viewer??null,notify(b){if(e.open)L({type:"control",control:b})}},ve=(b)=>{if(!h)return;if(!p||!("kind"in p)||p.kind!=="simulator")ft.claim(ht);b(h)};return{opened(){C.relay_ms??=Z()},received(b){ut+=b.byteLength;let d;try{d=s.push(b)}catch{le("viewer_protocol");return}for(let m of d){if(e.done)return;switch(m.type){case"ping":L({type:"pong",token:m.token});break;case"pointer":ve((T)=>T.pointer(m.x,m.y,m.buttons));break;case"key":ve((T)=>T.key(m.down,m.keysym));break;case"clientClipboard":ve((T)=>T.clipboard(m.text));break;case"config":if(m.preset!==i)i=m.preset,Ne();break;case"keyframeRequest":if(u&&!c)Ne();break;case"ack":Mr(m.seq);break;case"audioEnable":if(m.on)Or();else de();break;default:break}}if(!f&&!e.done){if(f=!0,C.viewer_ms=Z(),t.viewer)Ae=ft.join(ht);yt(),mt()}},close(){if(Ae?.(),Ae=null,ke?.close(),_)clearInterval(_);if(E)clearInterval(E);clearTimeout(Te),x?.leave(Xe),de(),h?.close()},summary:()=>({output_bytes:lt,input_bytes:ut,video:{preset:i,frames:qe,dropped:re,restarts:Ee,avg_fps:ce!==null&&De>ce?Math.round((qe-1)/((De-ce)/1e6)*10)/10:0,min_rtt_ms:Math.round(Pe??0),p50_rtt_ms:B?Qr():0,audio_packets:A,audio_dropped:q,connect:C}})}}var xr=null,Dr=null,As=null,ks=null;function Xs(){let e=P();return e?.features.display?e.ffmpeg:null}function Tr(e){return xr??=new Promise((t)=>{os(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(Dr={x264:s("libx264"),videotoolbox:s("h264_videotoolbox")})})}),xr}var mr=null;function ji(){return mr??=(async()=>{let e=[P()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&is(n)));if(!e)return null;let t=await Tr(e);return t.videotoolbox||t.x264?e:null})(),mr}function ot(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Xs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??Tr)(n);if(e==="linux")return o.then((i)=>i.x264);if(e==="win32"){let i=t.windowsScreen?t.windowsScreen():ks??=Ut();return Promise.all([o,i]).then(([p,l])=>p.x264&&(l?.session??0)>0)}let s=t.macScreen?t.macScreen():As??=ze(nt());return Promise.all([o,s]).then(([i,p])=>(i.x264||i.videotoolbox)&&p?.screen===!0&&p.accessibility)}var Bs=43200000,_e=":99",Js=60000,we=15000,pt={width:1280,height:800},js=/^[A-Za-z0-9._:-]{1,160}$/;function Ws(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Fs=["video","viewer","viewer_same_network","viewer_network"];function $s(e,t=Date.now()){let n=["relay_url","session_id","expires_at"];if(!Ws(e)||n.some((l)=>!(l in e))||Object.keys(e).some((l)=>!n.includes(l)&&!Fs.includes(l)))throw new r("invalid_display_request","Reason desktop request is malformed.");let o="video"in e?oo(e.video):void 0,s="viewer"in e?On(e.viewer):null;if(o===null)throw new r("invalid_display_request","Reason desktop video request is invalid.");let i=null;try{i=typeof e.relay_url==="string"?new URL(e.relay_url):null}catch{}if(!i||i.protocol!=="wss:"&&i.protocol!=="ws:"||i.username||i.password)throw new r("invalid_display_request","Reason desktop relay URL is invalid.");if(typeof e.session_id!=="string"||!js.test(e.session_id))throw new r("invalid_display_request","Reason desktop session identity is invalid.");let p=typeof e.expires_at==="string"?Date.parse(e.expires_at):Number.NaN;if(!Number.isFinite(p)||p<=t)throw new r("invalid_display_request","Reason desktop session has already expired.");return{relay_url:e.relay_url,session_id:e.session_id,expires_at:new Date(Math.min(p,t+Bs)).toISOString(),...o?{video:o}:{},...s?{viewer:s}:{},...o&&e.viewer_same_network===!0?{viewer_same_network:!0}:{}}}function At(e=process.platform){return(e==="linux"||e==="darwin"||e==="win32")&&P()?.features.display===!0}async function us(){if(process.platform==="win32")return At()&&await ot();if(process.platform!=="darwin")return At();return await ot()}function V(e){Ms(e,{recursive:!0,mode:448});let t=Ls(e);if(!t.isDirectory()||t.isSymbolicLink()||process.getuid&&t.uid!==process.getuid())throw new r("display_unavailable","Reason desktop state directory is not private.");vs(e,448)}function Gs(e,t){let n=(s)=>{let i=Buffer.alloc(2);return i.writeUInt16BE(s.length),Buffer.concat([i,s])},o=Buffer.from([255,255]);return Buffer.concat([o,n(Buffer.alloc(0)),n(Buffer.from(e)),n(Buffer.from("MIT-MAGIC-COOKIE-1")),n(t)])}function ee(e,t,n=2000){return new Promise((o)=>{let s=Os(e),i="",p=(l)=>{s.destroy(),o(l)};s.setTimeout(n,()=>p(!1)),s.once("error",()=>p(!1)),s.once("close",()=>p(!1)),s.once("connect",()=>{if(!t)p(!0)}),s.on("data",(l)=>{if(i+=l.toString("latin1"),i.length>=4)p(i.startsWith("RFB "))})})}async function Xr(e,t){let n=Date.now()+t;while(Date.now()<n){if(await e())return!0;await new Promise((o)=>setTimeout(o,100))}return!1}function ct(e,t,n){return new Promise((o)=>{let s=Ar(e,t,{detached:!0,stdio:"ignore",env:n});s.once("error",()=>o(-1)),s.once("exit",(i)=>o(i)),s.unref(),setTimeout(()=>o(null),we).unref()})}var it=null;function Be(e=a()){return it??=Vs(e).finally(()=>{it=null}),it}async function Vs(e){let t=P({home:e});if(!t?.xvfb||!t.x11vnc||!t.openbox)throw new r("display_unavailable","Run `reason desktop install` on this machine to enable its desktop.");gt({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let n=X(t.root,"display");V(n);let o=await Is(e,n,t.x11vnc);if(o)return o;let s={display:_e,xauthority:X(n,"Xauthority"),rfbSocket:X(n,"rfb.sock")},i=X(n,"pulse"),p=(async()=>{try{V(i)}catch{return null}return await nr(i,t.pulseaudio)})(),l=X(n,"home");V(l);let h={HOME:l,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:s.display,XAUTHORITY:s.xauthority};if(t.pulseaudio)h.PULSE_SERVER=Qe(Ye(i));let f=async()=>({...s,sound:await p});if(await ee({path:s.rfbSocket},!0))return await f();if(!kr(s.xauthority))at(s.xauthority,Gs(_e.slice(1),Ns(16)),{mode:384,flag:"wx"});let x=Zs(X(n,"theme"),s.display),u={path:`/tmp/.X11-unix/X${_e.slice(1)}`};if(!await ee(u,!1)){if(ct(t.xvfb,[s.display,"-screen","0",`${pt.width}x${pt.height}x24`,"-nolisten","tcp","-auth",s.xauthority],h),!await Xr(()=>ee(u,!1),we))throw new r("display_unavailable","Reason could not start the virtual display.");ct(t.openbox,["--config-file",x.openboxConfig],h)}if(await Ys(x,h),!await Cr(t.x11vnc,s,n,"x11vnc.log",h))throw new r("display_unavailable","Reason could not start the desktop server.");return await f()}async function Cr(e,t,n,o,s){if(await ee({path:t.rfbSocket},!0))return!0;Us(t.rfbSocket,{force:!0});let i=await ct(e,["-display",t.display,"-auth",t.xauthority,"-rfbport","0","-rfbportv6","-1","-unixsock",t.rfbSocket,"-nopw","-forever","-shared","-noxdamage","-sb","0","-rfbversion","3.7","-quiet","-bg","-o",X(n,o)],s);if(i!==null&&i!==0)return!1;return await Xr(()=>ee({path:t.rfbSocket},!0),we)}async function Ks(){let e=["DISPLAY","XAUTHORITY","WAYLAND_DISPLAY","XDG_SESSION_TYPE"],t=(n)=>Object.fromEntries(e.flatMap((o)=>n[o]?[[o,n[o]]]:[]));if(process.env.DISPLAY)return t(process.env);try{let n=await new Promise((o,s)=>Cs("systemctl",["--user","show-environment"],{encoding:"utf8",timeout:2000},(i,p)=>i?s(i):o(p)));return t(Object.fromEntries(n.split(`
|
|
247
|
-
`).flatMap((o)=>{let s=o.indexOf("=");return s>0?[[o.slice(0,s),o.slice(s+1)]]:[]})))}catch{return{}}}var Rr=new Set;async function Is(e,t,n){let o=await Ks(),s=/^:(\d+)(?:\.\d+)?$/.exec(o.DISPLAY??"")?.[1];if(!s||`:${s}`===_e||o.WAYLAND_DISPLAY||o.XDG_SESSION_TYPE==="wayland")return null;let i={display:`:${s}`,xauthority:o.XAUTHORITY??X(e,".Xauthority"),rfbSocket:X(t,`rfb-${s}.sock`)},p=`${i.display} ${i.xauthority}`;if(Rr.has(p)||!await ee({path:`/tmp/.X11-unix/X${s}`},!1))return null;let l={HOME:e,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:i.display,XAUTHORITY:i.xauthority};if(await Cr(n,i,t,`x11vnc-${s}.log`,l))return{...i,sound:null};return Rr.add(p),process.stderr.write(`Reason worker: your screen ${i.display} could not be served; using the virtual desktop
|
|
248
|
-
`),null}function Zs(e,t){let n=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,o=[["terminal","xterm"],["files","pcmanfm"]].filter(([,i])=>!kr(`/usr/bin/${i}`)).map(([i])=>i),s=Rt({root:e,display:t,screen:pt,browserExec:n,absent:o});for(let i of["","openbox","tint2","picom"])V(X(e,i));for(let[i,p]of Object.entries(s.files))at(X(e,i),p,{mode:384});for(let[i,p]of Object.entries(Tt))at(X(e,`ara-${i}`),Qs(p),{mode:384});return{root:e,openboxConfig:X(e,"openbox","rc.xml"),start:s.start}}async function Ys(e,t){let n=[`ROOT=${JSON.stringify(e.root)}`,...e.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
|
|
249
|
-
`);await new Promise((o)=>{let s=Ar("/bin/sh",["-c",n],{stdio:"ignore",env:{...t,PATH:"/usr/bin:/bin"}}),i=setTimeout(()=>{s.kill(),o()},we);s.once("error",()=>{clearTimeout(i),o()}),s.once("exit",()=>{clearTimeout(i),o()})})}async function Pt(e,t={}){let n=t.now??Date.now,o=$s(e.payload,n());if(e.signal.throwIfAborted(),!o.video)throw new r("display_video_required","Reason desktops stream as video now; this request came without it.");let s=t.platform??process.platform;if(s!=="linux"&&s!=="darwin"&&s!=="win32")throw new r("display_video_unsupported","This machine does not serve desktop video.");let i=o.video,p=(t.video?.desktop??(s==="darwin"?async()=>hr:s==="win32"?async()=>gr:Be))();return await zs(e.signal,o,t,n,(l)=>Er(l,{request:i,desktop:p,...o.viewer?{viewer:o.viewer}:{},viewerSameNetwork:o.viewer_same_network===!0},t.video),(l)=>Fr({type:"error",code:l}))}function zs(e,t,n,o,s,i){let p=o();return new Promise((l,h)=>{let f=null,x=!1,u=!1,S,y,A,q=!1,c=null,_=(w)=>{if(u)return;if(c)w=c;u=!0,clearTimeout(S),clearTimeout(y),e.removeEventListener("abort",D),A?.close();try{f?.close(1000,"display_session_over")}catch{}if("error"in w){h(w.error);return}l({reason:w.reason,...A?.summary(),duration_ms:Math.max(0,o()-p)})},E=()=>_({error:new r("display_relay_unavailable","Reason could not reach the desktop relay.")}),D=()=>{let w=e.reason;_({error:w instanceof r?w:new r("cancelled","Reason closed the desktop session.")})},N=()=>{if(!c||!f)return;let w=c.error;try{f.send(i(w instanceof r?w.code:"display_unavailable"))}catch{}_(c)};if(A=s({get done(){return u||c!==null},get open(){return x&&!u&&c===null},get bufferedAmount(){return f?.bufferedAmount??0},send(w){if(u||c||!x||!f)return;try{f.send(w)}catch{_({reason:"relay_closed"})}},end:(w)=>{if(u||c)return;if(!("error"in w)){_(w);return}if(c=w,q&&x)N()}}),u){A.close();return}if(e.aborted){D();return}e.addEventListener("abort",D,{once:!0}),S=setTimeout(()=>_({reason:"session_expired"}),Math.max(1,Date.parse(t.expires_at)-o())),y=setTimeout(()=>_({reason:"viewer_absent"}),n.viewerWaitMs??Js);try{f=(n.connect??vr)(t.relay_url,(n.loadProxy??j)()?.url)}catch{E();return}f.binaryType="arraybuffer",f.onopen=()=>{if(u||!f)return;x=!0,A?.opened()},f.onmessage=(w)=>{if(u)return;let M=w.data,B=M instanceof ArrayBuffer?new Uint8Array(M):ArrayBuffer.isView(M)?new Uint8Array(M.buffer,M.byteOffset,M.byteLength):null;if(!B||B.byteLength===0)return;if(clearTimeout(y),q=!0,c){N();return}A?.received(B)},f.onclose=()=>{if(u)return;if(!x){E();return}_({reason:"relay_closed"})},f.onerror=()=>{if(u||x)return;E()}})}
|
|
250
|
-
export{$e,Fi,F,Qe,ji,Ct,yr,P,Ui,At,us,V,Be,Pt};
|