@reason-machines/cli-linux-arm64-musl 0.2.315 → 0.2.317
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/connect-cli-tmegy1zz.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-wzq9x8k5.js +2 -0
- package/bin/vm-hands/desktop-account-e9asw4vf.js +2 -0
- package/bin/vm-hands/{device-workspace-ecq3hfd6.js → device-workspace-1dm2ry6e.js} +1 -1
- package/bin/vm-hands/{hands-worker-source-w477y8ad.js → hands-worker-source-snbsr08g.js} +1 -1
- package/bin/vm-hands/{index-nxzv9qe7.js → index-p6kg955p.js} +1 -1
- package/bin/vm-hands/local-automation-wxx64z00.js +2 -0
- package/bin/vm-hands/local-capabilities-nx9mgygs.js +2 -0
- package/bin/vm-hands/local-desktop-users-j09q8cnt.js +2 -0
- package/bin/vm-hands/local-display-mac-mjjems8c.js +2 -0
- package/bin/vm-hands/local-display-session-r9n0cnf2.js +2 -0
- package/bin/vm-hands/{network-contract-57qe40tm.js → network-contract-kxgvk10y.js} +1 -1
- package/bin/vm-hands/package-28msp113.js +2 -0
- package/bin/vm-hands/permissions-zjrdww61.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-as5477xr.js → reason-hands-protocol-7t7mewye.js} +1 -1
- package/bin/vm-hands/{status-b63rer3v.js → status-5ardrey9.js} +2 -2
- package/bin/vm-hands/version-6qnegds2.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-wgx7z7gt.js → vm-hands-entry-lite-14t846kp.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-6j2yaa4n.js → vm-hands-entry-lite-22jgncrd.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-t4hkghhm.js → vm-hands-entry-lite-37h9vzhv.js} +34 -34
- package/bin/vm-hands/vm-hands-entry-lite-3rx6cm14.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-msgz8sgz.js → vm-hands-entry-lite-5a34n6sz.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-53cyjs1a.js → vm-hands-entry-lite-5d1hcp23.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-mgn96c0f.js → vm-hands-entry-lite-7ve198cs.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ya1a2eep.js → vm-hands-entry-lite-93ejmwqn.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-em388nee.js → vm-hands-entry-lite-cp1wqjs5.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-79ww0h62.js → vm-hands-entry-lite-famqdhz7.js} +77 -77
- package/bin/vm-hands/{vm-hands-entry-lite-5z6prrcd.js → vm-hands-entry-lite-hths5rsx.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-q6fshf3h.js → vm-hands-entry-lite-kqn1bkrr.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-c3jqrn7n.js → vm-hands-entry-lite-m8tb88zv.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-7k65s010.js → vm-hands-entry-lite-mzxhng4z.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-btwvn63p.js → vm-hands-entry-lite-n4xx6qfr.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yp315y25.js → vm-hands-entry-lite-ne8kkvk4.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-rrk5g62b.js → vm-hands-entry-lite-q8b738zj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-v2wx52wn.js → vm-hands-entry-lite-qa7d2zwf.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-hf0mk7vd.js → vm-hands-entry-lite-t3gpbwqp.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-21qkhpm0.js → vm-hands-entry-lite-t9kc2r71.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-xsq25kmd.js → vm-hands-entry-lite-v6tkjqb1.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-gx1z18j4.js → vm-hands-entry-lite-vreqarwc.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-pf1ft65e.js → vm-hands-entry-lite-wh0qp1gf.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-bswnp5ve.js → vm-hands-entry-lite-xf6schkk.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-q2pb31vh.js → vm-hands-entry-lite-yhz6sv35.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-sd4qj8xc.js → vm-hands-executor-ggktb5tz.js} +1 -1
- package/bin/vm-hands/{vm-hands-op-runner-krvw3y2n.js → vm-hands-op-runner-4a4e5cmr.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-t87hg6ne.js → vm-hands-runtime-wv3mr81c.js} +3 -3
- package/bin/vm-hands/worker-sandbox-7zfttr2t.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/connect-cli-kxkvwnwa.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-p2bvtf6p.js +0 -2
- package/bin/vm-hands/desktop-account-axaenf68.js +0 -2
- package/bin/vm-hands/local-automation-7w9j1nws.js +0 -2
- package/bin/vm-hands/local-capabilities-6smn23kd.js +0 -2
- package/bin/vm-hands/local-desktop-users-4756c92y.js +0 -2
- package/bin/vm-hands/local-display-mac-3zz66vzn.js +0 -2
- package/bin/vm-hands/local-display-session-7pds34s8.js +0 -2
- package/bin/vm-hands/package-s6y0j1as.js +0 -2
- package/bin/vm-hands/permissions-hy10xxeg.js +0 -2
- package/bin/vm-hands/version-ktk9b8p6.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-0ergg2ky.js +0 -3
- package/bin/vm-hands/worker-sandbox-snmfpfax.js +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ee as w}from"./vm-hands-entry-lite-kqn1bkrr.js";var _="inference.custom.v1",K=32768,O=67108864,P=16384,Q=204800,$=600000,S=["content-type","anthropic-version","user-agent"],L=w.enum(["openai-completions","openai-responses","anthropic-messages"]),T=new Set(S),U=w.record(w.string(),w.string().max(2048)).refine((j)=>Object.keys(j).every((A)=>T.has(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)),"Only non-secret custom endpoint request headers are permitted");function F(j){try{let A=new URL(j);return["http:","https:"].includes(A.protocol)&&!A.username&&!A.password&&!A.search&&!A.hash?A:null}catch{return null}}function V(j,A){let B=F(j.baseUrl),H=F(A.baseUrl),D=F(j.url);if(!B||!H||!D||j.method!=="POST"||A.execution!=="device")return!1;let I=(J)=>J.origin+J.pathname.replace(/\/+$/,"");if(I(B)!==I(H)||D.origin!==B.origin)return!1;let N=A.api==="openai-completions"?"/chat/completions":A.api==="openai-responses"?"/responses":"/v1/messages";return D.pathname===B.pathname.replace(/\/+$/,"")+N}var x=w.object({baseUrl:w.string().max(2048),url:w.string().max(4096),method:w.literal("POST"),body:w.string().refine((j)=>new TextEncoder().encode(j).byteLength<=Q).optional(),headers:U,credentialOrganizationId:w.string().uuid(),accountKey:w.string().min(1).max(256).optional()}).strict().refine((j)=>L.options.some((A)=>V(j,{baseUrl:j.baseUrl,api:A,execution:"device"})),"Invalid custom endpoint inference URL"),C=w.object({status:w.number().int().min(200).max(599),statusText:w.string().max(256).refine((j)=>!/[\r\n\0]/.test(j)),headers:w.record(w.string(),w.string().max(4096)).refine((j)=>Object.keys(j).every((A)=>["content-type","retry-after","x-request-id","request-id"].includes(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)))}).strict(),E=w.union([w.object({eof:w.literal(!0)}).strict(),w.object({eof:w.literal(!1),data:w.string().max(Math.ceil(K/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((j)=>j.length>0&&j.length*3/4-(j.endsWith("==")?2:j.endsWith("=")?1:0)<=K)}).strict()]),M=w.object({bytes:w.number().int().min(0).max(O),chunks:w.number().int().min(0).max(P)}).strict(),R=w.object({apiKey:w.string().min(1).max(16384).refine((j)=>!/[\r\n\0]/.test(j)),api:L}).strict(),W=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function z(j){return typeof j==="string"&&W.includes(j)}var X="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",G={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${X}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."},Y=new Set(Object.values(G));function p(j){return Object.hasOwn(G,j)?G[j]:null}function b(j){return typeof j==="string"&&Y.has(j)}
|
|
3
|
+
export{_ as _b,K as $b,O as ac,P as bc,Q as cc,$ as dc,S as ec,V as fc,x as gc,C as hc,E as ic,M as jc,R as kc,W as lc,z as mc,p as nc,b as oc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{if as Z8}from"./vm-hands-entry-lite-wh0qp1gf.js";import{rf as R0}from"./vm-hands-entry-lite-yhz6sv35.js";import{ng as Kq}from"./vm-hands-entry-lite-5d1hcp23.js";import{Jg as p,Mg as V0,Pg as F0,Qg as C8,Rg as eq,Tg as g8,Wg as q0,Yg as x0}from"./vm-hands-entry-lite-22jgncrd.js";import{bh as wq}from"./vm-hands-entry-lite-mzxhng4z.js";import{ch as o,dh as C0}from"./vm-hands-entry-lite-cp1wqjs5.js";import{qh as B0}from"./vm-hands-entry-lite-ne8kkvk4.js";import{Hh as A0}from"./vm-hands-entry-lite-14t846kp.js";import{Oh as Z}from"./vm-hands-entry-lite-v6tkjqb1.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
|
|
181
|
+
export{T1 as fe,T0 as ge,D1 as he,D9 as ie,B9 as je,O8 as ke,PX as le,NX as me,i as ne,R8 as oe,Q9 as pe,U0 as qe,Vq as re,Hq as se,r as te,HX as ue,fX as ve,gX as we,E1 as xe,G8 as ye,g1 as ze,h1 as Ae,$9 as Be,A8 as Ce,I1 as De,O9 as Ee};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Tg as wz,Ug as Nz}from"./vm-hands-entry-lite-22jgncrd.js";import{ch as N}from"./vm-hands-entry-lite-cp1wqjs5.js";import{Ch as A}from"./vm-hands-entry-lite-hths5rsx.js";import{Sh as Fz}from"./vm-hands-entry-lite-t3gpbwqp.js";import{spawnSync as iz}from"child_process";import{dirname as g}from"path";import{spawn as cz}from"child_process";import{accessSync as lz,constants as sz}from"fs";import{basename as nz,join as pz}from"path";import{randomUUID as p}from"crypto";import{spawnSync as M}from"child_process";import{chmodSync as Hz,cpSync as Rz,existsSync as U,lstatSync as O,mkdirSync as i,readdirSync as Cz,readFileSync as E,readlinkSync as Lz,realpathSync as T,renameSync as R,rmdirSync as Mz,rmSync as P,symlinkSync as c,writeFileSync as Oz}from"fs";import{dirname as C,join as D,relative as Uz,resolve as Tz}from"path";var a="so.ara.cli",_z="5LJFSBRY2F";var o="ReasonBackgroundIdentity",r="Contents/Helpers/ReasonPermissionTile";var x="AraBackgroundIdentity",Az="Reason",Iz=`anchor apple generic and identifier "${a}" and certificate leaf[subject.OU] = "${_z}"`;class L extends Error{code;constructor(z,J){super(J);this.code=z;this.name="MacOSBackgroundIdentityError"}}var k="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function v(z=N()){return D(z,"Library","Application Support","Reason","Background","Reason.app")}function _(z=N()){return D(z,"Library","Application Support","Ara","Background","Ara.app")}function kz(z){try{return O(z).isFile()}catch{return!1}}function y(z){return[o,x].map((J)=>D(z,"Contents","MacOS",J)).find(kz)??null}function w(z){try{if(!O(z).isDirectory())return!1;let J=E(D(z,"Contents","Info.plist"),"utf8");return J.includes(`<string>${a}</string>`)&&(J.includes(`<string>${Az}</string>`)||J.includes("<string>Ara</string>"))&&y(z)!==null}catch{return!1}}function I(z=N()){let J=v(z);if(!w(J))return null;try{let Z=E(D(J,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(Z)?.[1]??null}catch{return null}}function Sz(z,J=N()){let Z=I(J);return Z===null||$z(S(Z.split(".")),S(z.split(/[.-]/).slice(0,3)))}var fz=1e4;function t(z,J){return M(z,[...J],{stdio:"ignore",timeout:fz}).status??1}var e=new Set;function zz(z){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let J=(Z)=>{try{return T(Z)}catch{return Tz(Z)}};if(z!==void 0&&J(z)!==J(N()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var Jz=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.ara(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,Zz=new Set(["ara","ara.exe","reason","reason.exe"]);function S(z){return z.map((J)=>Number(J))}function $z(z,J){for(let Z=0;Z<3;Z+=1)if(z[Z]!==J[Z])return z[Z]<J[Z];return!1}var Ez=[0,2,161];function xz(z){if(z===null)return!0;let J=Ez,Z=null;try{Z=T(process.execPath)}catch{}return z.some(($)=>{let j=Jz.exec($);if(j){let Q=j[1]===void 0?j.slice(4,7):j.slice(1,4);return $z(S(Q),J)}let q=$.slice($.lastIndexOf("/")+1);return Zz.has(q)&&$!==Z&&$!==process.execPath})}function yz(){let z=M("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(z.status!==0)return null;let J=[];for(let Z of z.stdout.split(`
|
|
3
3
|
`)){let $=/^\s*(\d+)\s+(\S.*)$/.exec(Z);if(!$||Number($[1])===process.pid)continue;let j=$[2].trimEnd(),q=j.slice(j.lastIndexOf("/")+1);if(!Jz.test(j)&&Zz.has(q)){let V=M("/usr/sbin/lsof",["-a","-p",$[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((X)=>X.startsWith("n/"));if(V)j=V.slice(1)}J.push(j)}return J}function bz(z){if(zz(z.home),!w(z.sourceApp))throw new L("identity_invalid","The packaged Reason background identity is missing or invalid.");let J=z.command??t,Z=v(z.home),$=C(Z);i($,{recursive:!0,mode:448}),Hz($,448);let j=T(z.sourceApp),q=null;try{q=T(Z)}catch{}if(j!==q){let Q=`${process.pid}.${p()}`,V=D($,`.Reason.app.${Q}.tmp`),X=D($,`.Reason.app.${Q}.old`),W=!1;try{if(Rz(j,V,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!w(V))throw new L("identity_invalid","The copied Reason background identity is invalid.");let Y=z.releaseSigned?["--test-requirement",`=${Iz}`]:[];if(J("/usr/bin/codesign",["--verify","--strict",...Y,V])!==0)throw new L("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let B=!1;for(let F=0;F<4;F+=1){let G=!1;try{R(Z,X),G=!0,W=!0}catch(K){if(K.code!=="ENOENT")throw K}if(F===0)z.beforePublish?.();try{R(V,Z),B=!0}catch(K){let m=K.code;if(!["EEXIST","ENOTEMPTY"].includes(m??""))throw K;if(G)P(X,{recursive:!0,force:!0}),W=!1;if(F===3)throw K;continue}if(G)P(X,{recursive:!0,force:!0}),W=!1;break}if(!B)throw Error("Could not publish Reason's background identity.")}catch(Y){if(W&&!U(Z)&&U(X))R(X,Z);throw Y}finally{P(V,{recursive:!0,force:!0}),P(X,{recursive:!0,force:!0})}}return Wz(Z,z,{verified:j!==q}),Z}function jz(z){return D(C(z),".Reason.app.registered")}function qz(z){try{let J=O(z);return J.isDirectory()?`${J.ino}:${J.birthtimeMs}`:null}catch{return null}}function f(z){let J=qz(z);try{return J!==null&&E(jz(z),"utf8")===J}catch{return!1}}function Qz(z){if(w(z))return"bundle";try{if(O(D(z,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return O(D(z,"Contents","MacOS",x)).isSymbolicLink()?"retired":null}catch{return null}}function Wz(z,J,Z={}){let $=J.command??t;if(!Z.verified&&$("/usr/bin/codesign",["--verify","--strict",z])!==0)throw new L("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if($(k,["-f",z])!==0)throw new L("identity_register_failed","Could not register Reason's macOS background identity.");let j=qz(z);try{if(j)Oz(jz(z),j,{mode:384})}catch{}try{gz(z,J.home,$,J.runningExecutables??yz)}catch(q){let Q=q.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${Q})
|
|
5
5
|
`)}}function gz(z,J,Z,$){let j=y(z);if(!j)return;let q=_(J),Q=C(q),V=(K)=>D(K,"Contents","MacOS",x),X=Uz(C(V(q)),j),W=`${process.pid}.${p()}`,Y=Qz(q);if(Y===null)return;let B=Y==="bundle";if(B)Z(k,["-u",q]);let F=D(Q,`.Ara.app.${W}.old`);if(!e.has(q)&&!xz($())){if(!B)Z(k,["-u",q]);try{R(q,F)}catch(K){if(K.code==="ENOENT")return;throw K}P(F,{recursive:!0,force:!0}),uz(Q);return}if(!B){if(Lz(V(q))===X)return;let K=`${V(q)}.${W}`;c(X,K);try{R(K,V(q))}finally{P(K,{force:!0})}return}let G=D(Q,`.Ara.app.${W}.shim`);i(C(V(G)),{recursive:!0}),c(X,V(G));try{try{R(q,F)}catch(K){if(K.code==="ENOENT")return;throw K}try{R(G,q)}catch(K){if(U(q))return;throw R(F,q),K}}finally{P(G,{recursive:!0,force:!0}),P(F,{recursive:!0,force:!0})}}function uz(z){try{if(Cz(z).some((Z)=>Z!==".DS_Store"))return;P(D(z,".DS_Store"),{force:!0}),Mz(z)}catch{}}var l=new Map;function hz(z=N()){let J=l.get(z);if(J)return J;if(process.platform!=="darwin")return[];let Z=s(z);if(Z===null&&U(C(v(z))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),Z=s(z);if(Z===null)return[];return l.set(z,Z),Z}function s(z){let J=v(z),Z=_(z);if(!w(J)||!f(J))try{dz({home:z,skipWhenSettled:!0})}catch{}let $=w(J)&&(f(J)||!w(Z))?J:w(Z)?Z:null,j=$?y($):null;if(!j)return null;if($===Z)e.add(Z);let q=M(j,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return q.status===0&&q.stdout===`spawn
|
|
@@ -20,7 +20,7 @@ The macOS privacy permissions of this computer's Reason worker:
|
|
|
20
20
|
allow asks for each missing one, or the one named. macOS cannot ask for Full
|
|
21
21
|
Disk Access: allow disk opens its pane, shows the file to add in Finder and
|
|
22
22
|
waits until the worker has it.
|
|
23
|
-
`,u="x-apple.systempreferences:com.apple.preference.security",az="curl -fsSL https://reasonmachines.com/install.sh | bash",oz=180000,rz=2000,h=["screen","accessibility","disk"],d={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${u}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${u}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${u}?Privacy_AllFiles`}};function Bz(z){return z.executable}function tz(z,J){if(z==="computer_use_identity_missing")return`Reason's background identity is not installed (${z}); reinstall Reason: ${az}`;if(z==="computer_use_identity_outdated")return`Reason's background identity is outdated (${I(J)??"unknown"}; this CLI is ${A}) (${z}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${z}); run the installed \`reason\``}function ez(z=N()){let J=b(z);if(J.length>0)return{state:"ready",path:g(g(g(J[0]))),prefix:J};let Z=Kz(J,z)??"computer_use_identity_unavailable";return{state:Z,path:v(z),detail:tz(Z,z)}}function Pz(){return{identity:()=>ez(),grants:(z)=>wz(z),request:(z,J)=>Nz(z,J),worker:async()=>(await import("./status-
|
|
23
|
+
`,u="x-apple.systempreferences:com.apple.preference.security",az="curl -fsSL https://reasonmachines.com/install.sh | bash",oz=180000,rz=2000,h=["screen","accessibility","disk"],d={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${u}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${u}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${u}?Privacy_AllFiles`}};function Bz(z){return z.executable}function tz(z,J){if(z==="computer_use_identity_missing")return`Reason's background identity is not installed (${z}); reinstall Reason: ${az}`;if(z==="computer_use_identity_outdated")return`Reason's background identity is outdated (${I(J)??"unknown"}; this CLI is ${A}) (${z}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${z}); run the installed \`reason\``}function ez(z=N()){let J=b(z);if(J.length>0)return{state:"ready",path:g(g(g(J[0]))),prefix:J};let Z=Kz(J,z)??"computer_use_identity_unavailable";return{state:Z,path:v(z),detail:tz(Z,z)}}function Pz(){return{identity:()=>ez(),grants:(z)=>wz(z),request:(z,J)=>Nz(z,J),worker:async()=>(await import("./status-5ardrey9.js")).connectionMacState(),open:(z)=>{iz("/usr/bin/open",z,{stdio:"ignore",timeout:1e4})},tile:Xz,restartConnection:async()=>(await import("./connect-cli-tmegy1zz.js")).restartConnection(),sleep:(z)=>new Promise((J)=>setTimeout(J,z)),now:()=>Date.now()}}function Yz(z,J,Z){if(z.state!=="ready"||!J)return"unknown";return J[Z]?"granted":"missing"}async function vz(z){let J=z.identity(),Z=J.state==="ready"?await z.grants(J.prefix):null,$=await z.worker(),j=$?Bz($):null,q=!j||$?.full_disk_access==="unknown"?"unknown":$?.full_disk_access==="granted"?"granted":"missing",Q=(V,X,W)=>{let{label:Y,purpose:B,level:F}=d[V];return{id:V,label:Y,purpose:B,level:F,state:X,holder:W}};return{identity:{state:J.state,path:J.path,detail:J.state==="ready"?null:J.detail},worker_detail:j?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[Q("screen",Yz(J,Z,"screen"),J.path),Q("accessibility",Yz(J,Z,"accessibility"),J.path),Q("disk",q,j)]}}function MJ(z){let J=z.identity.state==="ready"?null:z.identity.state,Z=z.permissions.filter((q)=>q.state==="granted").length,$=[...J?[J]:[],...z.permissions.filter((q)=>q.state!=="granted"&&!(J&&q.id!=="disk")).map((q)=>`${q.label} ${q.state}`)],j=!J&&z.permissions.some((q)=>q.state==="missing");return`Permissions: ${Z} of ${z.permissions.length}${$.length>0?` (${$.join(", ")})`:""}`+(j?" \u2014 reason permissions allow":$.length>0?" \u2014 reason permissions":"")}function zJ(z){let J=[];if(z.identity.detail)J.push(z.identity.detail);J.push(`Reason: ${z.identity.path}`);let Z=z.permissions.find(($)=>$.id==="disk");J.push(Z?.holder?`Worker: ${Z.holder}`:`Worker: ${z.worker_detail}`),J.push("");for(let $ of z.permissions){let j=`${$.label}${$.level==="recommended"?" (recommended)":""}`;J.push(` ${$.id.padEnd(13)} ${$.state.padEnd(7)} ${j}: ${$.purpose}`)}if(z.permissions.some(($)=>$.state==="missing"))J.push("","Allow the missing ones: reason permissions allow");return`${J.join(`
|
|
24
24
|
`)}
|
|
25
25
|
`}async function Gz(z,J){let Z=J.now()+oz;for(;;){if(await z())return!0;if(J.now()>=Z)return!1;await J.sleep(rz)}}async function JJ(z,J){let Z=J.host??Pz(),{io:$}=J,j=await vz(Z),q=j.permissions.filter((W)=>z.includes(W.id)&&W.state!=="granted");if(q.length===0)return $.stdout.write(`Reason permissions: ${z.map((W)=>d[W].label).join(", ")} already allowed.
|
|
26
26
|
`),0;let Q=!1,V=!1,X=Z.identity();for(let W of q){let{label:Y,pane:B}=d[W.id];if(W.id!=="disk"){if(X.state!=="ready"){if(!Q)$.stderr.write(`Reason permissions: ${X.detail}
|
|
@@ -40,4 +40,4 @@ ${Dz}`),1;if($.command==="help")return Z.stdout.write(Dz),0;let j=J.platform??pr
|
|
|
40
40
|
`:`Reason permissions: macOS privacy permissions do not apply on this computer.
|
|
41
41
|
`),0;let q=J.host??Pz();if($.command==="allow")return JJ($.ids,{io:Z,wait:!0,host:q});let Q=await vz(q);return Z.stdout.write($.json?`${JSON.stringify({platform:j,applicable:!0,...Q},null,2)}
|
|
42
42
|
`:zJ(Q)),0}
|
|
43
|
-
export{a as
|
|
43
|
+
export{a as lg,k as mg,hz as ng,b as og,Kz as pg,dz as qg,mz as rg,VJ as sg,XJ as tg,Xz as ug,Dz as vg,h as wg,Bz as xg,ez as yg,vz as zg,MJ as Ag,zJ as Bg,JJ as Cg,ZJ as Dg,OJ as Eg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ld as CJ,ad as jJ,id as EJ}from"./vm-hands-entry-lite-btwvn63p.js";import{createHash as H,randomBytes as $J}from"crypto";import{closeSync as UJ,fsyncSync as LJ,mkdirSync as vJ,openSync as NJ,renameSync as yJ,rmSync as IJ,statSync as qJ,writeSync as DJ,constants as S}from"fs";import{join as d}from"path";var RJ=1;var r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GJ(J){if(J.environment!==void 0||J.payload.environment!==void 0)throw new W("vm_hands_bind_invalid","bind carries a plaintext environment");if(J.payload.vm_hands_env_deferred===!0&&J.environment_sealed!==void 0)throw new W("vm_hands_bind_invalid","split bind carries an environment");return J.environment_sealed!==void 0}function BJ(J,Z){let{payload:z,authority:K}=J;if(!z||typeof z!=="object"||Array.isArray(z)||!K||typeof K!=="object"||Array.isArray(K)||!Z.deviceId||!Z.rootId||z.run_id!==Z.runId||z.device_id!==Z.deviceId||K.device_id!==Z.deviceId||z.root_id!==Z.rootId||Z.snapshotId!==void 0&&z.snapshot_id!==Z.snapshotId)throw new W("vm_hands_env_invalid","environment does not match this Hands");return z}function AJ(J){if(J.capability!=="hands.connect")throw new W("vm_hands_bind_invalid","not a hands.connect claim");let Z=J.payload;return{kind:"vm_hands.bind",v:1,bind_id:J.attempt_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,run_id:J.run_id,session_id:typeof Z.workspace_id==="string"&&r.test(Z.workspace_id)?Z.workspace_id:J.run_id,brain_generation:Z.target_generation,fence_id:Z.target_fence_id,lease_until:J.lease_until,policy:{agent_profile:"",confinement_key:String(Z.hands_confinement??""),browser_egress:Z.browser_egress??null,policy_digest:Z.vm_hands_policy_digest},cwd:typeof Z.cwd==="string"?Z.cwd:"",claim:J,env:GJ(J)?J.environment_sealed:null}}class W extends Error{code;constructor(J,Z){super(Z);this.code=J}}var g=(J)=>Buffer.from(J instanceof Uint8Array?J:new Uint8Array(J)).toString("base64url"),V=(J)=>new Uint8Array(Buffer.from(J,"base64url"));function v(J){if(J===null||typeof J!=="object")return JSON.stringify(J);if(Array.isArray(J))return`[${J.map(v).join(",")}]`;return`{${Object.keys(J).sort().map((Z)=>`${JSON.stringify(Z)}:${v(J[Z])}`).join(",")}}`}async function zZ(J){let Z=await crypto.subtle.importKey("pkcs8",V(J.device_key.pkcs8),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=V(J.device_key.spki),K=await crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!1,["deriveKey"]),C=new Uint8Array(await crypto.subtle.exportKey("spki",K.publicKey)),N=H("sha256").update(z).digest("base64url");return{signing:{privateKey:Z},agreement:K,signingSpki:z,agreementSpki:C,fingerprint:N}}var fJ=4;class mJ{init;keys;hooks;options;identity="identity_free";lastBrainGeneration=new Map;bound=new Map;binding=new Map;unbinding=new Set;servedRun=!1;verifiedSinceRun=!1;unverified=new Set;structural=Promise.resolve();exclusive(J){let Z=this.structural.then(J,J);return this.structural=Z.catch(()=>{return}),Z}constructor(J,Z,z,K){this.init=J;this.keys=Z;this.hooks=z;this.options=K;if(!r.test(J.workspace_id)&&!/^ws-[a-z0-9]{8,64}$/.test(J.workspace_id))throw new W("vm_hands_layout_invalid","bad workspace id");if(!Number.isSafeInteger(J.instance_generation)||J.instance_generation<1)throw new W("vm_hands_layout_invalid","bad generation")}get phase(){if(this.identity==="identity_free")return"identity_free";if(this.unbinding.size)return"unbinding";return this.bound.size||this.binding.size?"bound":"registered"}isBoundRun(J){for(let Z of this.bound.values())if(Z.runId===J)return!0;return!1}bindIdForRun(J){for(let Z of this.bound.values())if(Z.runId===J)return Z.bindId;return null}get liveBindIds(){return[...new Set([...this.bound.keys(),...this.binding.keys(),...this.unbinding])]}async environmentInstalled(J,Z,z){for(let K=Date.now()+Z;;){let C=this.bound.get(J);if(!C)return!1;if(C.envInstalled)return!0;if(Date.now()>=K||z?.aborted)return!1;await new Promise((N)=>setTimeout(N,25))}}canSpawn(J){for(let Z of this.bound.values())if(Z.runId===J)return Z.envInstalled;return!1}async registerFrame(J){if(this.identity!=="identity_free")throw new W("vm_hands_register_twice","already registered");if(typeof J!=="string"||J.length<16||J.length>256)throw new W("vm_hands_challenge_invalid","bad register challenge");let Z={challenge:J,t:"register",v:RJ,workspace_id:this.init.workspace_id,instance_generation:this.init.instance_generation,credential:this.init.credential,device_public_key:g(this.keys.signingSpki),env_public_key:g(this.keys.agreementSpki),key_fingerprint:this.keys.fingerprint,manifest_digest:this.init.manifest_digest,nonce:g($J(32)),timestamp_ms:(this.options.now??Date.now)(),vm_hands_attest_hold:!0},z=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new TextEncoder().encode(v(Z)));return{...Z,device_signature:g(z)}}async helloFrame(J,Z){if(this.identity==="identity_free")throw new W("vm_hands_not_registered","hello before register");let z=String((this.options.now??Date.now)()),K=g($J(32)),C=CJ({method:"GET",pathAndQuery:jJ,timestamp:z,nonce:K,challenge:J,bodySha256:H("sha256").update("").digest("hex")}),N=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new Uint8Array(C)));return{t:"hello",timestamp:z,nonce:K,signature:g(cJ(N)),...Z?{vm_hands_previous_connection:Z}:{}}}registered(){if(this.identity!=="identity_free")throw new W("vm_hands_register_unexpected","registered twice");this.identity="registered"}async bind(J){if(this.identity!=="registered")throw new W("vm_hands_not_registered","bind before register");if(J.kind!=="vm_hands.bind"||J.v!==1)throw new W("vm_hands_bind_invalid","bad bind");for(let z of[J.bind_id,J.attempt_id,J.run_id,J.session_id,J.fence_id])if(!r.test(z))throw new W("vm_hands_bind_invalid","bad id");if(!Number.isSafeInteger(J.brain_generation)||J.brain_generation<=(this.lastBrainGeneration.get(J.run_id)??0))throw new W("vm_hands_generation_stale","brain generation not strictly higher");if(J.env&&(J.env.aad!==J.bind_id||J.env.alg!=="ECDH-P256+A256GCM"))throw new W("vm_hands_bind_invalid","bad env envelope");if(!/^[0-9a-f]{64}$/.test(J.policy.policy_digest))throw new W("vm_hands_bind_invalid","bad policy or nonce");if(H("sha256").update(v({hands_confinement:J.policy.confinement_key||null,browser_egress:J.policy.browser_egress??null})).digest("hex")!==J.policy.policy_digest)throw new W("vm_hands_policy_mismatch","policy digest does not match the claim");if(this.liveBindIds.includes(J.bind_id)||[...this.bound.values()].some((z)=>z.runId===J.run_id)||[...this.binding.values()].includes(J.run_id))throw new W("vm_hands_busy","this run already holds a bind here");if(this.liveBindIds.length>=fJ)throw new W("vm_hands_busy","every bind slot is held");return this.lastBrainGeneration.set(J.run_id,J.brain_generation),this.binding.set(J.bind_id,J.run_id),this.exclusive(()=>this.setUp(J))}async setUp(J){let Z=[...this.bound.keys()],z=null,K=!1;try{if(Z.length===0){if(this.servedRun&&!this.verifiedSinceRun)await this.hooks.killAndVerifyPayload(),this.unverified.clear()}else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({keep:Z}),this.unverified.clear();this.verifiedSinceRun=!1,this.servedRun=!0,K=!0;let{launchId:C,applied:N,readyData:P}=await this.hooks.startExecutor({bindId:J.bind_id,sessionId:J.session_id,policyDigest:J.policy.policy_digest,confinementKey:J.policy.confinement_key,browserEgress:J.policy.browser_egress,cwd:J.cwd,claim:J.claim}),E=this.hooks.restatLayout(),D=null;if(J.env){let O=J.claim?.owner??{},k=BJ(await this.openSealed(J.env,J.bind_id),{runId:J.run_id,deviceId:typeof O.device_id==="string"?O.device_id:"",rootId:J.claim?.root_id??""});D=this.hooks.installEnvironment(J.bind_id,k),z=this.writeJobEnvRootOnly(J.bind_id,k)}if(this.unbinding.has(J.bind_id))throw new W("vm_hands_bind_lost","unbound while binding");return this.bound.set(J.bind_id,{bindId:J.bind_id,runId:J.run_id,sessionId:J.session_id,brainGeneration:J.brain_generation,policyDigest:J.policy.policy_digest,launchId:C,envInstalled:D!==null,rootId:J.claim?.root_id??"",envDirectory:z}),this.binding.delete(J.bind_id),{bind_id:J.bind_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,launch_id:C,snapshot_revision:D,layout:E,...P?{ready_data:P}:{},policy_digest:H("sha256").update(v({hands_confinement:N.hands_confinement??null,browser_egress:N.browser_egress??null})).digest("hex")}}catch(C){if(z)zJ(z);if(K){let P=[...this.bound.keys()];await this.hooks.killAndVerifyPayload(P.length?{bindId:J.bind_id,keep:P}:void 0).then(()=>{if(!P.length)this.verifiedSinceRun=!0,this.unverified.clear()},()=>{this.unverified.add(J.bind_id),this.verifiedSinceRun=!1})}this.binding.delete(J.bind_id);let N=C&&typeof C==="object"&&"code"in C&&typeof C.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(C.code)?C.code:"vm_hands_bind_failed";throw C instanceof W?C:new W(N,"executor refused the bind")}}async deliverEnvironment(J){let Z=this.bound.get(J.attemptId);if(!Z||this.unbinding.has(J.attemptId))throw new W("vm_hands_not_bound","environment delivered while not bound");if(!r.test(J.attemptId)||typeof J.snapshotId!=="string"||!J.snapshotId||J.snapshotId.length>128||J.snapshotId.includes("/"))throw new W("vm_hands_env_invalid","bad snapshot id");let z=`${J.attemptId}/${J.snapshotId}`;if(J.sealed?.alg!=="ECDH-P256+A256GCM"||J.sealed.aad!==z)throw new W("vm_hands_env_invalid","bad env envelope");let K=BJ(await this.openSealed(J.sealed,z),{runId:Z.runId,deviceId:J.deviceId,rootId:Z.rootId,snapshotId:J.snapshotId}),C=this.hooks.installEnvironment(Z.bindId,K);if(Z.envInstalled=!0,Z.envDirectory)zJ(Z.envDirectory);return Z.envDirectory=null,Z.envDirectory=this.writeJobEnvRootOnly(`${Z.bindId}-r${C}`,K),{snapshot_id:J.snapshotId,installed_revision:C,installed:!0}}async attestFrame(J,Z){if(this.identity==="identity_free")throw new W("vm_hands_not_registered","attest before register");if(!J||J.length>65536)throw new W("vm_hands_attest_invalid","no probe script");return this.exclusive(async()=>{if(this.liveBindIds.length)throw new W("vm_hands_attest_invalid","attest beside a bind");let z=await this.hooks.runProbe({nonce:Z,script:J});try{await this.hooks.killAndVerifyPayload(),this.verifiedSinceRun=!0}catch{this.servedRun=!0,this.verifiedSinceRun=!1}return{t:"attest",nonce:Z,exit_code:z.exitCode,markers:z.markers,proof_dir_inode:z.proofDirInode,script_sha256:H("sha256").update(J).digest("hex")}})}executorExited(J){return this.hooks.executorExited?.(J)??new Promise(()=>{})}async boundRefused(J){await this.unbind(J)}async unbind(J){let Z=this.bound.get(J)??null;if(this.unbinding.add(J),this.bound.delete(J),Z)try{this.hooks.freezeBind?.(J)}catch{}return this.exclusive(()=>this.tearDown(J,Z))}async tearDown(J,Z){try{this.bound.delete(J);let z=[...this.bound.keys()].filter((K)=>K!==J);try{await this.hooks.killAndVerifyPayload(z.length?{bindId:J,keep:z}:void 0)}catch(K){throw this.unverified.add(J),this.verifiedSinceRun=!1,K}if(!z.length)this.verifiedSinceRun=!0,this.unverified.clear();if(Z?.envDirectory)zJ(Z.envDirectory);return{bind_id:Z?J:null,killed_verified:!0,shredded:!0,srt_fallbacks:z.length?null:this.hooks.takeSrtFallbacks?.()??null}}finally{this.unbinding.delete(J)}}async openSealed(J,Z){let z=()=>{throw new W("vm_hands_env_invalid","env did not decrypt")},K=await crypto.subtle.importKey("spki",V(J.epk),{name:"ECDH",namedCurve:"P-256"},!1,[]).catch(z),C=await crypto.subtle.deriveKey({name:"ECDH",public:K},this.keys.agreement.privateKey,{name:"AES-GCM",length:256},!1,["decrypt"]),N=await crypto.subtle.decrypt({name:"AES-GCM",iv:V(J.iv),additionalData:new TextEncoder().encode(Z)},C,V(J.ct)).catch(z),P=JSON.parse(new TextDecoder().decode(N));if(!P||typeof P!=="object"||Array.isArray(P))throw new W("vm_hands_env_invalid","env not an object");return P}writeJobEnvRootOnly(J,Z){let z=d(this.options.envRoot,`bind-${J}`);vJ(z,{mode:448});let K=qJ(z);if(!K.isDirectory()||(K.mode&63)!==0||K.uid!==(process.getuid?.()??-1))throw new W("vm_hands_env_dir_unsafe","env directory is not root's 0700");let C=Z.variables&&typeof Z.variables==="object"?Z.variables:{},N=Object.entries(C).filter(([D,O])=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(D)&&typeof O==="string").map(([D,O])=>`export ${D}='${String(O).replaceAll("'","'\\''")}'`).join(`
|
|
2
|
+
import{Pd as CJ,ed as jJ,md as EJ}from"./vm-hands-entry-lite-n4xx6qfr.js";import{createHash as H,randomBytes as $J}from"crypto";import{closeSync as UJ,fsyncSync as LJ,mkdirSync as vJ,openSync as NJ,renameSync as yJ,rmSync as IJ,statSync as qJ,writeSync as DJ,constants as S}from"fs";import{join as d}from"path";var RJ=1;var r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GJ(J){if(J.environment!==void 0||J.payload.environment!==void 0)throw new W("vm_hands_bind_invalid","bind carries a plaintext environment");if(J.payload.vm_hands_env_deferred===!0&&J.environment_sealed!==void 0)throw new W("vm_hands_bind_invalid","split bind carries an environment");return J.environment_sealed!==void 0}function BJ(J,Z){let{payload:z,authority:K}=J;if(!z||typeof z!=="object"||Array.isArray(z)||!K||typeof K!=="object"||Array.isArray(K)||!Z.deviceId||!Z.rootId||z.run_id!==Z.runId||z.device_id!==Z.deviceId||K.device_id!==Z.deviceId||z.root_id!==Z.rootId||Z.snapshotId!==void 0&&z.snapshot_id!==Z.snapshotId)throw new W("vm_hands_env_invalid","environment does not match this Hands");return z}function AJ(J){if(J.capability!=="hands.connect")throw new W("vm_hands_bind_invalid","not a hands.connect claim");let Z=J.payload;return{kind:"vm_hands.bind",v:1,bind_id:J.attempt_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,run_id:J.run_id,session_id:typeof Z.workspace_id==="string"&&r.test(Z.workspace_id)?Z.workspace_id:J.run_id,brain_generation:Z.target_generation,fence_id:Z.target_fence_id,lease_until:J.lease_until,policy:{agent_profile:"",confinement_key:String(Z.hands_confinement??""),browser_egress:Z.browser_egress??null,policy_digest:Z.vm_hands_policy_digest},cwd:typeof Z.cwd==="string"?Z.cwd:"",claim:J,env:GJ(J)?J.environment_sealed:null}}class W extends Error{code;constructor(J,Z){super(Z);this.code=J}}var g=(J)=>Buffer.from(J instanceof Uint8Array?J:new Uint8Array(J)).toString("base64url"),V=(J)=>new Uint8Array(Buffer.from(J,"base64url"));function v(J){if(J===null||typeof J!=="object")return JSON.stringify(J);if(Array.isArray(J))return`[${J.map(v).join(",")}]`;return`{${Object.keys(J).sort().map((Z)=>`${JSON.stringify(Z)}:${v(J[Z])}`).join(",")}}`}async function zZ(J){let Z=await crypto.subtle.importKey("pkcs8",V(J.device_key.pkcs8),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=V(J.device_key.spki),K=await crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!1,["deriveKey"]),C=new Uint8Array(await crypto.subtle.exportKey("spki",K.publicKey)),N=H("sha256").update(z).digest("base64url");return{signing:{privateKey:Z},agreement:K,signingSpki:z,agreementSpki:C,fingerprint:N}}var fJ=4;class mJ{init;keys;hooks;options;identity="identity_free";lastBrainGeneration=new Map;bound=new Map;binding=new Map;unbinding=new Set;servedRun=!1;verifiedSinceRun=!1;unverified=new Set;structural=Promise.resolve();exclusive(J){let Z=this.structural.then(J,J);return this.structural=Z.catch(()=>{return}),Z}constructor(J,Z,z,K){this.init=J;this.keys=Z;this.hooks=z;this.options=K;if(!r.test(J.workspace_id)&&!/^ws-[a-z0-9]{8,64}$/.test(J.workspace_id))throw new W("vm_hands_layout_invalid","bad workspace id");if(!Number.isSafeInteger(J.instance_generation)||J.instance_generation<1)throw new W("vm_hands_layout_invalid","bad generation")}get phase(){if(this.identity==="identity_free")return"identity_free";if(this.unbinding.size)return"unbinding";return this.bound.size||this.binding.size?"bound":"registered"}isBoundRun(J){for(let Z of this.bound.values())if(Z.runId===J)return!0;return!1}bindIdForRun(J){for(let Z of this.bound.values())if(Z.runId===J)return Z.bindId;return null}get liveBindIds(){return[...new Set([...this.bound.keys(),...this.binding.keys(),...this.unbinding])]}async environmentInstalled(J,Z,z){for(let K=Date.now()+Z;;){let C=this.bound.get(J);if(!C)return!1;if(C.envInstalled)return!0;if(Date.now()>=K||z?.aborted)return!1;await new Promise((N)=>setTimeout(N,25))}}canSpawn(J){for(let Z of this.bound.values())if(Z.runId===J)return Z.envInstalled;return!1}async registerFrame(J){if(this.identity!=="identity_free")throw new W("vm_hands_register_twice","already registered");if(typeof J!=="string"||J.length<16||J.length>256)throw new W("vm_hands_challenge_invalid","bad register challenge");let Z={challenge:J,t:"register",v:RJ,workspace_id:this.init.workspace_id,instance_generation:this.init.instance_generation,credential:this.init.credential,device_public_key:g(this.keys.signingSpki),env_public_key:g(this.keys.agreementSpki),key_fingerprint:this.keys.fingerprint,manifest_digest:this.init.manifest_digest,nonce:g($J(32)),timestamp_ms:(this.options.now??Date.now)(),vm_hands_attest_hold:!0},z=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new TextEncoder().encode(v(Z)));return{...Z,device_signature:g(z)}}async helloFrame(J,Z){if(this.identity==="identity_free")throw new W("vm_hands_not_registered","hello before register");let z=String((this.options.now??Date.now)()),K=g($J(32)),C=CJ({method:"GET",pathAndQuery:jJ,timestamp:z,nonce:K,challenge:J,bodySha256:H("sha256").update("").digest("hex")}),N=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new Uint8Array(C)));return{t:"hello",timestamp:z,nonce:K,signature:g(cJ(N)),...Z?{vm_hands_previous_connection:Z}:{}}}registered(){if(this.identity!=="identity_free")throw new W("vm_hands_register_unexpected","registered twice");this.identity="registered"}async bind(J){if(this.identity!=="registered")throw new W("vm_hands_not_registered","bind before register");if(J.kind!=="vm_hands.bind"||J.v!==1)throw new W("vm_hands_bind_invalid","bad bind");for(let z of[J.bind_id,J.attempt_id,J.run_id,J.session_id,J.fence_id])if(!r.test(z))throw new W("vm_hands_bind_invalid","bad id");if(!Number.isSafeInteger(J.brain_generation)||J.brain_generation<=(this.lastBrainGeneration.get(J.run_id)??0))throw new W("vm_hands_generation_stale","brain generation not strictly higher");if(J.env&&(J.env.aad!==J.bind_id||J.env.alg!=="ECDH-P256+A256GCM"))throw new W("vm_hands_bind_invalid","bad env envelope");if(!/^[0-9a-f]{64}$/.test(J.policy.policy_digest))throw new W("vm_hands_bind_invalid","bad policy or nonce");if(H("sha256").update(v({hands_confinement:J.policy.confinement_key||null,browser_egress:J.policy.browser_egress??null})).digest("hex")!==J.policy.policy_digest)throw new W("vm_hands_policy_mismatch","policy digest does not match the claim");if(this.liveBindIds.includes(J.bind_id)||[...this.bound.values()].some((z)=>z.runId===J.run_id)||[...this.binding.values()].includes(J.run_id))throw new W("vm_hands_busy","this run already holds a bind here");if(this.liveBindIds.length>=fJ)throw new W("vm_hands_busy","every bind slot is held");return this.lastBrainGeneration.set(J.run_id,J.brain_generation),this.binding.set(J.bind_id,J.run_id),this.exclusive(()=>this.setUp(J))}async setUp(J){let Z=[...this.bound.keys()],z=null,K=!1;try{if(Z.length===0){if(this.servedRun&&!this.verifiedSinceRun)await this.hooks.killAndVerifyPayload(),this.unverified.clear()}else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({keep:Z}),this.unverified.clear();this.verifiedSinceRun=!1,this.servedRun=!0,K=!0;let{launchId:C,applied:N,readyData:P}=await this.hooks.startExecutor({bindId:J.bind_id,sessionId:J.session_id,policyDigest:J.policy.policy_digest,confinementKey:J.policy.confinement_key,browserEgress:J.policy.browser_egress,cwd:J.cwd,claim:J.claim}),E=this.hooks.restatLayout(),D=null;if(J.env){let O=J.claim?.owner??{},k=BJ(await this.openSealed(J.env,J.bind_id),{runId:J.run_id,deviceId:typeof O.device_id==="string"?O.device_id:"",rootId:J.claim?.root_id??""});D=this.hooks.installEnvironment(J.bind_id,k),z=this.writeJobEnvRootOnly(J.bind_id,k)}if(this.unbinding.has(J.bind_id))throw new W("vm_hands_bind_lost","unbound while binding");return this.bound.set(J.bind_id,{bindId:J.bind_id,runId:J.run_id,sessionId:J.session_id,brainGeneration:J.brain_generation,policyDigest:J.policy.policy_digest,launchId:C,envInstalled:D!==null,rootId:J.claim?.root_id??"",envDirectory:z}),this.binding.delete(J.bind_id),{bind_id:J.bind_id,attempt_id:J.attempt_id,attempt_token:J.attempt_token,launch_id:C,snapshot_revision:D,layout:E,...P?{ready_data:P}:{},policy_digest:H("sha256").update(v({hands_confinement:N.hands_confinement??null,browser_egress:N.browser_egress??null})).digest("hex")}}catch(C){if(z)zJ(z);if(K){let P=[...this.bound.keys()];await this.hooks.killAndVerifyPayload(P.length?{bindId:J.bind_id,keep:P}:void 0).then(()=>{if(!P.length)this.verifiedSinceRun=!0,this.unverified.clear()},()=>{this.unverified.add(J.bind_id),this.verifiedSinceRun=!1})}this.binding.delete(J.bind_id);let N=C&&typeof C==="object"&&"code"in C&&typeof C.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(C.code)?C.code:"vm_hands_bind_failed";throw C instanceof W?C:new W(N,"executor refused the bind")}}async deliverEnvironment(J){let Z=this.bound.get(J.attemptId);if(!Z||this.unbinding.has(J.attemptId))throw new W("vm_hands_not_bound","environment delivered while not bound");if(!r.test(J.attemptId)||typeof J.snapshotId!=="string"||!J.snapshotId||J.snapshotId.length>128||J.snapshotId.includes("/"))throw new W("vm_hands_env_invalid","bad snapshot id");let z=`${J.attemptId}/${J.snapshotId}`;if(J.sealed?.alg!=="ECDH-P256+A256GCM"||J.sealed.aad!==z)throw new W("vm_hands_env_invalid","bad env envelope");let K=BJ(await this.openSealed(J.sealed,z),{runId:Z.runId,deviceId:J.deviceId,rootId:Z.rootId,snapshotId:J.snapshotId}),C=this.hooks.installEnvironment(Z.bindId,K);if(Z.envInstalled=!0,Z.envDirectory)zJ(Z.envDirectory);return Z.envDirectory=null,Z.envDirectory=this.writeJobEnvRootOnly(`${Z.bindId}-r${C}`,K),{snapshot_id:J.snapshotId,installed_revision:C,installed:!0}}async attestFrame(J,Z){if(this.identity==="identity_free")throw new W("vm_hands_not_registered","attest before register");if(!J||J.length>65536)throw new W("vm_hands_attest_invalid","no probe script");return this.exclusive(async()=>{if(this.liveBindIds.length)throw new W("vm_hands_attest_invalid","attest beside a bind");let z=await this.hooks.runProbe({nonce:Z,script:J});try{await this.hooks.killAndVerifyPayload(),this.verifiedSinceRun=!0}catch{this.servedRun=!0,this.verifiedSinceRun=!1}return{t:"attest",nonce:Z,exit_code:z.exitCode,markers:z.markers,proof_dir_inode:z.proofDirInode,script_sha256:H("sha256").update(J).digest("hex")}})}executorExited(J){return this.hooks.executorExited?.(J)??new Promise(()=>{})}async boundRefused(J){await this.unbind(J)}async unbind(J){let Z=this.bound.get(J)??null;if(this.unbinding.add(J),this.bound.delete(J),Z)try{this.hooks.freezeBind?.(J)}catch{}return this.exclusive(()=>this.tearDown(J,Z))}async tearDown(J,Z){try{this.bound.delete(J);let z=[...this.bound.keys()].filter((K)=>K!==J);try{await this.hooks.killAndVerifyPayload(z.length?{bindId:J,keep:z}:void 0)}catch(K){throw this.unverified.add(J),this.verifiedSinceRun=!1,K}if(!z.length)this.verifiedSinceRun=!0,this.unverified.clear();if(Z?.envDirectory)zJ(Z.envDirectory);return{bind_id:Z?J:null,killed_verified:!0,shredded:!0,srt_fallbacks:z.length?null:this.hooks.takeSrtFallbacks?.()??null}}finally{this.unbinding.delete(J)}}async openSealed(J,Z){let z=()=>{throw new W("vm_hands_env_invalid","env did not decrypt")},K=await crypto.subtle.importKey("spki",V(J.epk),{name:"ECDH",namedCurve:"P-256"},!1,[]).catch(z),C=await crypto.subtle.deriveKey({name:"ECDH",public:K},this.keys.agreement.privateKey,{name:"AES-GCM",length:256},!1,["decrypt"]),N=await crypto.subtle.decrypt({name:"AES-GCM",iv:V(J.iv),additionalData:new TextEncoder().encode(Z)},C,V(J.ct)).catch(z),P=JSON.parse(new TextDecoder().decode(N));if(!P||typeof P!=="object"||Array.isArray(P))throw new W("vm_hands_env_invalid","env not an object");return P}writeJobEnvRootOnly(J,Z){let z=d(this.options.envRoot,`bind-${J}`);vJ(z,{mode:448});let K=qJ(z);if(!K.isDirectory()||(K.mode&63)!==0||K.uid!==(process.getuid?.()??-1))throw new W("vm_hands_env_dir_unsafe","env directory is not root's 0700");let C=Z.variables&&typeof Z.variables==="object"?Z.variables:{},N=Object.entries(C).filter(([D,O])=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(D)&&typeof O==="string").map(([D,O])=>`export ${D}='${String(O).replaceAll("'","'\\''")}'`).join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`,P=d(z,`.job.env.${$J(8).toString("hex")}`),E=NJ(P,S.O_WRONLY|S.O_CREAT|S.O_EXCL|S.O_NOFOLLOW,384);try{DJ(E,N),LJ(E)}finally{UJ(E)}return yJ(P,d(z,"job.env")),z}}function zJ(J){try{let Z=d(J,"job.env"),z=qJ(Z).size,K=NJ(Z,S.O_WRONLY|S.O_NOFOLLOW);try{DJ(K,Buffer.alloc(z)),LJ(K)}finally{UJ(K)}}catch{}IJ(J,{recursive:!0,force:!0})}function cJ(J){if(J.length!==64)throw new W("vm_hands_signature_invalid","unexpected ECDSA signature length");let Z=(C)=>{let N=0;while(N<C.length-1&&C[N]===0)N++;let P=C.subarray(N),E=P[0]&128?Uint8Array.of(0,...P):P;return Uint8Array.of(2,E.length,...E)},z=Z(J.subarray(0,32)),K=Z(J.subarray(32));return Uint8Array.of(48,z.length+K.length,...z,...K)}import{randomUUID as bJ}from"crypto";var pJ="/app/local-runtime/session?register=vm_hands_v1",lJ="/app/local-runtime",MJ=25000,uJ=20000,oJ=1e4,dJ=5000,rJ=new Set(["pty.start","jobs.control","preview.serve.v1","display.stream.v1"]),KJ=75000,iJ=2000,sJ=1e4,i=20000;class h extends Error{}var aJ=64;async function OJ(J,Z){let z=[...J.modelOps.get(Z)??[]];for(let K of z)K.abort.abort();await Promise.race([Promise.all(z.map((K)=>K.settled)),new Promise((K)=>setTimeout(K,dJ))])}async function y(J,Z,z){return await OJ(J,z),Z.unbind(z)}function s(J){for(let Z of J.outbox?.splice(0)??[])Z.reject(Error("vm_hands_attempt_ended"))}var xJ=15000,nJ=1e4;async function FZ(J){let Z=Date.now(),z={deviceId:null,connection:null,turns:new Map,lostAt:0,receipts:[],attest:"pending",attestWaiters:[],modelOps:new Map},K=J.log??(()=>{}),C=async(N)=>{for(let[P,E]of[...z.turns]){z.turns.delete(P),J.onTurn?.(P,null),s(E);let D=await y(z,J.agent,P).catch(()=>null);if(D)z.receipts.push({turn:E,failure:"vm_hands_bind_lost",unbound:D});K("vm_hands.bound_dropped",{reason:N})}};try{for(let N=0;!J.signal.aborted;N++){let P=await tJ(J,z).catch((D)=>{if(D instanceof W&&z.deviceId===null&&D.code==="vm_hands_no_session"&&Date.now()-Z<sJ)return{closeCode:0,closeReason:"vm_hands_no_session"};if(D instanceof W&&z.deviceId===null)throw D;return{closeCode:0,closeReason:D instanceof Error?D.message:String(D)}});if(K("vm_hands.session_closed",{close_code:P.closeCode,reason:P.closeReason.slice(0,120),registered:z.deviceId!==null}),P.closeCode===4401||z.attest==="refused")return;if(J.signal.aborted)return;if(z.turns.size&&Date.now()-z.lostAt>=KJ)await C("reconnect_deadline");let E=P.closeReason==="vm_hands_no_session"?Math.min(250*2**Math.min(N,5),2000):z.turns.size?Math.min(250*2**Math.min(N,5),5000,Math.max(0,z.lostAt+KJ-Date.now())):Math.min(500*2**N,30000);if(await new Promise((D)=>setTimeout(D,E)),z.turns.size&&Date.now()-z.lostAt>=KJ)await C("reconnect_deadline")}}finally{await C("session_ended")}}async function tJ(J,Z){let z=Z.deviceId,K=J.log??(()=>{}),C=z?`/app/local-runtime/session?device_id=${encodeURIComponent(z)}`:pJ,N=`${J.apiOrigin.replace(/^http/,"ws")}${C}`,P=new WebSocket(N),E=0,D="",O=new Map,k=[],I=null,_J=new Promise(($)=>{P.onclose=(Q)=>{E=Q.code,D=Q.reason;for(let G of O.values())G.reject(new h(`session closed ${Q.code}`));for(let G of Z.attestWaiters.splice(0))G(!1);O.clear(),$()}});P.onmessage=($)=>{let Q;try{Q=JSON.parse(String($.data))}catch{P.close(4400);return}if(Q.t==="res"){let G=Q;O.get(G.id)?.resolve({status:G.status,body:G.body}),O.delete(G.id);return}if(!I?.(Q))k.push(Q)};let R=($,Q)=>new Promise((G,X)=>{let j=k.findIndex((U)=>$.includes(U.t));if(j>=0){G(k.splice(j,1)[0]);return}let L=setTimeout(()=>{I=null,X(new W("vm_hands_no_register",`no ${$.join("/")} in ${Q} ms`))},Q);I=(U)=>{if(!$.includes(U.t))return!1;return clearTimeout(L),I=null,G(U),!0}}),f=($)=>P.send(JSON.stringify($)),w=($,Q)=>new Promise((G,X)=>{if(P.readyState!==WebSocket.OPEN){X(new h("session closed"));return}let j=bJ(),L=typeof Q.wait_ms==="number"?Q.wait_ms:0,U=setTimeout(()=>{if(!O.delete(j))return;X(new h(`no answer to ${$.split("/").pop()} in ${L+xJ} ms`)),P.close(4000,"request_timeout")},L+xJ);O.set(j,{reject:(Y)=>{clearTimeout(U),X(Y)},resolve:({status:Y,body:F})=>{clearTimeout(U);let B=null;try{B=F?JSON.parse(F):null}catch{}G({status:Y,json:B})}}),f({t:"req",id:j,path:`${lJ}${$}`,body:JSON.stringify(Q)})}),YJ=()=>P.close(1001,"stopping");J.signal.addEventListener("abort",YJ,{once:!0});let a,m=new Map,c=new Map,n=!1,t=new Set,e=new Set,JJ=Promise.resolve(),b=!1;try{await new Promise((Y,F)=>{let B=setTimeout(()=>F(Error("session open timeout")),nJ);P.onopen=()=>{clearTimeout(B),K("vm_hands.ws_open",{}),Y()},P.onerror=()=>{clearTimeout(B),F(Error("session socket error"))}});let $=await R(["challenge"],5000);K("vm_hands.challenge",{});let Q=[],G=null,X;if(z){f(await J.agent.helloFrame($.challenge,Z.connection));let Y=await R(["ready"],1e4);if(typeof Y.vm_hands_connection==="string")Z.connection=Y.vm_hands_connection;if(X={device_id:z,...Y.cadence?{cadence:Y.cadence}:{}},typeof Y.vm_hands_probe_script==="string"){if(G=Y.vm_hands_probe_script,b=!0,J.agent.phase==="registered"&&!Z.turns.size)Z.attest="pending"}K("vm_hands.reconnected",{device_id:z});let F=Array.isArray(Y.vm_hands_binds)?Y.vm_hands_binds:Y.vm_hands_bind?[Y.vm_hands_bind]:[];for(let[B,q]of[...Z.turns]){if(F.some((A)=>A&&A.operation_id===q.claim.operation_id&&A.attempt_id===q.claim.attempt_id)){Q.push(q),K("vm_hands.bound_resumed",{operation_id:q.claim.operation_id});continue}Z.turns.delete(B),J.onTurn?.(B,null),s(q);let x=await y(Z,J.agent,B).catch(()=>null);if(x)Z.receipts.push({turn:q,failure:"vm_hands_bind_lost",unbound:x});K("vm_hands.bound_dropped",{reason:"not_named_on_reconnect"})}}else{f(await J.agent.registerFrame($.challenge)),K("vm_hands.register_sent",{});let Y=await R(["registered","register_refused"],1e4);if(Y.t==="register_refused")throw new W(Y.code,"register refused");J.agent.registered();let F=Y;if(X=F,Z.deviceId=F.device_id,typeof F.vm_hands_connection==="string")Z.connection=F.vm_hands_connection;if(typeof F.vm_hands_probe_script==="string"){if(G=F.vm_hands_probe_script,b=!0,J.agent.phase==="registered"&&!Z.turns.size)Z.attest="pending"}K("vm_hands.registered",{device_id:X.device_id})}let j=async()=>{let Y=await w("/heartbeat",await J.heartbeat());if(Y.status>=300)throw Error(`heartbeat ${Y.status}`)};await j();let L=X.cadence?.presence_interval_ms??30000;if(a=setInterval(()=>{j().catch(()=>P.close())},L),G&&Z.attest!=="accepted"&&J.agent.phase==="registered"&&!Z.turns.size)hJ(G,$.challenge);let U=(Y,F)=>{c.set(Y,F().catch(async(B)=>{if(await QJ(B,Y),B instanceof h)P.close();else await ZJ().catch(()=>{return})}).finally(()=>{c.delete(Y)}))};try{await ZJ();for(let Y of Q)Y.flush=()=>XJ(Y),Y.flush(),U(Y.claim.attempt_id,()=>FJ(Y));while(!J.signal.aborted&&P.readyState===WebSocket.OPEN){let Y=await w("/operations/claim",{wait_ms:Math.min(X.cadence?.claim_wait_ms??MJ,MJ)});if(Y.status===204||!Y.json)continue;if(Y.status>=300)throw Error(`claim ${Y.status}`);let F=Y.json;if(F.capability==="hands.connect"){if(c.has(F.attempt_id)){_({claim:F,eventSeq:0}).complete("failed",{error_code:"vm_hands_busy"}).catch(()=>{return});continue}U(F.attempt_id,()=>wJ(F))}else kJ(F).catch(()=>{return})}}catch(Y){await QJ(Y,null)}}finally{if(a)clearInterval(a);J.signal.removeEventListener("abort",YJ);for(let $ of Z.turns.values())$.flush=null;P.close(),await _J,await Promise.all([...c.values()]);for(let $ of J.agent.liveBindIds){if(Z.turns.has($))continue;let Q=await y(Z,J.agent,$).catch(()=>null),G=m.get($);if(Q&&G)Z.receipts.push({turn:{...G,eventSeq:G.eventSeq+1},failure:"vm_hands_bind_lost",unbound:Q});K("vm_hands.bound_dropped",{reason:"bound_after_loss"})}for(let $ of t)$.abort()}return{closeCode:E,closeReason:D};async function QJ($,Q){if($ instanceof h){if(!n&&Z.turns.size)Z.lostAt=Date.now();n=!0}else{let G=Q!==null?[Q]:[...new Set([...Z.turns.keys(),...J.agent.liveBindIds])];if(Q===null)n=!0;for(let X of G){let j=Z.turns.get(X);if(Z.turns.delete(X),j)s(j),J.onTurn?.(X,null);if(J.agent.liveBindIds.includes(X)){let L=await y(Z,J.agent,X).catch(()=>null),U=m.get(X)??j;if(L&&U)Z.receipts.push({turn:{...U,eventSeq:U.eventSeq+1},failure:"vm_hands_bind_lost",unbound:L})}}}K("vm_hands.session_lost",{error:$ instanceof Error?$.message:String($),bound_kept:Z.turns.size})}function _($){let Q=$.claim,G={attempt_id:Q.attempt_id,attempt_token:Q.attempt_token},X=encodeURIComponent(Q.operation_id);return{fence:G,op:X,complete:(L,U={})=>w(`/operations/${X}/complete`,{...G,status:L,...U}),emit:(L,U)=>{let Y=($.chain??Promise.resolve()).catch(()=>{return}).then(()=>j(L,U));return $.chain=Y,Y}};async function j(L,U){let Y=$.eventSeq,F=(A)=>w(`/operations/${X}/events`,{...G,event_seq_start:A,events:[{kind:L,payload:{sequence:A,capability:String(Q.capability??"hands.connect"),data:U}}]}),B=Y,q=await F(B),x=q.status===409?q.json?.expected_event_seq:void 0;if(typeof x==="number"&&x===Y+1)q={status:200,json:{duplicate:!0}};else if(typeof x==="number"&&x>=0&&x!==Y)B=x,q=await F(B);if(q.status<300)$.eventSeq=B+1;return q}}function TJ($){return(Q,G)=>new Promise((X,j)=>{if(Z.turns.get($.claim.attempt_id)!==$){j(Error("vm_hands_attempt_ended"));return}if($.outbox??=[],$.outbox.length>=aJ){j(Error("vm_hands_outbox_full"));return}$.outbox.push({kind:Q,data:G,resolve:X,reject:j}),$.flush?.()})}function XJ($){if(e.has($))return;e.add($),(async()=>{try{while($.outbox?.length&&Z.turns.get($.claim.attempt_id)===$&&P.readyState===WebSocket.OPEN){let Q=$.outbox[0],G;try{G=await _($).emit(Q.kind,Q.data)}catch(X){if(X instanceof h)return;G={status:500}}if($.outbox.shift(),G.status<300)Q.resolve();else Q.reject(Error(`${Q.kind} refused ${G.status}`))}}finally{e.delete($)}})()}async function hJ($,Q){try{let G=await J.agent.attestFrame($,Q);if(P.readyState!==WebSocket.OPEN)return;f(G);let X=await R(["attested","attest_refused"],15000);Z.attest=X.t==="attested"?"accepted":"refused";for(let j of Z.attestWaiters.splice(0))j(Z.attest==="accepted");if(K("vm_hands.attest",{result:Z.attest,exit_code:G.exit_code,...X.t==="attest_refused"?{code:String(X.code??"")}:{}}),Z.attest==="refused")P.close(4401,"attest_refused")}catch(G){K("vm_hands.attest_failed",{code:G instanceof W?G.code:"probe_error"});for(let X of Z.attestWaiters.splice(0))X(!1);if(Z.attest!=="accepted")P.close(4000,"attest_unanswered")}}async function wJ($){let Q=b&&Z.attest==="pending",G=$.vm_hands_attest,X=G;if(Z.attest==="refused"){K("vm_hands.claim_attest_refused",{said:typeof G==="string"?G.slice(0,16):typeof G,local:Z.attest}),await _({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(X==="accepted"){if(!Q&&Z.attest!=="accepted"){Z.attest="accepted";for(let A of Z.attestWaiters.splice(0))A(!0)}}else if(X!=="pending"||!Q){K("vm_hands.claim_attest_refused",{said:typeof G==="string"?G.slice(0,16):typeof G,local:Z.attest}),await _({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(Z.attest!=="accepted"){let A=Date.parse($.lease_until)-Date.now()-5000,p=Math.max(0,Math.min(i,Number.isFinite(A)?A:i));if(!await new Promise((u)=>{let M=setTimeout(()=>u(!1),p);Z.attestWaiters.push((T)=>{clearTimeout(M),u(T)})})){await _({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}}let j={claim:$,eventSeq:0},{complete:L,emit:U}=_(j),Y;try{if($.capability!=="hands.connect")throw new W("vm_hands_bind_invalid","not hands.connect");Y=!GJ($)}catch(A){K("vm_hands.bind_refused",{code:A instanceof W?A.code:"unexpected"}),await L("failed",{error_code:A instanceof W?A.code:"vm_hands_bind_invalid"});return}let F;try{F=await J.agent.bind(AJ($))}catch(A){K("vm_hands.bind_refused",{code:A instanceof W?A.code:"unexpected"}),await L("failed",{error_code:A instanceof W?A.code:"vm_hands_bind_failed"});return}let B={...F.ready_data??J.readyData({launchId:F.launch_id,claim:$})};if(Y)delete B.environment_installed;m.set($.attempt_id,{claim:$,launchId:F.launch_id,readyData:B,eventSeq:j.eventSeq,ackSeq:-1});let q=await U("hands.ready",{...B,vm_hands:{layout:F.layout,policy_digest:F.policy_digest,launch_id:F.launch_id}});if(m.delete($.attempt_id),q.status>=300){await OJ(Z,$.attempt_id),await J.agent.boundRefused($.attempt_id),await L("failed",{error_code:String(q.json?.error??"vm_hands_probe_failed")});return}let x={claim:$,launchId:F.launch_id,readyData:B,eventSeq:j.eventSeq,ackSeq:-1};Z.turns.set($.attempt_id,x),x.flush=()=>XJ(x),J.onTurn?.($.attempt_id,TJ(x)),await FJ(x)}async function FJ($){let{fence:Q,op:G}=_($),X=null,j=null,L=J.agent.executorExited($.claim.attempt_id).then((U)=>{return j=U,null});J:for(;;){let U=await Promise.race([L,w(`/operations/${G}/heartbeat`,{...Q,control_ack_seq:$.ackSeq,wait_ms:uJ})]);if(!U){X="vm_hands_executor_exited",K("vm_hands.executor_exited",{reason:j});break}if(U.status>=300)break;let Y=(U.json?.controls??[]).slice().sort((F,B)=>F.seq-B.seq);for(let F of Y){if(F.seq<=$.ackSeq)continue;if(F.kind==="operation.cancel"||F.kind==="cancel"){$.ackSeq=F.seq;break J}if(F.kind===EJ)try{await SJ($,F.payload??{})}catch(B){if(B instanceof h)throw B;X=B instanceof W?B.code:"environment_unavailable",K("vm_hands.environment_refused",{code:X});break J}$.ackSeq=F.seq}}await gJ($,X)}async function kJ($){let Q=$,G={claim:Q,eventSeq:0},{complete:X,emit:j,fence:L,op:U}={..._(G)},Y=$.vm_hands_origin==="person"?"person":"model",F=String($.capability??"");if(!J.executeOp){await X("failed",{error_code:"vm_hands_op_unsupported"});return}if($.vm_hands_attest==="accepted"&&Z.attest==="pending"&&!(b&&Z.attest==="pending")){Z.attest="accepted";for(let M of Z.attestWaiters.splice(0))M(!0)}if(Z.attest!=="accepted"){let M=Date.parse(String($.lease_until??""))-Date.now()-5000,T=Z.attest==="refused"?0:Math.max(0,Math.min(i,Number.isFinite(M)?M:i));if(!(T>0&&await new Promise((PJ)=>{let HJ=setTimeout(()=>PJ(!1),T);Z.attestWaiters.push((VJ)=>{clearTimeout(HJ),PJ(VJ)})}))){await X("failed",{error_code:"vm_hands_unattested"});return}}let B=J.agent.bindIdForRun(Q.run_id);if(Y==="model"&&B===null){await X("failed",{error_code:"vm_hands_not_bound"});return}if(rJ.has(F)&&J.agent.liveBindIds.length===0){await X("failed",{error_code:"vm_hands_not_bound"});return}let q=new AbortController;t.add(q);let x,A=new Promise((M)=>{x=M}),p={abort:q,settled:A};if(Y==="model"&&B){let M=Z.modelOps.get(B)??new Set;M.add(p),Z.modelOps.set(B,M),await J.agent.environmentInstalled(B,iJ,q.signal)}let l=-1,u=setInterval(()=>{w(`/operations/${U}/heartbeat`,{...L,control_ack_seq:l,wait_ms:0}).then((M)=>{if(M.status>=300){q.abort();return}let T=M.json?.controls??[];for(let o of T)if(l=Math.max(l,o.seq),o.kind==="operation.cancel"||o.kind==="cancel")q.abort()},()=>q.abort())},oJ);try{let M=await J.executeOp({kind:Y,claim:$,...Y==="model"&&B?{bindId:B}:{},signal:q.signal,emit:async(T)=>{await j(T.kind,T.data??{})}});await X(M.status,{...M.result?{result:M.result}:{},...M.error_code!==void 0?{error_code:M.error_code}:{}}),K("vm_hands.op",{capability:F,kind:Y,status:M.status,code:M.error_code??null})}finally{if(clearInterval(u),t.delete(q),B)Z.modelOps.get(B)?.delete(p);x()}}async function gJ($,Q){let G=$.claim.attempt_id;if(Z.turns.get(G)===$)Z.turns.delete(G);J.onTurn?.(G,null),s($);let X=await y(Z,J.agent,G);Z.receipts.push({turn:$,failure:Q,unbound:X}),await ZJ()}function ZJ(){return JJ=JJ.then(WJ,WJ),JJ}async function WJ(){while(Z.receipts.length){let{turn:$,failure:Q,unbound:G}=Z.receipts[0],{complete:X,emit:j}=_($);try{if(await j("hands.stopped",{...$.readyData,reason_code:Q?"failed":"cancelled",killed_verified:G.killed_verified,shredded:G.shredded,...G.srt_fallbacks?{vm_hands_srt_fallbacks:G.srt_fallbacks}:{}}),Q)await X("failed",{error_code:Q});else await X("cancelled",{error_code:"driver_stopped"})}catch(L){if(L instanceof h)return}Z.receipts.shift()}}async function SJ($,Q){let{fence:G,op:X}=_($),j=Q.snapshot_id;if(Q.version!==1||typeof j!=="string"||Object.keys(Q).length!==2)throw new W("vm_hands_env_invalid","invalid environment delivery");let L=await w(`/operations/${X}/environment`,{...G,snapshot_id:j}),U=L.json?.environment_sealed;if(L.status!==200||!U||L.json?.payload!==void 0)throw new W("vm_hands_env_invalid","environment not delivered sealed");let Y=await J.agent.deliverEnvironment({attemptId:$.claim.attempt_id,snapshotId:j,deviceId:Z.deviceId??"",sealed:U});if((await w(`/operations/${X}/environment-ack`,{...G,...Y})).status>=300)throw new W("vm_hands_env_ack_refused","environment ack refused")}}
|
|
5
5
|
export{zZ as u,mJ as v,FZ as w};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qb as D}from"./vm-hands-entry-lite-qvrnx0vk.js";import{
|
|
2
|
+
import{Qb as D}from"./vm-hands-entry-lite-qvrnx0vk.js";import{Oh as j}from"./vm-hands-entry-lite-v6tkjqb1.js";import{statSync as i}from"fs";import{delimiter as n,join as t}from"path";function _(q,z=process.env.PATH??""){if(!q||q.includes("/")||q.includes("\x00"))return!1;return z.split(n).some((G)=>{if(!G)return!1;try{let Q=i(t(G,q));return Q.isFile()&&(Q.mode&73)!==0}catch{return!1}})}import{spawn as r,spawnSync as e}from"child_process";import{existsSync as k,mkdtempSync as E,readFileSync as O,readdirSync as o,realpathSync as qq,rmSync as b,statSync as zq}from"fs";import{platform as y,tmpdir as g}from"os";import{dirname as A,join as Z}from"path";import{fileURLToPath as Gq,pathToFileURL as T}from"url";var Hq=["bwrap","socat","rg"],Jq=2000,v=20000,Qq=3,P=4000,Vq=new Set([".git",".hg",".svn","node_modules"]),Wq=["runAsHostUid","sysrq-trigger"],Yq=Z(A(A(Gq(import.meta.url))),"packages/sandbox-runtime/src/index.ts"),h=!1;function fq(){h=!0}async function u(){let z=h?Z(A(qq(process.execPath)),"runtime","srt"):void 0;if(z&&process.platform==="linux"&&!k(Z(z,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(z){let J=O(Z(z,"sandbox-runtime.mjs"),"utf8");for(let Y of Wq)if(!J.includes(Y))throw Error(`packaged_sandbox_runtime_fork_missing:${Y}`)}let H=(await import(z?T(Z(z,"sandbox-runtime.mjs")).href:T(Yq).href)).SandboxManager;if(!H||typeof H.initialize!=="function"||typeof H.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:H}}function Zq(q={}){if((q.platformName??y())!=="linux")return!1;let G=q.fileExists??k,Q=q.readFile??((H)=>O(H,"utf8"));for(let H of["/.dockerenv","/run/.containerenv"])try{if(G(H))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(Q("/proc/1/cgroup"))}catch{return!1}}function l(q){return["/bin/true","/usr/bin/true"].find((z)=>q(z))??null}function $q(q,z){return q==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",z]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",z]}function jq(q,z){try{let G=e("bwrap",$q(q,z),{stdio:"ignore",timeout:Jq});return!G.error&&G.status===0}catch{return!1}}function Bq(q){let z=q.platformName??y();if(z!=="linux")return null;let G=q.hasExecutable??_;if(!Hq.every((V)=>G(V)))return null;let Q=q.fileExists??k,H=l(Q);if(!H)return null;let J=B??(q.containerized??Zq({platformName:z})?"weak":"strict");return(q.probeNamespaces??((V)=>jq(V,H)))(J)?J:null}var L=null,C=!1,K=null,S=null,f=null,B=null,F=null;function M(){throw I("sandbox_mode_conflict"),new j("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function xq(q){if(B!==null&&B!==q||C&&L!==null&&L!==q||F!==null&&F!==q)M();B=q}function I(q){K=q}function c(q){if(K)return!1;if(!C){if(L=Bq(q??{}),C=!0,L&&!q)d()}return L!==null}function Lq(){return c()?L:null}var U=null,w=0;function m(q){if(K)throw new j("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(B&&q.sandboxMode&&B!==q.sandboxMode)M();let z=B??q.sandboxMode??Lq();if(!z)throw new j("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(F&&F!==z)M();return F=z,U??=(async()=>{let{SandboxManager:G}=await(q.loadSandboxRuntime??u)();return await G.initialize(Iq(z)),G})().catch((G)=>{throw U=null,I(`initialize_failed: ${String(G)}`),G instanceof j?G:new j("sandbox_unavailable","The confined execution sandbox failed to start.")}),U.then((G)=>{if(K)throw new j("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return G})}async function Kq(){let q=U;if(U=null,!q)return;try{await(await q).reset()}catch{}}async function d(q={}){if(K)return!1;if(q.loadSandboxRuntime)return x(q.loadSandboxRuntime);if(!c())return!1;return S??=x(u),S}async function x(q){try{let{SandboxManager:z}=await q(),G=z.checkDependencies().errors;if(G.length>0)return I(`dependencies_missing: ${G.join(", ")}`),!1;return!K}catch(z){return I(`load_failed: ${String(z)}`),!1}}async function Rq(q={}){if(!q.loadSandboxRuntime&&!q.sandboxMode){if(!await d())return!1;return f??=R({}),f}return R(q)}async function R(q){let z;try{z=await m(q)}catch{return!1}let G=await Xq(z);if(!G)I("confined_command_failed");if(w===0)await Kq();return G}async function Xq(q){let z=l(k);if(!z)return!1;let G=E(Z(g(),"reason-device-probe-"));try{let{argv:Q}=await q.wrapWithSandboxArgv(a([z]),p(),{filesystem:s({root:G,allowWrite:!1,temporaryDirectory:G,protectedPaths:[]})},void 0,G),[H,...J]=Q;if(!H)return!1;return await Fq(H,J,G)}catch{return!1}finally{try{q.cleanupAfterCommand()}catch{}b(G,{recursive:!0,force:!0})}}function Fq(q,z,G,Q={}){return new Promise((H)=>{let J=!1,Y,V=(X)=>{if(J)return;J=!0,clearTimeout(Y),H(X)},W;try{W=(Q.spawnChild??r)(q,z,{cwd:G,env:{PATH:D,HOME:G,TMPDIR:G},stdio:"ignore"})}catch{V(!1);return}W.once("error",()=>V(!1));let $=(X,N)=>V(X===0&&N===null);if(W.once("exit",$),W.once("close",$),W.exitCode!==null||W.signalCode!==null)$(W.exitCode,W.signalCode);if(J)return;Y=setTimeout(()=>{V(!1);try{W.kill("SIGKILL")}catch{}},Math.min(Q.timeoutMs??v,v))})}function p(q=k){return["/bin/bash","/bin/sh"].find((z)=>q(z))??"/bin/sh"}function a(q){return q.map((z)=>`'${z.replaceAll("'","'\\''")}'`).join(" ")}function Uq(q,z,G=(Q)=>o(Q,{withFileTypes:!0}).filter((H)=>H.isDirectory()||H.isFile()).map((H)=>H.name)){let Q=[],H=[{path:q,depth:0}],J=0;while(H.length>0&&J<P){let Y=H.pop(),V;try{V=G(Y.path)}catch{continue}for(let W of V){if(J+=1,J>P)break;let $=Z(Y.path,W);if(z($)){Q.push($);continue}if(Y.depth+1<Qq&&!Vq.has(W))H.push({path:$,depth:Y.depth+1})}}return Q}function s(q){let z=Z(q.root,".git"),G=[];try{if(zq(z).isDirectory())G=[Z(z,"config"),Z(z,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...q.protectedPaths],allowRead:[q.root,q.temporaryDirectory],allowWrite:[...q.allowWrite?[q.root]:[],q.temporaryDirectory],denyWrite:[...q.protectedPaths,...G]}}function Iq(q){return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...q==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Dq(q){let z=q.createTemporaryDirectory??(()=>E(Z(g(),"reason-device-"))),G=q.removeTemporaryDirectory??((Q)=>b(Q,{recursive:!0,force:!0}));return async(Q,H,J)=>{let Y=await m(q),V=z();w+=1;try{let W;try{W=await Y.wrapWithSandboxArgv(a([Q,...H]),q.shell??p(),{filesystem:s({root:J.root,allowWrite:J.allowWrite,temporaryDirectory:V,protectedPaths:Uq(J.root,q.isProtectedPath)})},J.signal,J.cwd)}catch(N){throw N instanceof j?N:new j("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[$,...X]=W.argv;if(!$)throw new j("sandbox_unavailable","The confined execution sandbox produced no command.");return await q.spawnCaptured($,X,{cwd:J.cwd,timeoutMs:J.timeoutMs,signal:J.signal,env:q.scrubEnvironment(J.root,V)})}finally{w-=1;try{Y.cleanupAfterCommand()}catch{}G(V)}}}
|
|
3
3
|
export{_ as Jb,fq as Kb,xq as Lb,c as Mb,Rq as Nb,p as Ob,Dq as Pb};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{Q as
|
|
2
|
+
import{lh as X,nh as Y,ph as Z}from"./vm-hands-entry-lite-ne8kkvk4.js";import{execFileSync as z}from"child_process";import{existsSync as V,realpathSync as M}from"fs";import{userInfo as D}from"os";import{isAbsolute as $,join as C,normalize as F,parse as K}from"path";function Q(){let q=F(D().homedir);if(!$(q)||q===K(q).root)throw Error("Could not resolve the canonical macOS user home.");return q}function O(q,B,J=Q()){let L=Z(B);if(B.kind==="managed"&&B.base){let G=M(J);return{anchor:G,boundary:C(G,B.base),path:C(G,L)}}if(B.kind==="root"&&Y(B.path)){let G=M(J);return{anchor:G,boundary:C(G,X),path:C(G,L)}}return{anchor:q,boundary:q,path:C(q,L)}}function _(q=Q()){return C(q,".config")}function b(){if(process.platform!=="darwin")return null;try{let q=z("/usr/bin/getconf",["DARWIN_USER_DIR"],{encoding:"utf8",timeout:5000}).trim();return $(q)?M(q):null}catch{return null}}function g(q=Q()){let B=C(q,"Library","Application Support","Ara"),J=C(q,"Library","Application Support","Reason");return V(B)&&!V(J)?B:J}
|
|
3
|
+
export{Q as ch,O as dh,_ as eh,b as fh,g as gh};
|