@reason-machines/cli-linux-x64 0.2.560 → 0.2.561
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/reason +1 -1
- package/bin/vm-hands/{agent-network-j5f603sy.js → agent-network-kk36zca7.js} +1 -1
- package/bin/vm-hands/{api-credentials-7rhpwe7n.js → api-credentials-mtfdk175.js} +1 -1
- package/bin/vm-hands/{api-vkgf7wma.js → api-w6w7vfp3.js} +1 -1
- package/bin/vm-hands/{ask-relay-2vf6fa2t.js → ask-relay-xx0rzpch.js} +2 -2
- package/bin/vm-hands/{connect-cli-06x1wfgv.js → connect-cli-dmwph620.js} +1 -1
- package/bin/vm-hands/{local-automation-8b1znx0p.js → local-automation-vvt9d9xb.js} +1 -1
- package/bin/vm-hands/{local-capabilities-m6pzcc94.js → local-capabilities-pwv76ns5.js} +1 -1
- package/bin/vm-hands/{local-display-session-zyd8s6n6.js → local-display-session-axh9mfdk.js} +1 -1
- package/bin/vm-hands/local-display-video-pxhztqk7.js +2 -0
- package/bin/vm-hands/{local-managed-process-w26jhyfg.js → local-managed-process-4mgqn7tg.js} +1 -1
- package/bin/vm-hands/{managed-runtime-ykv5nyva.js → managed-runtime-pcagtyfz.js} +1 -1
- package/bin/vm-hands/{network-auto-update-mrjz964a.js → network-auto-update-wkzb91qz.js} +2 -2
- package/bin/vm-hands/{network-sign-in-8yvdx5rm.js → network-sign-in-61gmpmaa.js} +1 -1
- package/bin/vm-hands/{permissions-nmxr8238.js → permissions-348prrcx.js} +1 -1
- package/bin/vm-hands/{serve-service-det934tz.js → serve-service-3dkyznay.js} +1 -1
- package/bin/vm-hands/{status-fr7192eh.js → status-khqk4cjw.js} +3 -3
- package/bin/vm-hands/{version-5d6gbmrd.js → version-c1hen0wn.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fk2s50nc.js → vm-hands-entry-lite-2dak7e1h.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0ex2twm5.js → vm-hands-entry-lite-5y4phfv1.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-q3er9m6y.js → vm-hands-entry-lite-6jxshhps.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-4jgykvd3.js → vm-hands-entry-lite-7pfhwxn5.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-jhsa4av7.js → vm-hands-entry-lite-9yfmkd1f.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-qegwyvyz.js → vm-hands-entry-lite-bj3w2ven.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8w0ah5j9.js → vm-hands-entry-lite-gxpw14jv.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-cspd38hc.js → vm-hands-entry-lite-h7nk2848.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-bnpdn6fw.js → vm-hands-entry-lite-hn9pq7zj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0as6nsks.js → vm-hands-entry-lite-ht6hzkgj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fhx46jny.js → vm-hands-entry-lite-jgk5z8zc.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8pcs85ak.js → vm-hands-entry-lite-m1we91g4.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-f8p11q6h.js → vm-hands-entry-lite-vkhacd00.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-rhx6adbr.js → vm-hands-entry-lite-wcgm41jq.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-f95mg81d.js → vm-hands-entry-lite-xvccy3z4.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-y4df9n3f.js → vm-hands-entry-lite-y3nz20wb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-tvnfm4xg.js → vm-hands-entry-lite-z213y4pj.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-qny3mx8f.js → vm-hands-executor-csdtg7kj.js} +1 -1
- package/bin/vm-hands/{vm-hands-op-runner-5q01rhkc.js → vm-hands-op-runner-z7tsd84c.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-gjjm5fzd.js → vm-hands-runtime-1qxf96z7.js} +3 -3
- package/package.json +1 -1
- package/bin/vm-hands/local-display-video-rk680vwg.js +0 -2
package/bin/reason
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ce,al,cl,qr,Ji,Ot}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Ce,al,cl,qr,Ji,Ot}from"./vm-hands-entry-lite-jgk5z8zc.js";import"./vm-hands-entry-lite-84mc1f7h.js";export{Ot as AgentNetwork,Ce as AgentNetworkUnavailable,qr as DaemonRefusal,cl as installedEngineVersion,al as refreshEngine,Ji as sessionForgotten};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lt,Gc,Un,ir}from"./vm-hands-entry-lite-
|
|
2
|
+
import{lt,Gc,Un,ir}from"./vm-hands-entry-lite-7pfhwxn5.js";import"./vm-hands-entry-lite-ht6hzkgj.js";import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{lt as apiOriginFromEnvironment,Un as environmentApiKey,Gc as explicitApiOrigin,ir as resolveApiCredentials};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{C,eo,me}from"./vm-hands-entry-lite-
|
|
2
|
+
import{C,eo,me}from"./vm-hands-entry-lite-ht6hzkgj.js";import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{C as ApiError,me as ReasonApi,eo as createMachineEnrollmentTicketWithToken};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zn}from"./vm-hands-entry-lite-84mc1f7h.js";import{Fe,Ji,Ot}from"./vm-hands-entry-lite-
|
|
2
|
+
import{zn}from"./vm-hands-entry-lite-84mc1f7h.js";import{Fe,Ji,Ot}from"./vm-hands-entry-lite-jgk5z8zc.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import{g}from"./vm-hands-entry-lite-bj3w2ven.js";import{Ur}from"./vm-hands-entry-lite-hjjbjpd7.js";import{createHash as q}from"crypto";import{existsSync as C,mkdirSync as K,readFileSync as x,rmSync as B,writeFileSync as H}from"fs";import{homedir as z}from"os";import{dirname as S,join as J}from"path";import{existsSync as G,mkdirSync as de,rmSync as he,writeFileSync as ue}from"fs";import{dirname as fe,join as Y}from"path";var U=(e)=>Y(e,".reason","do-not-track");function W(e){let t=e.DO_NOT_TRACK?.trim().toLowerCase();if(!t)return null;return t!=="0"&&t!=="false"}function N(e,t){return W(e)===!0||G(U(t))}var D=86400000,Q=60000,M=300000,X=300000,Z=5,j=5,ee=300,te=900000,E=21600000,ne=60000,y=(e)=>J(e,".reason","ask-relay.json"),m=(e)=>J(e,".reason","ask-relay-refused.json");async function w(){let{loadCredentials:e}=await import("./credentials-s7ps7y6s.js"),t=e();return t?[t.apiOrigin,t.orgId,t.clientId].join("\x00"):""}var I=(e)=>q("sha256").update(e).digest("hex");function O(e){try{let t=JSON.parse(x(m(e),"utf8"));return typeof t.login==="string"&&typeof t.refusals==="number"&&typeof t.until==="number"?{login:t.login,refusals:t.refusals,until:t.until}:null}catch{return null}}function _(e,t){try{if(!t){B(m(e),{force:!0});return}if(!C(S(m(e))))K(S(m(e)),{recursive:!0});H(m(e),`${JSON.stringify(t)}
|
|
3
3
|
`,{mode:384})}catch{}}var se=300000,ie=8,re=300000,d=(e)=>`${e.agent}:${e.name}`;function p(e){try{let t=JSON.parse(x(y(e),"utf8"));return{sessions:Array.isArray(t.sessions)?t.sessions.filter((s)=>typeof s?.name==="string"&&typeof s.agent==="string"&&typeof s.usedAt==="number"):[],hosted:Array.isArray(t.hosted)?t.hosted.filter((s)=>typeof s?.name==="string"&&typeof s.agent==="string"&&typeof s.at==="number"):[]}}catch{return{sessions:[],hosted:[]}}}function P(e,t){try{if(!C(S(y(e))))K(S(y(e)),{recursive:!0});H(y(e),`${JSON.stringify(t)}
|
|
4
4
|
`,{mode:384})}catch{}}var h=(e,t)=>new Promise((s)=>{if(t.aborted)return s();let n=setTimeout(i,e);n.unref?.();function i(){clearTimeout(n),t.removeEventListener("abort",i),s()}t.addEventListener("abort",i,{once:!0})});function T(e){let t=e?.status;return typeof t==="number"?t:null}var L=60000;function ae(e){return{address:e.address.slice(0,300),state:e.state.slice(0,40),note:e.note.slice(0,500)}}function oe(e){let t=Number.isFinite(e.sentAt)&&Math.abs(e.sentAt)<8640000000000000?e.sentAt:Date.now();return{id:e.id.slice(0,100),from:e.from.slice(0,300),from_agent:e.fromAgent?.slice(0,100)??null,to:e.to.slice(0,300),reply_to:e.replyTo?.slice(0,100)??null,sent_at:t,body:e.body.length>L?`${e.body.slice(0,L)}
|
|
5
|
-
[cut: the answer was ${e.body.length} characters]`:e.body}}class V{network;api;home;signal;log;team;sessions=new Map;readers=new Set;hosted=new Map;addresses=new Map;reclaimed=new Map;reportSoon=!1;constructor(e,t,s,n,i,r){this.network=e;this.api=t;this.home=s;this.signal=n;this.log=i;this.team=r}async run(){let e=Date.now()-D,t=p(this.home);for(let l of t.hosted)if(Date.now()-l.at<=M)this.hosted.set(d(l),l);for(let l of[...t.sessions.filter((u)=>u.usedAt>e),...this.hosted.values()])this.read(l);let s=0,n=0,i=-1/0,r=-1/0,a=-1/0,o=O(this.home);if(o)if(o.login===I(await w()))n=o.refusals,await this.untilSignedInAgain(Math.min(E,o.until-Date.now()));else _(this.home,null);while(!this.signal.aborted){let l=await this.network.team().catch(()=>null);if(!l){await h(60000,this.signal);continue}if(this.team!==null&&l.name!==this.team)return;if(this.team===null&&Date.now()-r>=re)r=Date.now(),this.sendLink();let u,F=new Date(Date.now()+86400000).toISOString().slice(0,10),v=Date.now()-i>=se&&!N(process.env,this.home)?l.messageCounts?.filter((c)=>c.day<=F).slice(-ie):void 0,R=this.reportSoon||Date.now()-a>=Q;this.reportSoon=!1;try{let c=await this.api.claimAgentNetworkRelayJob({machine:l.machine,person:l.person,...this.onNetwork(l),version:g,wait_seconds:zn,...v?.length?{message_counts:v,...l.endpoint?{endpoint:l.endpoint}:{}}:{},...R?{hosted:this.hostedReport()}:{}},AbortSignal.any([this.signal,AbortSignal.timeout((zn+20)*1000)]));if(v?.length)i=Date.now();if(R)a=Date.now();if(c.hosted)this.carryHosted(c.hosted);if(s=0,n>0)_(this.home,null);if(n=0,c.retry_after_seconds)await h(c.retry_after_seconds*1000,this.signal);u=c.job}catch(c){if(this.signal.aborted)return;let f=T(c);if(f===401){let A=I(await w()),b=O(this.home);n=Math.max(n,b?.login===A?b.refusals:0)+1;let k=Math.min(E,te*2**Math.min(n-1,10));_(this.home,{login:A,refusals:n,until:Date.now()+k}),await this.untilSignedInAgain(k);continue}if(f===403){await h(900000,this.signal);continue}if(f===404||f===405){await h(120000,this.signal);continue}s+=1,await h(Math.min(60000,1000*2**Math.min(s,6)),this.signal);continue}if(u)this.carry(u)}}linkSends={sent:null,refused:null};async sendLink(){try{let{sendTeamLink:e}=await import("./network-sign-in-
|
|
5
|
+
[cut: the answer was ${e.body.length} characters]`:e.body}}class V{network;api;home;signal;log;team;sessions=new Map;readers=new Set;hosted=new Map;addresses=new Map;reclaimed=new Map;reportSoon=!1;constructor(e,t,s,n,i,r){this.network=e;this.api=t;this.home=s;this.signal=n;this.log=i;this.team=r}async run(){let e=Date.now()-D,t=p(this.home);for(let l of t.hosted)if(Date.now()-l.at<=M)this.hosted.set(d(l),l);for(let l of[...t.sessions.filter((u)=>u.usedAt>e),...this.hosted.values()])this.read(l);let s=0,n=0,i=-1/0,r=-1/0,a=-1/0,o=O(this.home);if(o)if(o.login===I(await w()))n=o.refusals,await this.untilSignedInAgain(Math.min(E,o.until-Date.now()));else _(this.home,null);while(!this.signal.aborted){let l=await this.network.team().catch(()=>null);if(!l){await h(60000,this.signal);continue}if(this.team!==null&&l.name!==this.team)return;if(this.team===null&&Date.now()-r>=re)r=Date.now(),this.sendLink();let u,F=new Date(Date.now()+86400000).toISOString().slice(0,10),v=Date.now()-i>=se&&!N(process.env,this.home)?l.messageCounts?.filter((c)=>c.day<=F).slice(-ie):void 0,R=this.reportSoon||Date.now()-a>=Q;this.reportSoon=!1;try{let c=await this.api.claimAgentNetworkRelayJob({machine:l.machine,person:l.person,...this.onNetwork(l),version:g,wait_seconds:zn,...v?.length?{message_counts:v,...l.endpoint?{endpoint:l.endpoint}:{}}:{},...R?{hosted:this.hostedReport()}:{}},AbortSignal.any([this.signal,AbortSignal.timeout((zn+20)*1000)]));if(v?.length)i=Date.now();if(R)a=Date.now();if(c.hosted)this.carryHosted(c.hosted);if(s=0,n>0)_(this.home,null);if(n=0,c.retry_after_seconds)await h(c.retry_after_seconds*1000,this.signal);u=c.job}catch(c){if(this.signal.aborted)return;let f=T(c);if(f===401){let A=I(await w()),b=O(this.home);n=Math.max(n,b?.login===A?b.refusals:0)+1;let k=Math.min(E,te*2**Math.min(n-1,10));_(this.home,{login:A,refusals:n,until:Date.now()+k}),await this.untilSignedInAgain(k);continue}if(f===403){await h(900000,this.signal);continue}if(f===404||f===405){await h(120000,this.signal);continue}s+=1,await h(Math.min(60000,1000*2**Math.min(s,6)),this.signal);continue}if(u)this.carry(u)}}linkSends={sent:null,refused:null};async sendLink(){try{let{sendTeamLink:e}=await import("./network-sign-in-61gmpmaa.js");this.linkSends=await e(this.network,this.linkSends,this.home,this.api)}catch{}}onNetwork(e){return{team:e.name,...e.teamId?{team_id:e.teamId}:{},...this.team===null?{workspace:!1}:{}}}async untilSignedInAgain(e){let t=await w(),s=Date.now()+e;while(!this.signal.aborted&&Date.now()<s)if(await h(Math.min(ne,Math.max(0,s-Date.now())),this.signal),await w()!==t)return}async carry(e){let t;try{t=e.kind==="who"?{who:await this.who(e)}:{sent:await this.send(e)}}catch(s){t={error:s instanceof Error?s.message:String(s)}}for(let s=1;;s+=1)try{if(await this.api.completeAgentNetworkRelayJob(e.id,t),e.kind==="send")this.log(Fe(`relayed a message to ${e.to} from ${"sent"in t?t.sent.from:e.from_name}`),"relayed");return}catch(n){if(s>=4||this.signal.aborted){this.log(Fe(`couldn't report a relayed call: ${n instanceof Error?n.message:String(n)}`));return}await h(s*1000,this.signal)}}async who(e){let t=e.all===!0,s=await this.network.snapshot({all:t});return{all:t,team:s.team,sessions:s.sessions.map((n)=>({address:n.address,person:n.person,machine:n.machine,agent:n.agent,repo:n.repo,branch:n.branch,status:n.status,since:n.since,doing:n.doing,worker:n.worker,...n.tier?{tier:n.tier.slice(0,10)}:{}})),machines:s.machines.map((n)=>({person:n.person,machine:n.machine,online:n.online}))}}hostedReport(){return[...this.hosted.values()].filter((e)=>this.wanted(e)).slice(0,50).map((e)=>{let t=this.addresses.get(d(e));return{name:e.name,...t?{address:t}:{}}})}carryHosted(e){let t=Date.now(),s=new Map(e.map((n)=>[d(n),{name:n.name,agent:n.agent,at:t}]));for(let[n,i]of this.hosted){if(s.has(n))continue;this.hosted.delete(n),this.letGo(i)}for(let[n,i]of s){if(this.hosted.has(n))this.sessions.get(n)?.then((r)=>r.idle()).catch(()=>{});this.hosted.set(n,i),this.read(i)}P(this.home,{...p(this.home),hosted:[...this.hosted.values()]})}letGo(e){if(this.wanted(e))return;let t=d(e),s=this.sessions.get(t);this.sessions.delete(t),this.addresses.delete(t),this.reclaimed.delete(t),s?.then(async(n)=>{for(let i=0;i<j;i+=1){let r=await n.next(Z).catch(()=>[]);if(r.length===0||!await this.handOver(e,n,r,!0).then(()=>!0,()=>!1))break}if(!this.sessions.has(t))await n.end()}).catch(()=>{})}async reclaim(e,t){let s=d(e);if(!this.hosted.has(s)||t.address.slice(t.address.indexOf("/")+1)===e.name)return;if(Date.now()-(this.reclaimed.get(s)??-1/0)<X)return;if(this.reclaimed.set(s,Date.now()),!await t.rename(e.name).then(()=>!0,()=>!1))return;this.addresses.set(s,t.address),this.reportSoon=!0}wanted(e){let t=this.hosted.get(d(e));if(t&&Date.now()-t.at<=M)return!0;let s=p(this.home).sessions.find((n)=>n.name===e.name&&n.agent===e.agent)?.usedAt??0;return Date.now()-s<=D}async send(e){let t={name:e.from_name,agent:e.from_agent},{session:s,result:n}=await this.withSession(t,(i)=>i.send(e.to,e.body,e.reply_to,{notify:e.notify===!0}));return this.remember(t),this.read(t),{ids:n.ids,recipients:n.recipients,from:s.address,deliveries:n.deliveries.slice(0,500).map(ae)}}async withSession(e,t,s=()=>!0){let n=this.session(e),i=await n;try{return{session:i,result:await t(i)}}catch(r){if(!Ji(r)||!s())throw r;let a=d(e);if(this.sessions.get(a)===n)this.sessions.delete(a);let o=await this.session(e);return{session:o,result:await t(o)}}}session(e){let t=d(e),s=this.sessions.get(t);if(!s)s=this.network.session(e.name,{agent:e.agent}).then(async(n)=>(this.addresses.set(t,n.address),await n.idle(`personal agent (${e.agent}), through Reason`).catch(()=>{}),n)),s.catch(()=>this.sessions.delete(t)),this.sessions.set(t,s);return s}remember(e){let t=p(this.home),s=t.sessions.filter((n)=>n.name!==e.name||n.agent!==e.agent);P(this.home,{...t,sessions:[...s,{...e,usedAt:Date.now()}].slice(-50)})}async handOver(e,t,s,n){let i=await this.network.team();if(!i)throw Error("not on a team");let r=n?{session:e.name,machine:i.machine}:{};await this.api.recordAgentNetworkRelayReplies({messages:s.map(oe),...this.onNetwork(i),...r}).catch((a)=>{let o=T(a);if(o===null||o>=500||o===429||o===401)throw a;this.log(`dropped ${s.length} answer(s) the server refused (HTTP ${o})`)}),await t.ack(s.map((a)=>a.id))}read(e){let t=d(e);if(this.readers.has(t))return;this.readers.add(t),(async()=>{let s=0;try{while(!this.signal.aborted&&this.wanted(e))try{let n=this.hosted.has(t),{session:i,result:r}=await this.withSession(e,async(a)=>(await this.reclaim(e,a),await a.next(ee)),()=>this.wanted(e));if(r.length===0)continue;await this.handOver(e,i,r,n||this.hosted.has(t)),s=0}catch{if(this.signal.aborted)return;s+=1,await h(Math.min(60000,1000*2**Math.min(s,6)),this.signal)}}finally{if(this.readers.delete(t),!this.signal.aborted&&this.hosted.has(t)&&!this.wanted(e))this.hosted.delete(t),this.letGo(e)}})()}}async function le(e){await new V(e.network,e.api,e.home??z(),e.signal,e.log??(()=>{}),e.team).run()}async function De(e,t=()=>{}){let s="";while(!e.aborted){try{let n=Ot.openInstalled();if(n)try{let[{resolveApiCredentials:i},{ReasonApi:r}]=await Promise.all([import("./api-credentials-mtfdk175.js"),import("./api-w6w7vfp3.js")]),a=await i({});if(a&&a.credentialKind!=="api_key"){let o=Ur(),l=o&&a.orgId.toLowerCase()===o.orgId.toLowerCase()?o.team:null;await le({network:n,api:new r(a),team:l,signal:e,log:t})}}finally{n.close()}s=""}catch(n){let i=Fe(`agent network relay: ${n instanceof Error?n.message:String(n)}`);if(i!==s)t(i);s=i}await h(300000,e)}}export{De as runBackgroundAskRelay};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fe,Xi,ll,ul,Yi,dl,pl}from"./vm-hands-entry-lite-
|
|
2
|
+
import{fe,Xi,ll,ul,Yi,dl,pl}from"./vm-hands-entry-lite-y3nz20wb.js";import"./vm-hands-entry-lite-ms99mzp0.js";import"./vm-hands-entry-lite-nn6zcvmp.js";import"./vm-hands-entry-lite-gxpw14jv.js";import"./vm-hands-entry-lite-7pfhwxn5.js";import"./vm-hands-entry-lite-ht6hzkgj.js";import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-h7nk2848.js";import"./vm-hands-entry-lite-52qz0n30.js";import"./vm-hands-entry-lite-5y4phfv1.js";import"./vm-hands-entry-lite-vkhacd00.js";import"./vm-hands-entry-lite-0wb1n769.js";import"./vm-hands-entry-lite-weqam12f.js";import"./vm-hands-entry-lite-v4hr9x9h.js";import"./vm-hands-entry-lite-yvws5zpx.js";import"./vm-hands-entry-lite-2dak7e1h.js";import"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-sy7dcccg.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{Xi as computerDisconnected,fe as connectionDirectory,Yi as connectionReport,dl as restartConnection,pl as restartConnectionWhenIdle,ll as runConnectCli,ul as runDisconnectCli};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hr,To,Io,Do,wl,Oo}from"./vm-hands-entry-lite-
|
|
2
|
+
import{hr,To,Io,Do,wl,Oo}from"./vm-hands-entry-lite-2dak7e1h.js";import"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-sy7dcccg.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{Io as ensureLocalBrowser,hr as localAutomationAvailable,Do as localBrowserProfile,To as localUserChromeHost,wl as runAutomationCallLocally,Oo as runLocalAutomation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Gr,Kr,lo,qn,Kc,Jc,Wn,uo,po,ho,Vn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Gr,Kr,lo,qn,Kc,Jc,Wn,uo,po,ho,Vn}from"./vm-hands-entry-lite-h7nk2848.js";import"./vm-hands-entry-lite-52qz0n30.js";import"./vm-hands-entry-lite-5y4phfv1.js";import"./vm-hands-entry-lite-vkhacd00.js";import"./vm-hands-entry-lite-0wb1n769.js";import"./vm-hands-entry-lite-weqam12f.js";import"./vm-hands-entry-lite-v4hr9x9h.js";import"./vm-hands-entry-lite-yvws5zpx.js";import"./vm-hands-entry-lite-2dak7e1h.js";import"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-sy7dcccg.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";export{r as LocalCapabilityError,Gr as SHORT_REQUEST_CAPABILITIES,uo as capabilityInventoryForRoots,Kr as confinedExecutionShell,qn as defaultLocalCommandRunner,po as deliverLocalHandsEnvironment,Wn as enrolledRootPaths,Vn as executeLocalOperation,ho as rebindLocalHandsControl,Kc as runFileCapability,Jc as runTransferCapability,lo as spawnCaptured};
|
package/bin/vm-hands/{local-display-session-zyd8s6n6.js → local-display-session-axh9mfdk.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{on,No,Te,Ft,sn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{on,No,Te,Ft,sn}from"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{Ft as ensureLinuxDesktop,on as localDisplayAvailable,No as localDisplayReady,Te as privateDirectory,sn as runLocalDisplayStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{qo,Wo,Vo,Go,Jt}from"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";export{qo as MAC_SCREEN,Wo as WINDOWS_SCREEN,Vo as createDisplayVideoLane,Jt as localDisplayVideoAvailable,Go as simulatorVideoFfmpeg};
|
package/bin/vm-hands/{local-managed-process-w26jhyfg.js → local-managed-process-4mgqn7tg.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lr,Xn,go,Yn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{lr,Xn,go,Yn}from"./vm-hands-entry-lite-5y4phfv1.js";import"./vm-hands-entry-lite-vkhacd00.js";import"./vm-hands-entry-lite-0wb1n769.js";import"./vm-hands-entry-lite-weqam12f.js";import"./vm-hands-entry-lite-v4hr9x9h.js";import"./vm-hands-entry-lite-yvws5zpx.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{lr as ManagedProcessStoppedError,go as controlManagedDeviceProcess,Yn as retireManagedDeviceProcess,Xn as runManagedDeviceProcess};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Vc,Nt,hl,Wr,fl,ml,Ye,gl,_l,ie,yl,N,Qi}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Vc,Nt,hl,Wr,fl,ml,Ye,gl,_l,ie,yl,N,Qi}from"./vm-hands-entry-lite-gxpw14jv.js";import"./vm-hands-entry-lite-yvws5zpx.js";import{mn,Ri}from"./vm-hands-entry-lite-vdv4nm5f.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{Vc as MANAGED_RUNTIME_MANIFEST_URL,mn as MANAGED_RUNTIME_MAX_MANIFEST_BYTES,ie as acquireManagedRuntimeDirectoryLock,yl as acquireManagedRuntimeLock,Ye as currentManagedRuntimeVersion,Wr as fetchManagedRuntimeBytes,Qi as flushManagedRuntimeLifecycleEvents,ml as installManagedRuntimeLauncher,gl as isManagedRuntimeVersionExecutable,hl as legacyManagedRuntimePaths,_l as managedRuntimeExecutableVersion,Nt as managedRuntimePaths,Ri as parseAndVerifyManagedRuntimeManifest,N as recordManagedRuntimeLifecycle,fl as updateManagedRuntime};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w}from"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-krpqqx12.js";import"./vm-hands-entry-lite-9g52kxyj.js";import{it,qe}from"./vm-hands-entry-lite-sy7dcccg.js";import{us}from"./vm-hands-entry-lite-
|
|
3
|
-
`,{mode:384,flag:"wx"}),O(r,e)}finally{V(r,{force:!0})}}function Q(e={}){let n=h(g(e.env??process.env,e.home??u()),G),r=(e.now??new Date).getTime(),t=()=>{let i=(e.random??Math.random)();return Number.isFinite(i)?Math.min(Math.max(i,0),1):0},o=(i)=>z(n,{schema_version:1,next_at:new Date(i).toISOString()}),s=X(n),c=s?Date.parse(s.next_at):NaN;if(!s||c>r+f+_)return o(r+Math.floor(t()*f)),!1;if(r<c)return!1;return o(r+f+Math.round((t()*2-1)*_)),!0}function Z(e,n={}){let r=n.platform??process.platform,t=n.kill??Be,o=(c)=>{try{t(e,c,r)}catch{}};if(o("SIGTERM"),r==="win32")return;setTimeout(()=>o("SIGKILL"),n.graceMs??J).unref?.()}function ee(e={}){let n=e.env??process.env,r=e.platform??process.platform,t=h(g(n,e.home??u()),H);y(p(t),{recursive:!0,mode:448});let o=N(t,"w",384);return new Promise((s)=>{let c=!1,i=(d)=>{if(c)return;c=!0,clearTimeout(a),s(d)},l=I(e.executablePath??process.execPath,["update","--quiet"],{env:n,stdio:["ignore",o,o],windowsHide:!0,...Me(r)});M(o);let a=setTimeout(()=>{if(l.pid)Z(l.pid,{platform:r,...e.killGraceMs===void 0?{}:{graceMs:e.killGraceMs},...e.kill?{kill:e.kill}:{}});i(124)},e.timeoutMs??q);a.unref?.(),l.once("error",()=>i(127)),l.once("exit",(d,m)=>i(m?128:d??1))})}function te(e,n){return new Promise((r)=>{if(n.aborted)return r();let t=setTimeout(r,e);n.addEventListener("abort",()=>{clearTimeout(t),r()},{once:!0})})}function ne(e,n=()=>new Date){let r=-1/0,t="";return(o)=>{let s=n().getTime();if(s-r<B||o===t&&s-r<j)return;r=s,t=o,e(o)}}async function Gt(e,n,r,t={}){let o=t.env??process.env,s=t.home??u(),c=t.sleep??te,i=t.now??(()=>new Date);if(o.REASON_NETWORK_NO_UPDATE||o.TINCAN_NO_UPDATE)return;let l=ne(n,i);try{let a=t.refreshEngine??(async(m)=>(await import("./agent-network-
|
|
2
|
+
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w}from"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-krpqqx12.js";import"./vm-hands-entry-lite-9g52kxyj.js";import{it,qe}from"./vm-hands-entry-lite-sy7dcccg.js";import{us}from"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-gxpw14jv.js";import"./vm-hands-entry-lite-pxtycfdv.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-ht6hzkgj.js";import"./vm-hands-entry-lite-7pfhwxn5.js";import"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-vkhacd00.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-y3nz20wb.js";import"./vm-hands-entry-lite-weqam12f.js";import"./vm-hands-entry-lite-52qz0n30.js";import"./vm-hands-entry-lite-nn6zcvmp.js";import"./vm-hands-entry-lite-h7nk2848.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-v4hr9x9h.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-5y4phfv1.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-2dak7e1h.js";import"./vm-hands-entry-lite-ms99mzp0.js";import"./vm-hands-entry-lite-0wb1n769.js";import"./vm-hands-entry-lite-yvws5zpx.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-zawytz09.js";import{Me,Be}from"./vm-hands-entry-lite-8xv6c0rm.js";import{spawn as I}from"child_process";import{randomUUID as A}from"crypto";import{closeSync as M,existsSync as T,mkdirSync as y,openSync as N,readFileSync as U,renameSync as O,rmSync as V,writeFileSync as F}from"fs";import{homedir as u}from"os";import{dirname as p,join as h}from"path";var L=["curl","npm","bun","brew"];function x(e){return L.includes(e)}function v(e,n=process.env){let r=P(n,"REASON_INSTALL_METHOD");if(x(r))return r;let t=e.replaceAll("\\","/").toLowerCase();if(t.includes("/.bun/install/global/"))return"bun";if(t.includes("/node_modules/"))return"npm";if(t.includes("/cellar/")||t.includes("/homebrew/"))return"brew";return"curl"}var f=86400000,_=7200000,W=900000,q=900000,J=30000,B=3600000,j=43200000,G="network-update-check.json",K="automatic-updates-declined.json",H="network-update.log";function g(e,n){return p(it(e,n))}function S(e=process.env,n=u()){return T(h(g(e,n),K))}function R(e){if(!e||e.channel!=="production"||e.install_method!=="curl")return"no_receipt";return e.background_mode==="cli_only"?null:"background_updater"}function Y(e={}){let n=e.env??process.env,r=e.home??u(),t=e.executablePath??process.execPath;if(!(e.compiled??us(e.main)))return"source_checkout";if(w({env:n,executablePath:t})!=="production")return"not_production";if(v(t,n)!=="curl")return"package_manager";let o=e.receipt===void 0?qe(it(n,r)):e.receipt,s=R(o);if(s)return s;if(S(n,r))return"declined";return"eligible"}async function jt(e,n=process.env,r=u()){if(e.background_mode!=="cli_only")return"background_updater";if(S(n,r))return"declined";if(R(e)!==null)return"none";let{installedEngineVersion:t}=await import("./agent-network-kk36zca7.js");return t(r)===null?"none":"reason_network"}function X(e){try{let n=JSON.parse(U(e,"utf8"));return n?.schema_version===1&&typeof n.next_at==="string"&&Number.isFinite(Date.parse(n.next_at))?n:null}catch{return null}}function z(e,n){y(p(e),{recursive:!0,mode:448});let r=`${e}.${process.pid}.${A()}.tmp`;try{F(r,`${JSON.stringify(n)}
|
|
3
|
+
`,{mode:384,flag:"wx"}),O(r,e)}finally{V(r,{force:!0})}}function Q(e={}){let n=h(g(e.env??process.env,e.home??u()),G),r=(e.now??new Date).getTime(),t=()=>{let i=(e.random??Math.random)();return Number.isFinite(i)?Math.min(Math.max(i,0),1):0},o=(i)=>z(n,{schema_version:1,next_at:new Date(i).toISOString()}),s=X(n),c=s?Date.parse(s.next_at):NaN;if(!s||c>r+f+_)return o(r+Math.floor(t()*f)),!1;if(r<c)return!1;return o(r+f+Math.round((t()*2-1)*_)),!0}function Z(e,n={}){let r=n.platform??process.platform,t=n.kill??Be,o=(c)=>{try{t(e,c,r)}catch{}};if(o("SIGTERM"),r==="win32")return;setTimeout(()=>o("SIGKILL"),n.graceMs??J).unref?.()}function ee(e={}){let n=e.env??process.env,r=e.platform??process.platform,t=h(g(n,e.home??u()),H);y(p(t),{recursive:!0,mode:448});let o=N(t,"w",384);return new Promise((s)=>{let c=!1,i=(d)=>{if(c)return;c=!0,clearTimeout(a),s(d)},l=I(e.executablePath??process.execPath,["update","--quiet"],{env:n,stdio:["ignore",o,o],windowsHide:!0,...Me(r)});M(o);let a=setTimeout(()=>{if(l.pid)Z(l.pid,{platform:r,...e.killGraceMs===void 0?{}:{graceMs:e.killGraceMs},...e.kill?{kill:e.kill}:{}});i(124)},e.timeoutMs??q);a.unref?.(),l.once("error",()=>i(127)),l.once("exit",(d,m)=>i(m?128:d??1))})}function te(e,n){return new Promise((r)=>{if(n.aborted)return r();let t=setTimeout(r,e);n.addEventListener("abort",()=>{clearTimeout(t),r()},{once:!0})})}function ne(e,n=()=>new Date){let r=-1/0,t="";return(o)=>{let s=n().getTime();if(s-r<B||o===t&&s-r<j)return;r=s,t=o,e(o)}}async function Gt(e,n,r,t={}){let o=t.env??process.env,s=t.home??u(),c=t.sleep??te,i=t.now??(()=>new Date);if(o.REASON_NETWORK_NO_UPDATE||o.TINCAN_NO_UPDATE)return;let l=ne(n,i);try{let a=t.refreshEngine??(async(m)=>(await import("./agent-network-kk36zca7.js")).refreshEngine({home:s,env:o,beforeRestart:m})),d=()=>l("moved the network engine to this release's pin; its daemon restarts on it");if(await a(d)){d();return}}catch(a){l(`couldn't move the network engine to this release's pin: ${a instanceof Error?a.message:String(a)}`)}while(!e.aborted){try{if(Y({env:o,home:s,...t.executablePath?{executablePath:t.executablePath}:{},...t.compiled===void 0?{}:{compiled:t.compiled}})==="eligible"&&Q({env:o,home:s,now:i(),...t.random?{random:t.random}:{}})){let d=await(t.update??(()=>ee({env:o,home:s,...t.executablePath?{executablePath:t.executablePath}:{}})))();if(d===0)await r();else l(`reason update failed (exit ${d}); the next try is in about a day`)}}catch(a){l(`automatic update: ${a instanceof Error?a.message:String(a)}`)}await c(t.tickMs??W,e)}}export{jt as automaticUpdatesFor,Gt as keepNetworkComputerCurrent};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./vm-hands-entry-lite-84mc1f7h.js";import{Fe}from"./vm-hands-entry-lite-
|
|
2
|
+
import"./vm-hands-entry-lite-84mc1f7h.js";import{Fe}from"./vm-hands-entry-lite-jgk5z8zc.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-9g52kxyj.js";import{ve}from"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-krpqqx12.js";import{be}from"./vm-hands-entry-lite-ht6hzkgj.js";import{xr}from"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-7pfhwxn5.js";import"./vm-hands-entry-lite-sy7dcccg.js";import{ma,ga,_a,Ur,zr}from"./vm-hands-entry-lite-hjjbjpd7.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import{createHash as y}from"crypto";var _={start:"/network/auth/start",poll:"/network/auth/poll",key:"/network/auth/key",teams:"/v3/network/teams",leave:"/v3/network/teams/leave",proof:"/v3/network/proof"};async function I(r,e,t={}){let o=AbortSignal.timeout(t.timeoutMs??30000),i=await fetch(r,{method:"POST",redirect:"error",signal:t.signal?AbortSignal.any([t.signal,o]):o,headers:{"content-type":"application/json","user-agent":xr,...t.token?{authorization:`Bearer ${t.token}`}:{}},body:JSON.stringify(e)}),n=await i.json().catch(()=>({}));return{status:i.status,body:n&&typeof n==="object"?n:{}}}var d=(r)=>y("sha256").update(r).digest("hex");async function b(r,e,t,o,i=!1){let n={team_id:t.teamId,team_name:t.teamName,link:o,...i?{own_copy:!0}:{}},s=await I(`${r}${_.teams}`,n,{token:e}).catch(()=>null);return s!==null&&s.status>=200&&s.status<300}async function v(r,e,t,o,i={}){let n=zr(t);if(!n||!i.ownCopy&&e.registered===d(n.secret))return!0;let s=ma(i.home),a=ve(s)?await be({path:s}).catch(()=>null):null,c=(await r.team())?.name??e.team;if(a&&await b(a.apiOrigin,a.accessToken,{teamId:n.teamId,teamName:c},t,i.ownCopy)){if(!i.ownCopy&&e.registered!==d(n.secret))_a({...e,registered:d(n.secret)},i.home);return!0}return o?.stderr.write(T(`Your Reason account still lists ${Fe(c)}'s old link; signing in for this network refreshes it: reason network join '${t}'`)+`
|
|
3
3
|
`),!1}var S=300000,R=21600000;async function xe(r,e,t,o){let i=ga(t),n=o?await r.team():null;if(i&&(!o||i.team===n?.name)){let{url:l}=await r.link(),u=zr(l);if(!u||d(u.secret)===e.sent)return e;return await v(r,i,l,null,{ownCopy:!0,...t?{home:t}:{}})?{...e,sent:d(u.secret)}:e}if(!o||!n?.teamId||Ur(t)?.team===n.name)return e;let{url:s}=await r.link(),a=zr(s);if(!a||a.teamId!==n.teamId.toLowerCase())return e;let c=d(a.secret);if(c===e.sent||e.refused?.link===c&&Date.now()<e.refused.until)return e;if(await(async()=>{let l=await o.agentNetwork();if(l.team===n.name||l.link&&zr(l.link)?.teamId===a.teamId)return!1;return await o.registerNetworkTeam({team_id:a.teamId,team_name:n.name,link:s,own_copy:!0}),!0})().catch(()=>!1))return{sent:c,refused:null};let g=e.refused?.link===c?e.refused.tries+1:1;return{...e,refused:{link:c,tries:g,until:Date.now()+Math.min(R,S*2**Math.min(g-1,10))}}}var T=(r)=>process.stdout.isTTY?`\x1B[2m${r}\x1B[22m`:r;export{xe as sendTeamLink};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qc,bc,vl,el,Sl}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Qc,bc,vl,el,Sl}from"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";export{el as allowMacPermissions,vl as permissionsSummary,bc as readMacPermissions,Qc as reasonIdentity,Sl as runPermissionsCli};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ke,de,j,Ue,Jo,bn,Xo,ze,Ii,Di,Yo,vn,Ie,Zo,Sn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{ke,de,j,Ue,Jo,bn,Xo,ze,Ii,Di,Yo,vn,Ie,Zo,Sn}from"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-sy7dcccg.js";import"./vm-hands-entry-lite-hs6sdn60.js";import"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-2rgf8866.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-bj3w2ven.js";import"./vm-hands-entry-lite-zawytz09.js";import"./vm-hands-entry-lite-9g52kxyj.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import"./vm-hands-entry-lite-krpqqx12.js";export{ke as WORKER_SERVICE_ENV,j as WorkerServiceError,bn as connectServiceLabel,de as defaultWorkerServiceHost,vn as installWorkerService,ze as installedWorkerService,Xo as isConnectServiceLabel,Sn as removeWorkerService,Ie as restartWorkerService,Zo as retargetWorkerServiceLogs,Ii as retireLegacyWorkerService,Yo as workerServiceDefinitionCurrent,Ue as workerServiceLauncher,Di as workerServiceProcessRunning,Jo as workerServiceRetargetPending};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-2rgf8866.js";import{w,We,_c}from"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-9g52kxyj.js";import{Q}from"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-krpqqx12.js";import{me}from"./vm-hands-entry-lite-
|
|
2
|
+
import"./vm-hands-entry-lite-84mc1f7h.js";import"./vm-hands-entry-lite-2rgf8866.js";import{w,We,_c}from"./vm-hands-entry-lite-q9s1e2y1.js";import"./vm-hands-entry-lite-9g52kxyj.js";import{Q}from"./vm-hands-entry-lite-a7bf7xr7.js";import"./vm-hands-entry-lite-krpqqx12.js";import{me}from"./vm-hands-entry-lite-ht6hzkgj.js";import{g}from"./vm-hands-entry-lite-bj3w2ven.js";import{ir}from"./vm-hands-entry-lite-7pfhwxn5.js";import{un,tt}from"./vm-hands-entry-lite-pxtycfdv.js";import{f,S,nr,Z,fe,Xi,Yi}from"./vm-hands-entry-lite-y3nz20wb.js";import"./vm-hands-entry-lite-71ebge0c.js";import"./vm-hands-entry-lite-57ajjwmh.js";import"./vm-hands-entry-lite-h7nk2848.js";import"./vm-hands-entry-lite-vkhacd00.js";import"./vm-hands-entry-lite-weqam12f.js";import"./vm-hands-entry-lite-52qz0n30.js";import"./vm-hands-entry-lite-nn6zcvmp.js";import"./vm-hands-entry-lite-hn9pq7zj.js";import"./vm-hands-entry-lite-j10cw3d9.js";import"./vm-hands-entry-lite-6jxshhps.js";import"./vm-hands-entry-lite-wcgm41jq.js";import"./vm-hands-entry-lite-q9djb28r.js";import"./vm-hands-entry-lite-gxpw14jv.js";import{qe}from"./vm-hands-entry-lite-sy7dcccg.js";import"./vm-hands-entry-lite-m1we91g4.js";import"./vm-hands-entry-lite-jpvmkce5.js";import"./vm-hands-entry-lite-v4hr9x9h.js";import"./vm-hands-entry-lite-zh6ncdjn.js";import"./vm-hands-entry-lite-5y4phfv1.js";import"./vm-hands-entry-lite-z0ht62s4.js";import"./vm-hands-entry-lite-hxfxs7r9.js";import"./vm-hands-entry-lite-z213y4pj.js";import"./vm-hands-entry-lite-2dak7e1h.js";import"./vm-hands-entry-lite-ms99mzp0.js";import"./vm-hands-entry-lite-0wb1n769.js";import"./vm-hands-entry-lite-yvws5zpx.js";import"./vm-hands-entry-lite-hs6sdn60.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{t,o,d,n,c,i}from"./vm-hands-entry-lite-k5ytpgzz.js";import"./vm-hands-entry-lite-8xv6c0rm.js";import{createHash as Ye,randomBytes as Qe}from"crypto";import{readFileSync as Ze,realpathSync as ye,renameSync as en,unlinkSync as nn,writeFileSync as tn}from"fs";import{dirname as rn,join as we}from"path";import{spawnSync as xe}from"child_process";import{accessSync as $e,constants as Ue,existsSync as J,mkdirSync as Le,readFileSync as Te,renameSync as Ee,writeFileSync as Oe}from"fs";import{homedir as De}from"os";import{delimiter as Ne,dirname as Fe,join as D}from"path";import{existsSync as Me,readFileSync as Ae}from"fs";import{join as Pe}from"path";var Ie=`---
|
|
3
3
|
name: reason
|
|
4
4
|
description: Integrate software with Reason's public REST API using a scoped API key. Use for API clients, CI, service integrations, or cloud coding-session automation.
|
|
5
5
|
---
|
|
@@ -63,7 +63,7 @@ retired MCP configuration that can be cleaned up, and automatic updates.
|
|
|
63
63
|
`,sn=5000,an=300000,cn=n({version:i(1),key:t(),at:o(),self:n({principal_type:t(),user_id:t().optional(),user_name:t().nullish(),email:t().nullish(),org_id:t(),organization_name:t().nullish(),organization_slug:t().nullish(),mcp_connections:d(n({client_id:t(),client_name:t(),last_used_at:t().nullable()})).optional()})}),Re=(e)=>`${e.apiOrigin}
|
|
64
64
|
${Ye("sha256").update(e.accessToken).digest("hex")}`;function ln(e,r,a){try{let u=cn.safeParse(JSON.parse(Ze(e,"utf8")));if(!u.success||u.data.key!==Re(r))return null;let l=a-u.data.at;return l>=0&&l<an?u.data.self:null}catch{return null}}function dn(e,r,a,u){let l=`${e}.${process.pid}.${Qe(6).toString("hex")}.tmp`;try{let m={version:1,key:Re(r),at:u,self:a};tn(l,`${JSON.stringify(m)}
|
|
65
65
|
`,{mode:384,flag:"wx"}),en(l,e)}catch{try{nn(l)}catch{}}}var pn=30000;function mn(e,r=Date.now(),a=null){let u=tt(e),l=(()=>{if(u?.state!=="connected"&&u?.state!=="starting")return!1;try{return process.kill(u.pid,0),!0}catch{return!1}})(),m=l&&u?.state==="connected",R=(k)=>m&&r-k>=0&&r-k<pn,v=he.safeParse(u?.fullDiskAccess),_=un(u,a,r);return{..._?{permission_recovery:_}:{},full_disk_access:v.success&&R(v.data.checkedAt)?v.data.status:"unknown",keep_awake:{enabled:nr(e)==="battery_and_ac",holding:u?.idleSleepHold===!0&&R(Date.parse(u.lastHeartbeatAt??""))},executable:l&&v.success?v.data.executablePath:null}}function gn(e=w()){if(process.platform!=="darwin")return null;let r=Z(we(fe(ye(s()),e),"worker.json"));return r?mn(f(r).daemon,Date.now(),S(r)):null}var fn={background_updater:"enabled",reason_network:"enabled, daily by Reason Network",declined:"disabled (installed with --background-mode cli_only)",none:"disabled"},Ce={connected:"connected",starting:"starting",reconnecting:"reconnecting",stopping:"stopping",not_running:"not running",removed:"removed from Reason (run `reason connect` to connect it again)"};async function it(e,r={}){let a=r.io??{stdout:process.stdout,stderr:process.stderr};if(e.includes("--help")||e.includes("-h"))return a.stdout.write(on),0;if(e.some((m)=>m!=="--json"))return a.stderr.write(`Usage: reason status [--json]
|
|
66
|
-
`),1;let u=new AbortController,l=setTimeout(()=>u.abort(Error("timed out reading the account")),sn);try{let m=r.now?.()??new Date,R=performance.now(),v=R,_=()=>{let p=performance.now(),P=Math.round(p-v);return v=p,P},k=null,N=(p)=>(k=p instanceof Error?p.message:String(p),null),b=await ir(r,u.signal).catch(N),q=_(),C=b?.credentialKind==="api_key",M=b&&!C?we(rn(Q(r.env??process.env)),"status-account.json"):null,x=b&&M&&e.includes("--json")?ln(M,b,m.getTime()):null,h=x??(b?await(r.getSelf??((p,P)=>new me(p).self(P)))(b,u.signal).catch(N):null);if(b&&h&&!x&&M)dn(M,b,h,m.getTime());let W=_(),F=r.manager??new K,j=e.includes("--json")?[]:F.statuses(),U=(r.loadReceipt??qe)(),z=U?await(r.automaticUpdates??(async(p)=>p.background_mode==="cli_only"?(await import("./network-auto-update-
|
|
66
|
+
`),1;let u=new AbortController,l=setTimeout(()=>u.abort(Error("timed out reading the account")),sn);try{let m=r.now?.()??new Date,R=performance.now(),v=R,_=()=>{let p=performance.now(),P=Math.round(p-v);return v=p,P},k=null,N=(p)=>(k=p instanceof Error?p.message:String(p),null),b=await ir(r,u.signal).catch(N),q=_(),C=b?.credentialKind==="api_key",M=b&&!C?we(rn(Q(r.env??process.env)),"status-account.json"):null,x=b&&M&&e.includes("--json")?ln(M,b,m.getTime()):null,h=x??(b?await(r.getSelf??((p,P)=>new me(p).self(P)))(b,u.signal).catch(N):null);if(b&&h&&!x&&M)dn(M,b,h,m.getTime());let W=_(),F=r.manager??new K,j=e.includes("--json")?[]:F.statuses(),U=(r.loadReceipt??qe)(),z=U?await(r.automaticUpdates??(async(p)=>p.background_mode==="cli_only"?(await import("./network-auto-update-wkzb91qz.js")).automaticUpdatesFor(p,r.env??process.env,r.home):"background_updater"))(U).catch(()=>U.background_mode==="cli_only"?"none":"background_updater"):null,B=await(r.readConnection??(()=>Yi({channel:r.channel})))().catch(()=>null),I=null;try{if(B)I=(r.readConnectionMacState??(()=>gn(r.channel??w())))()}catch{}let y=B&&I?{...B,...I}:B,G=(()=>{try{return(r.readDisconnected??(()=>Xi(ye(s()),r.channel??w())))()}catch{return!1}})(),_e=_(),ne=h?{id:h.org_id,name:h.organization_name??null,slug:h.organization_slug??null}:null,T=h?{id:h.user_id??null,name:(C?h.service_user_name:h.user_name)??null,email:h.email??null,credential:C?"api_key":"login"}:null,X=r.channel??w(),L={version:g,channel:X,api_origin:b?.apiOrigin??We(X),account:T,account_error:k,organization:ne,mcp:j.map((p)=>({client:p.id,label:p.label,status:le(p),installed_at:p.installed?F.installationPath(p.id):null,last_used_at:h?ue(p,h):null})),connection:y,disconnected:G,installation:U&&z?{background_mode:U.background_mode,automatic_updates:z==="background_updater"||z==="reason_network",automatic_updates_by:z,future_device_consent:U.device_consent?.decision??"disabled"}:null,timings_ms:{process:Math.round(R),credentials:q,account:W,local:_e,total:Math.round(performance.now()-R)}};if(e.includes("--json"))return a.stdout.write(`${JSON.stringify(L,null,2)}
|
|
67
67
|
`),0;if(X==="staging")a.stdout.write(`Reason ${g} \xB7 channel: STAGING
|
|
68
68
|
`),a.stdout.write(`API: ${L.api_origin}
|
|
69
69
|
`);else a.stdout.write(`Reason ${g}
|
|
@@ -79,7 +79,7 @@ This computer
|
|
|
79
79
|
`),y.version)a.stdout.write(`Version: ${y.version}${y.version===g?"":` (${g} is installed; \`reason connect\` restarts it on that)`}
|
|
80
80
|
`);if(a.stdout.write(`Folder: ${y.folder}
|
|
81
81
|
`),a.stdout.write(`Sessions: ${y.sessions_running===null?"":`${y.sessions_running} running, `}${y.sessions_max===null?"every Session you start":y.sessions_max===1?"one at a time":`up to ${y.sessions_max} at once`}
|
|
82
|
-
`),I){let p=I,P=await(r.readPermissionsSummary??(async()=>{let{permissionsSummary:Se,readMacPermissions:ve,reasonIdentity:be}=await import("./permissions-
|
|
82
|
+
`),I){let p=I,P=await(r.readPermissionsSummary??(async()=>{let{permissionsSummary:Se,readMacPermissions:ve,reasonIdentity:be}=await import("./permissions-348prrcx.js"),{macScreenStatus:ke}=await import("./local-display-mac-yxcxvg2z.js");return Se(await ve({identity:()=>be(),grants:ke,worker:async()=>p}))}))().catch(()=>null);if(P)a.stdout.write(`${P}
|
|
83
83
|
`);a.stdout.write(`Keep awake: ${I.keep_awake.enabled?"on":"off"}${I.keep_awake.holding?" (holding)":""}
|
|
84
84
|
`)}if(y.service)a.stdout.write(`Logs: ${y.service.logs}
|
|
85
85
|
`);for(let p of y.workspaces??[]){let P=p.state==="removed"?"removed from that workspace":p.blocked?"offline (this computer is outside that workspace's allowed networks)":p.device_id?Ce[p.state]:"connecting";a.stdout.write(`Also in workspace ${p.name??p.organization_id}${p.account?" (another Reason account's)":""}: ${P}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g,xr,Nc,El,us}from"./vm-hands-entry-lite-
|
|
2
|
+
import{g,xr,Nc,El,us}from"./vm-hands-entry-lite-bj3w2ven.js";export{xr as CLI_USER_AGENT,g as CLI_VERSION,Nc as CLI_VERSION_PATTERN,El as compareCliVersions,us as isCompiledRelease};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Gt,lc,le,Kt,yn,wn,T}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Gt,lc,le,Kt,yn,wn,T}from"./vm-hands-entry-lite-hn9pq7zj.js";import{ue}from"./vm-hands-entry-lite-q9djb28r.js";import{Er}from"./vm-hands-entry-lite-j10cw3d9.js";import{kr}from"./vm-hands-entry-lite-6jxshhps.js";import{Li}from"./vm-hands-entry-lite-wcgm41jq.js";import{Br,pa}from"./vm-hands-entry-lite-z0ht62s4.js";import{Te,Ft}from"./vm-hands-entry-lite-z213y4pj.js";import{de,Ue}from"./vm-hands-entry-lite-m1we91g4.js";import{Tr}from"./vm-hands-entry-lite-71ebge0c.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{B}from"./vm-hands-entry-lite-8xv6c0rm.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as k,spawnSync as rt}from"child_process";import{createHash as nt,randomUUID as ge}from"crypto";import{closeSync as st,copyFileSync as ne,existsSync as M,fstatSync as it,mkdirSync as se,openSync as at,readdirSync as D,readFileSync as G,readlinkSync as ct,renameSync as he,rmSync as lt,statSync as ut,writeFileSync as dt}from"fs";import{connect as pt}from"net";import{tmpdir as L,userInfo as _e}from"os";import{basename as ie,delimiter as mt,dirname as U,join as f}from"path";var K=`import { spawn, execFileSync } from "node:child_process";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{te}from"./vm-hands-entry-lite-9g52kxyj.js";import{U,H,R}from"./vm-hands-entry-lite-v4hr9x9h.js";import{ge,Lt,ti,ko,xo,ur}from"./vm-hands-entry-lite-
|
|
2
|
+
import{te}from"./vm-hands-entry-lite-9g52kxyj.js";import{U,H,R}from"./vm-hands-entry-lite-v4hr9x9h.js";import{ge,Lt,ti,ko,xo,ur}from"./vm-hands-entry-lite-vkhacd00.js";import{mt}from"./vm-hands-entry-lite-pxtycfdv.js";import{v,dr,Co,pt,ht}from"./vm-hands-entry-lite-0wb1n769.js";import{b,m}from"./vm-hands-entry-lite-yvws5zpx.js";import{s,St,Mc}from"./vm-hands-entry-lite-zawytz09.js";import{Vi,I,t,V,o,_,tl,Pt,ca,d,n,we,A,$e,c,i,Gi}from"./vm-hands-entry-lite-k5ytpgzz.js";import{Xe,G}from"./vm-hands-entry-lite-8xv6c0rm.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{randomUUID as X}from"crypto";import{spawn as ke}from"child_process";import{existsSync as Y,lstatSync as de,mkdirSync as Oe,readFileSync as Me,realpathSync as q,rmSync as Te,writeFileSync as je}from"fs";import{dirname as Le,join as k,relative as We,sep as Ne}from"path";var he=["process.run.v1","process.full.v1"],be=600000,ve=1800000,ye=20000,re="process.cancel.v1",oe=n({action:i("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:c(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(ve).default(be).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),B={device_id:t().uuid(),root_id:t().uuid()},Se=A("action",[oe.extend(B),n({...B,action:i("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(ye).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),n({...B,action:i("cancel"),process_id:t().uuid()}).strict()]),qe=Vi(Se,{io:"input"}),Je=oe.extend({process_brain_fence:t().uuid(),process_expires_at:I.datetime()}).strict(),W=n({version:i(1),process_id:t().uuid(),state:c(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:_(),observed_at:I.datetime(),output:d(n({cursor:o().int().min(1),stream:c(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let p=e.first_cursor-1;for(let l of e.output){if(l.cursor<=p||l.cursor>e.next_cursor)return!1;p=l.cursor}return!0});function Jn(e){return he.includes(e)}var ze=n({operation_constraints:$e(t(),Pt())}),Ge=n({ready:i(!0),version:i(1),execution_mode:c(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var xe=n({version:i(1),process_id:t().uuid(),state:c(["queued","cancelled_before_start","not_started"]),exit_code:tl(),output:d(ca()).length(0),first_cursor:i(0),next_cursor:i(0),truncated:i(!1),cancellation_requested:i(!1),reason_code:c(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:I.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),Pe=n({...W.shape,state:c(["queued","starting","running","exited","cancelled","expired","uncertain","cancelled_before_start","not_started"]),observed_at:I.datetime().optional(),expires_at:I.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it."),cancellation_requested:_(),reason_code:t().nullable().optional(),execution_authority:i("lost").optional().describe("Historical receipt only; the current Brain cannot control this older-generation process."),recovery:n({cause:i("brain_generation_changed"),terminal_confirmed:_(),next_step:c(["inspect_until_terminal","reconcile_effects_before_new_intent"])}).strict().optional().describe("Historical process recovery only. An unconfirmed outcome forbids replay. A confirmed terminal observation proves the old process stopped, not that its command had no effects. Reconcile the result; only restart still-needed, safely repeatable work with a new request_id and current authority. Respect user cancellation."),last_observed_state:W.shape.state.or(i("cancelled_before_start")).nullable().optional().describe("Last saved observation before authority was lost; a running observation does not establish current child liveness.")}).strict(),Be=Vi(Pe),Fe=we([W,xe.refine((e)=>e.state==="cancelled_before_start")]),F=n({version:i(1),process_id:t().uuid(),state:c(["exited","cancelled","expired"]),exit_code:o().int().min(0).max(255),observed_at:I.datetime()}).strict().refine((e)=>(e.state!=="cancelled"||e.exit_code===130)&&(e.state!=="expired"||e.exit_code===124)),Ee=n({process_terminal_observation:F}).strict();function Ra(e,a){let p=Ee.safeParse(e);return p.success&&p.data.process_terminal_observation.process_id===a?p.data:null}var Ta="preview.serve.v1",Ia=43200000;var Da=3,ne="preview.open.v1",se=1,fo="gid_proxy_v1",Oa="egress",mo=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Re=n({version:i(fo),allowed_domains:d(t().max(260).regex(mo)).max(1024)}).strict(),Ie=Gi((e)=>te(e)!==null,"invalid workspace"),De=n({version:i(1),request_id:V(),session_id:V(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),port:o().int().min(1024).max(65535),workspace:Ie,egress:Re.optional()}).strict(),Na=De.extend({expires_at:I.datetime()}).strict();var Ce=4,Ae=5000;function K(e,a,p){let l=null;try{l=dr(e)}catch{}Co({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:a,port:l?.binding.port??0,reason:l?p:"binding_invalid"})}function ie(e){let a=new Map;return{open(p){let l=(w)=>K(p,e.claim.operation_id,w),P;try{P=dr(p)}catch{return l("binding_invalid")}let{binding:h,deviceRelayUrl:N}=P,S=e.claim.owner;if(!S||h.organizationId!==S.organization_id||h.userId!==S.user_id||h.deviceId!==S.device_id||h.rootId!==e.claim.root_id||h.jobId!==e.claim.operation_id||h.fenceId!==e.claim.operation_id||h.generation!==se||h.expiresAtMs>Math.min(Date.now()+v.lifetimeMs+Ae,e.expiresAtMs))return l("binding_mismatch");if(h.expiresAtMs<=Date.now())return l("binding_expired");if(a.get(h.port)?.abort(),a.delete(h.port),a.size>=Ce)return l("preview_capacity");let O=new AbortController;a.set(h.port,O);let y=ht({binding:h,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(O.signal.aborted)return null;let w=await e.inspect();return w?{binding:h,executorLaunchId:e.executorLaunchId,job:w}:null}});pt({binding:h,deviceRelayUrl:N,port:y,signal:O.signal}).then((w)=>w.closed,(w)=>{let x=w instanceof Error?w.message:"preview_failed";if(x!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:h.jobId,port:h.port,reason_code:x})}
|
|
3
3
|
`)}).finally(()=>{if(a.get(h.port)===O)a.delete(h.port)})},dispose(){for(let p of a.values())p.abort();a.clear()}}}class lr extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var le=256,J=new Map,pe="preview.serve.v1",T=new Map;function ue(e){let a=T.get(e.operation_id);if(a){if(a.claim!==e)throw D("process_authority_lost");return a}if(T.size>=le)throw D("process_journal_capacity");let p={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return T.set(e.operation_id,p),p}function ae(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ce=(e)=>new Promise((a)=>setTimeout(a,e)),D=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function Ve(e=s(),a=He()){let p=Le(mt({},e)),l=We(St(e),p),[P,...h]=l.split(Ne);return{directory:k(a,l,"processes"),previous:[k(p,"processes"),...P==="reason"?[k(a,"ara",...h,"processes")]:[]]}}function He(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Mc();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function Xn(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw D("process_authority_lost");let a=ue(e.claim);if(a.executing)throw D("process_busy");if(a.executing=!0,a.cancelRequested)return a.phase="settling",ae(e.claim.operation_id);a.phase="starting";let p=e.journals??Ve();Oe(p.directory,{recursive:!0,mode:448});let l=Lt({runtimeDirectory:q(p.directory),previousRuntimeDirectories:(p.previous??[]).filter((u)=>Y(u)).map((u)=>q(u)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:le,folders:[e.root,e.cwd]});try{for(let u of[e.root,e.cwd])if(!ge(q(u),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(u){throw l.disposeSocket(),u}let P=de(l.journalDirectory),h=e.claim.capability===pe,N=()=>J.set(e.claim.operation_id,{path:l.journalDirectory,ino:P.ino,dev:P.dev,anyCompletion:h}),S=l.launchDirectory,O=k(S,"config.json"),y={url:"",transport:"local_job_ipc",directShell:{mode:e.mode,executable:e.shell,jobId:e.claim.operation_id},workerVersion:U,protocolVersion:2,workerArtifactSha256:R,workerEntrypoint:H,targetGeneration:1,fenceId:X(),...process.platform==="win32"?{bashExecutable:Xe()}:{},workRoot:e.root,workspaceAliasPath:e.root,repoPath:e.cwd,jobEnvPath:k(S,"unused.env"),replSocketPath:k(S,"unused.sock"),readyPath:k(S,"ready.json"),directTerminalReceiptPath:k(S,"terminal.json"),launchId:X(),expiresAtMs:e.expiresAtMs+5000,bashTimeoutMs:60000,replTimeoutMs:1000,allowedTools:["bash"],managedJobs:{journalDirectory:l.journalDirectory,scopeId:l.scopeId},jobControlSocketPath:l.socketPath,...e.prefix?{bashCommandPrefix:e.prefix}:{},...e.jobsUser?{jobsUser:e.jobsUser}:{}},w;try{je(O,JSON.stringify(y),{mode:384});let u=ko({configPath:O,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:S});w=e.spawnWorker?.(O,y)??ke(u.command,u.args,{...u.options,env:e.environment,stdio:[xo,"ignore","ignore"]})}catch(u){throw l.disposeSocket(),u}let x=!1,z=new Promise((u,g)=>{w.once("exit",(f)=>{x=!0,u(f)}),w.once("error",(f)=>{x=!0,g(f)})});z.catch(()=>{});let me={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:y.fenceId,executorLaunchId:y.launchId,expiresAtMs:y.expiresAtMs},M=async(u)=>{let g=await ti(me,{type:"job",version:2,generation:1,id:X(),jobId:e.claim.operation_id,...u==="start"?{action:u,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:u==="inspect"?{action:u,input:{after:0}}:u==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:u,input:{}}},new AbortController().signal);if(!g.ok)throw D(g.error);return g.job},j=!1,L=!1,Q,Z=()=>{j=!0,ur(w,"SIGTERM")};e.signal.addEventListener("abort",Z,{once:!0});let C,ee=0,_e=async(u)=>{let g=[...u.output],f={version:1,process_id:e.claim.operation_id,state:u.state,exit_code:u.exitCode,first_cursor:u.firstCursor,next_cursor:u.nextCursor,truncated:u.truncated,output:g,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&g.length)g.shift(),f.truncated=!0,f.first_cursor=g[0]?.cursor??f.next_cursor+1;C=W.parse(f),await e.emit(C),ee=Date.now()};try{let u=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Y(y.readyPath)){if(x)throw new r("process_start_failed","The managed process supervisor exited before accepting a command; no command was dispatched.");if(e.signal.aborted||Date.now()>=u)throw D("process_start_unconfirmed");await ce(25)}let g=JSON.parse(Me(y.readyPath,"utf8"));if(g.launchId!==y.launchId||g.fenceId!==y.fenceId||g.workerArtifactSha256!==R)throw D();if(e.signal.throwIfAborted(),a.cancelRequested)return ae(e.claim.operation_id);let f;try{L=!0,f=await M("start")}catch(E){if(!(E instanceof r)||E.code!=="hands_job_result_unknown")throw E;f=await M("inspect")}if(a.phase="running",a.cancel=async()=>{await M("cancel")},h&&e.preview)a.tunnels=ie({claim:e.claim,executorLaunchId:y.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>a.phase==="running"&&!x?await M("probe"):null});if(a.cancelRequested)await a.cancel(),f=await M("inspect");for(;;){if(!["starting","running"].includes(f.state))a.phase="settling",a.cancel=void 0;if(!C||C.state!==f.state||C.next_cursor!==f.nextCursor&&Date.now()-ee>=5000)await _e(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||x)throw D();await ce(1000);try{f=await M("inspect"),Q=void 0}catch(E){if(!(E instanceof r)||E.code!=="hands_job_result_unknown"||e.signal.aborted||x||Date.now()-(Q??=Date.now())>120000)throw E}}if(!C||C.state==="uncertain")throw D();return C}finally{if(a.phase="settling",a.cancel=void 0,a.tunnels?.dispose(),a.tunnels=void 0,await a.cancelInFlight?.catch(()=>{}),e.signal.removeEventListener("abort",Z),!x&&!j)ur(w,"SIGTERM");let u,g=await Promise.race([z.then((f)=>({code:f})),new Promise((f)=>{u=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(u)});if(!g){try{ur(w,"SIGKILL")}catch{}try{await z}finally{if(x)l.disposeSocket()}throw D("process_cleanup_unconfirmed")}try{if((j||e.signal.aborted)&&g.code===0&&L){b(S);let f=JSON.parse(m(y.directTerminalReceiptPath)),E=F.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===y.launchId&&f.fence_id===y.fenceId&&f.scope_id===l.scopeId&&E.success&&E.data.process_id===e.claim.operation_id){if(h)N();throw new lr(E.data)}}}catch(f){if(f instanceof lr)throw f}finally{if(x)l.disposeSocket()}if(g.code!==0&&!j&&L)throw D("process_cleanup_unconfirmed");if(!j&&g.code===0&&(C&&["exited","cancelled","expired"].includes(C.state)||!L&&a.cancelRequested)||h&&g.code===0&&!L)N()}}async function go(e,a){if(a.kind===ne&&e.capability===pe){let P=T.get(e.operation_id);if(P?.claim===e&&P.tunnels)P.tunnels.open(a.payload);else K(a.payload,e.operation_id,"server_not_running");return!0}if(a.kind!==re||!Jn(e.capability)||!e.owner||a.payload.process_id!==e.operation_id)return!1;let p=T.get(e.operation_id);if(p&&p.claim!==e)return!1;let l=ue(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Yn(e,a){T.delete(e);let p=J.get(e);if(!p||a!=="succeeded"&&!p.anyCompletion)return J.delete(e),!1;try{let l=de(p.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==p.ino||l.dev!==p.dev||!G(l)||q(p.path)!==p.path||Y(k(p.path,"owner.lock")))return!1;return Te(p.path,{recursive:!0}),J.delete(e),!0}catch{return!1}}
|
|
4
4
|
export{Jn,Ra,Ta,Ia,Da,fo,Oa,mo,Na,lr,Xn,go,Yn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g}from"./vm-hands-entry-lite-
|
|
2
|
+
import{g}from"./vm-hands-entry-lite-bj3w2ven.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var ss="so.ara.cli",w=[ss,"com.reasonmachines.cli"],$i="5LJFSBRY2F";function Mi(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${$i}"`}var Y="ReasonBackgroundIdentity",Ic="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=Mi([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=Mi(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${$i}"`;class vt extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var Tn="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function ot(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=ot(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function as(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))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 W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
|
|
3
3
|
`)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!W.test(i)&&H.has(o)){let a=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function cs(e){if(K(e.home),!d(e.sourceApp))throw new vt("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=ot(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new vt("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(Tn,["-f",e])!==0)throw new vt("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
|
|
5
5
|
`)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(Tn,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(Tn,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function ls(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(ot(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=ot(e),n=O(e);if(!d(t)||!N(t))try{Bi({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w,We}from"./vm-hands-entry-lite-q9s1e2y1.js";import{be,C}from"./vm-hands-entry-lite-
|
|
2
|
+
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w,We}from"./vm-hands-entry-lite-q9s1e2y1.js";import{be,C}from"./vm-hands-entry-lite-ht6hzkgj.js";import{q}from"./vm-hands-entry-lite-a6ss0ges.js";function lt(e,i){let t=P(e,"REASON_API_URL")?.trim();if(!t)return We(i);let n=new URL(t);if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(n.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return n.origin}function Gc(e){return P(e,"REASON_API_URL")?.trim()?lt(e,"production"):void 0}function Un(e){return P(e,"REASON_API_KEY")?.trim()||void 0}async function ir(e,i){let t=e.env??process.env,n=Un(t);if(!n)return(e.getCredentials??be)({apiOrigin:Gc(t),signal:i});let a=lt(t,e.channel??w({env:t})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+n,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),r=q(p)?p:{};if(!o.ok){let s=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:"API key authentication failed ("+o.status+")";throw new C(o.status,typeof r.error==="string"?r.error:"api_key_auth_failed",s)}if(typeof r.org_id!=="string"||!r.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let l=Array.isArray(r.scopes)?r.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:n,orgId:r.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:l}}export{lt,Gc,Un,ir};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var jn="--vm-hands-op-runner-kind=person",Hn="--vm-hands-op-runner-kind=surface",Fr="--vm-hands-surface-uid=",jr="--vm-hands-surface-dir=",Hr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-
|
|
2
|
+
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var jn="--vm-hands-op-runner-kind=person",Hn="--vm-hands-op-runner-kind=surface",Fr="--vm-hands-surface-uid=",jr="--vm-hands-surface-dir=",Hr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-vvt9d9xb.js"),import("./local-display-session-axh9mfdk.js"),import("./local-display-video-pxhztqk7.js"),import("./worker-preview-readiness-06tygyjs.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function sl(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-pwv76ns5.js"),import("./local-pty-session-edd8ttf9.js"),import("./desktop-account-eg8thn79.js"),import("./worker-sandbox-e1cpkzfz.js")]);y();let i=process.argv.includes(jn),s=process.argv.includes(Hn),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(Fr))?.slice(Fr.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-4mgqn7tg.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-4mgqn7tg.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(Hr.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(jr))?.slice(jr.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
|
|
3
3
|
export{jn,Hn,Fr,jr,Hr,sl};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{On}from"./vm-hands-entry-lite-
|
|
2
|
+
import{On}from"./vm-hands-entry-lite-xvccy3z4.js";var g=On.version,xr=`reason-cli/${g}`,Nc=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function El(r,c){if(!Nc.test(r)||!Nc.test(c))throw Error("cannot compare invalid CLI versions");let f=(t)=>{let e=t.indexOf("-");return e===-1?[t,void 0]:[t.slice(0,e),t.slice(e+1)]},[h,i]=f(r),[x,s]=f(c),u=h.split(".").map(BigInt),d=x.split(".").map(BigInt);for(let t=0;t<3;t+=1){if(u[t]===d[t])continue;return u[t]<d[t]?-1:1}if(i===void 0||s===void 0){if(i===s)return 0;return i===void 0?1:-1}let l=i.split("."),a=s.split("."),C=Math.max(l.length,a.length);for(let t=0;t<C;t+=1){let e=l[t],n=a[t];if(e===void 0||n===void 0){if(e===n)return 0;return e===void 0?-1:1}if(e===n)continue;let o=/^\d+$/.test(e),p=/^\d+$/.test(n);if(o&&p){let I=BigInt(e),m=BigInt(n);if(I===m)continue;return I<m?-1:1}if(o!==p)return o?-1:1;return e<n?-1:1}return 0}function us(r=Bun.main){return r.startsWith("/$bunfs/")||/^B:[\\/]~BUN[\\/]/i.test(r)}
|
|
3
3
|
export{g,xr,Nc,El,us};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{$i,Mi,vt,Yt,as,cs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{$i,Mi,vt,Yt,as,cs}from"./vm-hands-entry-lite-6jxshhps.js";import{rc,nc}from"./vm-hands-entry-lite-tcmye5ny.js";import{Ai,Pi,mn,yr,l,ac,Ri,cc,gn,Vt,_n}from"./vm-hands-entry-lite-vdv4nm5f.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{G}from"./vm-hands-entry-lite-8xv6c0rm.js";import{randomUUID as p}from"crypto";import{chmodSync as Z,closeSync as J,constants as C,existsSync as A,fstatSync as ke,lstatSync as h,mkdirSync as q,openSync as Ie,readFileSync as K,readdirSync as re,readlinkSync as w,realpathSync as T,renameSync as S,rmSync as I,statSync as V,symlinkSync as Q,unlinkSync as R,writeFileSync as U}from"fs";import{basename as H,dirname as E,isAbsolute as We,join as m,relative as Xe,resolve as M,sep as me}from"path";import{spawnSync as ee}from"child_process";import{createRequire as Te}from"module";var ae=1,xe=1,Ze=128,Qe=65536,Vc="https://reasonmachines.com/api/runtime-manifest-v2",et=30000,tt=600000,Ee=1e4,nt=60000,rt=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var Me=/^[a-z0-9_.-]{1,80}$/,it=64,at="so.ara.device-broker",Pe=[at,"com.reasonmachines.device-broker"],An=Mi(Pe),we=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory"],ot=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function W(e){if(e?.aborted)throw new l("update_cancelled","Managed runtime update request was cancelled.")}function fe(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function ge(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function b(e){return typeof e==="string"&&rt.test(e)}function De(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function st(e){return yr.includes(e)}function x(e){q(e,{recursive:!0,mode:448}),Z(e,448)}function Oe(e,t){x(E(e));let n=`${e}.${process.pid}.${p()}.tmp`;try{U(n,t,{mode:384,flag:"wx"}),Z(n,384),S(n,e)}finally{if(A(n))R(n)}}function Nt(e={}){if((e.platform??process.platform)!=="darwin")throw new l("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=P(n,"REASON_CLI_CHANNEL")==="staging",i=r?P(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&We(i))?null:m(e.home??s(),"Library","Application Support"),c=e.root??(o?m(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:c,...o?{legacyRoot:m(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:m(c,"versions"),current:m(c,"current"),previous:m(c,"previous"),brokerLock:m(c,"broker.lock"),transitionLock:m(c,"transition.lock"),lifecycleEvents:m(c,"lifecycle-events")}}function hl(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:m(t,"versions"),current:m(t,"current"),previous:m(t,"previous"),brokerLock:m(t,"broker.lock"),transitionLock:m(t,"transition.lock"),lifecycleEvents:m(t,"lifecycle-events")}}function F(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let n=m(e.versions,t,"ara");if(!e.executableName)return n;let r=m(e.versions,t,e.executableName),i=(c)=>{try{return h(c),!0}catch(d){if(d.code==="ENOENT")return!1;throw d}},a=i(n),o=i(r);if(a&&o)throw new l("installed_artifact_mismatch","Ambiguous managed runtime executable layout.");return a?n:r}function oe(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");return _e(F(e,t))}function _e(e){return m(E(e),H(e)==="reason"?Pi:Ai)}function Ce(e,t){if(!b(e)||!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let[n,r]=e.split("-",2),[i,a]=t.split("-",2),o=n.split(".").map(Number),c=i.split(".").map(Number);for(let _=0;_<3;_+=1){let g=o[_]-c[_];if(g!==0)return g<0?-1:1}if(r===void 0||a===void 0){if(r===a)return 0;return r===void 0?1:-1}let d=r.split("."),u=a.split("."),f=Math.max(d.length,u.length);for(let _=0;_<f;_+=1){let g=d[_],y=u[_];if(g===void 0||y===void 0){if(g===y)return 0;return g===void 0?-1:1}if(g===y)continue;let v=/^\d+$/.test(g),L=/^\d+$/.test(y);if(v&&L)return Number(g)<Number(y)?-1:1;if(v!==L)return v?-1:1;return g<y?-1:1}return 0}function ct(e=process.arch){let t=`darwin-${e}`;if(!st(t))throw new l("unsupported_architecture","The managed Reason runtime supports only Apple Silicon and Intel Macs.");return t}function Re(e){return[...e.matchAll(/<key>\s*([^<]+?)\s*<\/key>/g)].map((t)=>t[1].trim())}function pe(e){let t=e.match(/^CodeDirectory .*$/gm)??[];return t.length>0&&t.every((n)=>(/ flags=0x[0-9a-f]+\(([^)]*)\)(?: |$)/.exec(n)?.[1]?.split(/[ ,]+/).filter(Boolean)??[]).includes("runtime"))}function lt(e){let t=`TeamIdentifier=${$i}`,n=Pe.map((a)=>`Identifier=${a}`),r=Re(e.brokerEntitlements),i=Re(e.credentialLibraryEntitlements);if(!e.brokerDetail.split(`
|
|
3
3
|
`).includes(t)||!e.brokerDetail.split(`
|
|
4
4
|
`).some((a)=>n.includes(a))||!pe(e.brokerDetail)||r.length!==we.length||we.some((a)=>!new RegExp(`<key>\\s*${a.replaceAll(".","\\.")}\\s*</key>\\s*<true\\s*/>`).test(e.brokerEntitlements)))throw new l("invalid_code_signature","Managed runtime broker has an invalid Reason signature, identifier, or entitlement set.");if(!e.credentialLibraryDetail.split(`
|
|
5
5
|
`).includes(t)||!pe(e.credentialLibraryDetail)||i.length!==0)throw new l("invalid_code_signature","Managed runtime credential library has an invalid signature or entitlement.")}function D(e,t){let n=ee("/usr/bin/codesign",e,{stdio:["ignore","pipe","pipe"]});if(n.status!==0)throw new l("invalid_code_signature",t);return[new TextDecoder().decode(n.stdout??new Uint8Array),new TextDecoder().decode(n.stderr??new Uint8Array)].join("")}var ye=(e,t)=>{D(["--verify","--strict","--verbose=2",e],"Managed runtime broker code signature is invalid."),D(["--verify","--strict","--verbose=2",t],"Managed runtime credential library code signature is invalid."),lt({brokerDetail:D(["-d","--verbose=4",e],"Managed runtime broker signer could not be inspected."),brokerEntitlements:D(["-d","--entitlements",":-",e],"Managed runtime broker entitlements could not be inspected."),credentialLibraryDetail:D(["-d","--verbose=4",t],"Managed runtime credential library signer could not be inspected."),credentialLibraryEntitlements:D(["-d","--entitlements",":-",t],"Managed runtime credential library entitlements could not be inspected.")})};async function dt(e,t,n){let r=e.headers.get("content-length");if(r!==null){let f=Number(r);if(!Number.isSafeInteger(f)||f<0||f>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.")}if(!e.body){let f=new Uint8Array(await e.arrayBuffer());if(f.byteLength>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.");return f}let i=e.body.getReader(),a=[],o=0,c=()=>{if(!n)return i.read();return new Promise((f,_)=>{let g=()=>{n.removeEventListener("abort",g),i.cancel(n.reason).catch(()=>{}),_(n.reason??new DOMException("Aborted","AbortError"))};if(n.aborted){g();return}n.addEventListener("abort",g,{once:!0}),i.read().then((y)=>{n.removeEventListener("abort",g),f(y)},(y)=>{n.removeEventListener("abort",g),_(y)})})};try{while(!0){let f=await c();if(f.done)break;if(o+=f.value.byteLength,o>t)throw await i.cancel(),new l("response_too_large","Managed runtime response exceeded its size limit.");a.push(f.value)}}finally{try{i.releaseLock()}catch{}}let d=new Uint8Array(o),u=0;for(let f of a)d.set(f,u),u+=f.byteLength;return d}async function Wr(e){let t;try{t=new URL(e.url)}catch{throw new l("invalid_update_url","Managed runtime update URL is invalid.")}if(t.protocol!=="https:"||t.username||t.password||t.hash)throw new l("invalid_update_url","Managed runtime update URL must use HTTPS.");let n=new AbortController,r,i=()=>{r??="caller",n.abort(e.signal?.reason)};if(e.signal?.aborted)i();else e.signal?.addEventListener("abort",i,{once:!0});let a=setTimeout(()=>{r??="timeout",n.abort(Error("managed runtime fetch timed out"))},e.timeoutMs),o=(c,d)=>{if(c instanceof l)return c;if(r==="caller")return new l("update_cancelled","Managed runtime update request was cancelled.");if(r==="timeout")return new l("update_fetch_timeout","Managed runtime update request timed out.");return new l("update_fetch_failed",d)};try{let c;try{if(c=await e.fetchImpl(t,{headers:{accept:e.accept},signal:n.signal}),n.signal.aborted)throw o(n.signal.reason,"Managed runtime update request was cancelled.")}catch(d){throw o(d,"Managed runtime update request failed.")}if(!c.ok)throw new l("update_http_error","Managed runtime update request was rejected.");if(c.url&&new URL(c.url).protocol!=="https:")throw new l("insecure_redirect","Managed runtime update redirected to an insecure URL.");try{let d=await dt(c,e.maximumBytes,n.signal);if(n.signal.aborted)throw o(n.signal.reason,"Managed runtime update response was cancelled.");return d}catch(d){throw o(d,"Managed runtime update response failed.")}}finally{clearTimeout(a),e.signal?.removeEventListener("abort",i)}}async function Ve(e,t,n=Ee,r){let i=typeof n==="number"?n:Ee,a=typeof n==="number"?r:n;if(a?.aborted)return!1;let o=await rc([e,"--version"],{timeoutMs:i,...a?{signal:a}:{}});return o.exitCode===0&&o.stdout.trim().replace(/^v/,"")===t}async function ut(e){let t=!1,n=null,r=null,i=(a)=>{try{N(e.paths,a,{now:e.now})}catch{}};try{let a=e.home??s();if(!as(e.manifest.version,a))return{status:"current"};r=Yt(a);let o=await Wr({url:new URL(ac,e.manifest.artifacts[e.target].broker.url).toString(),maximumBytes:mn,fetchImpl:async(g,y)=>{let v=await e.fetchImpl(g,y);return t=v.status===404,v},timeoutMs:e.timeoutMs,accept:"application/json",signal:e.signal}),{manifest:c}=cc(new TextDecoder().decode(o),e.trustedKeys);if(c.version!==e.manifest.version||c.published_at!==e.manifest.published_at)throw new l("identity_manifest_mismatch","Background identity manifest names another release.");let d=c.artifacts[e.target],u=await Wr({url:d.url,maximumBytes:d.size_bytes,fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs,accept:"application/octet-stream",signal:e.signal});Vt(u,d),x(e.workDirectory),n=m(e.workDirectory,`.identity-${process.pid}-${p()}`),q(n,{mode:448});let f=m(n,"identity.tgz");if(U(f,u,{mode:384,flag:"wx"}),ee("/usr/bin/tar",["-xzf",f,"-C",n],{stdio:"ignore",timeout:60000}).status!==0)throw new l("identity_extract_failed","Background identity archive could not be extracted.");return cs({sourceApp:m(n,"Reason.app"),home:a,releaseSigned:!0,...e.command?{command:e.command}:{}}),i({event:"identity.refresh_completed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version}),{status:"installed"}}catch(a){if(t)return{status:"unpublished"};let o=a instanceof l||a instanceof vt?a.code:"identity_install_failed";return process.stderr.write(`Reason background identity: identity_update_failed (${o})
|