@reason-machines/cli-linux-arm64-musl 0.2.358 → 0.2.359
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/bin/ara +1 -1
- package/bin/vm-hands/api-credentials-axffq0pk.js +2 -0
- package/bin/vm-hands/api-texm6ayv.js +2 -0
- package/bin/vm-hands/ask-relay-fkb3bj30.js +8 -0
- package/bin/vm-hands/connect-cli-ev4xex04.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-j3e3zjd5.js → custom-endpoint-device-bsanzqj2.js} +1 -1
- package/bin/vm-hands/desktop-account-jxfva4m1.js +2 -0
- package/bin/vm-hands/{device-workspace-7yg5x68n.js → device-workspace-fhbpenda.js} +1 -1
- package/bin/vm-hands/hands-worker-source-ze6q6h8b.js +2 -0
- package/bin/vm-hands/{index-swa20ch8.js → index-tv4kcb2a.js} +1 -1
- package/bin/vm-hands/install-receipt-3s9amwp3.js +2 -0
- package/bin/vm-hands/local-automation-f8f33qpp.js +2 -0
- package/bin/vm-hands/local-capabilities-ya6yzxh5.js +2 -0
- package/bin/vm-hands/local-desktop-users-3th2aaac.js +2 -0
- package/bin/vm-hands/local-display-mac-neweyjpa.js +2 -0
- package/bin/vm-hands/local-display-session-v00nv1fm.js +2 -0
- package/bin/vm-hands/local-pty-session-2crsy5td.js +2 -0
- package/bin/vm-hands/managed-runtime-mg7kmckn.js +2 -0
- package/bin/vm-hands/{network-contract-rm9x646s.js → network-contract-gq8x3ehk.js} +1 -1
- package/bin/vm-hands/package-s3eg9zrd.js +2 -0
- package/bin/vm-hands/permissions-3kjdp3ge.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-3z7bas06.js → reason-hands-protocol-67d4b6fm.js} +1 -1
- package/bin/vm-hands/serve-service-nqshfese.js +2 -0
- package/bin/vm-hands/{status-psxtsknj.js → status-f146chye.js} +2 -2
- package/bin/vm-hands/version-ss25ccvh.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-he2z2137.js → vm-hands-entry-lite-07er2w8q.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-5b29hq7h.js → vm-hands-entry-lite-1j9r1fca.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-22we2jrv.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-xhjbc3e4.js → vm-hands-entry-lite-3ew5ftk0.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-463aheya.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-5kgvss4p.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-5xtkyx25.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-jfwz0br7.js → vm-hands-entry-lite-9z6k7898.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-bybpy28m.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-c0m2jewa.js +11 -0
- package/bin/vm-hands/{vm-hands-entry-lite-3zxjyj62.js → vm-hands-entry-lite-c7krpmd8.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-dys7am1h.js → vm-hands-entry-lite-d2hbz0r4.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-nvhzj5b0.js → vm-hands-entry-lite-f4gvypnx.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-wpx6sg6d.js → vm-hands-entry-lite-gxjxx1r2.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-gzxxsjmr.js +62 -0
- package/bin/vm-hands/{vm-hands-entry-lite-nd1k2jz9.js → vm-hands-entry-lite-h2xemq1f.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-c9wp99nr.js → vm-hands-entry-lite-ha1ej910.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-nbtpm59m.js → vm-hands-entry-lite-j05685sg.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-6f5eypjm.js → vm-hands-entry-lite-jn95s3j4.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-kt4831mq.js +340 -0
- package/bin/vm-hands/{vm-hands-entry-lite-k17ntg9v.js → vm-hands-entry-lite-kv0qat0x.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-kxdw4myj.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-0hv9ek0t.js → vm-hands-entry-lite-n867d88m.js} +9 -68
- package/bin/vm-hands/{vm-hands-entry-lite-c8hfat7y.js → vm-hands-entry-lite-p8662x7z.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-pf1gagky.js +37 -0
- package/bin/vm-hands/{vm-hands-entry-lite-rr0hhz7g.js → vm-hands-entry-lite-qbnz4h30.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-8jmwhybq.js → vm-hands-entry-lite-qhgfnhjt.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-trcg4jv7.js → vm-hands-entry-lite-qm18wqgz.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-beannz0s.js → vm-hands-entry-lite-r5y08n0q.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-r6pap1kh.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-s98hjhz3.js +5 -0
- package/bin/vm-hands/{vm-hands-entry-lite-zrvaqawr.js → vm-hands-entry-lite-sx2gpbap.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-qf01e5f1.js → vm-hands-entry-lite-szfy3kx7.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-95k4g3jj.js → vm-hands-entry-lite-taw01cp4.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0tdpjsxc.js → vm-hands-entry-lite-tg2bkah3.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-mybm2kyz.js → vm-hands-entry-lite-v08mjs3f.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-84d59wrf.js → vm-hands-entry-lite-w88zkzhr.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-wej1p1ry.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-gcn3rmz6.js → vm-hands-entry-lite-wry37am5.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-x4j4058x.js +9 -0
- package/bin/vm-hands/{vm-hands-entry-lite-tj1y61bg.js → vm-hands-entry-lite-ygx9kj92.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-dqqdgtqq.js → vm-hands-executor-5nqmf61x.js} +1 -1
- package/bin/vm-hands/vm-hands-op-runner-zedtdcmk.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-y89fmev1.js → vm-hands-runtime-hnpk8xmf.js} +3 -3
- package/bin/vm-hands/worker-sandbox-vmp22sk6.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-emdf5nm5.js +0 -2
- package/bin/vm-hands/api-js29ghm5.js +0 -2
- package/bin/vm-hands/ask-relay-qv9ddzr1.js +0 -8
- package/bin/vm-hands/connect-cli-8nxph9td.js +0 -2
- package/bin/vm-hands/desktop-account-gcysz0m3.js +0 -2
- package/bin/vm-hands/hands-worker-source-hbp5n31r.js +0 -2
- package/bin/vm-hands/local-automation-nw3bj9b5.js +0 -2
- package/bin/vm-hands/local-capabilities-7m54wthn.js +0 -2
- package/bin/vm-hands/local-desktop-users-pccz3sz9.js +0 -2
- package/bin/vm-hands/local-display-mac-gj72gkfb.js +0 -2
- package/bin/vm-hands/local-display-session-5ajajxtg.js +0 -2
- package/bin/vm-hands/local-pty-session-zen80k1k.js +0 -2
- package/bin/vm-hands/package-1e3w44ve.js +0 -2
- package/bin/vm-hands/permissions-0ej6xgrj.js +0 -2
- package/bin/vm-hands/version-fw3dwa12.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-33ttamma.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-3ms5bb0b.js +0 -43
- package/bin/vm-hands/vm-hands-entry-lite-6qfax5p2.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-d9k3dzaq.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-dyy62gt3.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-pm0j47qj.js +0 -343
- package/bin/vm-hands/vm-hands-entry-lite-tdgbgcer.js +0 -3
- package/bin/vm-hands/vm-hands-op-runner-msdteb31.js +0 -2
- package/bin/vm-hands/worker-sandbox-yw24sxyp.js +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{createHash as f,createPublicKey as V,verify as G}from"crypto";var H="libara_device_keychain.dylib",Y="libreason_device_keychain.dylib",k=1,x=2,h=536870912,p=262144;var U=["darwin-arm64","darwin-x64"];class J extends Error{code;constructor(z,F){super(F);this.code=z;this.name="ManagedRuntimeError"}}var C=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,N=/^[a-f0-9]{64}$/;function X(z){return Boolean(z)&&typeof z==="object"&&!Array.isArray(z)}function $(z,F,Q=[]){let Z=new Set([...F,...Q]);return F.every((W)=>(W in z))&&Object.keys(z).every((W)=>Z.has(W))}function B(z){return typeof z==="string"&&C.test(z)}function O(z){return typeof z==="string"&&!Number.isNaN(Date.parse(z))&&new Date(z).toISOString()===z}function c(z){return U.includes(z)}function I(z,F){if(!B(z)||!c(F))throw new J("invalid_release_asset","Invalid managed runtime release asset.");return`ara-runtime-v${z}-${F}`}function m(z,F){return`${I(z,F)}-${H}`}var R="managed-runtime-identity.json",D="reason-macos-background-identity-v1";function q(z){if(z===null)return"null";if(typeof z==="string"||typeof z==="boolean")return JSON.stringify(z);if(typeof z==="number"){if(!Number.isFinite(z))throw new J("invalid_manifest","Manifest numbers must be finite.");return JSON.stringify(z)}if(Array.isArray(z))return`[${z.map((F)=>q(F)).join(",")}]`;if(X(z))return`{${Object.keys(z).sort().map((F)=>`${JSON.stringify(F)}:${q(z[F])}`).join(",")}}`;throw new J("invalid_manifest","Manifest contains an unsupported value.")}function j(z){if(!X(z)||!$(z,["url","sha256","size_bytes"])||typeof z.url!=="string"||typeof z.sha256!=="string"||!N.test(z.sha256)||typeof z.size_bytes!=="number"||!Number.isSafeInteger(z.size_bytes)||z.size_bytes<=0||z.size_bytes>h)throw new J("invalid_manifest","Manifest contains an invalid runtime artifact.");let F;try{F=new URL(z.url)}catch{throw new J("invalid_manifest","Runtime artifact URL is invalid.")}if(F.protocol!=="https:"||F.username||F.password||F.hash)throw new J("invalid_manifest","Runtime artifact URL must be an HTTPS URL without credentials or a fragment.");return{url:F.toString(),sha256:z.sha256,size_bytes:z.size_bytes}}function b(z){if(!X(z)||!$(z,["broker","credential_library"]))throw new J("invalid_manifest","Manifest must bind the broker and credential library as one runtime.");return{broker:j(z.broker),credential_library:j(z.credential_library)}}function K(z){if(!X(z)||!$(z,["schema_version","version","published_at","artifacts"])||z.schema_version!==x||!B(z.version)||!O(z.published_at)||!X(z.artifacts)||!$(z.artifacts,[...U]))throw new J("invalid_manifest","Managed Reason runtime manifest is invalid.");return{schema_version:x,version:z.version,published_at:z.published_at,artifacts:{"darwin-arm64":b(z.artifacts["darwin-arm64"]),"darwin-x64":b(z.artifacts["darwin-x64"])}}}function _(z){if(!X(z)||!$(z,["schema_version","version","published_at","artifacts"])||z.schema_version!==k||!B(z.version)||!O(z.published_at)||!X(z.artifacts)||!$(z.artifacts,[...U]))throw new J("invalid_manifest","Legacy managed runtime manifest is invalid.");return{schema_version:k,version:z.version,published_at:z.published_at,artifacts:{"darwin-arm64":j(z.artifacts["darwin-arm64"]),"darwin-x64":j(z.artifacts["darwin-x64"])}}}function M(z){if(!X(z)||!$(z,["schema","version","published_at","artifacts"])||z.schema!==D||!B(z.version)||!O(z.published_at)||!X(z.artifacts)||!$(z.artifacts,[...U]))throw new J("invalid_manifest","Reason background identity manifest is invalid.");return{schema:D,version:z.version,published_at:z.published_at,artifacts:{"darwin-arm64":j(z.artifacts["darwin-arm64"]),"darwin-x64":j(z.artifacts["darwin-x64"])}}}function S(z){if(typeof z!=="string"||!/^[A-Za-z0-9+/]+={0,2}$/.test(z))throw new J("invalid_signature","Runtime manifest signature is invalid.");let F=Buffer.from(z,"base64");if(F.length!==64||F.toString("base64")!==z)throw new J("invalid_signature","Runtime manifest signature is invalid.");return F}function L(z){let F=z;if(typeof z==="string")try{F=JSON.parse(z)}catch{throw new J("invalid_manifest","Managed Reason runtime manifest is not valid JSON.")}if(!X(F)||!$(F,["key_id","manifest","signature"])||typeof F.key_id!=="string"||!/^[A-Za-z0-9._-]{1,80}$/.test(F.key_id)||typeof F.signature!=="string")throw new J("invalid_manifest","Signed managed Reason runtime manifest is invalid.");return F}function o(z,F){let Q=L(z),Z=F[Q.key_id];if(!Z)throw new J("untrusted_key","Runtime manifest was signed by an unknown key.");let W=K(Q.manifest),w=S(Q.signature),P=!1;try{P=G(null,Buffer.from(q(W)),V(Z),w)}catch{throw new J("invalid_signature","Runtime manifest signature could not be verified.")}if(!P)throw new J("invalid_signature","Runtime manifest signature did not match.");return{key_id:Q.key_id,manifest:W,signature:Q.signature}}function E(z,F){let Q=L(z),Z=F[Q.key_id];if(!Z)throw new J("untrusted_key","Background identity manifest was signed by an unknown key.");let W=M(Q.manifest),w=S(Q.signature),P=!1;try{P=G(null,Buffer.from(q(W)),V(Z),w)}catch{throw new J("invalid_signature","Background identity manifest signature could not be verified.")}if(!P)throw new J("invalid_signature","Background identity manifest signature did not match.");return{key_id:Q.key_id,manifest:W,signature:Q.signature}}function d(z,F){let Q=z;if(typeof z==="string")try{Q=JSON.parse(z)}catch{throw new J("invalid_manifest","Legacy managed runtime manifest is not valid JSON.")}if(!X(Q)||!$(Q,["key_id","manifest","signature"])||typeof Q.key_id!=="string"||!/^[A-Za-z0-9._-]{1,80}$/.test(Q.key_id)||typeof Q.signature!=="string")throw new J("invalid_manifest","Signed legacy managed runtime manifest is invalid.");let Z=F[Q.key_id];if(!Z)throw new J("untrusted_key","Legacy runtime manifest was signed by an unknown key.");let W=_(Q.manifest),w=S(Q.signature),P=!1;try{P=G(null,Buffer.from(q(W)),V(Z),w)}catch{throw new J("invalid_signature","Legacy runtime manifest signature could not be verified.")}if(!P)throw new J("invalid_signature","Legacy runtime manifest signature did not match.");return{key_id:Q.key_id,manifest:W,signature:Q.signature}}function A(z){return f("sha256").update(z).digest("hex")}function i(z,F){if(z.byteLength!==F.size_bytes)throw new J("artifact_size_mismatch","Runtime artifact size did not match its manifest.");if(A(z)!==F.sha256)throw new J("artifact_checksum_mismatch","Runtime artifact checksum did not match its manifest.")}import{existsSync as y}from"fs";import{join as T}from"path";function v(z){let F=T(z,Y);return y(F)?F:T(z,H)}
|
|
3
|
+
export{H as Gh,Y as Hh,k as Ih,x as Jh,h as Kh,p as Lh,U as Mh,J as Nh,I as Oh,m as Ph,R as Qh,q as Rh,o as Sh,E as Th,d as Uh,A as Vh,i as Wh,v as Xh};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Hd as ie,Jd as oe}from"./vm-hands-entry-lite-gzxxsjmr.js";import{if as he}from"./vm-hands-entry-lite-szfy3kx7.js";import{Gf as q,Hf as ee,Jf as D,Kf as ye,Nf as W,Of as z,Pf as v,Yf as T,Zf as Fe}from"./vm-hands-entry-lite-07er2w8q.js";import{Dg as ge}from"./vm-hands-entry-lite-3ew5ftk0.js";import{pi as re}from"./vm-hands-entry-lite-pf1gagky.js";import{Li as J}from"./vm-hands-entry-lite-x4j4058x.js";import{Ri as y}from"./vm-hands-entry-lite-1j9r1fca.js";import{Ij as xe,Jj as te}from"./vm-hands-entry-lite-ha1ej910.js";import{Pj as be,Vj as we}from"./vm-hands-entry-lite-jn95s3j4.js";import{Wj as f}from"./vm-hands-entry-lite-ygx9kj92.js";import{spawn as O}from"child_process";import{randomUUID as Se}from"crypto";import{closeSync as ct,copyFileSync as ce,existsSync as G,fstatSync as lt,mkdirSync as le,openSync as ut,readdirSync as F,readFileSync as Ae,readlinkSync as dt,renameSync as ft,rmSync as mt,statSync as pt}from"fs";import{connect as _t}from"net";import{userInfo as Oe}from"os";import{basename as ue,dirname as U,join as _}from"path";var V=`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,70 +691,11 @@ 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
|
|
695
|
-
`).at(-1)?.slice(-300)??"";if(!
|
|
696
|
-
`);if(
|
|
697
|
-
`
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
<string>${O(c.app)}</string>${n}`);return i===r?null:i}function Fr(t,e){let r=ht(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&&ht(o.definition,e)!==null}var h="com.reasonmachines.worker.",nt="so.reason.worker.",Qt=[h,nt];function kt(t,e=h){return`${e}connect${t==="production"?"":`.${t}`}`}function ns(t,e){return Qt.some((r)=>t===kt(e,r))}function Rr(t,e,r){if(e==="connect")return kt(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 Yt(t,e,r)[0]??null}function Yt(t,e,r){return Qt.map((o)=>T(t,e,r,o)).filter((o)=>o!==null&&st(o.definition))}function Xt(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=Xt(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===Kt(e,s,a,r,o.home,t.path);let i=Pt(c);return c.replace(M,"").replace(it,(f,n,l,u)=>`${n}${i?`${ct([i.launcher,...i.args])}
|
|
701
|
-
|
|
702
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
703
|
-
<plist version="1.0">
|
|
704
|
-
<dict>
|
|
705
|
-
<key>Label</key>
|
|
706
|
-
<string>${O(r.label)}</string>
|
|
707
|
-
<key>AssociatedBundleIdentifiers</key>
|
|
708
|
-
<array>
|
|
709
|
-
<string>${Jt}</string>
|
|
710
|
-
</array>
|
|
711
|
-
<key>ProgramArguments</key>
|
|
712
|
-
<array>
|
|
713
|
-
${ct(i.program)}
|
|
714
|
-
</array>
|
|
715
|
-
<key>EnvironmentVariables</key>
|
|
716
|
-
<dict>
|
|
717
|
-
${Object.entries(d).map(([f,n])=>` <key>${f}</key>
|
|
718
|
-
<string>${O(n)}</string>`).join(`
|
|
719
|
-
`)}
|
|
720
|
-
</dict>
|
|
721
|
-
<key>RunAtLoad</key>
|
|
722
|
-
<true/>
|
|
723
|
-
<key>KeepAlive</key>
|
|
724
|
-
<dict>
|
|
725
|
-
<key>SuccessfulExit</key>
|
|
726
|
-
<false/>
|
|
727
|
-
</dict>
|
|
728
|
-
<key>ThrottleInterval</key>
|
|
729
|
-
<integer>10</integer>
|
|
730
|
-
<key>ExitTimeOut</key>
|
|
731
|
-
<integer>${Math.ceil(t.shutdownGraceMs/1000)+10}</integer>
|
|
732
|
-
<key>ProcessType</key>
|
|
733
|
-
<string>Standard</string>
|
|
734
|
-
<key>Umask</key>
|
|
735
|
-
<integer>63</integer>
|
|
736
|
-
<key>StandardOutPath</key>
|
|
737
|
-
<string>${O(r.logs)}</string>
|
|
738
|
-
<key>StandardErrorPath</key>
|
|
739
|
-
<string>${O(r.logs)}</string>
|
|
740
|
-
</dict>
|
|
741
|
-
</plist>
|
|
742
|
-
`}}function Kt(t,e,r,o,s,a){let c=Wt(t,e);return`[Unit]
|
|
743
|
-
Description=${c.description}
|
|
744
|
-
|
|
745
|
-
[Service]
|
|
746
|
-
ExecStart=${[o,...c.args].map((i)=>Lt(i,!0)).join(" ")}
|
|
747
|
-
Environment=${[`HOME=${s}`,`PATH=${a}`,`${at}=${r.label}`,...Object.entries(c.environment).map(([i,d])=>`${i}=${d}`)].map((i)=>Lt(i)).join(" ")}
|
|
748
|
-
Restart=on-failure
|
|
749
|
-
RestartSec=10
|
|
750
|
-
TimeoutStopSec=${Math.ceil(t.shutdownGraceMs/1000)+10}
|
|
751
|
-
UMask=0077
|
|
752
|
-
|
|
753
|
-
[Install]
|
|
754
|
-
WantedBy=default.target
|
|
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.","worker_service_root_user");return`gui/${t.uid}`}function ls(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=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"?Ht(e,s,i,r,o,t.path):null;if(Q(i.definition,d?d.plist:Kt(e,s,i,r,o.home,t.path)),Vt(e,o,i,c?null:a),d)return d.identity?i:{...i,identityProblem:qr};return{...i,lingering:o.command("loginctl",["enable-linger"])===0}}function Vt(t,e,r,o){if(e.platform==="darwin"){let c=L(e);if(o)e.command("/bin/launchctl",["bootout",`${c}/${o.label}`]);if(Et(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).","worker_service_start_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).","worker_service_start_failed")}if(o)N(o.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function Et(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)),Vt(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=Et(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}.`,"worker_service_restart_failed");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=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}`]);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),vt="x-apple.systempreferences:com.apple.preference.security",kr={accessibility:`${vt}?Privacy_Accessibility`,screen:`${vt}?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=Mt(Dt(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)=>se(t,e),tile:ae,installDesktop:Xr},te=!1;async function ee(t,e,r){try{await e.open(["-a","Google Chrome",t],r)}catch{r.throwIfAborted(),await e.open([t],r)}}async function ie(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 ie(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. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function re(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 ce(t,e=X){let{call:r,runId:o,signal:s}=t;if(r.kind==="browser"){if(r.operation==="discover")return re({result:{tools:[Hr]}});if(r.operation!=="call")throw new _("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(t.desktopMissing&&!te){te=!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 ie(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 ee(oe,e,s).catch(()=>{});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 ee(c,e,s),re({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 bt=172032,ao=18874368,io=8192,co=65536,no=55000,fo=60000,lo=4,_o=40000,uo=/^[0-9a-f-]{36}$/,_e=At,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??xt)(),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)
|
|
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
|
|
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:_t,storages:[b(r,"browser-profile","Default","Local Extension Settings",_t)]})}var ue=/^(Default|Profile ([0-9]+))$/;async function go(t,e,r=q(),o=St){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)&&ut(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=St){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 ft=new Map;function lt(t,e){let r=ft.get(t);if(!r)r=e().finally(()=>ft.delete(t)),ft.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=wt(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=wt(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(!ut(e)||!Co(t.automation))return t.automation;if(!Bo(Fe(t,e)))try{eo(e,t.automation)}catch{}return ut(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:`${mt(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:bo};if(!e)return n;await lt("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:`${mt(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 lt("bus",()=>qo(d,f)),e)await lt("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:`${mt(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>bt?$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,bt).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+bt).toString("base64")}}let s=(e.components??$)(),a=(e.platform??process.platform)==="darwin",c=a?(e.macIdentity??xt)():[],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 ce({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??Nt)(l,r.call,t.signal);else u=await Le(s,r.call,t.signal,e)}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{Ut as Gc,at as Hc,Dt as Ic,A as Jc,Mt as Kc,cs as Lc,kt as Mc,ns as Nc,dt as Oc,Ur as Pc,ds as Qc,fs as Rc,ls as Sc,_s as Tc,us as Uc,ms as Vc,We as Wc,bt as Xc,qe as Yc,Ws as Zc,xo as _c,Hs as $c,Ks as ad,go as bd,To as cd,Vs as dd,Es as ed,vs as fd,ta as gd};
|
|
694
|
+
`;import{spawn as Le}from"child_process";import{basename as De}from"path";var Ge="__desktop-call",Ue="/usr/bin/setpriv",Me=27262976,ze=8192,Je=2000;function P(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function We(e){try{return JSON.parse(e)}catch{return null}}function je(){return[process.execPath,...De(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],Ge]}function Ke(e,r,t,i={}){t.throwIfAborted();let o=i.command??je();return new Promise((a,c)=>{let s=(i.spawnProcess??Le)(Ue,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...o],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),l=[],u=0,n="",d=null,m=!1,p,b=(g)=>{try{process.kill(-s.pid,g)}catch{s.kill(g)}},A=(g)=>{d??=g,b("SIGTERM"),p??=setTimeout(()=>b("SIGKILL"),Je)},x=()=>A(new f("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",x,{once:!0});let h=(g)=>{if(m)return;m=!0,clearTimeout(p),t.removeEventListener("abort",x),g()};if(s.stdout.on("data",(g)=>{if(u+=g.byteLength,u>Me)A(new f("desktop_delegate_failed","Reason's desktop reply is too large."));else l.push(g)}),s.stderr.setEncoding("utf8").on("data",(g)=>{n=(n+g).slice(-ze)}),s.stdin.on("error",()=>{}),s.once("error",()=>h(()=>c(d??new f("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),s.once("close",(g,Pe)=>h(()=>{if(d)return c(d);let w=We(Buffer.concat(l).toString("utf8"));if(P(w)&&w.ok===!0&&P(w.result))return a(w.result);let N=P(w)&&w.ok===!1&&typeof w.code==="string"&&typeof w.message==="string"?new f(w.code.slice(0,120),w.message.slice(0,2000)):null,j=`exited ${g??Pe}${N?"":" with no reply"}`,K=n.trim().split(`
|
|
695
|
+
`).at(-1)?.slice(-300)??"";if(!N||N.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${j}${n?`: ${n.trim().slice(-500)}`:""}
|
|
696
|
+
`);if(N)return c(N);c(new f("desktop_delegate_failed",`Reason's desktop operation failed (${j}${K?`: ${K}`:""}).`))})),t.aborted)x();s.stdin.end(JSON.stringify(r))})}async function X(e,r,t,i={}){let o=await Ke(e,{op:"automation",call:r},t,i);if(!Number.isSafeInteger(o.code)||typeof o.stdout!=="string"||typeof o.stderr!=="string")throw new f("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:o.code,stdout:Buffer.from(o.stdout,"base64"),stderr:o.stderr}}import{execFile as Ve,spawn as Xe}from"child_process";import{closeSync as Ze,mkdirSync as Ye,openSync as Qe}from"fs";import{dirname as C,join as He}from"path";import{promisify as et}from"util";var tt=et(Ve),Z="x-apple.systempreferences:com.apple.preference.security",rt={accessibility:`${Z}?Privacy_Accessibility`,screen:`${Z}?Privacy_ScreenCapture`},it=64,R=new Map;function I(e,r){let t=R.get(e);if(t?.has(r))return!1;if(!t){if(R.size>=it)R.delete(R.keys().next().value);t=new Set,R.set(e,t)}return t.add(r),!0}function ot(){let e=y(),r=oe(ie(e),process.env),t=He(e,".local","share","reason","desktop-install.log");Ye(C(t),{recursive:!0,mode:448});let i=Qe(t,"a",384);try{let o=Xe(r,["desktop","install"],{detached:!0,stdio:["ignore",i,i],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});o.on("error",()=>{return}),o.unref()}finally{Ze(i)}}var k={open:async(e,r)=>{await tt("/usr/bin/open",e,{signal:r,timeout:1e4,maxBuffer:8192})},request:(e,r)=>te(e,r),tile:re,installDesktop:ot},Y=!1;async function Q(e,r,t){try{await r.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await r.open([e],t)}}async function ae(e,r,t,i){if(await t.open([rt[r]],i).catch(()=>{}),e[0]&&!i.aborted)t.tile(C(C(C(e[0]))),r)}async function at(e,r,t,i,o){for(let a of t){if(!I(e,`grant:${a}`))continue;o.throwIfAborted(),await i.request(r,a).catch(()=>null),await ae(r,a,i,o)}}var st={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. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function H(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function nt(e){if(typeof e!=="string")return null;try{let r=new URL(e);return r.protocol==="https:"||r.protocol==="http:"?r.href:null}catch{return null}}async function se(e,r=k){let{call:t,runId:i,signal:o}=e;if(t.kind==="browser"){if(t.operation==="discover")return H({result:{tools:[st]}});if(t.operation!=="call")throw new f("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!Y){Y=!0;try{r.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&I(i,"grant:probe")){let s=await r.request(e.identity).catch(()=>null),l=s?[...s.accessibility?[]:["accessibility"],...s.screen?[]:["screen"]]:[];for(let u of l)I(i,`grant:${u}`);for(let u of l)await ae(e.identity,u,r,o)}throw new f("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(I(i,"page:chrome-extension"))await Q(ee,r,o).catch(()=>{});let a=t.arguments,c=t.operation==="call"&&t.tool==="open_tab"&&a&&typeof a==="object"&&!Array.isArray(a)?nt(a.url):null;if(!c)throw new f("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 Q(c,r,o),H({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(e,r=k){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let i=t.permissions;if(!i||typeof i!=="object")return e.output;let o=i,a=[...o.accessibility==="missing"?["accessibility"]:[],...o.screenRecording==="missing"?["screen"]:[]];if(a.length===0)return e.output;return await at(e.runId,e.identity,a,r,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:a}))}}var M=172032,ht=18874368,gt=8192,bt=65536,wt=55000,xt=60000,yt=4,St=40000,At=/^[0-9a-f-]{36}$/,de=V,Ot=Se();function E(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function B(){throw new f("invalid_automation_request","Reason automation request is malformed.")}function ve(e){let r=Object.keys(e).sort().join(",");if(r==="call"||r==="browser,call"){let t=e.call,i=r==="browser,call";if(!E(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||i&&(e.browser!==he||t.kind!=="browser")||JSON.stringify(t).length>bt)B();return{call:t,userChrome:i}}if(r==="offset,output_id"){if(typeof e.output_id!=="string"||!At.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)B();return{output_id:e.output_id,offset:e.offset}}return B()}function Or(e=process.platform,r=v){if(e==="darwin")return!0;return e==="linux"&&r()?.features.computer===!0}var vt="__computer-use";function Nt(e){let r=(t)=>t?"granted":"missing";return`Permissions: accessibility=${r(e.accessibility)}, screenRecording=${r(e.screen)}
|
|
697
|
+
`}function Rt(e,r,t,i={stdin:process.stdin,stdout:process.stdout}){return new Promise((o)=>{let a=O(e,r,{env:t,stdio:["pipe","pipe","inherit"]}),c=(n)=>{a.kill(n)},s=["SIGTERM","SIGINT","SIGHUP"];for(let n of s)process.on(n,c);i.stdin.pipe(a.stdin),a.stdin.on("error",()=>{return}),a.stdout.pipe(i.stdout,{end:!1});let l=!1,u=(n)=>{if(l)return;l=!0;for(let d of s)process.off(d,c);i.stdin.unpipe(a.stdin),i.stdout.write("",()=>o(n))};a.once("error",()=>u(127)),a.once("close",(n)=>u(n??1))})}async function vr(e,r={}){let t=r.stderr??process.stderr,i=(r.identity??J)(),o=(r.components??v)();if(i.length===0||o?.platform!=="darwin-arm64")return t.write(`Reason computer use: Reason's background identity cannot run Open Computer Use here (computer_use_identity_unavailable)
|
|
698
|
+
`),1;if(e.length===1&&e[0]==="doctor"){let s=await(r.grants??xe)(i);if(!s)return t.write(`Reason computer use: Reason's permissions could not be read (computer_use_permission_status_unavailable)
|
|
699
|
+
`),1;return(r.stdout??process.stdout).write(Nt(s)),0}if(e.length!==1||e[0]!=="mcp")return t.write(`Usage: reason __computer-use mcp|doctor
|
|
700
|
+
`),2;let[a,...c]=i;return(r.run??Rt)(a,[...c,o.ocu,"mcp"],{...process.env,OPEN_COMPUTER_USE_DISABLE_APP_AGENT_PROXY:"1"})}function Nr(e=v){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function Ne(e,r,t,i){return new Promise((o)=>{let a=O(e,r,{env:t,stdio:"ignore"}),c=setTimeout(()=>{a.kill("SIGKILL"),o(-1)},i);a.once("error",()=>{clearTimeout(c),o(-1)}),a.once("exit",(s)=>{clearTimeout(c),o(s??-1)})})}function Tt(e,r,t,i){return new Promise((o)=>{let a=O(e,r,{env:t,stdio:["ignore","pipe","ignore"]}),c="";a.stdout.setEncoding("utf8").on("data",(l)=>{c+=l});let s=setTimeout(()=>{a.kill("SIGKILL"),o(null)},i);a.once("error",()=>{clearTimeout(s),o(null)}),a.once("close",(l)=>{clearTimeout(s),o(l===0?c:null)})})}var Ct="/tmp/open-browser-use",It=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,kt=33554432;function qt(e,r){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let i=E(t)&&E(t.result)?t.result.metadata:null;if(!E(i)||i.extensionId!==r)return null;return typeof i.extensionInstanceId==="string"&&It.test(i.extensionInstanceId)?i.extensionInstanceId:null}async function Re(e,r,t){let i=t.storages.map((s)=>{try{return F(s).filter((l)=>l.endsWith(".log")||l.endsWith(".ldb")).map((l)=>_(s,l))}catch{return[]}}),o;try{o=i.some((s)=>s.length>0)?F(t.socketDir).filter((s)=>s.endsWith(".sock")):[]}catch{return[]}let a=[];for(let s of o){let l=_(t.socketDir,s),u=qt(await Tt(e,["info","--socket",l,"--timeout","2s"],r,5000),t.extensionId);if(u)a.push({instance:u,socket:l})}let c=[];for(let[s,l]of(a.length>0?i:[]).entries())for(let u of l)try{if(pt(u).size>kt)continue;let n=Ae(u),d=a.find((m)=>n.includes(m.instance));if(d){c.push({storage:t.storages[s],...d});break}}catch{}return c}async function Et(e,r,t){return(await Re(e,r,t))[0]?.instance??null}function Te(e,r,t){return Et(e,r,{socketDir:Ct,extensionId:D,storages:[_(t,"browser-profile","Default","Local Extension Settings",D)]})}var fe=/^(Default|Profile ([0-9]+))$/;async function Bt(e,r,t=y(),i=W){let o=_(t,"Library","Application Support","Google","Chrome"),a=[];try{a=F(o)}catch(n){if(n.code==="EPERM")throw new f("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(fe.exec(n)?.[2]??-1),s=a.filter((n)=>fe.test(n)&&G(_(o,n,"Extensions",q))).sort((n,d)=>c(n)-c(d)),l=(n)=>_(o,n,"Local Extension Settings",q);return(await Re(e,r,{socketDir:i,extensionId:q,storages:s.map(l)})).map(({storage:n,instance:d,socket:m})=>({profile:s.find((p)=>l(p)===n),instance:d,socket:m}))}async function Ft(e,r,t=y(),i=W){let o=(await Bt(e,r,t,i))[0]?.instance;if(!o)throw new f("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 o}function me(e){return new Promise((r)=>{let t=_t({path:e}),i=(o)=>{t.destroy(),r(o)};t.setTimeout(1000,()=>i(!1)),t.once("error",()=>i(!1)),t.once("connect",()=>i(!0))})}async function Ce(e,r){let t=Date.now()+r;while(Date.now()<t){if(await e())return!0;await new Promise((i)=>setTimeout(i,200))}return!1}var $=new Map;function L(e,r){let t=$.get(e);if(!t)t=r().finally(()=>$.delete(e)),$.set(e,t);return t}async function Pt(e,r){if(await me(e))return;if(mt(e,{force:!0}),await Ne("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],r,1e4)!==0||!await Ce(()=>me(e),5000))throw new f("automation_unavailable","Reason could not start the desktop session bus.")}async function pe(e,r,t){let i=e.platform==="darwin-arm64"?async()=>await Te(e.nativeHost,r,t)!==null:async()=>await Ne(e.nativeHost,["info"],r,5000)===0;if(await i())return;let o=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],a,c=null,s=0;if(e.platform==="darwin-arm64"){let n=_(t,"browser-profile");T(n);let d=_(n,"NativeMessagingHosts");le(d,{recursive:!0,mode:448});let m=z(e.platform).nativeHostManifests[0];ce(m,_(d,ue(m)));let p=e.browser.slice(0,e.browser.indexOf(".app/")+4),b=o.filter((A)=>A!=="about:blank").concat("--no-startup-window","--use-mock-keychain");a=O("/usr/bin/open",["-g","-n","-a",p,"--args",`--user-data-dir=${n}`,...b],{env:r,stdio:"ignore"})}else{let n=_(r.HOME,".config","google-chrome"),d=_(n,"NativeMessagingHosts");le(d,{recursive:!0,mode:448});let m=z(e.platform).nativeHostManifests[0];ce(m,_(d,ue(m)));let p=process.geteuid?.()===0?["--no-sandbox"]:[];c=_(t,"browser.log");let b=ut(c,"a",384);s=lt(b).size,a=O(e.browser,[`--user-data-dir=${n}`,...o,...p,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",b,b],env:{...r,ACCESSIBILITY_ENABLED:"1"}}),ct(b)}let l=!1;a.once("error",()=>{l=!0}),a.once("exit",(n)=>{l||=n!==0}),a.unref();let u=!1;if(await Ce(async()=>l||(u=await i()),St),!u){if(c&&Ae(c).subarray(s).toString("utf8").includes("No usable sandbox"))throw new f("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 f("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Rr(e){await qe(e,!0)}function Tr(e){return Ie(e,ke(e))}function Ie(e,r){return e.platform==="darwin-arm64"?_(r,"browser-profile"):_(r,"home",".config","google-chrome")}function ke(e){let r=_(e.root,"automation");if(!G(r)||!$t(e.automation))return e.automation;if(!Lt(Ie(e,r)))try{ft(r,e.automation)}catch{}return G(r)?r:e.automation}function $t(e){try{return F(e).length===0}catch(r){return r.code==="ENOENT"}}function Lt(e){let r;try{r=dt(_(e,"SingletonLock"))}catch{return!1}let t=Number(r.slice(r.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(i){return i.code==="EPERM"}}async function qe(e,r){be({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=ke(e);T(t);let i=Oe().username,o={USER:i,LOGNAME:i,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"){let n={...o,HOME:y(),PATH:`${U(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:vt};if(!r)return n;await L("browser",()=>pe(e,n,t));let d=await Te(e.nativeHost,n,t);if(!d)throw new f("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...n,REASON_AUTOMATION_OBU_INSTANCE:d,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let a=await Fe(),c=_(t,"home"),s=_(t,"runtime");T(c),T(s);let l=_(t,"bus"),u={...o,HOME:c,PATH:`${U(e.node)}:/usr/bin:/bin`,DISPLAY:a.display,XAUTHORITY:a.xauthority,XDG_RUNTIME_DIR:s,DBUS_SESSION_BUS_ADDRESS:`unix:path=${l}`,...a.sound?{PULSE_SERVER:ye(a.sound)}:{}};if(await L("bus",()=>Pt(l,u)),r)await L("browser",()=>pe(e,u,t));return u}async function Dt(e,r,t){let i=Oe().username,o={USER:i,LOGNAME:i,HOME:y(),PATH:`${U(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:r,REASON_AUTOMATION_BACKGROUND_TABS:"1"},a=await Ft(r,o);return t.throwIfAborted(),{...o,REASON_AUTOMATION_OBU_INSTANCE:a}}function Ee(e,r,t,i){if(typeof de!=="string")return Promise.reject(new f("automation_unavailable","This Reason build has no automation runtime."));let o=de;return new Promise((a,c)=>{let s=O(e,["--input-type=module","--eval",o],{env:{...r,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:!0}),l=[],u=0,n="",d=null,m=!1,p=(h)=>{d??=h;try{process.kill(-s.pid,"SIGKILL")}catch{s.kill("SIGKILL")}},b=(h)=>{if(m)return;m=!0,clearTimeout(A),i.removeEventListener("abort",x),h()},A=setTimeout(()=>p(new f("automation_timed_out","Reason automation did not finish in time.")),wt),x=()=>p(new f("cancelled","Reason cancelled the automation call."));if(i.addEventListener("abort",x,{once:!0}),s.stdout.on("data",(h)=>{if(u+=h.byteLength,u>ht)p(new f("automation_output_too_large","Reason automation output is too large."));else l.push(h)}),s.stderr.setEncoding("utf8").on("data",(h)=>{n=(n+h).slice(-gt)}),s.stdin.on("error",()=>{}),s.once("error",()=>b(()=>c(d??new f("automation_unavailable","Reason could not start the automation runtime.")))),s.once("close",(h)=>b(()=>{if(d)c(d);else a({code:h??1,stdout:Buffer.concat(l),stderr:n})})),i.aborted)x();s.stdin.end(t)})}var S=new Map;function Gt(e,r,t){for(let[o,a]of S)if(a.expiresAt<=t)S.delete(o);while(S.size>=yt)S.delete(S.keys().next().value);let i=Se();return S.set(i,{runId:e,bytes:r,expiresAt:t+xt}),i}async function Be(e,r,t,i={}){let o=await(i.environment??qe)(e,r.kind==="browser");return t.throwIfAborted(),await(i.runtime??Ee)(e.node,o,JSON.stringify(r),t)}async function Cr(e,r){let t=ve({call:e});if(!("call"in t))B();let i=v();if(!i?.features.computer||t.call.kind==="browser"&&!i.features.browser)throw new f("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Be(i,t.call,r)}function _e(e,r,t){let i=e.stdout.byteLength>M?Gt(r,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:Ot,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,M).toString("base64"),...i?{output_id:i}:{}}}async function Ir(e,r={}){let t=ve(e.payload),i=(r.now??Date.now)();if("output_id"in t){let p=S.get(t.output_id);if(!p||p.runId!==e.runId||p.expiresAt<=i||t.offset>p.bytes.byteLength)throw new f("automation_output_unavailable","Reason automation output expired.");return{chunk:p.bytes.subarray(t.offset,t.offset+M).toString("base64")}}let o=(r.components??v)(),a=(r.platform??process.platform)==="darwin",c=a?(r.macIdentity??J)():[],s=r.macSetup??k,l=!o?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!o.features.browser;if(a&&(l||c.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return _e(await se({runId:e.runId,call:t.call,identity:c,desktopMissing:l,signal:e.signal},s),e.runId,i);if(!o?.features.computer)throw new f("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let u=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!u)throw new f("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(t.call.kind==="browser"&&!u&&!o.features.browser)throw new f("automation_browser_not_installed",o.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`.");e.signal.throwIfAborted();let n=await we(e.runId,e.signal,r.now),d="account"in r?r.account??null:ge(),m;try{if(u){let p=await(r.userChromeEnvironment??Dt)(o,u,e.signal);e.signal.throwIfAborted(),m=await(r.runtime??Ee)(o.node,p,JSON.stringify(t.call),e.signal)}else if(d)m=await(r.delegate??X)(d,t.call,e.signal);else m=await Be(o,t.call,e.signal,r)}finally{n()}if(a)m=await ne({runId:e.runId,call:t.call,identity:c,output:m,signal:e.signal},s);return _e(m,e.runId,i)}
|
|
701
|
+
export{Ke as sd,M as td,ve as ud,Or as vd,Rt as wd,vr as xd,Nr as yd,Bt as zd,Ft as Ad,Rr as Bd,Tr as Cd,Cr as Dd,Ir as Ed};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{O as
|
|
2
|
+
import{tj as $}from"./vm-hands-entry-lite-qhgfnhjt.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 pj,Z as qj,S as rj,k as sj};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ci as v,Fi as _,Hi as w,Li as S,Mi as x}from"./vm-hands-entry-lite-x4j4058x.js";import{Ri as I}from"./vm-hands-entry-lite-1j9r1fca.js";import{pj as O}from"./vm-hands-entry-lite-p8662x7z.js";import{Ij as L,Jj as T}from"./vm-hands-entry-lite-ha1ej910.js";import{ak as G}from"./vm-hands-entry-lite-h2xemq1f.js";import{spawnSync as l}from"child_process";import{dirname as B}from"path";import{spawn as y}from"child_process";import{accessSync as c,constants as g}from"fs";import{basename as h,join as m}from"path";var j=null;function U(q){if(j===q)j=null;if(q.exitCode===null&&q.signalCode===null)q.kill("SIGTERM")}var C=(q,z)=>{if(j)U(j);let J=m(q,v);try{c(J,g.X_OK)}catch{return()=>{}}let F;try{F=y(J,["--app",q,"--name",h(q,".app"),"--permission",z==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return F.on("error",()=>{if(j===F)j=null}),F.once("exit",()=>{if(j===F)j=null}),F.unref(),j=F,()=>U(F)};var M=`Reason permissions
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
reason permissions [--json]
|
|
6
|
+
reason permissions allow [screen|accessibility|disk]
|
|
7
|
+
|
|
8
|
+
The macOS privacy permissions of this computer's Reason worker:
|
|
9
|
+
screen Screen & System Audio Recording: desktop video, computer-use screenshots
|
|
10
|
+
accessibility Accessibility: computer-use clicks and typing, desktop input
|
|
11
|
+
disk Full Disk Access (recommended): Sessions in Desktop, Documents,
|
|
12
|
+
Downloads, iCloud Drive and Mail
|
|
13
|
+
|
|
14
|
+
allow asks for each missing one, or the one named. macOS cannot ask for Full
|
|
15
|
+
Disk Access: allow disk opens its pane, shows the file to add in Finder and
|
|
16
|
+
waits until the worker has it.
|
|
17
|
+
`,D="x-apple.systempreferences:com.apple.preference.security",a="curl -fsSL https://reasonmachines.com/install.sh | bash",d=180000,n=2000,E=["screen","accessibility","disk"],N={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${D}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${D}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${D}?Privacy_AllFiles`}};function k(q){return q.executable}function p(q,z){if(q==="computer_use_identity_missing")return`Reason's background identity is not installed (${q}); reinstall Reason: ${a}`;if(q==="computer_use_identity_outdated")return`Reason's background identity is outdated (${w(z)??"unknown"}; this CLI is ${O}) (${q}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${q}); run the installed \`reason\``}function s(q=I()){let z=S(q);if(z.length>0)return{state:"ready",path:B(B(B(z[0]))),prefix:z};let J=x(z,q)??"computer_use_identity_unavailable";return{state:J,path:_(q),detail:p(J,q)}}function u(){return{identity:()=>s(),grants:(q)=>L(q),request:(q,z)=>T(q,z),worker:async()=>(await import("./status-f146chye.js")).connectionMacState(),open:(q)=>{l("/usr/bin/open",q,{stdio:"ignore",timeout:1e4})},tile:C,restartConnection:async()=>(await import("./connect-cli-ev4xex04.js")).restartConnection(),sleep:(q)=>new Promise((z)=>setTimeout(z,q)),now:()=>Date.now()}}function P(q,z,J){if(q.state!=="ready"||!z)return"unknown";return z[J]?"granted":"missing"}async function b(q){let z=q.identity(),J=z.state==="ready"?await q.grants(z.prefix):null,F=await q.worker(),X=F?k(F):null,Q=!X||F?.full_disk_access==="unknown"?"unknown":F?.full_disk_access==="granted"?"granted":"missing",$=(K,H,Z)=>{let{label:R,purpose:W,level:V}=N[K];return{id:K,label:R,purpose:W,level:V,state:H,holder:Z}};return{identity:{state:z.state,path:z.path,detail:z.state==="ready"?null:z.detail},worker_detail:X?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[$("screen",P(z,J,"screen"),z.path),$("accessibility",P(z,J,"accessibility"),z.path),$("disk",Q,X)]}}function Rq(q){let z=q.identity.state==="ready"?null:q.identity.state,J=q.permissions.filter((Q)=>Q.state==="granted").length,F=[...z?[z]:[],...q.permissions.filter((Q)=>Q.state!=="granted"&&!(z&&Q.id!=="disk")).map((Q)=>`${Q.label} ${Q.state}`)],X=!z&&q.permissions.some((Q)=>Q.state==="missing");return`Permissions: ${J} of ${q.permissions.length}${F.length>0?` (${F.join(", ")})`:""}`+(X?" \u2014 reason permissions allow":F.length>0?" \u2014 reason permissions":"")}function t(q){let z=[];if(q.identity.detail)z.push(q.identity.detail);z.push(`Reason: ${q.identity.path}`);let J=q.permissions.find((F)=>F.id==="disk");z.push(J?.holder?`Worker: ${J.holder}`:`Worker: ${q.worker_detail}`),z.push("");for(let F of q.permissions){let X=`${F.label}${F.level==="recommended"?" (recommended)":""}`;z.push(` ${F.id.padEnd(13)} ${F.state.padEnd(7)} ${X}: ${F.purpose}`)}if(q.permissions.some((F)=>F.state==="missing"))z.push("","Allow the missing ones: reason permissions allow");return`${z.join(`
|
|
18
|
+
`)}
|
|
19
|
+
`}async function A(q,z){let J=z.now()+d;for(;;){if(await q())return!0;if(z.now()>=J)return!1;await z.sleep(n)}}async function o(q,z){let J=z.host??u(),{io:F}=z,X=await b(J),Q=X.permissions.filter((Z)=>q.includes(Z.id)&&Z.state!=="granted");if(Q.length===0)return F.stdout.write(`Reason permissions: ${q.map((Z)=>N[Z].label).join(", ")} already allowed.
|
|
20
|
+
`),0;let $=!1,K=!1,H=J.identity();for(let Z of Q){let{label:R,pane:W}=N[Z.id];if(Z.id!=="disk"){if(H.state!=="ready"){if(!$)F.stderr.write(`Reason permissions: ${H.detail}
|
|
21
|
+
`);$=!0;continue}let Y=Z.id;await J.request(H.prefix,Y),J.open([W]);let f=J.tile(H.path,Y);if(F.stdout.write(`Allow Reason in System Settings > Privacy & Security > ${R}.
|
|
22
|
+
`),!z.wait)continue;if(F.stdout.write(`Waiting for it (Ctrl-C to stop)\u2026
|
|
23
|
+
`),await A(async()=>(await J.grants(H.prefix))?.[Y]===!0,J).finally(f))F.stdout.write(`${R}: granted.
|
|
24
|
+
`),K=!0;else F.stderr.write(`${R} is not allowed yet; turn on Reason there, then run \`reason permissions\`.
|
|
25
|
+
`),$=!0;continue}let V=k(await J.worker()??{executable:null});if(!V){F.stderr.write(`Reason permissions: ${X.worker_detail} Then run \`reason permissions allow disk\`.
|
|
26
|
+
`),$=!0;continue}if(J.open([W]),J.open(["-R",V]),F.stdout.write(`Full Disk Access: click + and choose ${V} (shown in Finder), or drag it into the list.
|
|
27
|
+
`),!z.wait)continue;if(F.stdout.write(`Waiting for the worker to report it (Ctrl-C to stop)\u2026
|
|
28
|
+
`),await A(async()=>(await J.worker())?.full_disk_access==="granted",J))F.stdout.write(`Full Disk Access: granted.
|
|
29
|
+
`);else F.stderr.write("Full Disk Access is not reported yet. If you allowed it, `reason connect` restarts the worker with it.\n"),$=!0}if(K)try{if(await J.restartConnection())F.stdout.write(`This computer's Reason connection restarted to use them.
|
|
30
|
+
`)}catch(Z){F.stderr.write(`This computer's Reason connection uses them after it restarts (\`reason connect\`): ${Z instanceof Error?Z.message:String(Z)}
|
|
31
|
+
`)}return $?1:0}function i(q){if(q.some((F)=>["--help","-h","help"].includes(F)))return{command:"help"};let[z,...J]=q;if(z===void 0||z==="--json")return q.length<=1?{command:"list",json:z==="--json"}:{error:`Unknown option: ${q[1]}`};if(z!=="allow")return{error:`Unknown permissions command: ${z}`};if(J.length>1)return{error:`Unknown option: ${J[1]}`};if(J.length===0)return{command:"allow",ids:[...E]};if(!E.includes(J[0]))return{error:`allow expects ${E.join(", ")}.`};return{command:"allow",ids:[J[0]]}}async function Vq(q,z={}){let J=z.io??{stdout:process.stdout,stderr:process.stderr},F=i(q);if("error"in F)return J.stderr.write(`${F.error}
|
|
32
|
+
|
|
33
|
+
${M}`),1;if(F.command==="help")return J.stdout.write(M),0;let X=z.platform??process.platform;if(X!=="darwin")return J.stdout.write(F.command==="list"&&F.json?`${JSON.stringify({platform:X,applicable:!1})}
|
|
34
|
+
`:`Reason permissions: macOS privacy permissions do not apply on this computer.
|
|
35
|
+
`),0;let Q=z.host??u();if(F.command==="allow")return o(F.ids,{io:J,wait:!0,host:Q});let $=await b(Q);return J.stdout.write(F.json?`${JSON.stringify({platform:X,applicable:!0,...$},null,2)}
|
|
36
|
+
`:t($)),0}
|
|
37
|
+
export{C as pi,M as qi,E as ri,k as si,s as ti,b as ui,Rq as vi,t as wi,o as xi,i as yi,Vq as zi};
|