@reason-machines/cli-linux-arm64-musl 0.2.282 → 0.2.284

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 (61) hide show
  1. package/bin/ara +1 -1
  2. package/bin/vm-hands/connect-cli-qgb0c8w3.js +2 -0
  3. package/bin/vm-hands/{custom-endpoint-device-92914wyp.js → custom-endpoint-device-7kd3qh6r.js} +1 -1
  4. package/bin/vm-hands/desktop-account-5kmddfvt.js +2 -0
  5. package/bin/vm-hands/{device-workspace-zk5xwd10.js → device-workspace-te28d7t5.js} +1 -1
  6. package/bin/vm-hands/{hands-worker-source-da93x0qx.js → hands-worker-source-6ts5hhas.js} +1 -1
  7. package/bin/vm-hands/{index-w9nq2f0p.js → index-9aw1gjs5.js} +1 -1
  8. package/bin/vm-hands/local-automation-hke70vcy.js +2 -0
  9. package/bin/vm-hands/local-capabilities-kx04m22x.js +2 -0
  10. package/bin/vm-hands/local-desktop-users-nxyv3mk1.js +2 -0
  11. package/bin/vm-hands/local-display-mac-rp51a8w7.js +2 -0
  12. package/bin/vm-hands/local-display-session-3ax4x1jh.js +2 -0
  13. package/bin/vm-hands/{network-contract-41qanjhp.js → network-contract-wkc0ycet.js} +1 -1
  14. package/bin/vm-hands/package-56yg8k4a.js +2 -0
  15. package/bin/vm-hands/permissions-dtrq2yvs.js +2 -0
  16. package/bin/vm-hands/{reason-hands-protocol-51gs8j7v.js → reason-hands-protocol-2gkb9qeb.js} +1 -1
  17. package/bin/vm-hands/{status-sj500a30.js → status-1gp3c1j6.js} +2 -2
  18. package/bin/vm-hands/version-h4be3gh5.js +2 -0
  19. package/bin/vm-hands/{vm-hands-entry-lite-fraghb8k.js → vm-hands-entry-lite-4fnbmmp6.js} +1 -1
  20. package/bin/vm-hands/{vm-hands-entry-lite-ptmqg51y.js → vm-hands-entry-lite-53jm8bj7.js} +2 -2
  21. package/bin/vm-hands/vm-hands-entry-lite-5pb2jqh3.js +343 -0
  22. package/bin/vm-hands/{vm-hands-entry-lite-s2xydt0n.js → vm-hands-entry-lite-5vrdj7jm.js} +2 -2
  23. package/bin/vm-hands/{vm-hands-entry-lite-am0fatcw.js → vm-hands-entry-lite-7e0r93qr.js} +2 -2
  24. package/bin/vm-hands/{vm-hands-entry-lite-54n8tmj1.js → vm-hands-entry-lite-7neqq6s2.js} +24 -23
  25. package/bin/vm-hands/{vm-hands-entry-lite-c2nrar90.js → vm-hands-entry-lite-8kqg77ym.js} +1 -1
  26. package/bin/vm-hands/{vm-hands-entry-lite-z2np2gzv.js → vm-hands-entry-lite-9dr4z8fr.js} +2 -2
  27. package/bin/vm-hands/{vm-hands-entry-lite-bw9verbt.js → vm-hands-entry-lite-avqrqtfe.js} +2 -2
  28. package/bin/vm-hands/{vm-hands-entry-lite-1nnj48qj.js → vm-hands-entry-lite-csnwmngz.js} +2 -2
  29. package/bin/vm-hands/{vm-hands-entry-lite-65pbrs1x.js → vm-hands-entry-lite-h2xpqaxn.js} +1 -1
  30. package/bin/vm-hands/{vm-hands-entry-lite-bfwf82rw.js → vm-hands-entry-lite-k1wbh9dq.js} +2 -2
  31. package/bin/vm-hands/{vm-hands-entry-lite-84aq8d12.js → vm-hands-entry-lite-kxbpf40y.js} +1 -1
  32. package/bin/vm-hands/{vm-hands-entry-lite-sv6xwe0h.js → vm-hands-entry-lite-m5pmd2cz.js} +2 -2
  33. package/bin/vm-hands/{vm-hands-entry-lite-25t4e0vk.js → vm-hands-entry-lite-pfsce35z.js} +3 -3
  34. package/bin/vm-hands/{vm-hands-entry-lite-s5qn1k80.js → vm-hands-entry-lite-qbk0wxrz.js} +2 -2
  35. package/bin/vm-hands/{vm-hands-entry-lite-7gh1rbn7.js → vm-hands-entry-lite-ss2w3h3d.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-1fznjm91.js → vm-hands-entry-lite-vqcatbcw.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-9pmag2qk.js → vm-hands-entry-lite-vvmq0mtv.js} +2 -2
  38. package/bin/vm-hands/{vm-hands-entry-lite-ffg7rf02.js → vm-hands-entry-lite-wffqkcjq.js} +1 -1
  39. package/bin/vm-hands/{vm-hands-entry-lite-1hwdab4e.js → vm-hands-entry-lite-whcnpjdx.js} +1 -1
  40. package/bin/vm-hands/{vm-hands-entry-lite-anaydk9m.js → vm-hands-entry-lite-y9k070mt.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-bwt3y6wz.js → vm-hands-entry-lite-yf8h8gmh.js} +1 -1
  42. package/bin/vm-hands/{vm-hands-entry-lite-gqncr2j0.js → vm-hands-entry-lite-yh7n4svm.js} +2 -2
  43. package/bin/vm-hands/{vm-hands-entry-lite-k4c504n7.js → vm-hands-entry-lite-yvmzze06.js} +1 -1
  44. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  45. package/bin/vm-hands/{vm-hands-executor-p7kq9n00.js → vm-hands-executor-jqm7qrjs.js} +1 -1
  46. package/bin/vm-hands/{vm-hands-op-runner-350k7hem.js → vm-hands-op-runner-t3w7aasf.js} +1 -1
  47. package/bin/vm-hands/{vm-hands-runtime-st3eagc2.js → vm-hands-runtime-4fsnx2aq.js} +3 -3
  48. package/bin/vm-hands/worker-sandbox-4c9302zr.js +2 -0
  49. package/package.json +1 -1
  50. package/bin/vm-hands/connect-cli-26easn4y.js +0 -2
  51. package/bin/vm-hands/desktop-account-vsrtgkk9.js +0 -2
  52. package/bin/vm-hands/local-automation-hk8bgn7w.js +0 -2
  53. package/bin/vm-hands/local-capabilities-j6cmcwdc.js +0 -2
  54. package/bin/vm-hands/local-desktop-users-3j79jbyp.js +0 -2
  55. package/bin/vm-hands/local-display-mac-j1v3mcgx.js +0 -2
  56. package/bin/vm-hands/local-display-session-4402sa84.js +0 -2
  57. package/bin/vm-hands/package-rx9y4bwe.js +0 -2
  58. package/bin/vm-hands/permissions-avhf90my.js +0 -2
  59. package/bin/vm-hands/version-zanrbm0q.js +0 -2
  60. package/bin/vm-hands/vm-hands-entry-lite-21zpypby.js +0 -343
  61. package/bin/vm-hands/worker-sandbox-nnce49w0.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dd as me}from"./vm-hands-entry-lite-gqncr2j0.js";import{ee as X,fe as ee,he as lt,ie as pe,le as xt,me as bt,ne as $,we as L,xe as Ge}from"./vm-hands-entry-lite-bw9verbt.js";import{Be as v,Ce as z,Ke as gt,ze as E}from"./vm-hands-entry-lite-bfwf82rw.js";import{eg as ht,hg as wt,kg as D,mg as Lt,ng as oe}from"./vm-hands-entry-lite-25t4e0vk.js";import{Mg as Se,Ng as re}from"./vm-hands-entry-lite-s2xydt0n.js";import{Vg as be}from"./vm-hands-entry-lite-s5qn1k80.js";import{Xg as T}from"./vm-hands-entry-lite-9pmag2qk.js";import{Fh as xe,zh as we}from"./vm-hands-entry-lite-anaydk9m.js";import{Gh as _}from"./vm-hands-entry-lite-ffg7rf02.js";import{spawn as I}from"child_process";import{randomUUID as ye}from"crypto";import{closeSync as Vr,copyFileSync as ie,existsSync as _t,fstatSync as Er,mkdirSync as ce,openSync as vr,readdirSync as K,readFileSync as Ae,readlinkSync as to,renameSync as eo,rmSync as ro,statSync as oo}from"fs";import{connect as so}from"net";import{userInfo as ge}from"os";import{basename as ne,dirname as ut,join as b}from"path";var yt=`import { spawn, execFileSync } from "node:child_process";
2
+ import{Fd as xe}from"./vm-hands-entry-lite-yh7n4svm.js";import{ge as W,he as se,je as ut,ke as Ne,ne as pt,oe as xt,pe as $,ye as z,ze as Je}from"./vm-hands-entry-lite-avqrqtfe.js";import{Be as v,De as tt,Ee as D,Me as gt}from"./vm-hands-entry-lite-k1wbh9dq.js";import{gg as zt,jg as St,mg as Z,og as jt,pg as ie}from"./vm-hands-entry-lite-pfsce35z.js";import{Og as Ae,Pg as ae}from"./vm-hands-entry-lite-5vrdj7jm.js";import{Xg as Se}from"./vm-hands-entry-lite-qbk0wxrz.js";import{Zg as q}from"./vm-hands-entry-lite-vvmq0mtv.js";import{Bh as pe,Hh as ye}from"./vm-hands-entry-lite-y9k070mt.js";import{Ih as _}from"./vm-hands-entry-lite-wffqkcjq.js";import{spawn as I}from"child_process";import{randomUUID as Oe}from"crypto";import{closeSync as Vr,copyFileSync as de,existsSync as mt,fstatSync as Er,mkdirSync as fe,openSync as vr,readdirSync as V,readFileSync as ge,readlinkSync as to,renameSync as eo,rmSync as ro,statSync as oo}from"fs";import{connect as so}from"net";import{userInfo as Te}from"os";import{basename as le,dirname as bt,join as b}from"path";var Nt=`import { spawn, execFileSync } from "node:child_process";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -691,30 +691,31 @@ if(process.env.REASON_CLOUD_GATEWAY_EXEC === "1") {
691
691
  process.stdout.write(JSON.stringify(cloudAutomationFailure(error))+"\\n");process.exitCode=1;
692
692
  }
693
693
  }
