@reason-machines/cli-linux-arm64-musl 0.2.371 → 0.2.372
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-af9g18n7.js +2 -0
- package/bin/vm-hands/api-credentials-65mrr3tn.js +2 -0
- package/bin/vm-hands/{ask-relay-dq0v3bmt.js → ask-relay-ymd2qzgp.js} +3 -3
- package/bin/vm-hands/connect-cli-qc3wtvs2.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-wmcf39x6.js → custom-endpoint-device-zhpake9f.js} +1 -1
- package/bin/vm-hands/desktop-account-5zvgspyw.js +2 -0
- package/bin/vm-hands/{device-workspace-05nkwrpp.js → device-workspace-vbcry9d6.js} +1 -1
- package/bin/vm-hands/{hands-worker-source-5wv1djgv.js → hands-worker-source-h0b1j53p.js} +1 -1
- package/bin/vm-hands/{index-kf4q2kw5.js → index-bbk6a9sk.js} +1 -1
- package/bin/vm-hands/{install-receipt-vaytv1sf.js → install-receipt-7x81ek76.js} +1 -1
- package/bin/vm-hands/local-automation-a6jqeh24.js +2 -0
- package/bin/vm-hands/local-capabilities-mhszxbtw.js +2 -0
- package/bin/vm-hands/local-desktop-users-0hadyvx1.js +2 -0
- package/bin/vm-hands/local-display-mac-v1pc7177.js +2 -0
- package/bin/vm-hands/local-display-session-n39tx1qm.js +2 -0
- package/bin/vm-hands/local-pty-session-hs7rq03x.js +2 -0
- package/bin/vm-hands/{managed-runtime-dz0rtyvr.js → managed-runtime-jqx6n9c8.js} +1 -1
- package/bin/vm-hands/network-contract-zqvt1v0t.js +2 -0
- package/bin/vm-hands/package-3cd7cfyv.js +2 -0
- package/bin/vm-hands/permissions-yg7dazpa.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-dase3v7x.js → reason-hands-protocol-8fxjynte.js} +1 -1
- package/bin/vm-hands/{serve-service-47q4bmhj.js → serve-service-65kzxsrc.js} +1 -1
- package/bin/vm-hands/{status-czgrayjt.js → status-3wwz3xqm.js} +2 -2
- package/bin/vm-hands/version-bsyrze8b.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-2c88t2at.js → vm-hands-entry-lite-00qsbphw.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-w4swepp1.js → vm-hands-entry-lite-1085xsma.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-e9gq8n0f.js → vm-hands-entry-lite-2jbj99sk.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-sfsgeynk.js → vm-hands-entry-lite-3hbe4em3.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8emxhcny.js → vm-hands-entry-lite-3wgag7rz.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-nhfd61cx.js → vm-hands-entry-lite-45j8qwsf.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-gteq5e1n.js → vm-hands-entry-lite-4kfy4zcs.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-rjwk6sfj.js → vm-hands-entry-lite-4m40gwkf.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-zyc3qkej.js → vm-hands-entry-lite-576m681k.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-gzyps3ev.js → vm-hands-entry-lite-5kgvss4p.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-ymwv38dd.js → vm-hands-entry-lite-70xn5vnc.js} +23 -23
- package/bin/vm-hands/{vm-hands-entry-lite-e8skq97c.js → vm-hands-entry-lite-7shpbsw8.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-db4z7ekz.js → vm-hands-entry-lite-9cgm6g8t.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-dq1fdx0j.js → vm-hands-entry-lite-anmv8hp7.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ngytzkx1.js → vm-hands-entry-lite-bvbfcp1k.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-9fr904x2.js → vm-hands-entry-lite-c01eyep6.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-b775ysr4.js → vm-hands-entry-lite-dcynw6t2.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-vygp7vq8.js → vm-hands-entry-lite-dgxxsdwb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-7fx4xtf6.js → vm-hands-entry-lite-g036gtem.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-zmf1terc.js → vm-hands-entry-lite-hc3p6r9p.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-y3wncwjd.js → vm-hands-entry-lite-j2q1k9vb.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-d7y6aah1.js → vm-hands-entry-lite-jb2sr2r7.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-khjrcwrj.js +5 -0
- package/bin/vm-hands/{vm-hands-entry-lite-g576hpce.js → vm-hands-entry-lite-kxdw4myj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-k7twc1ch.js → vm-hands-entry-lite-maqkw6pg.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8sddhaka.js → vm-hands-entry-lite-mh0xecf3.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-gbzvzfe6.js → vm-hands-entry-lite-mrms7y4e.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-kc07ptqt.js → vm-hands-entry-lite-nb5kxm2n.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-bt6esncn.js → vm-hands-entry-lite-nhtb458c.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-5zmn6a7p.js → vm-hands-entry-lite-r6pap1kh.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-mcv6pse6.js → vm-hands-entry-lite-sb9a1jcn.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-5n6agg8d.js → vm-hands-entry-lite-vppy988d.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-5mz0m0k0.js → vm-hands-entry-lite-xdm9jkgq.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-cxgbb2yr.js → vm-hands-entry-lite-y3jxbhxs.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-8cmyg5e4.js → vm-hands-entry-lite-z964akpr.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-dm52srp5.js → vm-hands-entry-lite-za55dtte.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-x9pmwqjd.js → vm-hands-entry-lite-ze9msfq1.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-2fyemnas.js → vm-hands-entry-lite-zfwg7ehq.js} +5 -5
- package/bin/vm-hands/{vm-hands-entry-lite-y9wkxydj.js → vm-hands-entry-lite-zh8p7ndn.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-676cpsf2.js → vm-hands-executor-y16fdqnj.js} +2 -2
- package/bin/vm-hands/vm-hands-op-runner-sb4fa85z.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-d2jafcp6.js → vm-hands-runtime-vq9kf92k.js} +3 -3
- package/bin/vm-hands/worker-sandbox-wpzkvwer.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-ke2v1y5k.js +0 -2
- package/bin/vm-hands/api-ewpnfn05.js +0 -2
- package/bin/vm-hands/connect-cli-atmwwkqh.js +0 -2
- package/bin/vm-hands/desktop-account-cppm1dhr.js +0 -2
- package/bin/vm-hands/local-automation-yrra6zkg.js +0 -2
- package/bin/vm-hands/local-capabilities-ykbksvha.js +0 -2
- package/bin/vm-hands/local-desktop-users-ejwwkfer.js +0 -2
- package/bin/vm-hands/local-display-mac-x0eq4rzq.js +0 -2
- package/bin/vm-hands/local-display-session-xkbc5knp.js +0 -2
- package/bin/vm-hands/local-pty-session-pzg7bk32.js +0 -2
- package/bin/vm-hands/network-contract-zez17y8t.js +0 -2
- package/bin/vm-hands/package-gxv23nam.js +0 -2
- package/bin/vm-hands/permissions-jmcvwvgd.js +0 -2
- package/bin/vm-hands/version-42fp9wnk.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-pt633d84.js +0 -5
- package/bin/vm-hands/vm-hands-op-runner-4j51v1n0.js +0 -2
- package/bin/vm-hands/worker-sandbox-e4kvy715.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s as Mq}from"./vm-hands-entry-lite-
|
|
2
|
+
import{s as Mq}from"./vm-hands-entry-lite-4kfy4zcs.js";import{Lb as Uq,pc as Fq,rb as Lq,tc as Tq}from"./vm-hands-entry-lite-70xn5vnc.js";import"./vm-hands-entry-lite-sb9a1jcn.js";import"./vm-hands-entry-lite-anmv8hp7.js";import"./vm-hands-entry-lite-zfwg7ehq.js";import"./vm-hands-entry-lite-dgxxsdwb.js";import"./vm-hands-entry-lite-zh8p7ndn.js";import"./vm-hands-entry-lite-za55dtte.js";import"./vm-hands-entry-lite-kxdw4myj.js";import"./vm-hands-entry-lite-5kgvss4p.js";import"./vm-hands-entry-lite-r6pap1kh.js";import"./vm-hands-entry-lite-4m40gwkf.js";import"./vm-hands-entry-lite-c01eyep6.js";import"./vm-hands-entry-lite-9cgm6g8t.js";import"./vm-hands-entry-lite-mrms7y4e.js";import"./vm-hands-entry-lite-hc3p6r9p.js";import"./vm-hands-entry-lite-bvbfcp1k.js";import"./vm-hands-entry-lite-j2q1k9vb.js";import"./vm-hands-entry-lite-g036gtem.js";import{spawn as Iq}from"child_process";import{chmodSync as vq,chownSync as Oq,existsSync as l,lstatSync as o,mkdirSync as e,mkdtempSync as bq,readdirSync as s,readFileSync as A,realpathSync as hq,rmdirSync as r,rmSync as xq,writeFileSync as E}from"fs";import{join as U}from"path";var wq="/sys/fs/cgroup/reason-payload",_="vm-hands",Vq="/run/ara-srt/fallbacks.jsonl",y="/reason-person",qq=5000,_q=1e4,zq="__VM_HANDS_PROOF_DIR__",Hq="__VM_HANDS_PROBE_NONCE__";class T extends Error{code;constructor(q,z){super(z);this.code=q}}function gq(q,z){if(!/^[0-9a-f-]{36}$/i.test(z))throw new T("vm_hands_bind_invalid","bad bind id");return U(q,_,`b-${z.toLowerCase()}`)}var kq=5000,Rq=(q)=>`'${q.replaceAll("'","'\\''")}'`;function iq(q){let z=q.cgroup??wq,J=q.init.layout.payload_uid,X=q.log??(()=>{}),G=new Map,W=new Map,B=0,P=()=>{try{let Z=A("/run/ara-srt/starts.jsonl","utf8"),Q=Z.slice(B>Z.length?0:B).split(`
|
|
3
3
|
`).filter(Boolean);B=Z.length;let Y=Q.map((L)=>{try{return Number(JSON.parse(L).elapsed_ms)||0}catch{return 0}});if(Y.length)X("vm_hands.srt_server_starts",{count:Y.length,elapsed_ms:Y.slice(0,8)})}catch{}},D=null,H=!1,O=q.srtCgroup??"/sys/fs/cgroup/reason-srt",C=()=>{D??=Gq()},b=0,h=()=>{try{let Z=A(Vq,"utf8"),Q=Z.slice(b>Z.length?0:b);b=Z.length;let Y=Q.split(`
|
|
4
|
-
`).filter(Boolean).slice(0,1000);if(!Y.length)return null;let L={},F=0;for(let M of Y)try{let R=JSON.parse(M),K=typeof R.code==="string"&&/^[a-z_]{1,40}$/.test(R.code)?R.code:"other";if(L[K]=(L[K]??0)+1,typeof R.elapsed_ms==="number")F=Math.max(F,R.elapsed_ms)}catch{L.unparsed=(L.unparsed??0)+1}return X("vm_hands.srt_fallbacks",{count:Y.length,codes:L,max_elapsed_ms:F}),{count:Y.length,codes:L,max_elapsed_ms:F}}catch{return null}},f=!1,m=(Z,Q,Y)=>{if(f)throw Error("vm_hands_pool_held");return Nq(Z,Q,Y)},d=(Z)=>(Q,Y,L)=>Iq("/bin/sh",["-c",`echo $$ > ${Rq(U(Z,"cgroup.procs"))} || exit 125; exec "$@"`,"vm-hands-join",Q,...Y],L),Nq=d(U(z,_)),u=U(z,_,"probe"),S=(Z)=>gq(z,Z),Aq=(Z)=>{let Q=S(Z);try{e(Q,{mode:493})}catch(Y){if(!(Y&&typeof Y==="object"&&("code"in Y)&&Y.code==="EEXIST"))throw new T("vm_hands_bind_failed","bind cgroup")}return Q},Pq=(Z)=>{try{r(S(Z))}catch{}},x=q.prespawn?Uq({spawnProcess:m,...q.relayDependencies?.sourceEntrypoint?{sourceEntrypoint:q.relayDependencies.sourceEntrypoint}:{},log:(Z,Q)=>X(Z,Q??{})}):null;x?.arm();let i=x?setInterval(()=>{x.arm()},kq):null;i?.unref?.();async function c(Z){let Q=G.get(Z);if(G.delete(Z),!Q)return;Q.abort.abort(),await Q.done}return{bindCgroup:S,async startExecutor(Z){if(C(),W.set(Z.bindId,Gq()),H=!0,!Z.claim)throw new T("vm_hands_bind_invalid","an executor needs the claim it serves");await c(Z.bindId);let{claim:Q,bindId:Y}=Z,L=Aq(Y),F=Q.owner;if(!F||typeof F.device_id!=="string"||typeof Q.root_id!=="string")throw new T("vm_hands_bind_invalid","claim without its owner Device or root");let M=new AbortController,R,K,j=new Promise(($,w)=>{R=$,K=w}),I,N=new Promise(($)=>{I=$}),V=Tq({headless:!0,hostExecution:!0,runtimeDirectory:q.runtimeDirectory,deviceIdentity:{deviceId:F.device_id,rootId:Q.root_id,apiOrigin:q.apiOrigin},claimOwner:Q.owner,root:q.root,runId:Q.run_id,operationId:Q.operation_id,attemptId:Q.attempt_id,payload:Object.fromEntries(Object.entries(Q.payload).filter(([$])=>!$.startsWith("vm_hands_"))),signal:M.signal,emitEvent:async($,w)=>{if($==="hands.ready"){R(w);return}if($==="hands.started"||$==="hands.stopped"||$==="hands.failed")return;await q.forward(Y,$,w)}},{...q.relayDependencies,spawnWorker:($)=>d(L)($.command,$.args,$.options),...x?{takePrespawnedWorker:($)=>{let w=x.take($);if(!w?.pid)return w;try{return E(U(L,"cgroup.procs"),String(w.pid)),w}catch{try{w.kill("SIGKILL")}catch{}return null}},adoptSpawnedWorker:x.adopt}:{}}).then(()=>{I("executor_stopped")},($)=>{let w=$&&typeof $==="object"&&"code"in $?String($.code):"executor_failed";K(new T(w,$ instanceof Error?$.message:String($))),I(w)}).finally(()=>K(new T("vm_hands_executor_exited","executor ended before it was ready")));G.set(Y,{abort:M,done:V,exited:N,operationId:Q.operation_id,runId:Q.run_id,expiresAtMs:Date.parse(String(Q.payload.expires_at??""))||0});let g=await j,a=g.executor_launch_id;if(typeof a!=="string")throw new T("vm_hands_bind_failed","executor ready without a launch id");return{launchId:a,readyData:g,applied:{hands_confinement:typeof Q.payload.hands_confinement==="string"?Q.payload.hands_confinement:null,browser_egress:Q.payload.browser_egress??null}}},takeSrtFallbacks:h,executorExited(Z){return G.get(Z)?.exited??new Promise(()=>{})},freezeBind(Z){let Q=S(Z);if(l(U(Q,"cgroup.freeze")))E(U(Q,"cgroup.freeze"),"1")},async killAndVerifyPayload(Z){let Q=new Set(Z?.keep??[]);if(Q.size||Z?.own)return Cq(Z?.bindId??null,Q,Z?.own===!0);f=!0;let Y=Yq();try{await Bq();let L=Promise.all([...G.keys()].map((K)=>c(K).catch(()=>{return})));P();let F=Date.now()+qq;await p(z,F,"payload"),await L;let M=(H||q.srtWarmLate?.()===!0)&&l(U(O,"cgroup.events"));if(M)await p(O,F,"srt");let R=Zq(J).filter((K)=>!v(K,y));if(D!==null){let K=Xq(D).filter((j)=>j!==process.pid&&!v(j,y));if(K.length)throw X("vm_hands.kill_strays",{strays:K.slice(0,16).map((j)=>{let I="?",N="?";try{I=A(`/proc/${j}/comm`,"utf8").trim().slice(0,32)}catch{}try{N=(A(`/proc/${j}/cgroup`,"utf8").split(`
|
|
4
|
+
`).filter(Boolean).slice(0,1000);if(!Y.length)return null;let L={},F=0;for(let M of Y)try{let R=JSON.parse(M),K=typeof R.code==="string"&&/^[a-z_]{1,40}$/.test(R.code)?R.code:"other";if(L[K]=(L[K]??0)+1,typeof R.elapsed_ms==="number")F=Math.max(F,R.elapsed_ms)}catch{L.unparsed=(L.unparsed??0)+1}return X("vm_hands.srt_fallbacks",{count:Y.length,codes:L,max_elapsed_ms:F}),{count:Y.length,codes:L,max_elapsed_ms:F}}catch{return null}},f=!1,m=(Z,Q,Y)=>{if(f)throw Error("vm_hands_pool_held");return Nq(Z,Q,Y)},d=(Z)=>(Q,Y,L)=>Iq("/bin/sh",["-c",`echo $$ > ${Rq(U(Z,"cgroup.procs"))} || exit 125; exec "$@"`,"vm-hands-join",Q,...Y],L),Nq=d(U(z,_)),u=U(z,_,"probe"),S=(Z)=>gq(z,Z),Aq=(Z)=>{let Q=S(Z);try{e(Q,{mode:493})}catch(Y){if(!(Y&&typeof Y==="object"&&("code"in Y)&&Y.code==="EEXIST"))throw new T("vm_hands_bind_failed","bind cgroup")}return Q},Pq=(Z)=>{try{r(S(Z))}catch{}},x=q.prespawn?Uq({spawnProcess:m,...q.relayDependencies?.sourceEntrypoint?{sourceEntrypoint:q.relayDependencies.sourceEntrypoint}:{},log:(Z,Q)=>X(Z,Q??{})}):null;x?.arm();let i=x?setInterval(()=>{x.arm()},kq):null;i?.unref?.();async function c(Z){let Q=G.get(Z);if(G.delete(Z),!Q)return;Q.abort.abort(),await Q.done}return{bindCgroup:S,async startExecutor(Z){if(C(),W.set(Z.bindId,Gq()),H=!0,!Z.claim)throw new T("vm_hands_bind_invalid","an executor needs the claim it serves");await c(Z.bindId);let{claim:Q,bindId:Y}=Z,L=Aq(Y),F=Q.owner;if(!F||typeof F.device_id!=="string"||typeof Q.root_id!=="string")throw new T("vm_hands_bind_invalid","claim without its owner Device or root");let M=new AbortController,R,K,j=new Promise(($,w)=>{R=$,K=w}),I,N=new Promise(($)=>{I=$}),V=Tq({headless:!0,hostExecution:!0,runtimeDirectory:q.runtimeDirectory,deviceIdentity:{deviceId:F.device_id,rootId:Q.root_id,apiOrigin:q.apiOrigin},claimOwner:Q.owner,root:q.root,runId:Q.run_id,operationId:Q.operation_id,attemptId:Q.attempt_id,payload:Object.fromEntries(Object.entries(Q.payload).filter(([$])=>!$.startsWith("vm_hands_"))),signal:M.signal,...Z.workspaceGrant?{workspaceGrant:Z.workspaceGrant}:{},emitEvent:async($,w)=>{if($==="hands.ready"){R(w);return}if($==="hands.started"||$==="hands.stopped"||$==="hands.failed")return;await q.forward(Y,$,w)}},{...q.relayDependencies,spawnWorker:($)=>d(L)($.command,$.args,$.options),...x?{takePrespawnedWorker:($)=>{let w=x.take($);if(!w?.pid)return w;try{return E(U(L,"cgroup.procs"),String(w.pid)),w}catch{try{w.kill("SIGKILL")}catch{}return null}},adoptSpawnedWorker:x.adopt}:{}}).then(()=>{I("executor_stopped")},($)=>{let w=$&&typeof $==="object"&&"code"in $?String($.code):"executor_failed";K(new T(w,$ instanceof Error?$.message:String($))),I(w)}).finally(()=>K(new T("vm_hands_executor_exited","executor ended before it was ready")));G.set(Y,{abort:M,done:V,exited:N,operationId:Q.operation_id,runId:Q.run_id,expiresAtMs:Date.parse(String(Q.payload.expires_at??""))||0});let g=await j,a=g.executor_launch_id;if(typeof a!=="string")throw new T("vm_hands_bind_failed","executor ready without a launch id");return{launchId:a,readyData:g,applied:{hands_confinement:typeof Q.payload.hands_confinement==="string"?Q.payload.hands_confinement:null,browser_egress:Q.payload.browser_egress??null}}},takeSrtFallbacks:h,executorExited(Z){return G.get(Z)?.exited??new Promise(()=>{})},freezeBind(Z){let Q=S(Z);if(l(U(Q,"cgroup.freeze")))E(U(Q,"cgroup.freeze"),"1")},async killAndVerifyPayload(Z){let Q=new Set(Z?.keep??[]);if(Q.size||Z?.own)return Cq(Z?.bindId??null,Q,Z?.own===!0);f=!0;let Y=Yq();try{await Bq();let L=Promise.all([...G.keys()].map((K)=>c(K).catch(()=>{return})));P();let F=Date.now()+qq;await p(z,F,"payload"),await L;let M=(H||q.srtWarmLate?.()===!0)&&l(U(O,"cgroup.events"));if(M)await p(O,F,"srt");let R=Zq(J).filter((K)=>!v(K,y));if(D!==null){let K=Xq(D).filter((j)=>j!==process.pid&&!v(j,y));if(K.length)throw X("vm_hands.kill_strays",{strays:K.slice(0,16).map((j)=>{let I="?",N="?";try{I=A(`/proc/${j}/comm`,"utf8").trim().slice(0,32)}catch{}try{N=(A(`/proc/${j}/cgroup`,"utf8").split(`
|
|
5
5
|
`).find((V)=>V.startsWith("0::"))??"").slice(3,80)}catch{}return{pid:j,comm:I,cgroup:N}})}),new T("vm_hands_kill_unverified",`${K.length} process(es) the run started survived it`);D=null}if(H=!1,M)q.onSrtReset?.();if(R.length)throw X("vm_hands.kill_survivors",{pids:R.slice(0,16)}),new T("vm_hands_kill_unverified",`${R.length} payload-uid process(es) outside the payload cgroup`);W.clear();for(let K of Qq())try{r(U(z,_,K))}catch{}}finally{f=!1,Y()}if(x)setTimeout(()=>{if(!G.size)x.arm()},100).unref?.()},async killProbe(){let Z=Date.now()+qq;if(l(U(u,"cgroup.events"))){await p(u,Z,"probe");try{r(u)}catch{}}let Q=$q(process.pid);if(Q===null)throw new T("vm_hands_kill_unverified","agent start time unreadable");await yq(z,Q,Z);let Y=(F)=>{let M=$q(F);return M!==null&&M<=Q},L=Zq(J).filter((F)=>Y(F)&&!v(F,y));if(L.length)throw X("vm_hands.kill_survivors",{pids:L.slice(0,16),at:"attest"}),new T("vm_hands_kill_unverified",`${L.length} payload-uid process(es) from before this agent`);if(D!==null){let F=[z,U(z,_)].map((K)=>K.replace(/^\/sys\/fs\/cgroup/,"")),M=O.replace(/^\/sys\/fs\/cgroup/,""),R=Xq(D).filter((K)=>K!==process.pid&&!v(K,y)&&!v(K,"/reason-vm-hands")&&!v(K,M)&&!F.some((j)=>Wq(K,j)));if(R.length)throw X("vm_hands.kill_strays",{strays:R.slice(0,16).map((K)=>({pid:K})),at:"attest"}),new T("vm_hands_kill_unverified",`${R.length} process(es) the probe started survived it`);D=null}},async runProbe({nonce:Z,script:Q}){if(C(),!Q.includes(zq))throw new T("vm_hands_probe_failed","probe names no proof directory");let Y=q.proofParent??"/tmp/reason-vm-hands-proof";e(Y,{mode:457,recursive:!0});let L=o(Y);if(L.isSymbolicLink()||!L.isDirectory()||L.uid!==(process.getuid?.()??-1)||(L.mode&4095)!==457)throw new T("vm_hands_probe_failed","proof parent is not root's 0711 directory");let F=bq(U(Y,"p-")),M=!1;try{if(!/^[A-Za-z0-9/._-]+$/.test(F)||!/^[A-Za-z0-9_-]{1,128}$/.test(Z))throw new T("vm_hands_probe_failed","proof directory path or nonce");Oq(F,J,J),vq(F,448);let R=o(F).ino;try{e(u,{mode:493})}catch(N){if(!(N&&typeof N==="object"&&("code"in N)&&N.code==="EEXIST"))throw new T("vm_hands_probe_failed","probe cgroup")}let K=d(u)("/bin/bash",["-c",Q.replaceAll(zq,F).replaceAll(Hq,Z)],{cwd:"/",env:{PATH:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},stdio:["ignore","pipe","ignore"]}),j="";K.stdout?.on("data",(N)=>{if(j.length<16384)j+=N.toString("utf8").slice(0,16384-j.length)});let I=await new Promise((N)=>{let V=setTimeout(()=>{M=!0,K.kill("SIGKILL"),N(124)},_q);K.once("error",()=>{clearTimeout(V),N(127)}),K.once("close",(g)=>{clearTimeout(V),N(g??1)})});return X("vm_hands.probe",{nonce_len:Z.length,exit_code:I}),{exitCode:I,markers:j,proofDirInode:R}}finally{if(!M)xq(F,{recursive:!0,force:!0})}},restatLayout(){let{session_root:Z,alias:Q}=q.init.layout,Y="invalid";try{Fq(Z),Y="0:0:755"}catch{}let L=!1,F=-1;try{let M=o(Q);F=M.uid,L=Y==="0:0:755"&&Q===U(Z,"repo")&&!M.isSymbolicLink()&&M.isDirectory()&&hq(Q)===Q&&M.uid===J}catch{}return{root_mode:Y,alias_ok:L,owner_uid:F}},installEnvironment(Z,Q){let Y=G.get(Z);if(!Y)throw new T("environment_unavailable","no executor owns an environment");return Lq({root:q.root,operationId:Y.operationId,payload:Q}).installed_revision},async stop(){if(i)clearInterval(i);x?.close(),await Promise.all([...G.keys()].map((Z)=>c(Z)))}};function Qq(){try{return s(U(z,_),{withFileTypes:!0}).filter((Z)=>Z.isDirectory()&&/^b-[0-9a-f-]{36}$/.test(Z.name)).map((Z)=>Z.name)}catch{return[]}}async function Cq(Z,Q,Y=!1){let L=new Set([...Q].map((M)=>M.toLowerCase())),F=Yq();try{await Bq();let M=Date.now()+qq,R=new Set(Qq().filter(($)=>!L.has($.slice(2))).map(($)=>$.slice(2)));if(Z)R.add(Z.toLowerCase());let K=null;for(let $ of R){let w=c($).catch(()=>{return}),n=W.get($);if(n!==void 0)K=K===null?n:Math.min(K,n);if(l(U(S($),"cgroup.events")))await p(S($),M,"bind");await w}let j=[...L].map(($)=>S($).replace(/^\/sys\/fs\/cgroup/,"")),I=[z,U(z,_)].map(($)=>$.replace(/^\/sys\/fs\/cgroup/,"")),N=O.replace(/^\/sys\/fs\/cgroup/,""),V=($)=>v($,y)||j.some((w)=>v($,w)),g=Y?[]:Zq(J).filter(($)=>!V($));if(g.length)throw X("vm_hands.kill_survivors",{pids:g.slice(0,16),beside:L.size}),new T("vm_hands_kill_unverified",`${g.length} payload-uid process(es) outside a live bind`);let a=($)=>!V($)&&!v($,"/reason-vm-hands")&&!v($,N)&&!I.some((w)=>Wq($,w));if(K!==null){let $=Xq(K).filter((w)=>w!==process.pid&&a(w));if($.length)throw X("vm_hands.kill_strays",{strays:$.slice(0,16).map((w)=>({pid:w})),beside:L.size}),new T("vm_hands_kill_unverified",`${$.length} process(es) the run started survived it`)}for(let $ of R)W.delete($),Pq($)}finally{F()}}}function $q(q,z="/proc"){try{let J=A(U(z,String(q),"stat"),"utf8"),X=Number(J.slice(J.lastIndexOf(")")+2).split(" ")[19]);return Number.isFinite(X)?X:null}catch{return null}}function Sq(q,z="/proc"){try{let J=A(U(z,String(q),"stat"),"utf8"),X=Number(J.slice(J.lastIndexOf(")")+2).split(" ")[1]);return Number.isFinite(X)?X:null}catch{return null}}async function yq(q,z,J){try{E(U(q,"cgroup.freeze"),"1")}catch(X){throw new T("vm_hands_kill_unverified",`payload cgroup.freeze: ${X instanceof Error?X.message:String(X)}`)}try{for(;;){let X=Dq(q).filter((W)=>fq(W,q)),G=new Set(X.filter((W)=>{let B=$q(W);return B!==null&&B<=z}));for(let W=!0;W;){W=!1;for(let B of X){if(G.has(B))continue;let P=Sq(B);if(P!==null&&G.has(P))G.add(B),W=!0}}if(G.size===0)return;if(Date.now()>J)throw new T("vm_hands_kill_unverified",`${G.size} previous-boot process(es) survived`);for(let W of G)try{process.kill(W,"SIGKILL")}catch{}await new Promise((W)=>setTimeout(W,10))}}finally{try{E(U(q,"cgroup.freeze"),"0")}catch{}}}function Wq(q,z,J="/proc"){try{return A(U(J,String(q),"cgroup"),"utf8").split(`
|
|
6
6
|
`).find((G)=>G.startsWith("0::"))?.slice(3)===z}catch{return!1}}function v(q,z,J="/proc"){try{let G=A(U(J,String(q),"cgroup"),"utf8").split(`
|
|
7
7
|
`).find((W)=>W.startsWith("0::"))?.slice(3)??"";return G===z||G.startsWith(`${z}/`)}catch{return!1}}var Eq=100;function Gq(){try{return Math.floor(Number(A("/proc/uptime","utf8").split(" ")[0])*Eq)}catch{return 0}}async function p(q,z,J){try{E(U(q,"cgroup.freeze"),"1")}catch(X){throw new T("vm_hands_kill_unverified",`${J} cgroup.freeze: ${X instanceof Error?X.message:String(X)}`)}while(!/^populated 0$/m.test(A(U(q,"cgroup.events"),"utf8"))){if(Date.now()>z)throw new T("vm_hands_kill_unverified",`${J} cgroup still populated (left frozen)`);for(let X of Dq(q)){if(!fq(X,q))continue;try{process.kill(X,"SIGKILL")}catch{}}await new Promise((X)=>setTimeout(X,10))}try{E(U(q,"cgroup.freeze"),"0")}catch(X){throw new T("vm_hands_kill_unverified",`${J} cgroup thaw: ${X instanceof Error?X.message:String(X)}`)}}function fq(q,z){let J=z.replace(/^\/sys\/fs\/cgroup/,"")||"/",X="";try{X=A(`/proc/${q}/cgroup`,"utf8").split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xa as k,ya as m,za as l}from"./vm-hands-entry-lite-
|
|
3
|
-
`,{mode:420}),Q("srt_base_keyed",{})}catch{Q("srt_base_keyed_skipped",{reason:"error"})}}function R(Q,j){let J=(F)=>{return j("srt_warm_skipped",{reason:F}),Promise.resolve()};if(typeof Q.srt_base_settings!=="string")return J("no_settings");let Z=Buffer.from(Q.srt_base_settings,"base64");if(Z.length===0||Z.length>qj||Z.toString("base64")!==Q.srt_base_settings)return J("settings_invalid");try{let F=w(S);if(!F.isDirectory()||F.uid!==0||(F.mode&18)!==0)return J("cgroup_unsafe");for(let[H,g]of[[p,!1],["/usr/local/bin",!0]]){let Y=w(H);if((g?!Y.isDirectory():!Y.isFile())||Y.uid!==0||(Y.mode&18)!==0)return J("srt_exec_unsafe")}}catch{return J("cgroup_or_exec_missing")}if((process.getuid?.()??-1)!==0)return J("not_root");let X=performance.now(),z=t("sha256").update(Z).digest("hex"),W=`${P}/srt-base-settings.json`;try{d(W,Z,{mode:384,flag:"w"})}catch{return J("settings_write")}let L=a("/bin/sh",["-c",`echo $$ > ${S}/cgroup.procs || exit 125; exec "$@"`,"vm-hands-srt",p,"--settings",W,"--idle-ms",String(Jj),"--","/bin/true"],{cwd:"/",env:{PATH:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},stdio:"ignore"});return new Promise((F)=>{L.once("error",()=>{j("srt_warm_failed",{reason:"spawn"}),F()}),L.once("close",(H)=>{j(H===0?"srt_warm_done":"srt_warm_failed",{exit_code:H,warm_ms:Math.round(performance.now()-X),settings_sha256:z}),F()})})}var u=3000;function Lj(Q){if(!Q||typeof Q!=="object"||Array.isArray(Q))return null;let j=Q,J=j.layout,Z=j.device_key,X=j.credential;return typeof j.workspace_id==="string"&&Number.isSafeInteger(j.instance_generation)&&typeof j.api_origin==="string"&&jj.test(j.api_origin)&&typeof j.manifest_digest==="string"&&!!X&&typeof X.key_id==="string"&&Number.isSafeInteger(X.expires_at_ms)&&typeof X.signature==="string"&&!!J&&typeof J.session_root==="string"&&typeof J.alias==="string"&&Number.isSafeInteger(J.payload_uid)&&typeof J.kind==="string"&&!!Z&&typeof Z.pkcs8==="string"&&typeof Z.spki==="string"?j:null}function y(Q){s(Q,{recursive:!0,mode:448});let j=e(Q);if(!j.isDirectory()||(j.mode&63)!==0||j.uid!==(process.getuid?.()??-1))throw Error(`vm_hands_runtime_directory_unsafe: ${Q}`)}async function Zj(Q){let[{CLI_VERSION:j},J,Z,X]=await Promise.all([import("./version-
|
|
4
|
-
`)){let J=j.split(":");if(J.length>=4&&Number(J[2])===Q&&/^\d+$/.test(J[3]??"")&&Number(J[3])>0)return Number(J[3])}throw Error("vm_hands_payload_account_unavailable")}function Fj(Q,j){let J=j.owner;if(!J||typeof J.organization_id!=="string"||typeof J.device_id!=="string"||typeof j.root_id!=="string")return null;return{version:4,apiOrigin:Q.api_origin,orgId:J.organization_id,deviceId:J.device_id,devicePublicKey:"",displayName:"vm-hands",registeredAt:new Date(0).toISOString(),handsSlots:1,roots:[{id:j.root_id,label:"workspace",path:T,pathFingerprint:"0".repeat(64),permissions:{read:!0,write:!0,execute:!0,discover_environment:!0,expose_mcp:!1}}]}}async function Mj(Q,j){y(P),y(O),Qj(j);let J=R(Q,j),Z=!1,X=async()=>{if(!await Promise.race([J.then(()=>!0),new Promise(($)=>setTimeout(()=>$(!1),u).unref?.())]))Z=!0,j("srt_warm_late",{wait_ms:u})},[{configureDesktopAccount:z},{configureWorkerSandbox:W}]=await Promise.all([import("./desktop-account-
|
|
2
|
+
import{xa as k,ya as m,za as l}from"./vm-hands-entry-lite-khjrcwrj.js";import{ve as v}from"./vm-hands-entry-lite-zfwg7ehq.js";import"./vm-hands-entry-lite-hc3p6r9p.js";import{hk as G}from"./vm-hands-entry-lite-g036gtem.js";import{spawn as a}from"child_process";import{createHash as t}from"crypto";import{lstatSync as w,mkdirSync as s,readFileSync as i,statSync as e,writeFileSync as d}from"fs";var P="/run/reason-vm-hands",O="/run/reason-vm-hands/env",T="/home/runner/.reason/workspace",jj=/^https:\/\/[a-z0-9.-]+(?::\d{1,5})?$/,S="/sys/fs/cgroup/reason-srt",p="/usr/local/bin/ara-srt-exec",qj=65536,Jj=21600000;function Qj(Q,j="/run/ara-srt"){try{if((process.getuid?.()??-1)!==0)return;s(j,{recursive:!0,mode:448});let J=w(j);if(!J.isDirectory()||J.uid!==0||(J.mode&63)!==0){Q("srt_base_keyed_skipped",{reason:"socket_dir_unsafe"});return}d(`${j}/base-keyed`,`1
|
|
3
|
+
`,{mode:420}),Q("srt_base_keyed",{})}catch{Q("srt_base_keyed_skipped",{reason:"error"})}}function R(Q,j){let J=(F)=>{return j("srt_warm_skipped",{reason:F}),Promise.resolve()};if(typeof Q.srt_base_settings!=="string")return J("no_settings");let Z=Buffer.from(Q.srt_base_settings,"base64");if(Z.length===0||Z.length>qj||Z.toString("base64")!==Q.srt_base_settings)return J("settings_invalid");try{let F=w(S);if(!F.isDirectory()||F.uid!==0||(F.mode&18)!==0)return J("cgroup_unsafe");for(let[H,g]of[[p,!1],["/usr/local/bin",!0]]){let Y=w(H);if((g?!Y.isDirectory():!Y.isFile())||Y.uid!==0||(Y.mode&18)!==0)return J("srt_exec_unsafe")}}catch{return J("cgroup_or_exec_missing")}if((process.getuid?.()??-1)!==0)return J("not_root");let X=performance.now(),z=t("sha256").update(Z).digest("hex"),W=`${P}/srt-base-settings.json`;try{d(W,Z,{mode:384,flag:"w"})}catch{return J("settings_write")}let L=a("/bin/sh",["-c",`echo $$ > ${S}/cgroup.procs || exit 125; exec "$@"`,"vm-hands-srt",p,"--settings",W,"--idle-ms",String(Jj),"--","/bin/true"],{cwd:"/",env:{PATH:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},stdio:"ignore"});return new Promise((F)=>{L.once("error",()=>{j("srt_warm_failed",{reason:"spawn"}),F()}),L.once("close",(H)=>{j(H===0?"srt_warm_done":"srt_warm_failed",{exit_code:H,warm_ms:Math.round(performance.now()-X),settings_sha256:z}),F()})})}var u=3000;function Lj(Q){if(!Q||typeof Q!=="object"||Array.isArray(Q))return null;let j=Q,J=j.layout,Z=j.device_key,X=j.credential;return typeof j.workspace_id==="string"&&Number.isSafeInteger(j.instance_generation)&&typeof j.api_origin==="string"&&jj.test(j.api_origin)&&typeof j.manifest_digest==="string"&&!!X&&typeof X.key_id==="string"&&Number.isSafeInteger(X.expires_at_ms)&&typeof X.signature==="string"&&!!J&&typeof J.session_root==="string"&&typeof J.alias==="string"&&Number.isSafeInteger(J.payload_uid)&&typeof J.kind==="string"&&!!Z&&typeof Z.pkcs8==="string"&&typeof Z.spki==="string"?j:null}function y(Q){s(Q,{recursive:!0,mode:448});let j=e(Q);if(!j.isDirectory()||(j.mode&63)!==0||j.uid!==(process.getuid?.()??-1))throw Error(`vm_hands_runtime_directory_unsafe: ${Q}`)}async function Zj(Q){let[{CLI_VERSION:j},J,Z,X]=await Promise.all([import("./version-bsyrze8b.js"),import("./hands-worker-source-h0b1j53p.js"),import("./network-contract-zqvt1v0t.js"),import("./device-workspace-vbcry9d6.js")]),{REASON_HANDS_PROTOCOL_VERSION:z}=await import("./reason-hands-protocol-8fxjynte.js");return{reason_runtime_version:j,bridge_version:j,protocol_version:v,execution_eligible:!0,instance_generation:Q.instance_generation,capabilities:{supported_operations:["hands.connect"],hands_worker_artifact_sha256:J.REASON_HANDS_WORKER_ARTIFACT_SHA256,hands_worker_entrypoint:J.REASON_HANDS_WORKER_ENTRYPOINT,hands_slots:1,max_payload_bytes:Z.LOCAL_OPERATION_MAX_BYTES,max_result_bytes:Z.LOCAL_OPERATION_MAX_BYTES,operation_constraints:{"hands.connect":{ready:!0,execution_mode:"host",transport:"wss_relay",worker:"ara_hands",slots:1,session_group:Z.HANDS_SESSION_GROUP,worker_version:J.REASON_HANDS_WORKER_VERSION,protocol_version:z,worker_artifact_sha256:J.REASON_HANDS_WORKER_ARTIFACT_SHA256,worker_entrypoint:J.REASON_HANDS_WORKER_ENTRYPOINT,policy_mode:"full_access",policy_version:1,workspace_base:X.REASON_WORKSPACE_BASE,workspace_layout:X.SESSION_WORKSPACE_LAYOUT,browser_state:"optional_headless",desktop:!1,max_session_ms:43200000,environment_delivery:Z.HANDS_ENVIRONMENT_DELIVERY,[Z.HANDS_ENVIRONMENT_AT_CLAIM_KEY]:Z.HANDS_ENVIRONMENT_AT_CLAIM,[Z.HANDS_CLOUD_ACCESS_KEY]:Z.HANDS_CLOUD_ACCESS,[Z.HANDS_LARGE_ENVIRONMENT_KEY]:Z.HANDS_LARGE_ENVIRONMENT,[Z.HANDS_CONFINEMENT_KEY]:Z.HANDS_CONFINEMENT,[Z.HANDS_JOBS_USER_KEY]:Z.HANDS_JOBS_USER,vm_hands:"v1"}}}}}var V=["fs.read","fs.write","fs.export","fs.import","exec.run","exec.full","process.list","ports.list","pty.start","jobs.control","automation.call.v1"],$j=new Set(["pty.start","jobs.control"]);function Xj(Q,j){let J=j([{id:"vm-hands",label:"workspace",path:T,pathFingerprint:"0".repeat(64),permissions:{read:!0,write:!0,execute:!0,discover_environment:!0,expose_mcp:!1}}],{worker:{executionMode:"unsandboxed",readiness:Object.fromEntries(V.map((z)=>[z,!0]))}}),Z=Q.capabilities,X={...Z.operation_constraints};for(let z of V)X[z]={...J.operation_constraints?.[z]??{},ready:!0,execution_mode:J.operation_constraints?.[z]?.execution_mode??"host"};return{...Q,capabilities:{...Z,supported_operations:["hands.connect",...V],operation_constraints:X}}}function zj(Q){for(let j of i("/etc/passwd","utf8").split(`
|
|
4
|
+
`)){let J=j.split(":");if(J.length>=4&&Number(J[2])===Q&&/^\d+$/.test(J[3]??"")&&Number(J[3])>0)return Number(J[3])}throw Error("vm_hands_payload_account_unavailable")}function Fj(Q,j){let J=j.owner;if(!J||typeof J.organization_id!=="string"||typeof J.device_id!=="string"||typeof j.root_id!=="string")return null;return{version:4,apiOrigin:Q.api_origin,orgId:J.organization_id,deviceId:J.device_id,devicePublicKey:"",displayName:"vm-hands",registeredAt:new Date(0).toISOString(),handsSlots:1,roots:[{id:j.root_id,label:"workspace",path:T,pathFingerprint:"0".repeat(64),permissions:{read:!0,write:!0,execute:!0,discover_environment:!0,expose_mcp:!1}}]}}async function Mj(Q,j){y(P),y(O),Qj(j);let J=R(Q,j),Z=!1,X=async()=>{if(!await Promise.race([J.then(()=>!0),new Promise(($)=>setTimeout(()=>$(!1),u).unref?.())]))Z=!0,j("srt_warm_late",{wait_ms:u})},[{configureDesktopAccount:z},{configureWorkerSandbox:W}]=await Promise.all([import("./desktop-account-5zvgspyw.js"),import("./worker-sandbox-wpzkvwer.js")]);W();try{z({value:String(Q.layout.payload_uid)})}catch{j("payload_account_unavailable"),await new Promise(()=>{setInterval(()=>{return},1073741824)})}let L=new AbortController;for(let q of["SIGTERM","SIGINT"])process.on(q,()=>L.abort());let F=new Map,H,g=new Promise((q)=>{H=q}),Y=g.then(()=>import("./vm-hands-executor-y16fdqnj.js")).then(({createVmHandsExecutor:q})=>{let $=q({init:Q,root:T,runtimeDirectory:P,apiOrigin:Q.api_origin,prespawn:!0,onSrtReset:()=>{Z=!1,J=R(Q,j)},srtWarmLate:()=>Z,forward:(B,K,N)=>F.get(B)?.(K,N)??Promise.reject(Error("vm_hands_not_bound")),log:(B,K)=>j(B,K)});return j("executor_loaded"),$}),A=(q)=>async(...$)=>(await Y)[q](...$),C=null;Y.then((q)=>{C=($)=>q.executorExited($)});let M={startExecutor:async(...q)=>{return await X(),A("startExecutor")(...q)},killAndVerifyPayload:A("killAndVerifyPayload"),killProbe:A("killProbe"),runProbe:async(...q)=>{return await X(),A("runProbe")(...q)},restatLayout:()=>{throw Error("replaced below")},installEnvironment:()=>{throw Error("replaced below")},executorExited:(q)=>C?C(q):new Promise(()=>{}),takeSrtFallbacks:()=>null};Y.then((q)=>{M.restatLayout=()=>q.restatLayout(),M.installEnvironment=($,B)=>q.installEnvironment($,B),M.freezeBind=($)=>q.freezeBind($),M.takeSrtFallbacks=()=>q.takeSrtFallbacks?.()??null});let c=await k(Q),o=new m(Q,c,M,{envRoot:O}),h=Zj(Q),b=null,n=Promise.all([h,import("./local-capabilities-mhszxbtw.js")]).then(([q,$])=>{b=Xj(q,$.capabilityInventoryForRoots),j("device_ops_loaded")}).catch((q)=>j("device_ops_unavailable",{error:q instanceof Error?q.name:"error"})),f=g.then(()=>import("./vm-hands-executor-y16fdqnj.js")).then(({createVmHandsOpRunners:q,vmHandsBindCgroup:$,VM_HANDS_PAYLOAD_CGROUP:B})=>q({payloadUid:Q.layout.payload_uid,payloadGid:zj(Q.layout.payload_uid),bindCgroup:(K)=>$(B,K),log:(K,N)=>j(K,N)})).catch(()=>null);f.then((q)=>q?.warm("person")),j("agent_ready"),await l({apiOrigin:Q.api_origin,agent:o,signal:L.signal,heartbeat:async()=>b??await h,executeOp:async({kind:q,claim:$,bindId:B,signal:K,emit:N})=>{let x=Fj(Q,$);if(!x)return{status:"failed",error_code:"vm_hands_bind_invalid"};let E={executionMode:"unsandboxed",runtimeDirectory:P,readiness:Object.fromEntries(V.map((U)=>[U,!0]))},_=(U)=>{let D=typeof U.kind==="string"?U.kind:"";if(D)N({kind:D,...U.data&&typeof U.data==="object"?{data:U.data}:{}})};if($.capability==="exec.full"&&q!=="person")return{status:"failed",error_code:"capability_not_granted"};if($.capability==="automation.call.v1"&&q!=="model")return{status:"failed",error_code:"capability_not_granted"};let r=$.capability==="pty.start"&&q==="person"&&!$.authority;if($j.has(String($.capability))&&!r){let{executeLocalOperation:U}=await import("./local-capabilities-mhszxbtw.js");return U(x,$,{worker:E,signal:K,emit:(D)=>_(D)})}let I=await f;if(!I)return{status:"failed",error_code:"vm_hands_payload_account_unavailable"};return I.run(q,{id:String($.attempt_id),claim:$,state:x,worker:E},_,K,B)},readyData:({launchId:q})=>({executor_launch_id:q}),log:(q,$)=>{if(q==="vm_hands.registered"||q==="vm_hands.reconnected")H();j(q,$)},onTurn:(q,$)=>{if($)F.set(q,$);else F.delete(q)}}),await(await Y).stop(),(await f)?.stop()}export{R as startBaseSrtServer,Mj as runVmHands,Lj as parseVmHandsInit,Zj as heartbeatBody,Qj as enableBaseKeyedSrt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{r as a}from"./vm-hands-entry-lite-jb2sr2r7.js";import"./vm-hands-entry-lite-dcynw6t2.js";import"./vm-hands-entry-lite-sb9a1jcn.js";import"./vm-hands-entry-lite-hh24bq0d.js";import"./vm-hands-entry-lite-4m40gwkf.js";import"./vm-hands-entry-lite-j2q1k9vb.js";import"./vm-hands-entry-lite-g036gtem.js";export{a as configureWorkerSandbox};
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{v as a,w as b,x as c,y as d,z as e}from"./vm-hands-entry-lite-bt6esncn.js";import"./vm-hands-entry-lite-8sddhaka.js";import"./vm-hands-entry-lite-sfsgeynk.js";import"./vm-hands-entry-lite-g9rvf5qk.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{d as resolveApiCredentials,e as requireApiCredentials,b as explicitApiOrigin,c as environmentApiKey,a as apiOriginFromEnvironment};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{F as a,G as b,H as c,I as d,J as e,K as f}from"./vm-hands-entry-lite-8sddhaka.js";import"./vm-hands-entry-lite-sfsgeynk.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{d as sessionPlace,c as sessionMachine,e as createMachineEnrollmentTicketWithToken,f as ReasonApi,b as REASONING_EFFORTS,a as ApiError};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m}from"./vm-hands-entry-lite-kc07ptqt.js";import"./vm-hands-entry-lite-d7y6aah1.js";import"./vm-hands-entry-lite-bt6esncn.js";import"./vm-hands-entry-lite-8sddhaka.js";import"./vm-hands-entry-lite-k7twc1ch.js";import"./vm-hands-entry-lite-sfsgeynk.js";import"./vm-hands-entry-lite-8cmyg5e4.js";import"./vm-hands-entry-lite-ymwv38dd.js";import"./vm-hands-entry-lite-b775ysr4.js";import"./vm-hands-entry-lite-mcv6pse6.js";import"./vm-hands-entry-lite-dq1fdx0j.js";import"./vm-hands-entry-lite-g9rvf5qk.js";import"./vm-hands-entry-lite-hh24bq0d.js";import"./vm-hands-entry-lite-2c88t2at.js";import"./vm-hands-entry-lite-e9gq8n0f.js";import"./vm-hands-entry-lite-8emxhcny.js";import"./vm-hands-entry-lite-w4swepp1.js";import"./vm-hands-entry-lite-2fyemnas.js";import"./vm-hands-entry-lite-5n6agg8d.js";import"./vm-hands-entry-lite-x9pmwqjd.js";import"./vm-hands-entry-lite-vygp7vq8.js";import"./vm-hands-entry-lite-y9wkxydj.js";import"./vm-hands-entry-lite-dm52srp5.js";import"./vm-hands-entry-lite-g576hpce.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-zyc3qkej.js";import"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-cxgbb2yr.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-5mz0m0k0.js";import"./vm-hands-entry-lite-gbzvzfe6.js";import"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-ngytzkx1.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{g as runDisconnectCli,f as runConnectCli,m as restartConnectionWhenIdle,l as restartConnection,h as logoutConnection,k as connectionUsesUserChrome,i as connectionReport,j as connectionForBrowserExtension,c as connectionDirectory,d as computerDisconnected,e as addConnectionFolder,b as DISCONNECT_HELP,a as CONNECT_HELP};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ag as c,Bg as d,Cg as e,yg as a,zg as b}from"./vm-hands-entry-lite-y9wkxydj.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{b as passwdAccount,e as desktopHome,d as desktopAccount,c as configureDesktopAccount,a as DESKTOP_USER_ENV};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ad as j,Bd as k,Cd as l,rd as a,sd as b,td as c,ud as d,vd as e,wd as f,xd as g,yd as h,zd as i}from"./vm-hands-entry-lite-e9gq8n0f.js";import"./vm-hands-entry-lite-8emxhcny.js";import"./vm-hands-entry-lite-w4swepp1.js";import"./vm-hands-entry-lite-2fyemnas.js";import"./vm-hands-entry-lite-5n6agg8d.js";import"./vm-hands-entry-lite-x9pmwqjd.js";import"./vm-hands-entry-lite-vygp7vq8.js";import"./vm-hands-entry-lite-y9wkxydj.js";import"./vm-hands-entry-lite-dm52srp5.js";import"./vm-hands-entry-lite-g576hpce.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-zyc3qkej.js";import"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-cxgbb2yr.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-5mz0m0k0.js";import"./vm-hands-entry-lite-gbzvzfe6.js";import"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-ngytzkx1.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{d as runRelayed,e as runMacComputerUse,l as runLocalAutomation,k as runAutomationCallLocally,b as parseAutomationPayload,g as localUserChromeProfiles,h as localUserChromeInstance,f as localUserChromeHost,j as localBrowserProfile,c as localAutomationAvailable,i as ensureLocalBrowser,a as AUTOMATION_CHUNK_BYTES};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$a as m,Ra as c,Sa as d,Ta as e,Ua as f,Va as g,Wa as h,Xa as i,Ya as j,Za as k,_a as l,ab as n,bb as o,cb as p,db as q,eb as r,fb as s,gb as t}from"./vm-hands-entry-lite-8cmyg5e4.js";import"./vm-hands-entry-lite-ymwv38dd.js";import"./vm-hands-entry-lite-b775ysr4.js";import"./vm-hands-entry-lite-mcv6pse6.js";import"./vm-hands-entry-lite-dq1fdx0j.js";import"./vm-hands-entry-lite-g9rvf5qk.js";import"./vm-hands-entry-lite-hh24bq0d.js";import"./vm-hands-entry-lite-2c88t2at.js";import"./vm-hands-entry-lite-e9gq8n0f.js";import"./vm-hands-entry-lite-8emxhcny.js";import"./vm-hands-entry-lite-w4swepp1.js";import"./vm-hands-entry-lite-2fyemnas.js";import"./vm-hands-entry-lite-5n6agg8d.js";import"./vm-hands-entry-lite-x9pmwqjd.js";import"./vm-hands-entry-lite-vygp7vq8.js";import"./vm-hands-entry-lite-y9wkxydj.js";import"./vm-hands-entry-lite-dm52srp5.js";import"./vm-hands-entry-lite-g576hpce.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-zyc3qkej.js";import{Ei as b}from"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-cxgbb2yr.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-5mz0m0k0.js";import"./vm-hands-entry-lite-gbzvzfe6.js";import"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-ngytzkx1.js";import{$j as a}from"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{g as spawnCaptured,f as sandboxProfile,e as safeEnvironment,j as runTransferCapability,i as runFileCapability,s as rebindLocalHandsControl,b as isProtectedLocalPath,t as executeLocalOperation,l as enrolledWorkspaceRootFingerprint,p as enrolledRootPaths,o as enrolledHomeContainedRootFingerprints,m as enrolledAccountRootPath,n as enrolledAccountRootFingerprint,r as deliverLocalHandsEnvironment,h as defaultLocalCommandRunner,d as confinedExecutionShell,q as capabilityInventoryForRoots,c as SHORT_REQUEST_CAPABILITIES,a as LocalCapabilityError,k as LOCAL_CAPABILITY_REGISTRY};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Uj as a,Vj as b,Wj as c,Xj as d,Yj as e,Zj as f,_j as g}from"./vm-hands-entry-lite-ngytzkx1.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{f as trackDesktopRun,c as releaseLocalDesktop,a as noteLocalDesktopUse,g as holdLocalDesktop,b as forgetLocalDesktopUse,e as DESKTOP_WAIT_MS,d as DESKTOP_IDLE_MS};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Mj as a,Nj as b,Oj as c,Pj as d,Qj as e,Rj as f,Sj as g}from"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{c as requestMacScreenAccess,d as parseMacWindowBounds,a as parseMacScreenStatus,e as openMacWindowBounds,g as openMacInput,b as macScreenStatus,f as MacInputTranslator};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Rf as a,Sf as b,Tf as c,Uf as d,Vf as e,Wf as f,Xf as g,Yf as h}from"./vm-hands-entry-lite-5n6agg8d.js";import"./vm-hands-entry-lite-x9pmwqjd.js";import"./vm-hands-entry-lite-vygp7vq8.js";import"./vm-hands-entry-lite-y9wkxydj.js";import"./vm-hands-entry-lite-dm52srp5.js";import"./vm-hands-entry-lite-g576hpce.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-zyc3qkej.js";import"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-cxgbb2yr.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-5mz0m0k0.js";import"./vm-hands-entry-lite-gbzvzfe6.js";import"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-ngytzkx1.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{h as runLocalDisplayStream,f as privateDirectory,c as parseDisplayStreamPayload,e as localDisplayReady,d as localDisplayAvailable,g as ensureLinuxDesktop,a as LOCAL_DISPLAY_MAX_SESSION_MS,b as LINUX_WORKER_DISPLAY};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$f as c,Zf as a,_f as b,ag as d,bg as e,cg as f,dg as g,eg as h,fg as i,gg as j}from"./vm-hands-entry-lite-x9pmwqjd.js";import"./vm-hands-entry-lite-vygp7vq8.js";import"./vm-hands-entry-lite-dm52srp5.js";import"./vm-hands-entry-lite-g576hpce.js";import"./vm-hands-entry-lite-gzyps3ev.js";import"./vm-hands-entry-lite-5zmn6a7p.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{j as runLocalPtySession,e as resolvePtyWorkingDirectory,g as ptyRuntimeSupported,d as parsePtyStartPayload,h as defaultSpawnPty,f as defaultLoginShell,i as defaultConnect,a as LOCAL_PTY_MAX_SESSION_MS,c as LOCAL_PTY_MAX_SESSIONS,b as LOCAL_PTY_MAX_BUFFERED_OUTPUT_BYTES};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$e as G,Ae as f,Af as fa,Be as g,Bf as ga,Ce as h,Cf as ha,De as i,Df as ia,Ee as j,Fe as k,Ge as l,He as m,Ie as n,Je as o,Ke as p,Le as q,Me as r,Ne as s,Oe as t,Pe as u,Qe as v,Re as w,Se as x,Te as y,Ue as z,Ve as A,We as B,Xe as C,Ye as D,Ze as E,_e as F,af as H,bf as I,cf as J,df as K,ef as L,ff as M,gf as N,hf as O,if as P,jf as Q,kf as R,lf as S,mf as T,nf as U,of as V,pf as W,qf as X,rf as Y,sf as Z,tf as _,uf as $,ve as a,vf as aa,we as b,wf as ba,xe as c,xf as ca,ye as d,yf as da,ze as e,zf as ea}from"./vm-hands-entry-lite-2fyemnas.js";import"./vm-hands-entry-lite-zmf1terc.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{$ as parseLocalRuntimeRootsSyncResponse,X as parseLocalRuntimeRegistrationResponse,W as parseLocalRuntimeProofChallenge,fa as parseLocalRuntimeOperationHeartbeatResponse,ga as parseLocalRuntimeOperationEventsResponse,ha as parseLocalRuntimeOperationEnvironmentResponse,ia as parseLocalRuntimeOperationCompletionResponse,ea as parseLocalRuntimeOperationClaim,ca as parseLocalRuntimeLocalSubscriptionResponse,da as parseLocalRuntimeLifecycleResponse,aa as parseLocalRuntimeIdentityResponse,Z as parseLocalRuntimeHeartbeatResponse,_ as parseLocalRuntimeFirstHeartbeat,V as parseLocalRuntimeErrorEnvelope,Y as parseLocalRuntimeEnrollmentResponse,ba as parseLocalRuntimeDisconnectResponse,j as localRuntimeSessionRoutable,U as buildLocalRuntimeDeviceProofBytes,P as WORKER_STARTUP_TIMING_STAGES,K as WORKER_PREVIEW_CARRIED_JOBS,e as RELAY_HOST_ALIAS_VERSION,d as RELAY_HOST_ALIAS_HEADER,Q as LOCAL_RUNTIME_WORKER_STARTUP_MAX_MS,k as LOCAL_RUNTIME_SESSION_VM_HANDS_REGISTER,h as LOCAL_RUNTIME_SESSION_PRE_AUTH_MAX_BYTES,g as LOCAL_RUNTIME_SESSION_PATH,m as LOCAL_RUNTIME_SESSION_CLOSE,l as LOCAL_RUNTIME_SESSION_CLAIM_WAIT_MAX_MS,i as LOCAL_RUNTIME_SESSION_AUTH_DEADLINE_MS,b as LOCAL_RUNTIME_ROUTE_PREFIX,f as LOCAL_RUNTIME_ROUTES,a as LOCAL_RUNTIME_PROTOCOL_VERSION,R as LOCAL_RUNTIME_LIFECYCLE_EVENTS,T as LOCAL_RUNTIME_LEGACY_DEVICE_PROOF_TAG,S as LOCAL_RUNTIME_DEVICE_PROOF_TAG,c as LOCAL_OPERATION_MAX_BYTES,M as JOBS_START_WAIT_KEY,L as JOBS_START_WAIT,H as HANDS_SESSION_GROUP_KEY,G as HANDS_SESSION_GROUP,J as HANDS_SESSION_CAP_NONE,I as HANDS_SESSION_CAP_KEY,s as HANDS_REBIND_KEY,t as HANDS_REBIND_CONTROL,r as HANDS_REBIND,D as HANDS_MODEL_JOBS_EGRESS_KEY,C as HANDS_MODEL_JOBS_EGRESS,z as HANDS_LARGE_ENVIRONMENT_KEY,y as HANDS_LARGE_ENVIRONMENT,F as HANDS_JOBS_USER_KEY,E as HANDS_JOBS_USER,x as HANDS_HEADLESS_BROWSER_KEY,w as HANDS_HEADLESS_BROWSER,o as HANDS_ENVIRONMENT_DELIVER_CONTROL,n as HANDS_ENVIRONMENT_DELIVERY,q as HANDS_ENVIRONMENT_AT_CLAIM_KEY,p as HANDS_ENVIRONMENT_AT_CLAIM,B as HANDS_CONFINEMENT_KEY,A as HANDS_CONFINEMENT,v as HANDS_CLOUD_ACCESS_KEY,u as HANDS_CLOUD_ACCESS,N as AUTOMATION_USER_CHROME,O as AUTOMATION_CLOUD_SESSIONS};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{qi as a,ri as b,si as c,ti as d,ui as e,vi as f,wi as g,xi as h,yi as i,zi as j}from"./vm-hands-entry-lite-zyc3qkej.js";import"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-cxgbb2yr.js";import"./vm-hands-entry-lite-9fr904x2.js";import"./vm-hands-entry-lite-db4z7ekz.js";import"./vm-hands-entry-lite-5mz0m0k0.js";import"./vm-hands-entry-lite-gbzvzfe6.js";import"./vm-hands-entry-lite-e8skq97c.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{j as runPermissionsCli,d as reasonIdentity,e as readMacPermissions,f as permissionsSummary,i as parsePermissionsArgs,c as fullDiskAccessTarget,g as formatMacPermissions,h as allowMacPermissions,a as PERMISSIONS_HELP,b as MAC_PERMISSION_IDS};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Be as LJ,Je as _J,nf as CJ}from"./vm-hands-entry-lite-2fyemnas.js";import{createHash as I,randomBytes as zJ}from"crypto";import{closeSync as qJ,fsyncSync as NJ,mkdirSync as fJ,openSync as DJ,renameSync as mJ,rmSync as bJ,statSync as AJ,writeSync as xJ,constants as y}from"fs";import{join as i}from"path";var cJ=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 QJ(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 UJ(J,Z){let{payload:z,authority:Q}=J;if(!z||typeof z!=="object"||Array.isArray(z)||!Q||typeof Q!=="object"||Array.isArray(Q)||!Z.deviceId||!Z.rootId||z.run_id!==Z.runId||z.device_id!==Z.deviceId||Q.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 MJ(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:QJ(J)?J.environment_sealed:null}}class W extends Error{code;constructor(J,Z){super(Z);this.code=J}}var v=(J)=>Buffer.from(J instanceof Uint8Array?J:new Uint8Array(J)).toString("base64url"),R=(J)=>new Uint8Array(Buffer.from(J,"base64url"));function f(J){if(J===null||typeof J!=="object")return JSON.stringify(J);if(Array.isArray(J))return`[${J.map(f).join(",")}]`;return`{${Object.keys(J).sort().map((Z)=>`${JSON.stringify(Z)}:${f(J[Z])}`).join(",")}}`}async function jZ(J){let Z=await crypto.subtle.importKey("pkcs8",R(J.device_key.pkcs8),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=R(J.device_key.spki),Q=await crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!1,["deriveKey"]),j=new Uint8Array(await crypto.subtle.exportKey("spki",Q.publicKey)),q=I("sha256").update(z).digest("base64url");return{signing:{privateKey:Z},agreement:Q,signingSpki:z,agreementSpki:j,fingerprint:q}}var pJ=4;class lJ{init;keys;hooks;options;identity="identity_free";lastBrainGeneration=new Map;bound=new Map;binding=new Map;unbinding=new Set;servedRun=!1;commandsSinceVerified=!1;bootKillPending=!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,Q){this.init=J;this.keys=Z;this.hooks=z;this.options=Q;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 Q=Date.now()+Z;;){let j=this.bound.get(J);if(!j)return!1;if(j.envInstalled)return!0;if(Date.now()>=Q||z?.aborted)return!1;await new Promise((q)=>setTimeout(q,25))}}opServed(){this.commandsSinceVerified=!0}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:cJ,workspace_id:this.init.workspace_id,instance_generation:this.init.instance_generation,credential:this.init.credential,device_public_key:v(this.keys.signingSpki),env_public_key:v(this.keys.agreementSpki),key_fingerprint:this.keys.fingerprint,manifest_digest:this.init.manifest_digest,nonce:v(zJ(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(f(Z)));return{...Z,device_signature:v(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)()),Q=v(zJ(32)),j=CJ({method:"GET",pathAndQuery:LJ,timestamp:z,nonce:Q,challenge:J,bodySha256:I("sha256").update("").digest("hex")}),q=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},this.keys.signing.privateKey,new Uint8Array(j)));return{t:"hello",timestamp:z,nonce:Q,signature:v(uJ(q)),...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(I("sha256").update(f({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>=pJ)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,Q=!1;try{if(Z.length===0){if(this.bootKillPending&&!this.servedRun){try{await this.hooks.killProbe()}catch{throw new W("vm_hands_kill_unverified","the boot's scoped kill did not verify")}this.bootKillPending=!1}if(this.commandsSinceVerified)await this.hooks.killAndVerifyPayload(),this.unverified.clear(),this.commandsSinceVerified=!1;else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({own:!0}),this.unverified.clear()}else if(this.unverified.size>0)await this.hooks.killAndVerifyPayload({keep:Z}),this.unverified.clear();this.servedRun=!0,Q=!0;let{launchId:j,applied:q,readyData:B}=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}),O=this.hooks.restatLayout(),N=null,h=null;if(J.env){let D=J.claim?.owner??{},_=UJ(await this.openSealed(J.env,J.bind_id),{runId:J.run_id,deviceId:typeof D.device_id==="string"?D.device_id:"",rootId:J.claim?.root_id??""});this.commandsSinceVerified=!0,N=this.hooks.installEnvironment(J.bind_id,_),h=typeof _.snapshot_id==="string"&&_.snapshot_id?_.snapshot_id:null,z=this.writeJobEnvRootOnly(J.bind_id,_)}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:j,envInstalled:N!==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:j,snapshot_revision:N,snapshot_id:h,layout:O,...B?{ready_data:B}:{},policy_digest:I("sha256").update(f({hands_confinement:q.hands_confinement??null,browser_egress:q.browser_egress??null})).digest("hex")}}catch(j){if(z)KJ(z);if(Q){let B=[...this.bound.keys()];await this.hooks.killAndVerifyPayload({bindId:J.bind_id,keep:B,own:!0}).catch(()=>{this.unverified.add(J.bind_id)})}this.binding.delete(J.bind_id);let q=j&&typeof j==="object"&&"code"in j&&typeof j.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(j.code)?j.code:"vm_hands_bind_failed";throw j instanceof W?j:new W(q,"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 Q=UJ(await this.openSealed(J.sealed,z),{runId:Z.runId,deviceId:J.deviceId,rootId:Z.rootId,snapshotId:J.snapshotId});this.commandsSinceVerified=!0;let j=this.hooks.installEnvironment(Z.bindId,Q);if(Z.envInstalled=!0,Z.envDirectory)KJ(Z.envDirectory);return Z.envDirectory=null,Z.envDirectory=this.writeJobEnvRootOnly(`${Z.bindId}-r${j}`,Q),{snapshot_id:J.snapshotId,installed_revision:j,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.killProbe()}catch{this.bootKillPending=!0}return{t:"attest",nonce:Z,exit_code:z.exitCode,markers:z.markers,proof_dir_inode:z.proofDirInode,script_sha256:I("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((j)=>j!==J),Q=!z.length&&!this.commandsSinceVerified;try{await this.hooks.killAndVerifyPayload(z.length?{bindId:J,keep:z}:Q?{bindId:J,own:!0}:void 0)}catch(j){throw this.unverified.add(J),j}if(!z.length)this.unverified.clear(),this.commandsSinceVerified=!1;if(Z?.envDirectory)KJ(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")},Q=await crypto.subtle.importKey("spki",R(J.epk),{name:"ECDH",namedCurve:"P-256"},!1,[]).catch(z),j=await crypto.subtle.deriveKey({name:"ECDH",public:Q},this.keys.agreement.privateKey,{name:"AES-GCM",length:256},!1,["decrypt"]),q=await crypto.subtle.decrypt({name:"AES-GCM",iv:R(J.iv),additionalData:new TextEncoder().encode(Z)},j,R(J.ct)).catch(z),B=JSON.parse(new TextDecoder().decode(q));if(!B||typeof B!=="object"||Array.isArray(B))throw new W("vm_hands_env_invalid","env not an object");return B}writeJobEnvRootOnly(J,Z){let z=i(this.options.envRoot,`bind-${J}`);fJ(z,{mode:448});let Q=AJ(z);if(!Q.isDirectory()||(Q.mode&63)!==0||Q.uid!==(process.getuid?.()??-1))throw new W("vm_hands_env_dir_unsafe","env directory is not root's 0700");let j=Z.variables&&typeof Z.variables==="object"?Z.variables:{},q=Object.entries(j).filter(([N,h])=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(N)&&typeof h==="string").map(([N,h])=>`export ${N}='${String(h).replaceAll("'","'\\''")}'`).join(`
|
|
3
|
-
`)+`
|
|
4
|
-
`,B=i(z,`.job.env.${zJ(8).toString("hex")}`),O=DJ(B,y.O_WRONLY|y.O_CREAT|y.O_EXCL|y.O_NOFOLLOW,384);try{xJ(O,q),NJ(O)}finally{qJ(O)}return mJ(B,i(z,"job.env")),z}}function KJ(J){try{let Z=i(J,"job.env"),z=AJ(Z).size,Q=DJ(Z,y.O_WRONLY|y.O_NOFOLLOW);try{xJ(Q,Buffer.alloc(z)),NJ(Q)}finally{qJ(Q)}}catch{}bJ(J,{recursive:!0,force:!0})}function uJ(J){if(J.length!==64)throw new W("vm_hands_signature_invalid","unexpected ECDSA signature length");let Z=(j)=>{let q=0;while(q<j.length-1&&j[q]===0)q++;let B=j.subarray(q),O=B[0]&128?Uint8Array.of(0,...B):B;return Uint8Array.of(2,O.length,...O)},z=Z(J.subarray(0,32)),Q=Z(J.subarray(32));return Uint8Array.of(48,z.length+Q.length,...z,...Q)}import{randomUUID as oJ}from"crypto";var dJ="/app/local-runtime/session?register=vm_hands_v1",iJ="/app/local-runtime",OJ=25000,rJ=20000,sJ=1e4,TJ=5000,wJ=new Set(["pty.start","jobs.control","preview.serve.v1","display.stream.v1"]),FJ=75000,aJ=2000,nJ=1e4,tJ=new Set(["vm_hands_no_register","vm_hands_register_failed"]),eJ=3,JZ=20000,ZZ=250,$Z=2000,s=20000;function hJ(J,Z){return typeof J==="string"&&/^[A-Za-z0-9._:-]{1,160}$/.test(J)?J:Z}class g extends Error{}var zZ=64;async function kJ(J,Z){let z=[...J.modelOps.get(Z)??[]];for(let Q of z)Q.abort.abort();await Promise.race([Promise.all(z.map((Q)=>Q.settled)),new Promise((Q)=>setTimeout(Q,TJ))])}async function KZ(J){let Z=[...J.personTerminals];for(let z of Z)z.abort.abort();if(Z.length)await Promise.race([Promise.all(Z.map((z)=>z.settled)),new Promise((z)=>setTimeout(z,TJ))]);return Z.length}async function m(J,Z,z){return await kJ(J,z),Z.unbind(z)}function a(J){for(let Z of J.outbox?.splice(0)??[])Z.reject(Error("vm_hands_attempt_ended"))}var EJ=15000,QZ=1e4,FZ=1000;async function NZ(J){let Z=Date.now(),z={deviceId:null,connection:null,turns:new Map,lostAt:0,receipts:[],attest:"pending",attestWaiters:[],modelOps:new Map,personTerminals:new Set,bindsStarting:0},Q=J.log??(()=>{}),j=async(O)=>{for(let[N,h]of[...z.turns]){z.turns.delete(N),J.onTurn?.(N,null),a(h);let D=await m(z,J.agent,N).catch(()=>null);if(D)z.receipts.push({turn:h,failure:"vm_hands_bind_lost",unbound:D});Q("vm_hands.bound_dropped",{reason:O})}},q=0,B=0;try{for(let O=0;!J.signal.aborted;O++){let N=await XZ(J,z).catch((D)=>{if(D instanceof W&&z.deviceId===null&&D.code==="vm_hands_no_session"&&Date.now()-Z<nJ)return{closeCode:0,closeReason:"vm_hands_no_session"};if(D instanceof W&&z.deviceId===null&&tJ.has(D.code)&&q<eJ&&Date.now()-Z<JZ){q++;let _=Math.min(ZZ*2**(q-1),$Z);return B=Math.round(_/2+Math.random()*_/2),Q("vm_hands.register_retry",{attempt:q,code:D.code,delay_ms:B}),{closeCode:0,closeReason:"vm_hands_register_retry"}}if(D instanceof W&&z.deviceId===null)throw D;return{closeCode:0,closeReason:D instanceof Error?D.message:String(D)}});if(Q("vm_hands.session_closed",{close_code:N.closeCode,reason:N.closeReason.slice(0,120),registered:z.deviceId!==null}),N.closeCode===4401||z.attest==="refused")return;if(J.signal.aborted)return;if(z.turns.size&&Date.now()-z.lostAt>=FJ)await j("reconnect_deadline");if(z.served)z.served=!1,O=0;let h=N.closeReason==="drain_reconnect"?0:N.closeReason==="vm_hands_register_retry"?B:N.closeReason==="vm_hands_no_session"?Math.min(250*2**Math.min(O,5),2000):z.turns.size?Math.min(250*2**Math.min(O,5),5000,Math.max(0,z.lostAt+FJ-Date.now())):Math.min(500*2**O,30000);if(await new Promise((D)=>setTimeout(D,h)),z.turns.size&&Date.now()-z.lostAt>=FJ)await j("reconnect_deadline")}}finally{await j("session_ended")}}async function XZ(J,Z){let z=Z.deviceId,Q=J.log??(()=>{}),j=z?`/app/local-runtime/session?device_id=${encodeURIComponent(z)}`:dJ,q=`${J.apiOrigin.replace(/^http/,"ws")}${j}`,B=new WebSocket(q),O=0,N="",h=new Map,D=[],_=null,XJ=new Promise(($)=>{B.onclose=(X)=>{O=X.code,N=X.reason;for(let K of h.values())K.reject(new g(`session closed ${X.code}`));for(let K of Z.attestWaiters.splice(0))K(!1);h.clear(),$()}});B.onmessage=($)=>{let X;try{X=JSON.parse(String($.data))}catch{B.close(4400);return}if(X.t==="res"){let K=X;h.get(K.id)?.resolve({status:K.status,body:K.body}),h.delete(K.id);return}if(X.t==="reconnect"){let K=Math.max(0,Math.min(Number(X.after_ms)||0,FZ));Q("vm_hands.drain_reconnect",{after_ms:K}),setTimeout(()=>{try{B.close(4001,"drain_reconnect")}catch{}},K).unref?.();return}if(!_?.(X))D.push(X)};let b=($,X)=>new Promise((K,G)=>{let U=D.findIndex((L)=>$.includes(L.t));if(U>=0){K(D.splice(U,1)[0]);return}let C=setTimeout(()=>{_=null,G(new W("vm_hands_no_register",`no ${$.join("/")} in ${X} ms`))},X);_=(L)=>{if(!$.includes(L.t))return!1;return clearTimeout(C),_=null,K(L),!0}}),c=($)=>B.send(JSON.stringify($)),H=($,X)=>new Promise((K,G)=>{if(B.readyState!==WebSocket.OPEN){G(new g("session closed"));return}let U=oJ(),C=typeof X.wait_ms==="number"?X.wait_ms:0,L=setTimeout(()=>{if(!h.delete(U))return;G(new g(`no answer to ${$.split("/").pop()} in ${C+EJ} ms`)),B.close(4000,"request_timeout")},C+EJ);h.set(U,{reject:(F)=>{clearTimeout(L),G(F)},resolve:({status:F,body:Y})=>{clearTimeout(L);let P=null;try{P=Y?JSON.parse(Y):null}catch{}K({status:F,json:P})}}),c({t:"req",id:U,path:`${iJ}${$}`,body:JSON.stringify(X)})}),GJ=()=>B.close(1001,"stopping");J.signal.addEventListener("abort",GJ,{once:!0});let n,p=new Map,l=new Map,t=!1,e=new Set,JJ=new Set,ZJ=Promise.resolve(),u=!1;try{await new Promise((F,Y)=>{let P=setTimeout(()=>Y(Error("session open timeout")),QZ);B.onopen=()=>{clearTimeout(P),Q("vm_hands.ws_open",{}),F()},B.onerror=()=>{clearTimeout(P),Y(Error("session socket error"))}});let $=await b(["challenge"],5000);Q("vm_hands.challenge",{});let X=[],K=null,G;if(z){c(await J.agent.helloFrame($.challenge,Z.connection));let F=await b(["ready"],1e4);if(typeof F.vm_hands_connection==="string")Z.connection=F.vm_hands_connection;if(G={device_id:z,...F.cadence?{cadence:F.cadence}:{}},typeof F.vm_hands_probe_script==="string"){if(K=F.vm_hands_probe_script,u=!0,J.agent.phase==="registered"&&!Z.turns.size)Z.attest="pending"}Z.served=!0,Q("vm_hands.reconnected",{device_id:z});let Y=Array.isArray(F.vm_hands_binds)?F.vm_hands_binds:F.vm_hands_bind?[F.vm_hands_bind]:[];for(let[P,A]of[...Z.turns]){if(Y.some((E)=>E&&E.operation_id===A.claim.operation_id&&E.attempt_id===A.claim.attempt_id)){X.push(A),Q("vm_hands.bound_resumed",{operation_id:A.claim.operation_id});continue}Z.turns.delete(P),J.onTurn?.(P,null),a(A);let M=await m(Z,J.agent,P).catch(()=>null);if(M)Z.receipts.push({turn:A,failure:"vm_hands_bind_lost",unbound:M});Q("vm_hands.bound_dropped",{reason:"not_named_on_reconnect"})}}else{c(await J.agent.registerFrame($.challenge)),Q("vm_hands.register_sent",{});let F=await Promise.race([b(["registered","register_refused"],1e4),XJ.then(()=>{throw new W(N==="register_failed"?"vm_hands_register_failed":"vm_hands_register_closed","session closed before the register was answered")})]);if(F.t==="register_refused")throw new W(F.code,"register refused");J.agent.registered();let Y=F;if(G=Y,Z.deviceId=Y.device_id,typeof Y.vm_hands_connection==="string")Z.connection=Y.vm_hands_connection;if(typeof Y.vm_hands_probe_script==="string"){if(K=Y.vm_hands_probe_script,u=!0,J.agent.phase==="registered"&&!Z.turns.size)Z.attest="pending"}Z.served=!0,Q("vm_hands.registered",{device_id:G.device_id})}let U=async()=>{let F=await H("/heartbeat",await J.heartbeat());if(F.status>=300)throw Error(`heartbeat ${F.status}`)};await U();let C=G.cadence?.presence_interval_ms??30000;if(n=setInterval(()=>{U().catch(()=>B.close())},C),K&&Z.attest!=="accepted"&&J.agent.phase==="registered"&&!Z.turns.size)HJ(K,$.challenge);let L=(F,Y)=>{l.set(F,Y().catch(async(P)=>{if(await YJ(P,F),P instanceof g)B.close();else await $J().catch(()=>{return})}).finally(()=>{l.delete(F)}))};try{await $J();for(let F of X)F.flush=()=>WJ(F),F.flush(),L(F.claim.attempt_id,()=>PJ(F));while(!J.signal.aborted&&B.readyState===WebSocket.OPEN){let F=await H("/operations/claim",{wait_ms:Math.min(G.cadence?.claim_wait_ms??OJ,OJ)});if(F.status===204||!F.json)continue;if(F.status>=300)throw Error(`claim ${F.status}`);let Y=F.json;if(Y.capability==="hands.connect"){if(l.has(Y.attempt_id)){T({claim:Y,eventSeq:0}).complete("failed",{error_code:"vm_hands_busy"}).catch(()=>{return});continue}L(Y.attempt_id,()=>VJ(Y))}else SJ(Y).catch(()=>{return})}}catch(F){await YJ(F,null)}}finally{if(n)clearInterval(n);J.signal.removeEventListener("abort",GJ);for(let $ of Z.turns.values())$.flush=null;B.close(),await XJ,await Promise.all([...l.values()]);for(let $ of J.agent.liveBindIds){if(Z.turns.has($))continue;let X=await m(Z,J.agent,$).catch(()=>null),K=p.get($);if(X&&K)Z.receipts.push({turn:{...K,eventSeq:K.eventSeq+1},failure:"vm_hands_bind_lost",unbound:X});Q("vm_hands.bound_dropped",{reason:"bound_after_loss"})}for(let $ of e)$.abort()}return{closeCode:O,closeReason:N};async function YJ($,X){if($ instanceof g){if(!t&&Z.turns.size)Z.lostAt=Date.now();t=!0}else{let K=X!==null?[X]:[...new Set([...Z.turns.keys(),...J.agent.liveBindIds])];if(X===null)t=!0;for(let G of K){let U=Z.turns.get(G);if(Z.turns.delete(G),U)a(U),J.onTurn?.(G,null);if(J.agent.liveBindIds.includes(G)){let C=await m(Z,J.agent,G).catch(()=>null),L=p.get(G)??U;if(C&&L)Z.receipts.push({turn:{...L,eventSeq:L.eventSeq+1},failure:"vm_hands_bind_lost",unbound:C})}}}Q("vm_hands.session_lost",{error:$ instanceof Error?$.message:String($),bound_kept:Z.turns.size})}function T($){let X=$.claim,K={attempt_id:X.attempt_id,attempt_token:X.attempt_token},G=encodeURIComponent(X.operation_id);return{fence:K,op:G,complete:(C,L={})=>H(`/operations/${G}/complete`,{...K,status:C,...L}),emit:(C,L)=>{let F=($.chain??Promise.resolve()).catch(()=>{return}).then(()=>U(C,L));return $.chain=F,F}};async function U(C,L){let F=$.eventSeq,Y=(E)=>H(`/operations/${G}/events`,{...K,event_seq_start:E,events:[{kind:C,payload:{sequence:E,capability:String(X.capability??"hands.connect"),data:L}}]}),P=F,A=await Y(P),M=A.status===409?A.json?.expected_event_seq:void 0;if(typeof M==="number"&&M===F+1)A={status:200,json:{duplicate:!0}};else if(typeof M==="number"&&M>=0&&M!==F)P=M,A=await Y(P);if(A.status<300)$.eventSeq=P+1;return A}}function gJ($){return(X,K)=>new Promise((G,U)=>{if(Z.turns.get($.claim.attempt_id)!==$){U(Error("vm_hands_attempt_ended"));return}if($.outbox??=[],$.outbox.length>=zZ){U(Error("vm_hands_outbox_full"));return}$.outbox.push({kind:X,data:K,resolve:G,reject:U}),$.flush?.()})}function WJ($){if(JJ.has($))return;JJ.add($),(async()=>{try{while($.outbox?.length&&Z.turns.get($.claim.attempt_id)===$&&B.readyState===WebSocket.OPEN){let X=$.outbox[0],K;try{K=await T($).emit(X.kind,X.data)}catch(G){if(G instanceof g)return;K={status:500}}if($.outbox.shift(),K.status<300)X.resolve();else X.reject(Error(`${X.kind} refused ${K.status}`))}}finally{JJ.delete($)}})()}async function HJ($,X){try{let K=await J.agent.attestFrame($,X);if(B.readyState!==WebSocket.OPEN)return;c(K);let G=await b(["attested","attest_refused"],15000);Z.attest=G.t==="attested"?"accepted":"refused";for(let U of Z.attestWaiters.splice(0))U(Z.attest==="accepted");if(Q("vm_hands.attest",{result:Z.attest,exit_code:K.exit_code,...G.t==="attest_refused"?{code:String(G.code??"")}:{}}),Z.attest==="refused")B.close(4401,"attest_refused")}catch(K){Q("vm_hands.attest_failed",{code:K instanceof W?K.code:"probe_error"});for(let G of Z.attestWaiters.splice(0))G(!1);if(Z.attest!=="accepted")B.close(4000,"attest_unanswered")}}async function VJ($){let X=u&&Z.attest==="pending",K=$.vm_hands_attest,G=K;if(Z.attest==="refused"){Q("vm_hands.claim_attest_refused",{said:typeof K==="string"?K.slice(0,16):typeof K,local:Z.attest}),await T({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(G==="accepted"){if(!X&&Z.attest!=="accepted"){Z.attest="accepted";for(let w of Z.attestWaiters.splice(0))w(!0)}}else if(G!=="pending"||!X&&Z.attest!=="accepted"){Q("vm_hands.claim_attest_refused",{said:typeof K==="string"?K.slice(0,16):typeof K,local:Z.attest}),await T({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}if(Z.attest!=="accepted"){let w=Date.parse($.lease_until)-Date.now()-5000,S=Math.max(0,Math.min(s,Number.isFinite(w)?w:s));if(!await new Promise((d)=>{let x=setTimeout(()=>d(!1),S);Z.attestWaiters.push((k)=>{clearTimeout(x),d(k)})})){await T({claim:$,eventSeq:0}).complete("failed",{error_code:"vm_hands_unattested"}).catch(()=>{return});return}}let U={claim:$,eventSeq:0},{complete:C,emit:L}=T(U),F;try{if($.capability!=="hands.connect")throw new W("vm_hands_bind_invalid","not hands.connect");F=!QJ($)}catch(w){Q("vm_hands.bind_refused",{code:w instanceof W?w.code:"unexpected"}),await C("failed",{error_code:w instanceof W?w.code:"vm_hands_bind_invalid"});return}let Y;Z.bindsStarting++;try{let w=await KZ(Z);if(w)Q("vm_hands.person_terminals_closed",{count:w});Y=await J.agent.bind(MJ($))}catch(w){Q("vm_hands.bind_refused",{code:w instanceof W?w.code:"unexpected"}),await C("failed",{error_code:w instanceof W?w.code:"vm_hands_bind_failed"});return}finally{Z.bindsStarting--}let P={...Y.ready_data??J.readyData({launchId:Y.launch_id,claim:$})};if(F)delete P.environment_installed;let A=!F&&Y.snapshot_revision!==null&&Y.snapshot_id!==null?{environment_installed:{snapshot_id:Y.snapshot_id,installed_revision:Y.snapshot_revision}}:{};p.set($.attempt_id,{claim:$,launchId:Y.launch_id,readyData:P,eventSeq:U.eventSeq,ackSeq:-1});let M=await L("hands.ready",{...P,...A,vm_hands:{layout:Y.layout,policy_digest:Y.policy_digest,launch_id:Y.launch_id}});if(p.delete($.attempt_id),M.status>=300){await kJ(Z,$.attempt_id),await J.agent.boundRefused($.attempt_id),await C("failed",{error_code:hJ(M.json?.error,"vm_hands_probe_failed")});return}let E={claim:$,launchId:Y.launch_id,readyData:P,eventSeq:U.eventSeq,ackSeq:-1};Z.turns.set($.attempt_id,E),E.flush=()=>WJ(E),J.onTurn?.($.attempt_id,gJ(E)),await PJ(E)}async function PJ($){let{fence:X,op:K}=T($),G=null,U=null,C=J.agent.executorExited($.claim.attempt_id).then((L)=>{return U=L,null});J:for(;;){let L=await Promise.race([C,H(`/operations/${K}/heartbeat`,{...X,control_ack_seq:$.ackSeq,wait_ms:rJ})]);if(!L){G="vm_hands_executor_exited",Q("vm_hands.executor_exited",{reason:U});break}if(L.status>=300)break;let F=(L.json?.controls??[]).slice().sort((Y,P)=>Y.seq-P.seq);for(let Y of F){if(Y.seq<=$.ackSeq)continue;if(Y.kind==="operation.cancel"||Y.kind==="cancel"){$.ackSeq=Y.seq;break J}if(Y.kind===_J)try{await yJ($,Y.payload??{})}catch(P){if(P instanceof g)throw P;G=P instanceof W?P.code:"environment_unavailable";let A=P&&typeof P==="object"&&"code"in P&&typeof P.code==="string"&&/^[a-z][a-z0-9_]{2,63}$/.test(P.code)?P.code:null;Q("vm_hands.environment_refused",{code:G,cause:A});break J}$.ackSeq=Y.seq}}await vJ($,G)}async function SJ($){let X=$,K={claim:X,eventSeq:0},{complete:G,emit:U,fence:C,op:L}={...T(K)},F=$.vm_hands_origin==="person"?"person":"model",Y=String($.capability??"");if(!J.executeOp){await G("failed",{error_code:"vm_hands_op_unsupported"});return}if($.vm_hands_attest==="accepted"&&Z.attest==="pending"&&!(u&&Z.attest==="pending")){Z.attest="accepted";for(let x of Z.attestWaiters.splice(0))x(!0)}if(Z.attest!=="accepted"){let x=Date.parse(String($.lease_until??""))-Date.now()-5000,k=Z.attest==="refused"?0:Math.max(0,Math.min(s,Number.isFinite(x)?x:s));if(!(k>0&&await new Promise((BJ)=>{let IJ=setTimeout(()=>BJ(!1),k);Z.attestWaiters.push((RJ)=>{clearTimeout(IJ),BJ(RJ)})}))){await G("failed",{error_code:"vm_hands_unattested"});return}}let P=J.agent.bindIdForRun(X.run_id);if(F==="model"&&P===null){await G("failed",{error_code:"vm_hands_not_bound"});return}let A=Y==="pty.start"&&F==="person"&&!$.authority;if(A&&(J.agent.liveBindIds.length>0||Z.bindsStarting>0)){await G("failed",{error_code:"vm_hands_bound"});return}if(wJ.has(Y)&&!A&&J.agent.liveBindIds.length===0){await G("failed",{error_code:"vm_hands_not_bound"});return}if(F==="model"&&P||wJ.has(Y)&&!A)J.agent.opServed();let M=new AbortController;e.add(M);let E,w=new Promise((x)=>{E=x}),S={abort:M,settled:w};if(A)Z.personTerminals.add(S);if(F==="model"&&P){let x=Z.modelOps.get(P)??new Set;x.add(S),Z.modelOps.set(P,x),await J.agent.environmentInstalled(P,aJ,M.signal)}let o=-1,d=setInterval(()=>{H(`/operations/${L}/heartbeat`,{...C,control_ack_seq:o,wait_ms:0}).then((x)=>{if(x.status>=300){M.abort();return}let k=x.json?.controls??[];for(let V of k)if(o=Math.max(o,V.seq),V.kind==="operation.cancel"||V.kind==="cancel")M.abort()},()=>M.abort())},sJ);try{let x=await J.executeOp({kind:F,claim:$,...F==="model"&&P?{bindId:P}:{},signal:M.signal,emit:async(V)=>{await U(V.kind,V.data??{})}}),k=await G(x.status,{...x.result?{result:x.result}:{},...x.error_code?{error_code:hJ(x.error_code,"vm_hands_op_failed")}:{}});Q("vm_hands.op",{capability:Y,kind:F,status:x.status,code:x.error_code??null,...k.status>=300?{complete_status:k.status,complete_error:String(k.json?.error??"").slice(0,64)}:{}})}finally{if(clearInterval(d),e.delete(M),P)Z.modelOps.get(P)?.delete(S);Z.personTerminals.delete(S),E()}}async function vJ($,X){let K=$.claim.attempt_id;if(Z.turns.get(K)===$)Z.turns.delete(K);J.onTurn?.(K,null),a($);let G=await m(Z,J.agent,K);Z.receipts.push({turn:$,failure:X,unbound:G}),await $J()}function $J(){return ZJ=ZJ.then(jJ,jJ),ZJ}async function jJ(){while(Z.receipts.length){let{turn:$,failure:X,unbound:K}=Z.receipts[0],{complete:G,emit:U}=T($);try{if(await U("hands.stopped",{...$.readyData,reason_code:X?"failed":"cancelled",killed_verified:K.killed_verified,shredded:K.shredded,...K.srt_fallbacks?{vm_hands_srt_fallbacks:K.srt_fallbacks}:{}}),X)await G("failed",{error_code:X});else await G("cancelled",{error_code:"driver_stopped"})}catch(C){if(C instanceof g)return}Z.receipts.shift()}}async function yJ($,X){let{fence:K,op:G}=T($),U=X.snapshot_id;if(X.version!==1||typeof U!=="string"||Object.keys(X).length!==2)throw new W("vm_hands_env_invalid","invalid environment delivery");let C=await H(`/operations/${G}/environment`,{...K,snapshot_id:U}),L=C.json?.environment_sealed;if(C.status!==200||!L||C.json?.payload!==void 0)throw new W("vm_hands_env_invalid","environment not delivered sealed");let F=await J.agent.deliverEnvironment({attemptId:$.claim.attempt_id,snapshotId:U,deviceId:Z.deviceId??"",sealed:L});if((await H(`/operations/${G}/environment-ack`,{...K,...F})).status>=300)throw new W("vm_hands_env_ack_refused","environment ack refused")}}
|
|
5
|
-
export{jZ as xa,lJ as ya,NZ as za};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{r as a}from"./vm-hands-entry-lite-d7y6aah1.js";import"./vm-hands-entry-lite-b775ysr4.js";import"./vm-hands-entry-lite-mcv6pse6.js";import"./vm-hands-entry-lite-hh24bq0d.js";import"./vm-hands-entry-lite-rjwk6sfj.js";import"./vm-hands-entry-lite-y3wncwjd.js";import"./vm-hands-entry-lite-7fx4xtf6.js";export{a as configureWorkerSandbox};
|