694
- `;import{spawn as Le}from"child_process";import{basename as Je}from"path";var ze="__desktop-call",je="/usr/bin/setpriv",De=27262976,Me=8192,Pe=2000;function V(t){return Boolean(t)&&typeof t==="object"&&!Array.isArray(t)}function Ze(t){try{return JSON.parse(t)}catch{return null}}function ke(){return[process.execPath,...Je(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],ze]}function Qe(t,e,r,o={}){r.throwIfAborted();let s=o.command??ke();return new Promise((a,c)=>{let i=(o.spawnProcess??Le)(je,[`--reuid=${t.uid}`,`--regid=${t.gid}`,"--clear-groups","--no-new-privs","--",...s],{cwd:t.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:t.home,USER:t.username,LOGNAME:t.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),n=[],f=0,d="",l=null,m=!1,u,S=(x)=>{try{process.kill(-i.pid,x)}catch{i.kill(x)}},C=(x)=>{l??=x,S("SIGTERM"),u??=setTimeout(()=>S("SIGKILL"),Pe)},O=()=>C(new _("cancelled","Reason cancelled the desktop operation."));r.addEventListener("abort",O,{once:!0});let w=(x)=>{if(m)return;m=!0,clearTimeout(u),r.removeEventListener("abort",O),x()};if(i.stdout.on("data",(x)=>{if(f+=x.byteLength,f>De)C(new _("desktop_delegate_failed","Reason's desktop reply is too large."));else n.push(x)}),i.stderr.setEncoding("utf8").on("data",(x)=>{d=(d+x).slice(-Me)}),i.stdin.on("error",()=>{}),i.once("error",()=>w(()=>c(l??new _("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),i.once("close",(x,Ue)=>w(()=>{if(l)return c(l);let y=Ze(Buffer.concat(n).toString("utf8"));if(V(y)&&y.ok===!0&&V(y.result))return a(y.result);let F=V(y)&&y.ok===!1&&typeof y.code==="string"&&typeof y.message==="string"?new _(y.code.slice(0,120),y.message.slice(0,2000)):null,St=`exited ${x??Ue}${F?"":" with no reply"}`,pt=d.trim().split(`
695
- `).at(-1)?.slice(-300)??"";if(!F||F.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${St}${d?`: ${d.trim().slice(-500)}`:""}
696
- `);if(F)return c(F);c(new _("desktop_delegate_failed",`Reason's desktop operation failed (${St}${pt?`: ${pt}`:""}).`))})),r.aborted)O();i.stdin.end(JSON.stringify(e))})}async function At(t,e,r,o={}){let s=await Qe(t,{op:"automation",call:e},r,o);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new _("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as Jr,spawn as zr}from"child_process";import{closeSync as jr,mkdirSync as Dr,openSync as Mr}from"fs";import{dirname as k,join as Pr}from"path";import{promisify as Zr}from"util";import{spawnSync as j}from"child_process";import{createHash as br,randomUUID as wr}from"crypto";import{chmodSync as xr,existsSync as st,mkdirSync as Sr,readdirSync as es,readFileSync as M,renameSync as pr,rmSync as g,statSync as yr,writeFileSync as Ar}from"fs";import{dirname as gr,isAbsolute as Jt,join as G}from"path";import{chmodSync as Do,existsSync as Ye,mkdirSync as Mo,readlinkSync as Xe,readFileSync as We,renameSync as Po,unlinkSync as Zo,writeFileSync as ko}from"fs";import{homedir as Nt}from"os";import{basename as He,dirname as Ot,isAbsolute as Tt,join as R,normalize as Ke,relative as Ve,resolve as Ee}from"path";var tt=3,ve=1,tr=2,er=1,rr=1,or="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",sr="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",ar=[sr,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function ir(t){return typeof t==="string"&&ar.includes(t)}var cr=["future_device","updates_only","cli_only"];function qt(t){return typeof t==="string"&&cr.some((e)=>e===t)}function nr(t=process.env,e=Nt()){return t.XDG_CONFIG_HOME?.trim()||R(e,".config")}function et(t=process.env,e=Nt()){let r=z({env:t}),o=nr(t,e);return R(o,gt(o).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function p(t){return typeof t==="string"&&t.trim().length>0}var dr=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function fr(t){return typeof t==="string"&&dr.test(t)}function J(t){return p(t)&&Tt(t)&&Ke(t)===t}function Ct(t){if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;return J(e.path)&&(e.role==="launcher"&&(e.kind==="file"||e.kind==="symlink")||e.role==="worker_root"&&e.kind==="directory"||e.role==="alias"&&e.kind==="symlink"&&J(e.target))}function Bt(t){return t.owned_paths?.every((e)=>e.role!=="alias"||t.installer==="shell"&&e.path===R(t.install_dir,t.channel==="staging"?"reason-staging":"reason")&&e.target===R(t.install_dir,t.channel==="staging"?"ara-staging":"ara")&&t.owned_paths?.some((r)=>r.role==="launcher"&&r.path===e.target))??!1}function lr(t,e){try{return Ee(Ot(t),Xe(t))===e}catch{return!1}}function rt(t){let e=He(t),r=e==="ara"?"reason":e==="ara-staging"?"reason-staging":null;if(!r)return t;let o=R(Ot(t),r);return lr(o,t)?o:t}function It(t,e){let r=Ve(t,e);return r.length>0&&!r.startsWith("..")&&!Tt(r)}function $t(t){if(t===null)return!0;if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;return e.kind==="shell_profile"&&p(e.location)&&p(e.value)&&(typeof e.added_by_installer==="boolean"||typeof e.added_by_ara==="boolean")&&(e.added_by_installer===void 0||typeof e.added_by_installer==="boolean")&&(e.added_by_ara===void 0||typeof e.added_by_ara==="boolean")}function Ft(t,e){if(e===null)return t==="cli_only";if(!e||typeof e!=="object"||Array.isArray(e))return!1;let r=e;if(r.version!==er||!p(r.recorded_at))return!1;if(t==="future_device")return r.decision==="authorized"&&ir(r.scope);return r.scope===null&&r.decision===(t==="updates_only"?"ask":"disabled")}function _r(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.schema_version!==ve||!v.includes(e.channel)||e.install_method!=="curl"||e.installer!=="shell"||!p(e.installed_at)||!p(e.version)||!p(e.target)||!J(e.install_dir)||!Array.isArray(e.owned_paths)||!e.owned_paths.every(Ct)||!e.owned_paths.every((r)=>It(e.install_dir,r.path))||!Bt(e)||!$t(e.path_entry))return null;return{...e,schema_version:tt,installation_id:null,background_mode:"cli_only",device_consent:null}}function ur(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.schema_version!==tr||!Rt(e)||!qt(e.background_mode)||!Ft(e.background_mode,e.device_consent))return null;return{...e,schema_version:tt,installation_id:null}}function Rt(t){return v.includes(t.channel)&&(t.install_method==="curl"&&t.installer==="shell"||t.install_method==="desktop"&&t.installer==="desktop"&&Array.isArray(t.owned_paths)&&t.owned_paths.length===0&&t.path_entry===null)&&p(t.installed_at)&&p(t.version)&&p(t.target)&&J(t.install_dir)&&Array.isArray(t.owned_paths)&&t.owned_paths.every(Ct)&&t.owned_paths.every((e)=>It(t.install_dir,e.path))&&Bt(t)&&$t(t.path_entry)}function mr(t){let e=_r(t);if(e)return e;let r=ur(t);if(r)return r;if(!t||typeof t!=="object"||Array.isArray(t))return null;let o=t;if(o.schema_version!==tt||!fr(o.installation_id)||!Rt(o)||!qt(o.background_mode)||!Ft(o.background_mode,o.device_consent)||o.desktop_account_access!==void 0&&(o.desktop_account_access===null||typeof o.desktop_account_access!=="object"||Array.isArray(o.desktop_account_access)||o.desktop_account_access.version!==rr||o.desktop_account_access.scope!==or||!p(o.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(o.desktop_account_access.recorded_at))))return null;return o}function Gt(t=et()){if(!Ye(t))return null;try{return mr(JSON.parse(We(t,"utf8")))}catch{return null}}var at="REASON_WORKER_SERVICE",Nr="worker_identity_unavailable";function zt(t){return{platform:process.platform,home:t,uid:process.getuid?.(),command:(e,r)=>j(e,[...r],{stdio:"ignore"}).status??1,read:(e,r)=>{let o=j(e,[...r],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return o.status===0?o.stdout:null},sleep:(e)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e),workerIdentity:(e)=>Lt(t,e),insideService:(e)=>Or(e,process.platform,process.getuid?.())}}function Or(t,e,r){if(process.env[at]===t||process.env.XPC_SERVICE_NAME===t)return!0;if(e==="linux")try{return M("/proc/self/cgroup","utf8").includes(`/${t}.service`)}catch{return!0}if(e!=="darwin")return!1;if(typeof r!=="number")return!0;let o=j("/bin/launchctl",["print",`gui/${r}/${t}`],{encoding:"utf8",timeout:5000});if(o.status===Tr)return!1;if(o.error||o.status!==0)return!0;let s=Number(/^\s*pid = (\d+)$/m.exec(o.stdout??"")?.[1]??0);if(!s)return!1;let a=process.pid;for(let c=0;c<64&&a>1;c+=1){if(a===s)return!0;let i=j("/bin/ps",["-o","ppid=","-p",String(a)],{encoding:"utf8",timeout:5000}),n=Number(i.stdout?.trim());if(i.error||i.status!==0||!Number.isSafeInteger(n)||n<=0)return!0;if(n===a)return!1;a=n}return a>1}var Tr=113;class A extends Error{code;constructor(t,e){super(t);this.code=e}}function jt(t,e){if(t.platform!=="darwin"&&t.platform!=="linux")throw new A("A background service needs macOS (launchd) or Linux (systemd --user).");if(t.platform==="darwin")U(t);let o=[Gt(et(e,t.home))?.owned_paths.find((s)=>s.role==="launcher")?.path,E(e,"REASON_CLI_LAUNCHER_PATH")?.trim(),G(t.home,".local","bin",z({env:e})==="staging"?"ara-staging":"ara")];for(let s of o)try{if(s&&Jt(s)&&yr(s).isFile())return rt(s)}catch{}throw new A("A background service runs the installed Reason launcher, which was not found. Install Reason with: curl -fsSL https://reasonmachines.com/install | sh","worker_launcher_missing")}var Dt=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,ot=new RegExp(`(\\n\\s*<key>${D}</key>\\s*<string>)[^<]*(</string>)`),qr=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function Cr(t){return t.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&amp;","&")}function Br(t){let e=[...(Dt.exec(t)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((o)=>Cr(o[1])),r=e[1]==="--run-worker"?e.slice(2):e;return r[0]?{launcher:r[0],args:r.slice(1)}:null}function Mt(t,e,r){let o=r.workerIdentity?.(t)??null;return{program:o?[o.executable,"--run-worker",t,...e]:[t,...e],identity:o}}function Pt(t){return t.map((e)=>` <string>${N(e)}</string>`).join(`
697
- `)}function Zt(t,e){let r;try{r=M(t,"utf8")}catch{return null}let o=Br(r);if(!o)return null;let s=Jt(o.launcher)?rt(o.launcher):o.launcher,{program:a,identity:c}=Mt(s,o.args,e),i=r.replace(Dt,(n,f,d,l)=>`${f}${Pt(a)}
698
- ${l}`);if(!c)i=i.replace(ot,"");else if(ot.test(i))i=i.replace(ot,(n,f,d)=>`${f}${N(c.app)}${d}`);else i=i.replace(qr,(n,f,d)=>`${f}
699
- <key>${D}</key>
700
- <string>${N(c.app)}</string>${d}`);return i===r?null:i}function Ir(t,e){let r=Zt(t,e);if(r!==null)Z(t,r)}function cs(t,e,r){if(e.platform!=="darwin")return!1;let o=ct(t,e,r);return o!==null&&Zt(o.definition,e)!==null}var P="com.reasonmachines.worker.",it="so.reason.worker.",kt=[P,it];function Qt(t,e=P){return`${e}connect${t==="production"?"":`.${t}`}`}function ns(t,e){return kt.some((r)=>t===Qt(e,r))}function $r(t,e,r){if(e==="connect")return Qt(t.channel,r);let o=br("sha256").update(t.workspaceRoot).digest("hex").slice(0,8);return`${r}${t.name.toLowerCase()}.${o}`}function Fr(t,e){if(e==="darwin")return{directory:G(t,"Library","LaunchAgents"),suffix:".plist"};if(e==="linux")return{directory:G(t,".config","systemd","user"),suffix:".service"};return null}function B(t,e,r,o=P){let s=$r(t,r,o),a=Fr(e.home,e.platform);if(!a)return null;return{label:s,definition:G(a.directory,`${s}${a.suffix}`),logs:e.platform==="darwin"?G(t.stateDirectory,"service.log"):`journalctl --user -u ${s}.service`}}function ct(t,e,r="serve"){return Yt(t,e,r)[0]??null}function Yt(t,e,r){return kt.map((o)=>B(t,e,r,o)).filter((o)=>o!==null&&st(o.definition))}function Xt(t,e,r){let o=B(t,e,r,it);return o&&st(o.definition)?o:null}function Rr(t,e,r){let o=B(t,e,r),s=Xt(t,e,r);if(!o||!s||!st(o.definition)||e.insideService?.(s.label))return null;if(!Gr(o,e))return"current_not_running";if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${s.label}`]);return g(s.definition,{force:!0}),"retired"}return e.command("systemctl",["--user","disable","--now",`${s.label}.service`]),g(s.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),"retired"}function Gr(t,e){if(e.platform==="darwin")return typeof e.uid==="number"&&e.uid>0&&e.command("/bin/launchctl",["print",`gui/${e.uid}/${t.label}`])===0;let r=`${t.label}.service`;return e.command("systemctl",["--user","is-enabled","--quiet",r])===0&&Ur.has(e.read("systemctl",["--user","show","--property=ActiveState","--value",r])?.trim()??"")}var Ur=new Set(["active","activating","reloading"]);function Wt(t,e){if(e==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:t.channel},description:"Reason connection of this computer"};return{args:["serve",t.name,"--dir",t.workspaceRoot,...t.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${t.name} worker`}}function N(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Ut(t,e=!1){if(/[\0-\x1f\x7f]/.test(t))throw new A("A background service cannot use a path with control characters.");let r=t.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${e?r.replaceAll("$","$$$$"):r}"`}function hr(t,e,r,o,s,a){let c=Wt(t,e),i=Mt(o,c.args,s),n={HOME:s.home,PATH:a,[at]:r.label,...c.environment,...i.identity?{[D]:i.identity.app}:{}};return{identity:i.identity,plist:`<?xml version="1.0" encoding="UTF-8"?>
694
+ `;import{spawn as De}from"child_process";import{basename as Me}from"path";var Pe="__desktop-call",Ze="/usr/bin/setpriv",he=27262976,Qe=8192,ke=2000;function E(t){return Boolean(t)&&typeof t==="object"&&!Array.isArray(t)}function Ye(t){try{return JSON.parse(t)}catch{return null}}function Xe(){return[process.execPath,...Me(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],Pe]}function We(t,e,r,o={}){r.throwIfAborted();let s=o.command??Xe();return new Promise((a,c)=>{let i=(o.spawnProcess??De)(Ze,[`--reuid=${t.uid}`,`--regid=${t.gid}`,"--clear-groups","--no-new-privs","--",...s],{cwd:t.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:t.home,USER:t.username,LOGNAME:t.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),d=[],f=0,n="",l=null,u=!1,m,S=(x)=>{try{process.kill(-i.pid,x)}catch{i.kill(x)}},B=(x)=>{l??=x,S("SIGTERM"),m??=setTimeout(()=>S("SIGKILL"),ke)},g=()=>B(new _("cancelled","Reason cancelled the desktop operation."));r.addEventListener("abort",g,{once:!0});let w=(x)=>{if(u)return;u=!0,clearTimeout(m),r.removeEventListener("abort",g),x()};if(i.stdout.on("data",(x)=>{if(f+=x.byteLength,f>he)B(new _("desktop_delegate_failed","Reason's desktop reply is too large."));else d.push(x)}),i.stderr.setEncoding("utf8").on("data",(x)=>{n=(n+x).slice(-Qe)}),i.stdin.on("error",()=>{}),i.once("error",()=>w(()=>c(l??new _("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),i.once("close",(x,ze)=>w(()=>{if(l)return c(l);let y=Ye(Buffer.concat(d).toString("utf8"));if(E(y)&&y.ok===!0&&E(y.result))return a(y.result);let F=E(y)&&y.ok===!1&&typeof y.code==="string"&&typeof y.message==="string"?new _(y.code.slice(0,120),y.message.slice(0,2000)):null,yt=`exited ${x??ze}${F?"":" with no reply"}`,At=n.trim().split(`
695
+ `).at(-1)?.slice(-300)??"";if(!F||F.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${yt}${n?`: ${n.trim().slice(-500)}`:""}
696
+ `);if(F)return c(F);c(new _("desktop_delegate_failed",`Reason's desktop operation failed (${yt}${At?`: ${At}`:""}).`))})),r.aborted)g();i.stdin.end(JSON.stringify(e))})}async function Ot(t,e,r,o={}){let s=await We(t,{op:"automation",call:e},r,o);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new _("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as zr,spawn as jr}from"child_process";import{closeSync as Dr,mkdirSync as Mr,openSync as Pr}from"fs";import{dirname as k,join as Zr}from"path";import{promisify as hr}from"util";import{spawnSync as P}from"child_process";import{createHash as Sr,randomUUID as pr}from"crypto";import{chmodSync as yr,existsSync as st,mkdirSync as Ar,readdirSync as es,readFileSync as U,renameSync as Nr,rmSync as N,statSync as Or,writeFileSync as gr}from"fs";import{dirname as Tr,isAbsolute as Dt,join as G}from"path";import{chmodSync as Mo,existsSync as He,mkdirSync as Po,readlinkSync as Ke,readFileSync as Ve,renameSync as Zo,unlinkSync as ho,writeFileSync as Qo}from"fs";import{homedir as Tt}from"os";import{basename as Ee,dirname as qt,isAbsolute as Ct,join as R,normalize as ve,relative as tr,resolve as er}from"path";var et=3,rr=1,or=2,sr=1,ar=1,ir="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",cr="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",nr=[cr,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function dr(t){return typeof t==="string"&&nr.includes(t)}var fr=["future_device","updates_only","cli_only"];function Bt(t){return typeof t==="string"&&fr.some((e)=>e===t)}function lr(t=process.env,e=Tt()){return t.XDG_CONFIG_HOME?.trim()||R(e,".config")}function rt(t=process.env,e=Tt()){let r=D({env:t}),o=lr(t,e);return R(o,gt(o).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function p(t){return typeof t==="string"&&t.trim().length>0}var _r=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ur(t){return typeof t==="string"&&_r.test(t)}function j(t){return p(t)&&Ct(t)&&ve(t)===t}function It(t){if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;return j(e.path)&&(e.role==="launcher"&&(e.kind==="file"||e.kind==="symlink")||e.role==="worker_root"&&e.kind==="directory"||e.role==="alias"&&e.kind==="symlink"&&j(e.target))}function $t(t){return t.owned_paths?.every((e)=>e.role!=="alias"||t.installer==="shell"&&e.path===R(t.install_dir,t.channel==="staging"?"reason-staging":"reason")&&e.target===R(t.install_dir,t.channel==="staging"?"ara-staging":"ara")&&t.owned_paths?.some((r)=>r.role==="launcher"&&r.path===e.target))??!1}function mr(t,e){try{return er(qt(t),Ke(t))===e}catch{return!1}}function ot(t){let e=Ee(t),r=e==="ara"?"reason":e==="ara-staging"?"reason-staging":null;if(!r)return t;let o=R(qt(t),r);return mr(o,t)?o:t}function Ft(t,e){let r=tr(t,e);return r.length>0&&!r.startsWith("..")&&!Ct(r)}function Rt(t){if(t===null)return!0;if(!t||typeof t!=="object"||Array.isArray(t))return!1;let e=t;return e.kind==="shell_profile"&&p(e.location)&&p(e.value)&&(typeof e.added_by_installer==="boolean"||typeof e.added_by_ara==="boolean")&&(e.added_by_installer===void 0||typeof e.added_by_installer==="boolean")&&(e.added_by_ara===void 0||typeof e.added_by_ara==="boolean")}function Gt(t,e){if(e===null)return t==="cli_only";if(!e||typeof e!=="object"||Array.isArray(e))return!1;let r=e;if(r.version!==sr||!p(r.recorded_at))return!1;if(t==="future_device")return r.decision==="authorized"&&dr(r.scope);return r.scope===null&&r.decision===(t==="updates_only"?"ask":"disabled")}function br(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.schema_version!==rr||!tt.includes(e.channel)||e.install_method!=="curl"||e.installer!=="shell"||!p(e.installed_at)||!p(e.version)||!p(e.target)||!j(e.install_dir)||!Array.isArray(e.owned_paths)||!e.owned_paths.every(It)||!e.owned_paths.every((r)=>Ft(e.install_dir,r.path))||!$t(e)||!Rt(e.path_entry))return null;return{...e,schema_version:et,installation_id:null,background_mode:"cli_only",device_consent:null}}function wr(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.schema_version!==or||!Ut(e)||!Bt(e.background_mode)||!Gt(e.background_mode,e.device_consent))return null;return{...e,schema_version:et,installation_id:null}}function Ut(t){return tt.includes(t.channel)&&(t.install_method==="curl"&&t.installer==="shell"||t.install_method==="desktop"&&t.installer==="desktop"&&Array.isArray(t.owned_paths)&&t.owned_paths.length===0&&t.path_entry===null)&&p(t.installed_at)&&p(t.version)&&p(t.target)&&j(t.install_dir)&&Array.isArray(t.owned_paths)&&t.owned_paths.every(It)&&t.owned_paths.every((e)=>Ft(t.install_dir,e.path))&&$t(t)&&Rt(t.path_entry)}function xr(t){let e=br(t);if(e)return e;let r=wr(t);if(r)return r;if(!t||typeof t!=="object"||Array.isArray(t))return null;let o=t;if(o.schema_version!==et||!ur(o.installation_id)||!Ut(o)||!Bt(o.background_mode)||!Gt(o.background_mode,o.device_consent)||o.desktop_account_access!==void 0&&(o.desktop_account_access===null||typeof o.desktop_account_access!=="object"||Array.isArray(o.desktop_account_access)||o.desktop_account_access.version!==ar||o.desktop_account_access.scope!==ir||!p(o.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(o.desktop_account_access.recorded_at))))return null;return o}function Lt(t=rt()){if(!He(t))return null;try{return xr(JSON.parse(Ve(t,"utf8")))}catch{return null}}var at="REASON_WORKER_SERVICE",qr="worker_identity_unavailable";function Mt(t){return{platform:process.platform,home:t,uid:process.getuid?.(),command:(e,r)=>P(e,[...r],{stdio:"ignore"}).status??1,read:(e,r)=>{let o=P(e,[...r],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return o.status===0?o.stdout:null},sleep:(e)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e),workerIdentity:(e)=>jt(t,e),insideService:(e)=>Cr(e,process.platform,process.getuid?.())}}function Cr(t,e,r){if(process.env[at]===t||process.env.XPC_SERVICE_NAME===t)return!0;if(e==="linux")try{return U("/proc/self/cgroup","utf8").includes(`/${t}.service`)}catch{return!0}if(e!=="darwin")return!1;if(typeof r!=="number")return!0;let o=P("/bin/launchctl",["print",`gui/${r}/${t}`],{encoding:"utf8",timeout:5000});if(o.status===Br)return!1;if(o.error||o.status!==0)return!0;let s=Number(/^\s*pid = (\d+)$/m.exec(o.stdout??"")?.[1]??0);if(!s)return!1;let a=process.pid;for(let c=0;c<64&&a>1;c+=1){if(a===s)return!0;let i=P("/bin/ps",["-o","ppid=","-p",String(a)],{encoding:"utf8",timeout:5000}),d=Number(i.stdout?.trim());if(i.error||i.status!==0||!Number.isSafeInteger(d)||d<=0)return!0;if(d===a)return!1;a=d}return a>1}var Br=113;class A extends Error{code;constructor(t,e){super(t);this.code=e}}function Pt(t,e){if(t.platform!=="darwin"&&t.platform!=="linux")throw new A("A background service needs macOS (launchd) or Linux (systemd --user).");if(t.platform==="darwin")L(t);let o=[Lt(rt(e,t.home))?.owned_paths.find((s)=>s.role==="launcher")?.path,v(e,"REASON_CLI_LAUNCHER_PATH")?.trim(),G(t.home,".local","bin",D({env:e})==="staging"?"ara-staging":"ara")];for(let s of o)try{if(s&&Dt(s)&&Or(s).isFile())return ot(s)}catch{}throw new A("A background service runs the installed Reason launcher, which was not found. Install Reason with: curl -fsSL https://reasonmachines.com/install | sh","worker_launcher_missing")}var it=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,M=new RegExp(`(\\n\\s*<key>${Z}</key>\\s*<string>)[^<]*(</string>)`),Ir=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function $r(t){return t.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&amp;","&")}function Zt(t){let e=[...(it.exec(t)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((o)=>$r(o[1])),r=e[1]==="--run-worker"?e.slice(2):e;return r[0]?{launcher:r[0],args:r.slice(1)}:null}function ht(t,e,r){let o=r.workerIdentity?.(t)??null;return{program:o?[o.executable,"--run-worker",t,...e]:[t,...e],identity:o}}function ct(t){return t.map((e)=>` <string>${O(e)}</string>`).join(`
697
+ `)}function Qt(t,e){let r;try{r=U(t,"utf8")}catch{return null}let o=Zt(r);if(!o)return null;let s=Dt(o.launcher)?ot(o.launcher):o.launcher,{program:a,identity:c}=ht(s,o.args,e),i=r.replace(it,(d,f,n,l)=>`${f}${ct(a)}
698
+ ${l}`);if(!c)i=i.replace(M,"");else if(M.test(i))i=i.replace(M,(d,f,n)=>`${f}${O(c.app)}${n}`);else i=i.replace(Ir,(d,f,n)=>`${f}
699
+ <key>${Z}</key>
700
+ <string>${O(c.app)}</string>${n}`);return i===r?null:i}function Fr(t,e){let r=Qt(t,e);if(r!==null)Q(t,r)}function cs(t,e,r){if(e.platform!=="darwin")return!1;let o=dt(t,e,r);return o!==null&&Qt(o.definition,e)!==null}var h="com.reasonmachines.worker.",nt="so.reason.worker.",kt=[h,nt];function Yt(t,e=h){return`${e}connect${t==="production"?"":`.${t}`}`}function ns(t,e){return kt.some((r)=>t===Yt(e,r))}function Rr(t,e,r){if(e==="connect")return Yt(t.channel,r);let o=Sr("sha256").update(t.workspaceRoot).digest("hex").slice(0,8);return`${r}${t.name.toLowerCase()}.${o}`}function Gr(t,e){if(e==="darwin")return{directory:G(t,"Library","LaunchAgents"),suffix:".plist"};if(e==="linux")return{directory:G(t,".config","systemd","user"),suffix:".service"};return null}function T(t,e,r,o=h){let s=Rr(t,r,o),a=Gr(e.home,e.platform);if(!a)return null;return{label:s,definition:G(a.directory,`${s}${a.suffix}`),logs:e.platform==="darwin"?G(t.stateDirectory,"service.log"):`journalctl --user -u ${s}.service`}}function dt(t,e,r="serve"){return Xt(t,e,r)[0]??null}function Xt(t,e,r){return kt.map((o)=>T(t,e,r,o)).filter((o)=>o!==null&&st(o.definition))}function Wt(t,e,r){let o=T(t,e,r,nt);return o&&st(o.definition)?o:null}function Ur(t,e,r){let o=T(t,e,r),s=Wt(t,e,r);if(!o||!s||!st(o.definition)||e.insideService?.(s.label))return null;if(!Lr(o,e))return"current_not_running";if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${s.label}`]);return N(s.definition,{force:!0}),"retired"}return e.command("systemctl",["--user","disable","--now",`${s.label}.service`]),N(s.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),"retired"}function Lr(t,e){if(e.platform==="darwin")return typeof e.uid==="number"&&e.uid>0&&e.command("/bin/launchctl",["print",`gui/${e.uid}/${t.label}`])===0;let r=`${t.label}.service`;return e.command("systemctl",["--user","is-enabled","--quiet",r])===0&&Jr.has(e.read("systemctl",["--user","show","--property=ActiveState","--value",r])?.trim()??"")}var Jr=new Set(["active","activating","reloading"]);function ds(t,e){if(e.platform==="darwin"){if(typeof e.uid!=="number"||e.uid<=0)return!1;let r=e.read("/bin/launchctl",["print",`gui/${e.uid}/${t.label}`]);return Number(/^\s*pid = (\d+)$/m.exec(r??"")?.[1]??0)>0}return Number(e.read("systemctl",["--user","show","--property=MainPID","--value",`${t.label}.service`])?.trim()??0)>0}function fs(t){let{config:e,launcher:r,host:o,kind:s}=t,a=T(e,o,s);if(!a)return!1;let c;try{c=U(a.definition,"utf8")}catch{return!1}if(o.platform!=="darwin")return c===Vt(e,s,a,r,o.home,t.path);let i=Zt(c);return c.replace(M,"").replace(it,(f,n,l,u)=>`${n}${i?`${ct([i.launcher,...i.args])}
701
+ `:""}${u}`)===Kt(e,s,a,r,{...o,workerIdentity:()=>null},t.path).plist}function Ht(t,e){if(e==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:t.channel},description:"Reason connection of this computer"};return{args:["serve",t.name,"--dir",t.workspaceRoot,...t.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${t.name} worker`}}function O(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Jt(t,e=!1){if(/[\0-\x1f\x7f]/.test(t))throw new A("A background service cannot use a path with control characters.");let r=t.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${e?r.replaceAll("$","$$$$"):r}"`}function Kt(t,e,r,o,s,a){let c=Ht(t,e),i=ht(o,c.args,s),d={HOME:s.home,PATH:a,[at]:r.label,...c.environment,...i.identity?{[Z]:i.identity.app}:{}};return{identity:i.identity,plist:`<?xml version="1.0" encoding="UTF-8"?>
701
702
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
702
703
  <plist version="1.0">
703
704
  <dict>
704
705
  <key>Label</key>
705
- <string>${N(r.label)}</string>
706
+ <string>${O(r.label)}</string>
706
707
  <key>AssociatedBundleIdentifiers</key>
707
708
  <array>
708
- <string>${ht}</string>
709
+ <string>${zt}</string>
709
710
  </array>
710
711
  <key>ProgramArguments</key>
711
712
  <array>
712
- ${Pt(i.program)}
713
+ ${ct(i.program)}
713
714
  </array>
714
715
  <key>EnvironmentVariables</key>
715
716
  <dict>
716
- ${Object.entries(n).map(([f,d])=>` <key>${f}</key>
717
- <string>${N(d)}</string>`).join(`
717
+ ${Object.entries(d).map(([f,n])=>` <key>${f}</key>
718
+ <string>${O(n)}</string>`).join(`
718
719
  `)}
719
720
  </dict>
720
721
  <key>RunAtLoad</key>
@@ -733,17 +734,17 @@ ${Object.entries(n).map(([f,d])=>` <key>${f}</key>
733
734
  <key>Umask</key>
734
735
  <integer>63</integer>
735
736
  <key>StandardOutPath</key>
736
- <string>${N(r.logs)}</string>
737
+ <string>${O(r.logs)}</string>
737
738
  <key>StandardErrorPath</key>
738
- <string>${N(r.logs)}</string>
739
+ <string>${O(r.logs)}</string>
739
740
  </dict>
740
741
  </plist>
741
- `}}function Lr(t,e,r,o,s,a){let c=Wt(t,e);return`[Unit]
742
+ `}}function Vt(t,e,r,o,s,a){let c=Ht(t,e);return`[Unit]
742
743
  Description=${c.description}
743
744
 
744
745
  [Service]
745
- ExecStart=${[o,...c.args].map((i)=>Ut(i,!0)).join(" ")}
746
- Environment=${[`HOME=${s}`,`PATH=${a}`,`${at}=${r.label}`,...Object.entries(c.environment).map(([i,n])=>`${i}=${n}`)].map((i)=>Ut(i)).join(" ")}
746
+ ExecStart=${[o,...c.args].map((i)=>Jt(i,!0)).join(" ")}
747
+ Environment=${[`HOME=${s}`,`PATH=${a}`,`${at}=${r.label}`,...Object.entries(c.environment).map(([i,d])=>`${i}=${d}`)].map((i)=>Jt(i)).join(" ")}
747
748
  Restart=on-failure
748
749
  RestartSec=10
749
750
  TimeoutStopSec=${Math.ceil(t.shutdownGraceMs/1000)+10}
@@ -751,9 +752,9 @@ UMask=0077
751
752
 
752
753
  [Install]
753
754
  WantedBy=default.target
754
- `}function Z(t,e){Sr(gr(t),{recursive:!0,mode:448});let r=`${t}.${wr()}.tmp`;try{Ar(r,e,{mode:384,flag:"wx"}),xr(r,384),pr(r,t)}finally{g(r,{force:!0})}}function U(t){if(typeof t.uid!=="number"||!Number.isSafeInteger(t.uid)||t.uid<=0)throw new A("Set up a background service as your own user, not with sudo.");return`gui/${t.uid}`}function ds(t){let{config:e,launcher:r,host:o}=t,s=t.kind??"serve",a=Xt(e,o,s),c=a!==null&&o.insideService?.(a.label)===!0,i=B(e,o,s,c?it:P);if(!i)throw new A("A background service needs macOS (launchd) or Linux (systemd --user).");if(o.platform==="darwin")U(o);if(o.platform==="linux"&&o.command("systemctl",["--user","show-environment"])!==0)throw new A("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let n=o.platform==="darwin"?hr(e,s,i,r,o,t.path):null;if(Z(i.definition,n?n.plist:Lr(e,s,i,r,o.home,t.path)),Ht(e,o,i,c?null:a),n)return n.identity?i:{...i,identityProblem:Nr};return{...i,lingering:o.command("loginctl",["enable-linger"])===0}}function Ht(t,e,r,o){if(e.platform==="darwin"){let c=U(e);if(o)e.command("/bin/launchctl",["bootout",`${c}/${o.label}`]);if(Kt(t,r,e)){if(o)g(o.definition,{force:!0});return}if(g(r.definition,{force:!0}),o)e.command("/bin/launchctl",["bootstrap",c,o.definition]);throw new A("Could not start the background service (launchctl bootstrap failed).")}let s=`${r.label}.service`,a=o?`${o.label}.service`:null;if(e.command("systemctl",["--user","daemon-reload"])!==0||a!==null&&e.command("systemctl",["--user","disable","--now",a])!==0||e.command("systemctl",["--user","enable",s])!==0||e.command("systemctl",["--user","restart",s])!==0){if(e.command("systemctl",["--user","disable",s]),g(r.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),a)e.command("systemctl",["--user","enable","--now",a]);throw new A("Could not start the background service (systemctl --user failed).")}if(o)g(o.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function Kt(t,e,r){let o=U(r);r.command("/bin/launchctl",["bootout",`${o}/${e.label}`]);let s=(Math.ceil(t.shutdownGraceMs/1000)+10)*1000;for(let a=0,c=100;;c=Math.min(c*2,2000)){if(r.command("/bin/launchctl",["bootstrap",o,e.definition])===0)return!0;if(a>=s)return!1;r.sleep(c),a+=c}}function fs(t,e,r){let o=ct(t,e,r);if(!o)return null;let s=e.insideService?.(o.label)===!0;if(e.platform==="darwin"&&!s)Ir(o.definition,e);let a=B(t,e,r);if(a&&o.label!==a.label&&!s)return Z(a.definition,M(o.definition,"utf8").replaceAll(o.label,a.label)),Ht(t,e,a,o),a;let c=e.platform==="darwin"&&s,i;if(c)i=e.command("/bin/launchctl",["kickstart","-k",`${U(e)}/${o.label}`])===0;else if(e.platform==="darwin")i=Kt(t,o,e);else e.command("systemctl",["--user","enable",`${o.label}.service`]),i=e.command("systemctl",["--user","restart",`${o.label}.service`])===0;if(!i)throw new A(`Could not restart the background service ${o.label}.`);if(a&&o.label===a.label)Rr(t,e,r);return o}function ls(t,e,r,o){let s=ct(t,r,o),a=B(e,r,o);if(r.platform!=="darwin"||!s||!a)return;let c=`<string>${N(s.logs)}</string>`,i=M(s.definition,"utf8");if(i.includes(c))Z(s.definition,i.replaceAll(c,`<string>${N(a.logs)}</string>`))}function _s(t,e,r="serve"){let o=Yt(t,e,r);for(let s of o){if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${s.label}`]);g(s.definition,{force:!0});continue}e.command("systemctl",["--user","disable","--now",`${s.label}.service`]),g(s.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}return o[0]??null}var kr=Zr(Jr),Vt="x-apple.systempreferences:com.apple.preference.security",Qr={accessibility:`${Vt}?Privacy_Accessibility`,screen:`${Vt}?Privacy_ScreenCapture`},Yr=64,h=new Map;function Q(t,e){let r=h.get(t);if(r?.has(e))return!1;if(!r){if(h.size>=Yr)h.delete(h.keys().next().value);r=new Set,h.set(t,r)}return r.add(e),!0}function Xr(){let t=T(),e=jt(zt(t),process.env),r=Pr(t,".local","share","reason","desktop-install.log");Dr(k(r),{recursive:!0,mode:448});let o=Mr(r,"a",384);try{let s=zr(e,["desktop","install"],{detached:!0,stdio:["ignore",o,o],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{jr(o)}}var Y={open:async(t,e)=>{await kr("/usr/bin/open",t,{signal:e,timeout:1e4,maxBuffer:8192})},request:(t,e)=>re(t,e),tile:oe,installDesktop:Xr},Et=!1;async function vt(t,e,r){try{await e.open(["-a","Google Chrome",t],r)}catch{r.throwIfAborted(),await e.open([t],r)}}async function se(t,e,r,o){if(await r.open([Qr[e]],o).catch(()=>{}),t[0]&&!o.aborted)r.tile(k(k(k(t[0]))),e)}async function Wr(t,e,r,o,s){for(let a of r){if(!Q(t,`grant:${a}`))continue;s.throwIfAborted(),await o.request(e,a).catch(()=>null),await se(e,a,o,s)}}var Hr={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension, whose Chrome Web Store page Reason opened for the user.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function te(t){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...t}))}}function Kr(t){if(typeof t!=="string")return null;try{let e=new URL(t);return e.protocol==="https:"||e.protocol==="http:"?e.href:null}catch{return null}}async function nt(t,e=Y){let{call:r,runId:o,signal:s}=t;if(t.desktopMissing&&!Et){Et=!0;try{e.installDesktop()}catch{}}if(r.kind==="computer"){if(t.identity.length>0&&Q(o,"grant:probe")){let i=await e.request(t.identity).catch(()=>null),n=i?[...i.accessibility?[]:["accessibility"],...i.screen?[]:["screen"]]:[];for(let f of n)Q(o,`grant:${f}`);for(let f of n)await se(t.identity,f,e,s)}throw new _("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(Q(o,"page:chrome-extension"))await vt(ee,e,s).catch(()=>{});if(r.operation==="discover")return te({result:{tools:[Hr]}});let a=r.arguments,c=r.operation==="call"&&r.tool==="open_tab"&&a&&typeof a==="object"&&!Array.isArray(a)?Kr(a.url):null;if(!c)throw new _("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await vt(c,e,s),te({result:{content:[{type:"text",text:JSON.stringify({opened:c,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ae(t,e=Y){if(t.call.kind!=="computer"||t.call.operation!=="permission_status"||t.output.code!==0||t.identity.length===0)return t.output;let r;try{r=JSON.parse(t.output.stdout.toString("utf8"))}catch{return t.output}if(!r||typeof r!=="object"||Array.isArray(r))return t.output;let o=r.permissions;if(!o||typeof o!=="object")return t.output;let s=o,a=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(a.length===0)return t.output;return await Wr(t.runId,t.identity,a,e,t.signal),{...t.output,stdout:Buffer.from(JSON.stringify({...r,requested:a}))}}var mt=172032,ao=18874368,io=8192,co=65536,no=55000,fo=60000,lo=4,_o=40000,uo=/^[0-9a-f-]{36}$/,de=yt,mo=ye();function W(t){return Boolean(t)&&typeof t==="object"&&!Array.isArray(t)}function H(){throw new _("invalid_automation_request","Reason automation request is malformed.")}function Ne(t){let e=Object.keys(t).sort().join(",");if(e==="call"||e==="browser,call"){let r=t.call,o=e==="browser,call";if(!W(r)||r.version!==1||r.kind!=="computer"&&r.kind!=="browser"||o&&(t.browser!==me||r.kind!=="browser")||JSON.stringify(r).length>co)H();return{call:r,userChrome:o}}if(e==="offset,output_id"){if(typeof t.output_id!=="string"||!uo.test(t.output_id)||!Number.isSafeInteger(t.offset)||t.offset<0)H();return{output_id:t.output_id,offset:t.offset}}return H()}function Ys(t=process.platform,e=$){if(t==="darwin")return!0;return t==="linux"&&e()?.features.computer===!0}var bo="__computer-use";function wo(t){let e=(r)=>r?"granted":"missing";return`Permissions: accessibility=${e(t.accessibility)}, screenRecording=${e(t.screen)}
755
- `}function xo(t,e,r,o={stdin:process.stdin,stdout:process.stdout}){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:["pipe","pipe","inherit"]}),c=(d)=>{a.kill(d)},i=["SIGTERM","SIGINT","SIGHUP"];for(let d of i)process.on(d,c);o.stdin.pipe(a.stdin),a.stdin.on("error",()=>{return}),a.stdout.pipe(o.stdout,{end:!1});let n=!1,f=(d)=>{if(n)return;n=!0;for(let l of i)process.off(l,c);o.stdin.unpipe(a.stdin),o.stdout.write("",()=>s(d))};a.once("error",()=>f(127)),a.once("close",(d)=>f(d??1))})}async function Xs(t,e={}){let r=e.stderr??process.stderr,o=(e.identity??wt)(),s=(e.components??$)();if(o.length===0||s?.platform!=="darwin-arm64")return r.write(`Reason computer use: Reason's background identity cannot run Open Computer Use here (computer_use_identity_unavailable)
756
- `),1;if(t.length===1&&t[0]==="doctor"){let i=await(e.grants??Se)(o);if(!i)return r.write(`Reason computer use: Reason's permissions could not be read (computer_use_permission_status_unavailable)
755
+ `}function Q(t,e){Ar(Tr(t),{recursive:!0,mode:448});let r=`${t}.${pr()}.tmp`;try{gr(r,e,{mode:384,flag:"wx"}),yr(r,384),Nr(r,t)}finally{N(r,{force:!0})}}function L(t){if(typeof t.uid!=="number"||!Number.isSafeInteger(t.uid)||t.uid<=0)throw new A("Set up a background service as your own user, not with sudo.");return`gui/${t.uid}`}function ls(t){let{config:e,launcher:r,host:o}=t,s=t.kind??"serve",a=Wt(e,o,s),c=a!==null&&o.insideService?.(a.label)===!0,i=T(e,o,s,c?nt:h);if(!i)throw new A("A background service needs macOS (launchd) or Linux (systemd --user).");if(o.platform==="darwin")L(o);if(o.platform==="linux"&&o.command("systemctl",["--user","show-environment"])!==0)throw new A("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let d=o.platform==="darwin"?Kt(e,s,i,r,o,t.path):null;if(Q(i.definition,d?d.plist:Vt(e,s,i,r,o.home,t.path)),Et(e,o,i,c?null:a),d)return d.identity?i:{...i,identityProblem:qr};return{...i,lingering:o.command("loginctl",["enable-linger"])===0}}function Et(t,e,r,o){if(e.platform==="darwin"){let c=L(e);if(o)e.command("/bin/launchctl",["bootout",`${c}/${o.label}`]);if(vt(t,r,e)){if(o)N(o.definition,{force:!0});return}if(N(r.definition,{force:!0}),o)e.command("/bin/launchctl",["bootstrap",c,o.definition]);throw new A("Could not start the background service (launchctl bootstrap failed).")}let s=`${r.label}.service`,a=o?`${o.label}.service`:null;if(e.command("systemctl",["--user","daemon-reload"])!==0||a!==null&&e.command("systemctl",["--user","disable","--now",a])!==0||e.command("systemctl",["--user","enable",s])!==0||e.command("systemctl",["--user","restart",s])!==0){if(e.command("systemctl",["--user","disable",s]),N(r.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),a)e.command("systemctl",["--user","enable","--now",a]);throw new A("Could not start the background service (systemctl --user failed).")}if(o)N(o.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function vt(t,e,r){let o=L(r);r.command("/bin/launchctl",["bootout",`${o}/${e.label}`]);let s=(Math.ceil(t.shutdownGraceMs/1000)+10)*1000;for(let a=0,c=100;;c=Math.min(c*2,2000)){if(r.command("/bin/launchctl",["bootstrap",o,e.definition])===0)return!0;if(a>=s)return!1;r.sleep(c),a+=c}}function _s(t,e,r){let o=dt(t,e,r);if(!o)return null;let s=e.insideService?.(o.label)===!0;if(e.platform==="darwin"&&!s)Fr(o.definition,e);let a=T(t,e,r);if(a&&o.label!==a.label&&!s)return Q(a.definition,U(o.definition,"utf8").replaceAll(o.label,a.label)),Et(t,e,a,o),a;let c=e.platform==="darwin"&&s,i;if(c)i=e.command("/bin/launchctl",["kickstart","-k",`${L(e)}/${o.label}`])===0;else if(e.platform==="darwin")i=vt(t,o,e);else e.command("systemctl",["--user","enable",`${o.label}.service`]),i=e.command("systemctl",["--user","restart",`${o.label}.service`])===0;if(!i)throw new A(`Could not restart the background service ${o.label}.`);if(a&&o.label===a.label)Ur(t,e,r);return o}function us(t,e,r,o){let s=dt(t,r,o),a=T(e,r,o);if(r.platform!=="darwin"||!s||!a)return;let c=`<string>${O(s.logs)}</string>`,i=U(s.definition,"utf8");if(i.includes(c))Q(s.definition,i.replaceAll(c,`<string>${O(a.logs)}</string>`))}function ms(t,e,r="serve"){let o=Xt(t,e,r);for(let s of o){if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${s.label}`]);N(s.definition,{force:!0});continue}e.command("systemctl",["--user","disable","--now",`${s.label}.service`]),N(s.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}return o[0]??null}var Qr=hr(zr),te="x-apple.systempreferences:com.apple.preference.security",kr={accessibility:`${te}?Privacy_Accessibility`,screen:`${te}?Privacy_ScreenCapture`},Yr=64,J=new Map;function Y(t,e){let r=J.get(t);if(r?.has(e))return!1;if(!r){if(J.size>=Yr)J.delete(J.keys().next().value);r=new Set,J.set(t,r)}return r.add(e),!0}function Xr(){let t=q(),e=Pt(Mt(t),process.env),r=Zr(t,".local","share","reason","desktop-install.log");Mr(k(r),{recursive:!0,mode:448});let o=Pr(r,"a",384);try{let s=jr(e,["desktop","install"],{detached:!0,stdio:["ignore",o,o],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{Dr(o)}}var X={open:async(t,e)=>{await Qr("/usr/bin/open",t,{signal:e,timeout:1e4,maxBuffer:8192})},request:(t,e)=>ae(t,e),tile:ie,installDesktop:Xr},ee=!1;async function re(t,e,r){try{await e.open(["-a","Google Chrome",t],r)}catch{r.throwIfAborted(),await e.open([t],r)}}async function ce(t,e,r,o){if(await r.open([kr[e]],o).catch(()=>{}),t[0]&&!o.aborted)r.tile(k(k(k(t[0]))),e)}async function Wr(t,e,r,o,s){for(let a of r){if(!Y(t,`grant:${a}`))continue;s.throwIfAborted(),await o.request(e,a).catch(()=>null),await ce(e,a,o,s)}}var Hr={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension, whose Chrome Web Store page Reason opened for the user.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function oe(t){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...t}))}}function Kr(t){if(typeof t!=="string")return null;try{let e=new URL(t);return e.protocol==="https:"||e.protocol==="http:"?e.href:null}catch{return null}}async function ft(t,e=X){let{call:r,runId:o,signal:s}=t;if(t.desktopMissing&&!ee){ee=!0;try{e.installDesktop()}catch{}}if(r.kind==="computer"){if(t.identity.length>0&&Y(o,"grant:probe")){let i=await e.request(t.identity).catch(()=>null),d=i?[...i.accessibility?[]:["accessibility"],...i.screen?[]:["screen"]]:[];for(let f of d)Y(o,`grant:${f}`);for(let f of d)await ce(t.identity,f,e,s)}throw new _("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(Y(o,"page:chrome-extension"))await re(se,e,s).catch(()=>{});if(r.operation==="discover")return oe({result:{tools:[Hr]}});let a=r.arguments,c=r.operation==="call"&&r.tool==="open_tab"&&a&&typeof a==="object"&&!Array.isArray(a)?Kr(a.url):null;if(!c)throw new _("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await re(c,e,s),oe({result:{content:[{type:"text",text:JSON.stringify({opened:c,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ne(t,e=X){if(t.call.kind!=="computer"||t.call.operation!=="permission_status"||t.output.code!==0||t.identity.length===0)return t.output;let r;try{r=JSON.parse(t.output.stdout.toString("utf8"))}catch{return t.output}if(!r||typeof r!=="object"||Array.isArray(r))return t.output;let o=r.permissions;if(!o||typeof o!=="object")return t.output;let s=o,a=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(a.length===0)return t.output;return await Wr(t.runId,t.identity,a,e,t.signal),{...t.output,stdout:Buffer.from(JSON.stringify({...r,requested:a}))}}var wt=172032,ao=18874368,io=8192,co=65536,no=55000,fo=60000,lo=4,_o=40000,uo=/^[0-9a-f-]{36}$/,_e=Nt,mo=Oe();function H(t){return Boolean(t)&&typeof t==="object"&&!Array.isArray(t)}function K(){throw new _("invalid_automation_request","Reason automation request is malformed.")}function qe(t){let e=Object.keys(t).sort().join(",");if(e==="call"||e==="browser,call"){let r=t.call,o=e==="browser,call";if(!H(r)||r.version!==1||r.kind!=="computer"&&r.kind!=="browser"||o&&(t.browser!==xe||r.kind!=="browser")||JSON.stringify(r).length>co)K();return{call:r,userChrome:o}}if(e==="offset,output_id"){if(typeof t.output_id!=="string"||!uo.test(t.output_id)||!Number.isSafeInteger(t.offset)||t.offset<0)K();return{output_id:t.output_id,offset:t.offset}}return K()}function Ws(t=process.platform,e=$){if(t==="darwin")return!0;return t==="linux"&&e()?.features.computer===!0}var bo="__computer-use";function wo(t){let e=(r)=>r?"granted":"missing";return`Permissions: accessibility=${e(t.accessibility)}, screenRecording=${e(t.screen)}
756
+ `}function xo(t,e,r,o={stdin:process.stdin,stdout:process.stdout}){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:["pipe","pipe","inherit"]}),c=(n)=>{a.kill(n)},i=["SIGTERM","SIGINT","SIGHUP"];for(let n of i)process.on(n,c);o.stdin.pipe(a.stdin),a.stdin.on("error",()=>{return}),a.stdout.pipe(o.stdout,{end:!1});let d=!1,f=(n)=>{if(d)return;d=!0;for(let l of i)process.off(l,c);o.stdin.unpipe(a.stdin),o.stdout.write("",()=>s(n))};a.once("error",()=>f(127)),a.once("close",(n)=>f(n??1))})}async function Hs(t,e={}){let r=e.stderr??process.stderr,o=(e.identity??St)(),s=(e.components??$)();if(o.length===0||s?.platform!=="darwin-arm64")return r.write(`Reason computer use: Reason's background identity cannot run Open Computer Use here (computer_use_identity_unavailable)
757
+ `),1;if(t.length===1&&t[0]==="doctor"){let i=await(e.grants??Ae)(o);if(!i)return r.write(`Reason computer use: Reason's permissions could not be read (computer_use_permission_status_unavailable)
757
758
  `),1;return(e.stdout??process.stdout).write(wo(i)),0}if(t.length!==1||t[0]!=="mcp")return r.write(`Usage: reason __computer-use mcp|doctor
758
- `),2;let[a,...c]=o;return(e.run??xo)(a,[...c,s.ocu,"mcp"],{...process.env,OPEN_COMPUTER_USE_DISABLE_APP_AGENT_PROXY:"1"})}function Ws(t=$){return t()?.userChrome??{code:"user_chrome_browser_use_missing"}}function Oe(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:"ignore"}),c=setTimeout(()=>{a.kill("SIGKILL"),s(-1)},o);a.once("error",()=>{clearTimeout(c),s(-1)}),a.once("exit",(i)=>{clearTimeout(c),s(i??-1)})})}function So(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:["ignore","pipe","ignore"]}),c="";a.stdout.setEncoding("utf8").on("data",(n)=>{c+=n});let i=setTimeout(()=>{a.kill("SIGKILL"),s(null)},o);a.once("error",()=>{clearTimeout(i),s(null)}),a.once("close",(n)=>{clearTimeout(i),s(n===0?c:null)})})}var po="/tmp/open-browser-use",yo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Ao=33554432;function go(t,e){let r;try{r=t===null?null:JSON.parse(t)}catch{return null}let o=W(r)&&W(r.result)?r.result.metadata:null;if(!W(o)||o.extensionId!==e)return null;return typeof o.extensionInstanceId==="string"&&yo.test(o.extensionInstanceId)?o.extensionInstanceId:null}async function Te(t,e,r){let o=r.storages.map((i)=>{try{return K(i).filter((n)=>n.endsWith(".log")||n.endsWith(".ldb")).map((n)=>b(i,n))}catch{return[]}}),s;try{s=o.some((i)=>i.length>0)?K(r.socketDir).filter((i)=>i.endsWith(".sock")):[]}catch{return[]}let a=[];for(let i of s){let n=b(r.socketDir,i),f=go(await So(t,["info","--socket",n,"--timeout","2s"],e,5000),r.extensionId);if(f)a.push({instance:f,socket:n})}let c=[];for(let[i,n]of(a.length>0?o:[]).entries())for(let f of n)try{if(oo(f).size>Ao)continue;let d=Ae(f),l=a.find((m)=>d.includes(m.instance));if(l){c.push({storage:r.storages[i],...l});break}}catch{}return c}async function No(t,e,r){return(await Te(t,e,r))[0]?.instance??null}function qe(t,e,r){return No(t,e,{socketDir:po,extensionId:lt,storages:[b(r,"browser-profile","Default","Local Extension Settings",lt)]})}var fe=/^(Default|Profile ([0-9]+))$/;async function Oo(t,e,r=T(),o=xt){let s=b(r,"Library","Application Support","Google","Chrome"),a=[];try{a=K(s)}catch(d){if(d.code==="EPERM")throw new _("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let c=(d)=>Number(fe.exec(d)?.[2]??-1),i=a.filter((d)=>fe.test(d)&&_t(b(s,d,"Extensions",X))).sort((d,l)=>c(d)-c(l)),n=(d)=>b(s,d,"Local Extension Settings",X);return(await Te(t,e,{socketDir:o,extensionId:X,storages:i.map(n)})).map(({storage:d,instance:l,socket:m})=>({profile:i.find((u)=>n(u)===d),instance:l,socket:m}))}async function To(t,e,r=T(),o=xt){let s=(await Oo(t,e,r,o))[0]?.instance;if(!s)throw new _("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function le(t){return new Promise((e)=>{let r=so({path:t}),o=(s)=>{r.destroy(),e(s)};r.setTimeout(1000,()=>o(!1)),r.once("error",()=>o(!1)),r.once("connect",()=>o(!0))})}async function Ce(t,e){let r=Date.now()+e;while(Date.now()<r){if(await t())return!0;await new Promise((o)=>setTimeout(o,200))}return!1}var dt=new Map;function ft(t,e){let r=dt.get(t);if(!r)r=e().finally(()=>dt.delete(t)),dt.set(t,r);return r}async function qo(t,e){if(await le(t))return;if(ro(t,{force:!0}),await Oe("dbus-daemon",["--session",`--address=unix:path=${t}`,"--fork"],e,1e4)!==0||!await Ce(()=>le(t),5000))throw new _("automation_unavailable","Reason could not start the desktop session bus.")}async function _e(t,e,r){let o=t.platform==="darwin-arm64"?async()=>await qe(t.nativeHost,e,r)!==null:async()=>await Oe(t.nativeHost,["info"],e,5000)===0;if(await o())return;let s=["--profile-directory=Default",`--load-extension=${t.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],a,c=null,i=0;if(t.platform==="darwin-arm64"){let d=b(r,"browser-profile");L(d);let l=b(d,"NativeMessagingHosts");ce(l,{recursive:!0,mode:448});let m=bt(t.platform).nativeHostManifests[0];ie(m,b(l,ne(m)));let u=t.browser.slice(0,t.browser.indexOf(".app/")+4),S=s.filter((C)=>C!=="about:blank").concat("--no-startup-window","--use-mock-keychain");a=I("/usr/bin/open",["-g","-n","-a",u,"--args",`--user-data-dir=${d}`,...S],{env:e,stdio:"ignore"})}else{let d=b(e.HOME,".config","google-chrome"),l=b(d,"NativeMessagingHosts");ce(l,{recursive:!0,mode:448});let m=bt(t.platform).nativeHostManifests[0];ie(m,b(l,ne(m)));let u=process.geteuid?.()===0?["--no-sandbox"]:[];c=b(r,"browser.log");let S=vr(c,"a",384);i=Er(S).size,a=I(t.browser,[`--user-data-dir=${d}`,...s,...u,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",S,S],env:{...e,ACCESSIBILITY_ENABLED:"1"}}),Vr(S)}let n=!1;a.once("error",()=>{n=!0}),a.once("exit",(d)=>{n||=d!==0}),a.unref();let f=!1;if(await Ce(async()=>n||(f=await o()),_o),!f){if(c&&Ae(c).subarray(i).toString("utf8").includes("No usable sandbox"))throw new _("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new _("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Hs(t){await $e(t,!0)}function Ks(t){return Be(t,Ie(t))}function Be(t,e){return t.platform==="darwin-arm64"?b(e,"browser-profile"):b(e,"home",".config","google-chrome")}function Ie(t){let e=b(t.root,"automation");if(!_t(e)||!Co(t.automation))return t.automation;if(!Bo(Be(t,e)))try{eo(e,t.automation)}catch{}return _t(e)?e:t.automation}function Co(t){try{return K(t).length===0}catch(e){return e.code==="ENOENT"}}function Bo(t){let e;try{e=to(b(t,"SingletonLock"))}catch{return!1}let r=Number(e.slice(e.lastIndexOf("-")+1));if(!Number.isSafeInteger(r)||r<=0)return!0;try{return process.kill(r,0),!0}catch(o){return o.code==="EPERM"}}async function $e(t,e){we({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let r=Ie(t);L(r);let o=ge().username,s={USER:o,LOGNAME:o,REASON_AUTOMATION_OCU:t.ocu,REASON_AUTOMATION_OBU:t.nativeHost};if(t.platform==="darwin-arm64"){let d={...s,HOME:T(),PATH:`${ut(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:bo};if(!e)return d;await ft("browser",()=>_e(t,d,r));let l=await qe(t.nativeHost,d,r);if(!l)throw new _("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...d,REASON_AUTOMATION_OBU_INSTANCE:l,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let a=await Ge(),c=b(r,"home"),i=b(r,"runtime");L(c),L(i);let n=b(r,"bus"),f={...s,HOME:c,PATH:`${ut(t.node)}:/usr/bin:/bin`,DISPLAY:a.display,XAUTHORITY:a.xauthority,XDG_RUNTIME_DIR:i,DBUS_SESSION_BUS_ADDRESS:`unix:path=${n}`,...a.sound?{PULSE_SERVER:pe(a.sound)}:{}};if(await ft("bus",()=>qo(n,f)),e)await ft("browser",()=>_e(t,f,r));return f}async function Io(t,e,r){let o=ge().username,s={USER:o,LOGNAME:o,HOME:T(),PATH:`${ut(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:e,REASON_AUTOMATION_BACKGROUND_TABS:"1"},a=await To(e,s);return r.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:a}}function Fe(t,e,r,o){if(typeof de!=="string")return Promise.reject(new _("automation_unavailable","This Reason build has no automation runtime."));let s=de;return new Promise((a,c)=>{let i=I(t,["--input-type=module","--eval",s],{env:{...e,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:!0}),n=[],f=0,d="",l=null,m=!1,u=(w)=>{l??=w;try{process.kill(-i.pid,"SIGKILL")}catch{i.kill("SIGKILL")}},S=(w)=>{if(m)return;m=!0,clearTimeout(C),o.removeEventListener("abort",O),w()},C=setTimeout(()=>u(new _("automation_timed_out","Reason automation did not finish in time.")),no),O=()=>u(new _("cancelled","Reason cancelled the automation call."));if(o.addEventListener("abort",O,{once:!0}),i.stdout.on("data",(w)=>{if(f+=w.byteLength,f>ao)u(new _("automation_output_too_large","Reason automation output is too large."));else n.push(w)}),i.stderr.setEncoding("utf8").on("data",(w)=>{d=(d+w).slice(-io)}),i.stdin.on("error",()=>{}),i.once("error",()=>S(()=>c(l??new _("automation_unavailable","Reason could not start the automation runtime.")))),i.once("close",(w)=>S(()=>{if(l)c(l);else a({code:w??1,stdout:Buffer.concat(n),stderr:d})})),o.aborted)O();i.stdin.end(r)})}var q=new Map;function $o(t,e,r){for(let[s,a]of q)if(a.expiresAt<=r)q.delete(s);while(q.size>=lo)q.delete(q.keys().next().value);let o=ye();return q.set(o,{runId:t,bytes:e,expiresAt:r+fo}),o}async function Re(t,e,r,o={}){let s=await(o.environment??$e)(t,e.kind==="browser");return r.throwIfAborted(),await(o.runtime??Fe)(t.node,s,JSON.stringify(e),r)}async function Vs(t,e){let r=Ne({call:t});if(!("call"in r))H();let o=$();if(!o?.features.computer||r.call.kind==="browser"&&!o.features.browser)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Re(o,r.call,e)}function ue(t,e,r){let o=t.stdout.byteLength>mt?$o(e,t.stdout,r):void 0;return{code:t.code,stderr:t.stderr,instance_id:mo,output_bytes:t.stdout.byteLength,chunk:t.stdout.subarray(0,mt).toString("base64"),...o?{output_id:o}:{}}}async function Es(t,e={}){let r=Ne(t.payload),o=(e.now??Date.now)();if("output_id"in r){let u=q.get(r.output_id);if(!u||u.runId!==t.runId||u.expiresAt<=o||r.offset>u.bytes.byteLength)throw new _("automation_output_unavailable","Reason automation output expired.");return{chunk:u.bytes.subarray(r.offset,r.offset+mt).toString("base64")}}let s=(e.components??$)(),a=(e.platform??process.platform)==="darwin",c=a?(e.macIdentity??wt)():[],i=e.macSetup??Y,n=!s?.features.computer||r.call.kind==="browser"&&!r.userChrome&&!s.features.browser;if(a&&(n||c.length===0||r.call.kind==="browser"&&r.userChrome&&!t.userChrome))return ue(await nt({runId:t.runId,call:r.call,identity:c,desktopMissing:n,signal:t.signal},i),t.runId,o);if(!s?.features.computer)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let f=r.userChrome?t.userChrome:void 0;if(r.userChrome&&!f)throw new _("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(r.call.kind==="browser"&&!f&&!s.features.browser)throw new _("automation_browser_not_installed",s.platform==="darwin-arm64"?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");t.signal.throwIfAborted();let d=await xe(t.runId,t.signal,e.now),l="account"in e?e.account??null:be(),m;try{if(f){let u=await(e.userChromeEnvironment??Io)(s,f,t.signal);t.signal.throwIfAborted(),m=await(e.runtime??Fe)(s.node,u,JSON.stringify(r.call),t.signal)}else if(l)m=await(e.delegate??At)(l,r.call,t.signal);else m=await Re(s,r.call,t.signal,e)}catch(u){if(!a||!(u instanceof _)||u.code!=="automation_user_chrome_not_connected")throw u;m=await nt({runId:t.runId,call:r.call,identity:c,desktopMissing:!1,signal:t.signal},i)}finally{d()}if(a)m=await ae({runId:t.runId,call:r.call,identity:c,output:m,signal:t.signal},i);return ue(m,t.runId,o)}
759
- export{Gt as lc,at as mc,zt as nc,A as oc,jt as pc,cs as qc,Qt as rc,ns as sc,ct as tc,Rr as uc,ds as vc,fs as wc,ls as xc,_s as yc,Qe as zc,mt as Ac,Ne as Bc,Ys as Cc,xo as Dc,Xs as Ec,Ws as Fc,Oo as Gc,To as Hc,Hs as Ic,Ks as Jc,Vs as Kc,Es as Lc};
759
+ `),2;let[a,...c]=o;return(e.run??xo)(a,[...c,s.ocu,"mcp"],{...process.env,OPEN_COMPUTER_USE_DISABLE_APP_AGENT_PROXY:"1"})}function Ks(t=$){return t()?.userChrome??{code:"user_chrome_browser_use_missing"}}function Ce(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:"ignore"}),c=setTimeout(()=>{a.kill("SIGKILL"),s(-1)},o);a.once("error",()=>{clearTimeout(c),s(-1)}),a.once("exit",(i)=>{clearTimeout(c),s(i??-1)})})}function So(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:["ignore","pipe","ignore"]}),c="";a.stdout.setEncoding("utf8").on("data",(d)=>{c+=d});let i=setTimeout(()=>{a.kill("SIGKILL"),s(null)},o);a.once("error",()=>{clearTimeout(i),s(null)}),a.once("close",(d)=>{clearTimeout(i),s(d===0?c:null)})})}var po="/tmp/open-browser-use",yo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Ao=33554432;function No(t,e){let r;try{r=t===null?null:JSON.parse(t)}catch{return null}let o=H(r)&&H(r.result)?r.result.metadata:null;if(!H(o)||o.extensionId!==e)return null;return typeof o.extensionInstanceId==="string"&&yo.test(o.extensionInstanceId)?o.extensionInstanceId:null}async function Be(t,e,r){let o=r.storages.map((i)=>{try{return V(i).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>b(i,d))}catch{return[]}}),s;try{s=o.some((i)=>i.length>0)?V(r.socketDir).filter((i)=>i.endsWith(".sock")):[]}catch{return[]}let a=[];for(let i of s){let d=b(r.socketDir,i),f=No(await So(t,["info","--socket",d,"--timeout","2s"],e,5000),r.extensionId);if(f)a.push({instance:f,socket:d})}let c=[];for(let[i,d]of(a.length>0?o:[]).entries())for(let f of d)try{if(oo(f).size>Ao)continue;let n=ge(f),l=a.find((u)=>n.includes(u.instance));if(l){c.push({storage:r.storages[i],...l});break}}catch{}return c}async function Oo(t,e,r){return(await Be(t,e,r))[0]?.instance??null}function Ie(t,e,r){return Oo(t,e,{socketDir:po,extensionId:ut,storages:[b(r,"browser-profile","Default","Local Extension Settings",ut)]})}var ue=/^(Default|Profile ([0-9]+))$/;async function go(t,e,r=q(),o=pt){let s=b(r,"Library","Application Support","Google","Chrome"),a=[];try{a=V(s)}catch(n){if(n.code==="EPERM")throw new _("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let c=(n)=>Number(ue.exec(n)?.[2]??-1),i=a.filter((n)=>ue.test(n)&&mt(b(s,n,"Extensions",W))).sort((n,l)=>c(n)-c(l)),d=(n)=>b(s,n,"Local Extension Settings",W);return(await Be(t,e,{socketDir:o,extensionId:W,storages:i.map(d)})).map(({storage:n,instance:l,socket:u})=>({profile:i.find((m)=>d(m)===n),instance:l,socket:u}))}async function To(t,e,r=q(),o=pt){let s=(await go(t,e,r,o))[0]?.instance;if(!s)throw new _("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function me(t){return new Promise((e)=>{let r=so({path:t}),o=(s)=>{r.destroy(),e(s)};r.setTimeout(1000,()=>o(!1)),r.once("error",()=>o(!1)),r.once("connect",()=>o(!0))})}async function $e(t,e){let r=Date.now()+e;while(Date.now()<r){if(await t())return!0;await new Promise((o)=>setTimeout(o,200))}return!1}var lt=new Map;function _t(t,e){let r=lt.get(t);if(!r)r=e().finally(()=>lt.delete(t)),lt.set(t,r);return r}async function qo(t,e){if(await me(t))return;if(ro(t,{force:!0}),await Ce("dbus-daemon",["--session",`--address=unix:path=${t}`,"--fork"],e,1e4)!==0||!await $e(()=>me(t),5000))throw new _("automation_unavailable","Reason could not start the desktop session bus.")}async function be(t,e,r){let o=t.platform==="darwin-arm64"?async()=>await Ie(t.nativeHost,e,r)!==null:async()=>await Ce(t.nativeHost,["info"],e,5000)===0;if(await o())return;let s=["--profile-directory=Default",`--load-extension=${t.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],a,c=null,i=0;if(t.platform==="darwin-arm64"){let n=b(r,"browser-profile");z(n);let l=b(n,"NativeMessagingHosts");fe(l,{recursive:!0,mode:448});let u=xt(t.platform).nativeHostManifests[0];de(u,b(l,le(u)));let m=t.browser.slice(0,t.browser.indexOf(".app/")+4),S=s.filter((B)=>B!=="about:blank").concat("--no-startup-window","--use-mock-keychain");a=I("/usr/bin/open",["-g","-n","-a",m,"--args",`--user-data-dir=${n}`,...S],{env:e,stdio:"ignore"})}else{let n=b(e.HOME,".config","google-chrome"),l=b(n,"NativeMessagingHosts");fe(l,{recursive:!0,mode:448});let u=xt(t.platform).nativeHostManifests[0];de(u,b(l,le(u)));let m=process.geteuid?.()===0?["--no-sandbox"]:[];c=b(r,"browser.log");let S=vr(c,"a",384);i=Er(S).size,a=I(t.browser,[`--user-data-dir=${n}`,...s,...m,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",S,S],env:{...e,ACCESSIBILITY_ENABLED:"1"}}),Vr(S)}let d=!1;a.once("error",()=>{d=!0}),a.once("exit",(n)=>{d||=n!==0}),a.unref();let f=!1;if(await $e(async()=>d||(f=await o()),_o),!f){if(c&&ge(c).subarray(i).toString("utf8").includes("No usable sandbox"))throw new _("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new _("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Vs(t){await Ge(t,!0)}function Es(t){return Fe(t,Re(t))}function Fe(t,e){return t.platform==="darwin-arm64"?b(e,"browser-profile"):b(e,"home",".config","google-chrome")}function Re(t){let e=b(t.root,"automation");if(!mt(e)||!Co(t.automation))return t.automation;if(!Bo(Fe(t,e)))try{eo(e,t.automation)}catch{}return mt(e)?e:t.automation}function Co(t){try{return V(t).length===0}catch(e){return e.code==="ENOENT"}}function Bo(t){let e;try{e=to(b(t,"SingletonLock"))}catch{return!1}let r=Number(e.slice(e.lastIndexOf("-")+1));if(!Number.isSafeInteger(r)||r<=0)return!0;try{return process.kill(r,0),!0}catch(o){return o.code==="EPERM"}}async function Ge(t,e){pe({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let r=Re(t);z(r);let o=Te().username,s={USER:o,LOGNAME:o,REASON_AUTOMATION_OCU:t.ocu,REASON_AUTOMATION_OBU:t.nativeHost};if(t.platform==="darwin-arm64"){let n={...s,HOME:q(),PATH:`${bt(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:bo};if(!e)return n;await _t("browser",()=>be(t,n,r));let l=await Ie(t.nativeHost,n,r);if(!l)throw new _("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...n,REASON_AUTOMATION_OBU_INSTANCE:l,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let a=await Je(),c=b(r,"home"),i=b(r,"runtime");z(c),z(i);let d=b(r,"bus"),f={...s,HOME:c,PATH:`${bt(t.node)}:/usr/bin:/bin`,DISPLAY:a.display,XAUTHORITY:a.xauthority,XDG_RUNTIME_DIR:i,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...a.sound?{PULSE_SERVER:Ne(a.sound)}:{}};if(await _t("bus",()=>qo(d,f)),e)await _t("browser",()=>be(t,f,r));return f}async function Io(t,e,r){let o=Te().username,s={USER:o,LOGNAME:o,HOME:q(),PATH:`${bt(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:e,REASON_AUTOMATION_BACKGROUND_TABS:"1"},a=await To(e,s);return r.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:a}}function Ue(t,e,r,o){if(typeof _e!=="string")return Promise.reject(new _("automation_unavailable","This Reason build has no automation runtime."));let s=_e;return new Promise((a,c)=>{let i=I(t,["--input-type=module","--eval",s],{env:{...e,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:!0}),d=[],f=0,n="",l=null,u=!1,m=(w)=>{l??=w;try{process.kill(-i.pid,"SIGKILL")}catch{i.kill("SIGKILL")}},S=(w)=>{if(u)return;u=!0,clearTimeout(B),o.removeEventListener("abort",g),w()},B=setTimeout(()=>m(new _("automation_timed_out","Reason automation did not finish in time.")),no),g=()=>m(new _("cancelled","Reason cancelled the automation call."));if(o.addEventListener("abort",g,{once:!0}),i.stdout.on("data",(w)=>{if(f+=w.byteLength,f>ao)m(new _("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),i.stderr.setEncoding("utf8").on("data",(w)=>{n=(n+w).slice(-io)}),i.stdin.on("error",()=>{}),i.once("error",()=>S(()=>c(l??new _("automation_unavailable","Reason could not start the automation runtime.")))),i.once("close",(w)=>S(()=>{if(l)c(l);else a({code:w??1,stdout:Buffer.concat(d),stderr:n})})),o.aborted)g();i.stdin.end(r)})}var C=new Map;function $o(t,e,r){for(let[s,a]of C)if(a.expiresAt<=r)C.delete(s);while(C.size>=lo)C.delete(C.keys().next().value);let o=Oe();return C.set(o,{runId:t,bytes:e,expiresAt:r+fo}),o}async function Le(t,e,r,o={}){let s=await(o.environment??Ge)(t,e.kind==="browser");return r.throwIfAborted(),await(o.runtime??Ue)(t.node,s,JSON.stringify(e),r)}async function vs(t,e){let r=qe({call:t});if(!("call"in r))K();let o=$();if(!o?.features.computer||r.call.kind==="browser"&&!o.features.browser)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Le(o,r.call,e)}function we(t,e,r){let o=t.stdout.byteLength>wt?$o(e,t.stdout,r):void 0;return{code:t.code,stderr:t.stderr,instance_id:mo,output_bytes:t.stdout.byteLength,chunk:t.stdout.subarray(0,wt).toString("base64"),...o?{output_id:o}:{}}}async function ta(t,e={}){let r=qe(t.payload),o=(e.now??Date.now)();if("output_id"in r){let m=C.get(r.output_id);if(!m||m.runId!==t.runId||m.expiresAt<=o||r.offset>m.bytes.byteLength)throw new _("automation_output_unavailable","Reason automation output expired.");return{chunk:m.bytes.subarray(r.offset,r.offset+wt).toString("base64")}}let s=(e.components??$)(),a=(e.platform??process.platform)==="darwin",c=a?(e.macIdentity??St)():[],i=e.macSetup??X,d=!s?.features.computer||r.call.kind==="browser"&&!r.userChrome&&!s.features.browser;if(a&&(d||c.length===0||r.call.kind==="browser"&&r.userChrome&&!t.userChrome))return we(await ft({runId:t.runId,call:r.call,identity:c,desktopMissing:d,signal:t.signal},i),t.runId,o);if(!s?.features.computer)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let f=r.userChrome?t.userChrome:void 0;if(r.userChrome&&!f)throw new _("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(r.call.kind==="browser"&&!f&&!s.features.browser)throw new _("automation_browser_not_installed",s.platform==="darwin-arm64"?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");t.signal.throwIfAborted();let n=await ye(t.runId,t.signal,e.now),l="account"in e?e.account??null:Se(),u;try{if(f){let m=await(e.userChromeEnvironment??Io)(s,f,t.signal);t.signal.throwIfAborted(),u=await(e.runtime??Ue)(s.node,m,JSON.stringify(r.call),t.signal)}else if(l)u=await(e.delegate??Ot)(l,r.call,t.signal);else u=await Le(s,r.call,t.signal,e)}catch(m){if(!a||!(m instanceof _)||m.code!=="automation_user_chrome_not_connected")throw m;u=await ft({runId:t.runId,call:r.call,identity:c,desktopMissing:!1,signal:t.signal},i)}finally{n()}if(a)u=await ne({runId:t.runId,call:r.call,identity:c,output:u,signal:t.signal},i);return we(u,t.runId,o)}
760
+ export{Lt as lc,at as mc,Mt as nc,A as oc,Pt as pc,cs as qc,Yt as rc,ns as sc,dt as tc,Ur as uc,ds as vc,fs as wc,ls as xc,_s as yc,us as zc,ms as Ac,We as Bc,wt as Cc,qe as Dc,Ws as Ec,xo as Fc,Hs as Gc,Ks as Hc,go as Ic,To as Jc,Vs as Kc,Es as Lc,vs as Mc,ta as Nc};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Vb as i,Wb as l,Xb as g,Yb as y}from"./vm-hands-entry-lite-n07kxrd1.js";import{Af as I,Cf as O,ff as Q,gf as J,hf as z,if as Z,jf as K,kf as $,lf as k,nf as G,pf as X,qf as M,rf as Y,sf as H,tf as V,vf as S,wf as _,yf as P,zf as C}from"./vm-hands-entry-lite-ptmqg51y.js";import{lh as L,mh as W,nh as F,oh as j}from"./vm-hands-entry-lite-84aq8d12.js";var d=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var a=String.raw`(function(fs, path) {
2
+ import{Vb as i,Wb as l,Xb as g,Yb as y}from"./vm-hands-entry-lite-n07kxrd1.js";import{Af as P,Bf as C,Cf as I,Ef as O,hf as Q,if as J,jf as z,kf as Z,lf as K,mf as $,nf as k,pf as G,rf as X,sf as M,tf as Y,uf as H,vf as V,xf as S,yf as _}from"./vm-hands-entry-lite-53jm8bj7.js";import{nh as L,oh as W,ph as F,qh as j}from"./vm-hands-entry-lite-kxbpf40y.js";var d=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var a=String.raw`(function(fs, path) {
3
3
  const fail = (message, reasonCode) => { throw Object.assign(Error(message), {reasonCode}); };
4
4
  const read = (p, reasonCode, trim=true) => { try { const text=fs.readFileSync(p, "utf8"); return trim?text.trim():text; }
5
5
  catch { fail("memory_read", reasonCode); } };
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{yh as $}from"./vm-hands-entry-lite-1fznjm91.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
3
- export{O as uh,Z as vh,S as wh,k as xh};
2
+ import{Ah as $}from"./vm-hands-entry-lite-vqcatbcw.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
3
+ export{O as wh,Z as xh,S as yh,k as zh};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{cf as Z8}from"./vm-hands-entry-lite-bfwf82rw.js";import{lf as R0}from"./vm-hands-entry-lite-ptmqg51y.js";import{gg as Kq}from"./vm-hands-entry-lite-25t4e0vk.js";import{Cg as p,Fg as V0,Ig as F0,Jg as C8,Kg as eq,Mg as g8,Pg as q0,Rg as x0}from"./vm-hands-entry-lite-s2xydt0n.js";import{Wg as wq}from"./vm-hands-entry-lite-s5qn1k80.js";import{Xg as o,Yg as C0}from"./vm-hands-entry-lite-9pmag2qk.js";import{jh as B0}from"./vm-hands-entry-lite-84aq8d12.js";import{zh as A0}from"./vm-hands-entry-lite-anaydk9m.js";import{Gh as Z}from"./vm-hands-entry-lite-ffg7rf02.js";import{execFile as V1,spawn as w0}from"child_process";import{randomBytes as F1}from"crypto";import{chmodSync as w1,existsSync as K0,lstatSync as K1,mkdirSync as M1,readFileSync as z1,rmSync as Y1,writeFileSync as Xq}from"fs";import{connect as _1}from"net";import{join as H}from"path";var Bq="./desktop-wallpaper-0pjhgyfk.jpg";var Rq="./dock-browser-afp005mt.png";var Cq="./dock-files-rywdm96b.png";var yq="./dock-terminal-s41cj1jp.png";var Sq=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
2
+ import{ef as Z8}from"./vm-hands-entry-lite-k1wbh9dq.js";import{nf as R0}from"./vm-hands-entry-lite-53jm8bj7.js";import{ig as Kq}from"./vm-hands-entry-lite-pfsce35z.js";import{Eg as p,Hg as V0,Kg as F0,Lg as C8,Mg as eq,Og as g8,Rg as q0,Tg as x0}from"./vm-hands-entry-lite-5vrdj7jm.js";import{Yg as wq}from"./vm-hands-entry-lite-qbk0wxrz.js";import{Zg as o,_g as C0}from"./vm-hands-entry-lite-vvmq0mtv.js";import{lh as B0}from"./vm-hands-entry-lite-kxbpf40y.js";import{Bh as A0}from"./vm-hands-entry-lite-y9k070mt.js";import{Ih as Z}from"./vm-hands-entry-lite-wffqkcjq.js";import{execFile as V1,spawn as w0}from"child_process";import{randomBytes as F1}from"crypto";import{chmodSync as w1,existsSync as K0,lstatSync as K1,mkdirSync as M1,readFileSync as z1,rmSync as Y1,writeFileSync as Xq}from"fs";import{connect as _1}from"net";import{join as H}from"path";var Bq="./desktop-wallpaper-0pjhgyfk.jpg";var Rq="./dock-browser-afp005mt.png";var Cq="./dock-files-rywdm96b.png";var yq="./dock-terminal-s41cj1jp.png";var Sq=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
3
3
  # The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
4
4
  # python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
5
5
  # Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
@@ -178,4 +178,4 @@ Gtk.main()
178
178
  `).flatMap((Q)=>{let P=Q.indexOf("=");return P>0?[[Q.slice(0,P),Q.slice(P+1)]]:[]})))}catch{return{}}}var G0=new Set;async function u1(q,x,X){let Q=await v1(),P=/^:(\d+)(?:\.\d+)?$/.exec(Q.DISPLAY??"")?.[1];if(!P||`:${P}`===G8||Q.WAYLAND_DISPLAY||Q.XDG_SESSION_TYPE==="wayland")return null;let b={display:`:${P}`,xauthority:Q.XAUTHORITY??H(q,".Xauthority"),rfbSocket:H(x,`rfb-${P}.sock`)},J=`${b.display} ${b.xauthority}`;if(G0.has(J)||!await e({path:`/tmp/.X11-unix/X${P}`},!1))return null;let L={HOME:q,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:b.display,XAUTHORITY:b.xauthority};if(await z0(X,b,x,`x11vnc-${P}.log`,L))return{...b,sound:null};return G0.add(J),process.stderr.write(`Reason worker: your screen ${b.display} could not be served; using the virtual desktop
179
179
  `),null}function c1(q,x){let X=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,Q=[["terminal","xterm"],["files","pcmanfm"]].filter(([,b])=>!K0(`/usr/bin/${b}`)).map(([b])=>b),P=Aq({root:q,display:x,screen:Qq,browserExec:X,absent:Q});for(let b of["","openbox","tint2","picom"])A8(H(q,b));for(let[b,J]of Object.entries(P.files))Xq(H(q,b),J,{mode:384});for(let[b,J]of Object.entries(Gq))Xq(H(q,`ara-${b}`),z1(J),{mode:384});return{root:q,openboxConfig:H(q,"openbox","rc.xml"),start:P.start}}async function m1(q,x){let X=[`ROOT=${JSON.stringify(q.root)}`,...q.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
180
180
  `);await new Promise((Q)=>{let P=w0("/bin/sh",["-c",X],{stdio:"ignore",env:{...x,PATH:"/usr/bin:/bin"}}),b=setTimeout(()=>{P.kill(),Q()},V8);P.once("error",()=>{clearTimeout(b),Q()}),P.once("exit",()=>{clearTimeout(b),Q()})})}async function O9(q,x={}){let X=x.now??Date.now,Q=g1(q.payload,X());if(q.signal.throwIfAborted(),!Q.video)throw new Z("display_video_required","Reason desktops stream as video now; this request came without it.");let P=x.platform??process.platform;if(P!=="linux"&&P!=="darwin")throw new Z("display_video_unsupported","This machine does not serve desktop video.");let b=Q.video,J=(x.video?.desktop??(P==="darwin"?async()=>X0:I1))();return await r1(q.signal,Q,x,X,(L)=>W0(L,{request:b,desktop:J,...Q.viewer?{viewer:Q.viewer}:{},viewerSameNetwork:Q.viewer_same_network===!0},x.video),(L)=>C8({type:"error",code:L}))}function r1(q,x,X,Q,P,b){let J=Q();return new Promise((L,y)=>{let W=null,U=!1,C=!1,R,D,Y,A=!1,N=null,S=(V)=>{if(C)return;if(N)V=N;C=!0,clearTimeout(R),clearTimeout(D),q.removeEventListener("abort",K),Y?.close();try{W?.close(1000,"display_session_over")}catch{}if("error"in V){y(V.error);return}L({reason:V.reason,...Y?.summary(),duration_ms:Math.max(0,Q()-J)})},F=()=>S({error:new Z("display_relay_unavailable","Reason could not reach the desktop relay.")}),K=()=>{let V=q.reason;S({error:V instanceof Z?V:new Z("cancelled","Reason closed the desktop session.")})},$=()=>{if(!N||!W)return;let V=N.error;try{W.send(b(V instanceof Z?V.code:"display_unavailable"))}catch{}S(N)};if(Y=P({get done(){return C||N!==null},get open(){return U&&!C&&N===null},get bufferedAmount(){return W?.bufferedAmount??0},send(V){if(C||N||!U||!W)return;try{W.send(V)}catch{S({reason:"relay_closed"})}},end:(V)=>{if(C||N)return;if(!("error"in V)){S(V);return}if(N=V,A&&U)$()}}),C){Y.close();return}if(q.aborted){K();return}q.addEventListener("abort",K,{once:!0}),R=setTimeout(()=>S({reason:"session_expired"}),Math.max(1,Date.parse(x.expires_at)-Q())),D=setTimeout(()=>S({reason:"viewer_absent"}),X.viewerWaitMs??$1);try{W=(X.connect??qq)(x.relay_url,(X.loadProxy??Z8)()?.url)}catch{F();return}W.binaryType="arraybuffer",W.onopen=()=>{if(C||!W)return;U=!0,Y?.opened()},W.onmessage=(V)=>{if(C)return;let g=V.data,v=g instanceof ArrayBuffer?new Uint8Array(g):ArrayBuffer.isView(g)?new Uint8Array(g.buffer,g.byteOffset,g.byteLength):null;if(!v||v.byteLength===0)return;if(clearTimeout(D),A=!0,N){$();return}Y?.received(v)},W.onclose=()=>{if(C)return;if(!U){F();return}S({reason:"relay_closed"})},W.onerror=()=>{if(C||U)return;F()}})}
181
- export{T1 as $d,T0 as ae,D1 as be,D9 as ce,B9 as de,O8 as ee,PX as fe,NX as ge,i as he,R8 as ie,Q9 as je,U0 as ke,Vq as le,Hq as me,r as ne,HX as oe,fX as pe,gX as qe,E1 as re,G8 as se,g1 as te,h1 as ue,$9 as ve,A8 as we,I1 as xe,O9 as ye};
181
+ export{T1 as be,T0 as ce,D1 as de,D9 as ee,B9 as fe,O8 as ge,PX as he,NX as ie,i as je,R8 as ke,Q9 as le,U0 as me,Vq as ne,Hq as oe,r as pe,HX as qe,fX as re,gX as se,E1 as te,G8 as ue,g1 as ve,h1 as we,$9 as xe,A8 as ye,I1 as ze,O9 as Ae};