@reason-machines/cli-linux-x64 0.2.505 → 0.2.507
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/THIRD_PARTY_NOTICES.txt +8 -7
- package/bin/reason +2 -2
- package/bin/runtime/srt/sandbox-runtime.mjs +52 -52
- package/bin/vm-hands/api-credentials-q302458a.js +2 -0
- package/bin/vm-hands/api-e589y9e0.js +2 -0
- package/bin/vm-hands/connect-cli-zeqyjj5t.js +2 -0
- package/bin/vm-hands/credentials-drj5ktpt.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-j1x988g0.js +2 -0
- package/bin/vm-hands/desktop-account-4525j7h3.js +2 -0
- package/bin/vm-hands/device-workspace-pt07525s.js +2 -0
- package/bin/vm-hands/fsevents-8zxmv89w.js +2 -0
- package/bin/vm-hands/hands-worker-source-atg5dc7b.js +2 -0
- package/bin/vm-hands/index-ttmxy9nd.js +12818 -0
- package/bin/vm-hands/install-receipt-6v65enmf.js +2 -0
- package/bin/vm-hands/local-automation-43ry1qn6.js +2 -0
- package/bin/vm-hands/local-capabilities-e43ra579.js +2 -0
- package/bin/vm-hands/local-desktop-users-9dqayaej.js +2 -0
- package/bin/vm-hands/local-display-mac-fnp3317m.js +2 -0
- package/bin/vm-hands/local-display-session-9pm9ed2m.js +2 -0
- package/bin/vm-hands/local-display-video-xtjezayy.js +2 -0
- package/bin/vm-hands/local-managed-process-d179a1aq.js +2 -0
- package/bin/vm-hands/local-pty-session-5yh2a63r.js +2 -0
- package/bin/vm-hands/managed-runtime-mydc95fa.js +2 -0
- package/bin/vm-hands/network-contract-rzw769gw.js +2 -0
- package/bin/vm-hands/package-r7sgmw4t.js +2 -0
- package/bin/vm-hands/permissions-g919jepr.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-8fgk2s53.js +2 -0
- package/bin/vm-hands/serve-service-5twngyyg.js +2 -0
- package/bin/vm-hands/status-4da3v86c.js +10 -0
- package/bin/vm-hands/version-r5qbf8y9.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-2cf33ark.js +5 -0
- package/bin/vm-hands/{vm-hands-entry-lite-s8ty42st.js → vm-hands-entry-lite-2mskbtsd.js} +5 -9
- package/bin/vm-hands/vm-hands-entry-lite-38g65s5x.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-3ahrysca.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-3sjkzhf6.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-5gevvgec.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-5tbntcyq.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-6a96d80a.js +14 -0
- package/bin/vm-hands/vm-hands-entry-lite-6x1an7es.js +7 -0
- package/bin/vm-hands/vm-hands-entry-lite-7651j949.js +52 -0
- package/bin/vm-hands/vm-hands-entry-lite-7777m86y.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-b7wy89y0.js → vm-hands-entry-lite-77j164ps.js} +54 -54
- package/bin/vm-hands/vm-hands-entry-lite-7v1rd0sk.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-87vmbt38.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-8wcyveeh.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-b4q5e57n.js +105 -0
- package/bin/vm-hands/vm-hands-entry-lite-bnxh4ax9.js +452 -0
- package/bin/vm-hands/vm-hands-entry-lite-eabever7.js +112 -0
- package/bin/vm-hands/vm-hands-entry-lite-ewr54tpc.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-f62fvme8.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-f69t48dj.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-8p8hz0j1.js → vm-hands-entry-lite-fcvf8md1.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-gvjffc5t.js +65 -0
- package/bin/vm-hands/vm-hands-entry-lite-hmaazqdr.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-mcjca0ez.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-mk5ayds8.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ncbzy69k.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-np07qyeq.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-nqdstx24.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-psywfz8m.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-qpdpzg8g.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-qxq147a5.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-qy9xg6em.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ra8c0ytm.js +128 -0
- package/bin/vm-hands/{vm-hands-entry-lite-xd2dn3n8.js → vm-hands-entry-lite-rfz60hb3.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-rn2rhavz.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-rzr2ncf5.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-swrymqj9.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-tebh7dcm.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-txd50spx.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-v6yygjyx.js +126 -0
- package/bin/vm-hands/vm-hands-entry-lite-v9engyp5.js +539 -0
- package/bin/vm-hands/vm-hands-entry-lite-v9qq2cgv.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-vrenpefs.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-vtc8mjpc.js +9 -0
- package/bin/vm-hands/{vm-hands-entry-lite-c8bf82tx.js → vm-hands-entry-lite-wrvz9jxy.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-x39tmj7j.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-znd9c7x0.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +3 -1
- package/bin/vm-hands/vm-hands-executor-68r7m0z1.js +12 -0
- package/bin/vm-hands/vm-hands-op-runner-gppbedw9.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-w2fb9gsk.js +4 -0
- package/bin/vm-hands/worker-preview-readiness-7xtgxsar.js +2 -0
- package/bin/vm-hands/worker-sandbox-s9pyac8p.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-23k36ayh.js +0 -2
- package/bin/vm-hands/api-jd29p2kc.js +0 -2
- package/bin/vm-hands/ask-relay-zpp0rkhg.js +0 -4
- package/bin/vm-hands/connect-cli-xyxgcg6z.js +0 -2
- package/bin/vm-hands/credentials-byna24dv.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-p2agcsk0.js +0 -2
- package/bin/vm-hands/desktop-account-z16mmkxg.js +0 -2
- package/bin/vm-hands/device-workspace-y0tk3ne8.js +0 -2
- package/bin/vm-hands/hands-worker-source-0qa16xzj.js +0 -2
- package/bin/vm-hands/index-h6xkz48h.js +0 -12818
- package/bin/vm-hands/install-receipt-nnragt7p.js +0 -2
- package/bin/vm-hands/local-automation-xbpca0f3.js +0 -2
- package/bin/vm-hands/local-capabilities-30m8pzpv.js +0 -2
- package/bin/vm-hands/local-desktop-users-gxfywsan.js +0 -2
- package/bin/vm-hands/local-display-mac-n236gkpe.js +0 -2
- package/bin/vm-hands/local-display-session-ddafdm8k.js +0 -2
- package/bin/vm-hands/local-display-video-gha54xwa.js +0 -2
- package/bin/vm-hands/local-managed-process-0zwxyqxd.js +0 -2
- package/bin/vm-hands/local-pty-session-w1yrmjm0.js +0 -2
- package/bin/vm-hands/managed-runtime-8y90twae.js +0 -2
- package/bin/vm-hands/network-contract-v0fkg94d.js +0 -2
- package/bin/vm-hands/network-sign-in-3dkdkh3a.js +0 -34
- package/bin/vm-hands/package-z2dk6xva.js +0 -2
- package/bin/vm-hands/permissions-ga1ax8wd.js +0 -2
- package/bin/vm-hands/reason-hands-protocol-vzgxd159.js +0 -2
- package/bin/vm-hands/serve-service-42nqanvr.js +0 -2
- package/bin/vm-hands/status-m0g7k47a.js +0 -96
- package/bin/vm-hands/version-ye6800p2.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-00y3kn86.js +0 -7
- package/bin/vm-hands/vm-hands-entry-lite-0572m6cr.js +0 -344
- package/bin/vm-hands/vm-hands-entry-lite-07q2xvk1.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-0a4cy8gw.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-1nj03gbj.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-26xb026c.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-33h8294z.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-3882raa5.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-3rg3znp8.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-4swa18qz.js +0 -10
- package/bin/vm-hands/vm-hands-entry-lite-56v9haps.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-6x5pj2y0.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-8twscwtw.js +0 -112
- package/bin/vm-hands/vm-hands-entry-lite-8xe0wzp9.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-ah2ep922.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-b0p8f295.js +0 -52
- package/bin/vm-hands/vm-hands-entry-lite-c5gt0086.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-dgmap6z4.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-dhqmbqsh.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-e1xjfj57.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-e4hwb89r.js +0 -66
- package/bin/vm-hands/vm-hands-entry-lite-g6r5xrk0.js +0 -105
- package/bin/vm-hands/vm-hands-entry-lite-ghhpgt3v.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-h5smacqn.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-jd31as70.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-k9n1pk42.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-kqbats5n.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-p9fwt68c.js +0 -42
- package/bin/vm-hands/vm-hands-entry-lite-pkk555dx.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-pmw3ycgc.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-q9g11dbj.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-r374pchj.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-r665z809.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-rck5h8fr.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-rj8yq6gp.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-s8zfzv0k.js +0 -6
- package/bin/vm-hands/vm-hands-entry-lite-tafgty5k.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-tbdcmq09.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-td309c1y.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-v0bp1v66.js +0 -128
- package/bin/vm-hands/vm-hands-entry-lite-v0k8b768.js +0 -452
- package/bin/vm-hands/vm-hands-entry-lite-v4r1fggm.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-vqr3zrqr.js +0 -539
- package/bin/vm-hands/vm-hands-entry-lite-wbfmc0xn.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-x3pbyg92.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-yqn8h1p0.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-zj3hb5jk.js +0 -127
- package/bin/vm-hands/vm-hands-entry-lite-zz8tr0bm.js +0 -12
- package/bin/vm-hands/vm-hands-executor-6tncheya.js +0 -12
- package/bin/vm-hands/vm-hands-op-runner-s1ghsym7.js +0 -2
- package/bin/vm-hands/vm-hands-runtime-k6egwk2t.js +0 -4
- package/bin/vm-hands/worker-preview-readiness-wh0yg1dz.js +0 -2
- package/bin/vm-hands/worker-sandbox-s054x4zw.js +0 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{_}from"./vm-hands-entry-lite-nqdstx24.js";import{Kr,ei,Jr,ti}from"./vm-hands-entry-lite-hmaazqdr.js";import{Xn,Yt,Io}from"./vm-hands-entry-lite-vtc8mjpc.js";import{C}from"./vm-hands-entry-lite-87vmbt38.js";import{spawnSync as y}from"child_process";import{createHash as ke,randomUUID as Se}from"crypto";import{chmodSync as we,existsSync as P,mkdirSync as $e,readdirSync as Ve,readFileSync as p,renameSync as ye,rmSync as u,statSync as ve,writeFileSync as be}from"fs";import{dirname as We,isAbsolute as q,join as g}from"path";import{spawnSync as de}from"child_process";import{readFileSync as me}from"fs";import{userInfo as D}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function H(r){return fe(r,"AppData","Local","Reason","Tasks")}function S(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function M(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${S(r)};`}function K(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${S(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(S).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${S(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[M(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function A(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${D().username}`:D().username}function U(r){let e=A(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
|
|
3
|
+
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
4
|
+
<RegistrationInfo>
|
|
5
|
+
<Description>${A(r.description)}</Description>
|
|
6
|
+
</RegistrationInfo>
|
|
7
|
+
<Triggers>
|
|
8
|
+
${t}
|
|
9
|
+
</Triggers>
|
|
10
|
+
<Principals>
|
|
11
|
+
<Principal id="Author">
|
|
12
|
+
<UserId>${e}</UserId>
|
|
13
|
+
<LogonType>InteractiveToken</LogonType>
|
|
14
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
15
|
+
</Principal>
|
|
16
|
+
</Principals>
|
|
17
|
+
<Settings>
|
|
18
|
+
<MultipleInstancesPolicy>${n?"StopExisting":"IgnoreNew"}</MultipleInstancesPolicy>
|
|
19
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
20
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
21
|
+
<StartWhenAvailable>true</StartWhenAvailable>
|
|
22
|
+
<IdleSettings>
|
|
23
|
+
<StopOnIdleEnd>false</StopOnIdleEnd>
|
|
24
|
+
<RestartOnIdle>false</RestartOnIdle>
|
|
25
|
+
</IdleSettings>
|
|
26
|
+
<ExecutionTimeLimit>${n?"PT0S":"PT1H"}</ExecutionTimeLimit>
|
|
27
|
+
<Priority>${n?5:7}</Priority>
|
|
28
|
+
</Settings>
|
|
29
|
+
<Actions Context="Author">
|
|
30
|
+
<Exec>
|
|
31
|
+
<Command>%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe</Command>
|
|
32
|
+
<Arguments>${A(i)}</Arguments>
|
|
33
|
+
</Exec>
|
|
34
|
+
</Actions>
|
|
35
|
+
</Task>
|
|
36
|
+
`}function B(r){return Buffer.concat([Buffer.from([255,254]),Buffer.from(r.replaceAll(`\r
|
|
37
|
+
`,`
|
|
38
|
+
`).replaceAll(`
|
|
39
|
+
`,`\r
|
|
40
|
+
`),"utf16le")])}function V(r){let e=me(r);return(e[0]===255&&e[1]===254?e.subarray(2).toString("utf16le"):e.toString("utf8")).replaceAll(`\r
|
|
41
|
+
`,`
|
|
42
|
+
`)}function j(r,e){return["/Create","/TN",r,"/XML",e,"/F"]}function I(r){return["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(r,"utf16le").toString("base64")]}function x(r){return`'*${M(r).replaceAll("'","''")}*'`}function E(r,e){return I(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${x(r)} })`,...e.keepWrapper?[]:["foreach ($w in $wrappers) { Stop-Process -Id $w.ProcessId -Force -ErrorAction SilentlyContinue }"],`foreach ($w in $wrappers) { $all | ? { $_.ParentProcessId -eq $w.ProcessId } | % { taskkill.exe /F ${e.tree?"/T ":""}/PID $_.ProcessId | Out-Null } }`].join(`
|
|
43
|
+
`))}function F(r){return I(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${x(r)} })`,"foreach ($w in $wrappers) { if ($all | ? { $_.ParentProcessId -eq $w.ProcessId -and $_.Name -ne 'conhost.exe' }) { 'running'; exit 0 } }","exit 1"].join(`
|
|
44
|
+
`))}function X(r,e=process.pid){let n=de(C("powershell.exe"),I(["$all = @{}; Get-CimInstance Win32_Process | % { $all[[int]$_.ProcessId] = $_ }",`$p = $all[${Math.trunc(e)}]`,"for ($i = 0; $p -and $i -lt 64; $i++) {",` if ($p.CommandLine -like ${x(r)}) { exit 10 }`," $n = $all[[int]$p.ParentProcessId]"," if (-not $n -or $n.ProcessId -eq $p.ProcessId -or $n.CreationDate -gt $p.CreationDate) { exit 11 }"," $p = $n","}","exit 11"].join(`
|
|
45
|
+
`)),{stdio:"ignore",timeout:15000,windowsHide:!0});return n.status===10?!0:n.status===11?!1:null}var qr="REASON_WORKER_SERVICE",Ae="worker_identity_unavailable";function xe(r){return{platform:process.platform,home:r,uid:process.getuid?.(),command:(e,n)=>y(C(e),[...n],{stdio:"ignore"}).status??1,read:(e,n)=>{let t=y(C(e),[...n],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return t.status===0?t.stdout:null},sleep:(e)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e),workerIdentity:(e)=>Io(r,e),insideService:(e,n)=>Ie(e,process.platform,process.getuid?.(),n)}}function Ie(r,e,n,t=!0){if(process.env[qr]===r||process.env.XPC_SERVICE_NAME===r)return!0;if(e==="linux")try{return p("/proc/self/cgroup","utf8").includes(`/${r}.service`)}catch{return!0}if(e==="win32")return X(r)??t;if(e!=="darwin")return!1;if(typeof n!=="number")return!0;let i=y("/bin/launchctl",["print",`gui/${n}/${r}`],{encoding:"utf8",timeout:5000});if(i.status===Ee)return!1;if(i.error||i.status!==0)return!0;let s=Number(/^\s*pid = (\d+)$/m.exec(i.stdout??"")?.[1]??0);if(!s)return!1;let a=process.pid;for(let o=0;o<64&&a>1;o+=1){if(a===s)return!0;let l=y("/bin/ps",["-o","ppid=","-p",String(a)],{encoding:"utf8",timeout:5000}),c=Number(l.stdout?.trim());if(l.error||l.status!==0||!Number.isSafeInteger(c)||c<=0)return!0;if(c===a)return!1;a=c}return a>1}var Ee=113;class J extends Error{code;constructor(r,e){super(r);this.code=e}}function Jn(r,e){if(!re(r.home,r.platform))throw new J(ee);if(r.platform==="darwin")k(r);let n=ti(Kr(e,r.home)),t=_({env:e})==="staging",i=t?"ara-staging":"ara",s=[n?ei(n):null,T(e,"REASON_CLI_LAUNCHER_PATH")?.trim(),r.platform==="win32"?g(r.home,"AppData","Local","Reason",...t?["staging"]:[],"bin",t?"reason-staging.exe":"reason.exe"):g(r.home,".local","bin",i)];for(let a of s)try{if(a&&q(a)&&ve(a).isFile())return Jr(a)}catch{}throw new J(`A background service runs the installed Reason launcher, which was not found. Install Reason with: ${r.platform==="win32"?"irm https://reasonmachines.com/install.ps1 | iex":"curl -fsSL https://reasonmachines.com/install | sh"}`,"worker_launcher_missing")}var R=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,w=new RegExp(`(\\n\\s*<key>${Yt}</key>\\s*<string>)[^<]*(</string>)`),_e=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function Te(r){return r.replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("&","&")}function Y(r){let e=[...(R.exec(r)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((t)=>Te(t[1])),n=e[1]==="--run-worker"?e.slice(2):e;return n[0]?{launcher:n[0],args:n.slice(1)}:null}function z(r,e,n){let t=n.workerIdentity?.(r)??null;return{program:t?[t.executable,"--run-worker",r,...e]:[r,...e],identity:t}}function h(r){return r.map((e)=>` <string>${d(e)}</string>`).join(`
|
|
46
|
+
`)}function Z(r,e){let n;try{n=p(r,"utf8")}catch{return null}let t=Y(n);if(!t)return null;let i=q(t.launcher)?Jr(t.launcher):t.launcher,{program:s,identity:a}=z(i,t.args,e),o=n.replace(R,(l,c,m,O)=>`${c}${h(s)}
|
|
47
|
+
${O}`);if(!a)o=o.replace(w,"");else if(w.test(o))o=o.replace(w,(l,c,m)=>`${c}${d(a.app)}${m}`);else o=o.replace(_e,(l,c,m)=>`${c}
|
|
48
|
+
<key>${Yt}</key>
|
|
49
|
+
<string>${d(a.app)}</string>${m}`);return o===n?null:o}function Pe(r,e){let n=Z(r,e);if(n!==null)W(r,n)}function Hs(r,e,n){if(e.platform!=="darwin")return!1;let t=Ye(r,e,n);return t!==null&&Z(t.definition,e)!==null}var b="com.reasonmachines.worker.",N="so.reason.worker.",Q=[b,N];function Ao(r,e=b){return`${e}connect${r==="production"?"":`.${r}`}`}function zs(r,e){return Q.some((n)=>r===Ao(e,n))}function Re(r,e,n){if(e==="connect")return Ao(r.channel,n);let t=ke("sha256").update(r.workspaceRoot).digest("hex").slice(0,8);return`${n}${r.name.toLowerCase()}.${t}`}var ee="A background service needs macOS (launchd), Linux (systemd --user) or Windows (Task Scheduler).";function re(r,e){if(e==="darwin")return{directory:g(r,"Library","LaunchAgents"),suffix:".plist"};if(e==="linux")return{directory:g(r,".config","systemd","user"),suffix:".service"};if(e==="win32")return{directory:H(r),suffix:".xml"};return null}function f(r,e,n,t=b){let i=Re(r,n,t),s=re(e.home,e.platform);if(!s)return null;return{label:i,definition:g(s.directory,`${i}${s.suffix}`),logs:e.platform==="linux"?`journalctl --user -u ${i}.service`:g(r.stateDirectory,"service.log")}}function Ye(r,e,n="serve"){return ne(r,e,n)[0]??null}function ne(r,e,n){return Q.map((t)=>f(r,e,n,t)).filter((t)=>t!==null&&P(t.definition))}function te(r,e,n){let t=f(r,e,n,N);return t&&P(t.definition)?t:null}function is(r,e,n){let t=f(r,e,n),i=te(r,e,n);if(!t||!i||!P(t.definition)||e.insideService?.(i.label))return null;if(!Ce(t,e))return"current_not_running";if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);return u(i.definition,{force:!0}),"retired"}if(e.platform==="win32")return v(i,e,!0),"retired";return e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),"retired"}function Ce(r,e){if(e.platform==="darwin")return typeof e.uid==="number"&&e.uid>0&&e.command("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`])===0;if(e.platform==="win32")return e.command("schtasks",["/Query","/TN",r.label])===0;let n=`${r.label}.service`;return e.command("systemctl",["--user","is-enabled","--quiet",n])===0&&he.has(e.read("systemctl",["--user","show","--property=ActiveState","--value",n])?.trim()??"")}var he=new Set(["active","activating","reloading"]);function Zn(r,e){if(e.platform==="darwin"){if(typeof e.uid!=="number"||e.uid<=0)return!1;let n=e.read("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`]);return Number(/^\s*pid = (\d+)$/m.exec(n??"")?.[1]??0)>0}if(e.platform==="win32")return e.read("powershell.exe",F(r.label))?.trim()==="running";return Number(e.read("systemctl",["--user","show","--property=MainPID","--value",`${r.label}.service`])?.trim()??0)>0}function qs(r){let{config:e,launcher:n,host:t,kind:i}=r,s=f(e,t,i);if(!s)return!1;let a;try{a=t.platform==="win32"?V(s.definition):p(s.definition,"utf8")}catch{return!1}if(t.platform==="win32")return a===se(e,i,s,n);if(t.platform!=="darwin")return a===oe(e,i,s,n,t.home,r.path);let o=Y(a);return a.replace(w,"").replace(R,(c,m,O,ue)=>`${m}${o?`${h([o.launcher,...o.args])}
|
|
50
|
+
`:""}${ue}`)===ie(e,i,s,n,{...t,workerIdentity:()=>null},r.path).plist}function L(r,e){if(e==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:r.channel},description:"Reason connection of this computer"};return{args:["serve",r.name,"--dir",r.workspaceRoot,...r.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${r.name} worker`}}function d(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function G(r,e=!1){if(/[\0-\x1f\x7f]/.test(r))throw new J("A background service cannot use a path with control characters.");let n=r.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${e?n.replaceAll("$","$$$$"):n}"`}function ie(r,e,n,t,i,s){let a=L(r,e),o=z(t,a.args,i),l={HOME:i.home,PATH:s,[qr]:n.label,...a.environment,...o.identity?{[Yt]:o.identity.app}:{}};return{identity:o.identity,plist:`<?xml version="1.0" encoding="UTF-8"?>
|
|
51
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
52
|
+
<plist version="1.0">
|
|
53
|
+
<dict>
|
|
54
|
+
<key>Label</key>
|
|
55
|
+
<string>${d(n.label)}</string>
|
|
56
|
+
<key>AssociatedBundleIdentifiers</key>
|
|
57
|
+
<array>
|
|
58
|
+
<string>${Xn}</string>
|
|
59
|
+
</array>
|
|
60
|
+
<key>ProgramArguments</key>
|
|
61
|
+
<array>
|
|
62
|
+
${h(o.program)}
|
|
63
|
+
</array>
|
|
64
|
+
<key>EnvironmentVariables</key>
|
|
65
|
+
<dict>
|
|
66
|
+
${Object.entries(l).map(([c,m])=>` <key>${c}</key>
|
|
67
|
+
<string>${d(m)}</string>`).join(`
|
|
68
|
+
`)}
|
|
69
|
+
</dict>
|
|
70
|
+
<key>RunAtLoad</key>
|
|
71
|
+
<true/>
|
|
72
|
+
<key>KeepAlive</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>SuccessfulExit</key>
|
|
75
|
+
<false/>
|
|
76
|
+
</dict>
|
|
77
|
+
<key>ThrottleInterval</key>
|
|
78
|
+
<integer>10</integer>
|
|
79
|
+
<key>ExitTimeOut</key>
|
|
80
|
+
<integer>${Math.ceil(r.shutdownGraceMs/1000)+10}</integer>
|
|
81
|
+
<key>ProcessType</key>
|
|
82
|
+
<string>Standard</string>
|
|
83
|
+
<key>Umask</key>
|
|
84
|
+
<integer>63</integer>
|
|
85
|
+
<key>StandardOutPath</key>
|
|
86
|
+
<string>${d(n.logs)}</string>
|
|
87
|
+
<key>StandardErrorPath</key>
|
|
88
|
+
<string>${d(n.logs)}</string>
|
|
89
|
+
</dict>
|
|
90
|
+
</plist>
|
|
91
|
+
`}}function oe(r,e,n,t,i,s){let a=L(r,e);return`[Unit]
|
|
92
|
+
Description=${a.description}
|
|
93
|
+
|
|
94
|
+
[Service]
|
|
95
|
+
ExecStart=${[t,...a.args].map((o)=>G(o,!0)).join(" ")}
|
|
96
|
+
Environment=${[`HOME=${i}`,`PATH=${s}`,`${qr}=${n.label}`,...Object.entries(a.environment).map(([o,l])=>`${o}=${l}`)].map((o)=>G(o)).join(" ")}
|
|
97
|
+
Restart=on-failure
|
|
98
|
+
RestartSec=10
|
|
99
|
+
TimeoutStopSec=${Math.ceil(r.shutdownGraceMs/1000)+10}
|
|
100
|
+
UMask=0077
|
|
101
|
+
|
|
102
|
+
[Install]
|
|
103
|
+
WantedBy=default.target
|
|
104
|
+
`}function se(r,e,n,t){let i=L(r,e);return U({description:i.description,schedule:"logon",script:K({name:n.label,program:t,args:i.args,environment:{[qr]:n.label,...i.environment},log:n.logs,keepAlive:!0})})}function ae(r,e,n){e.command("powershell.exe",E(r.label,{tree:n,keepWrapper:!n}))}function v(r,e,n){e.command("schtasks",["/Delete","/F","/TN",r.label]),e.command("powershell.exe",E(r.label,{tree:n,keepWrapper:!1})),u(r.definition,{force:!0})}function W(r,e){$e(We(r),{recursive:!0,mode:448});let n=`${r}.${Se()}.tmp`;try{be(n,e,{mode:384,flag:"wx"}),we(n,384),ye(n,r)}finally{u(n,{force:!0})}}function k(r){if(typeof r.uid!=="number"||!Number.isSafeInteger(r.uid)||r.uid<=0)throw new J("Set up a background service as your own user, not with sudo.","worker_service_root_user");return`gui/${r.uid}`}function Ws(r){let{config:e,launcher:n,host:t}=r,i=r.kind??"serve",s=te(e,t,i),a=s!==null&&t.insideService?.(s.label)===!0,o=f(e,t,i,a?N:b);if(!o)throw new J(ee);if(t.platform==="darwin")k(t);if(t.platform==="linux"&&t.command("systemctl",["--user","show-environment"])!==0)throw new J("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let l=t.platform==="darwin"?ie(e,i,o,n,t,r.path):null;if(W(o.definition,l?l.plist:t.platform==="win32"?B(se(e,i,o,n)):oe(e,i,o,n,t.home,r.path)),le(e,t,o,a?null:s),l)return l.identity?o:{...o,identityProblem:Ae};if(t.platform==="win32")return o;return{...o,lingering:t.command("loginctl",["enable-linger"])===0}}function le(r,e,n,t){if(e.platform==="darwin"){let a=k(e);if(t)e.command("/bin/launchctl",["bootout",`${a}/${t.label}`]);if(ce(r,n,e)){if(t)u(t.definition,{force:!0});return}if(u(n.definition,{force:!0}),t)e.command("/bin/launchctl",["bootstrap",a,t.definition]);throw new J("Could not start the background service (launchctl bootstrap failed).","worker_service_start_failed")}if(e.platform==="win32"){if(t)v(t,e,!0);if(e.command("schtasks",j(n.label,n.definition))===0){if(ae(n,e,e.insideService?.(n.label)!==!0),e.command("schtasks",["/Run","/TN",n.label])===0)return}throw v(n,e,!0),new J("Could not start the background service (schtasks failed).")}let i=`${n.label}.service`,s=t?`${t.label}.service`:null;if(e.command("systemctl",["--user","daemon-reload"])!==0||s!==null&&e.command("systemctl",["--user","disable","--now",s])!==0||e.command("systemctl",["--user","enable",i])!==0||e.command("systemctl",["--user","restart",i])!==0){if(e.command("systemctl",["--user","disable",i]),u(n.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),s)e.command("systemctl",["--user","enable","--now",s]);throw new J("Could not start the background service (systemctl --user failed).","worker_service_start_failed")}if(t)u(t.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function ce(r,e,n){let t=k(n);n.command("/bin/launchctl",["bootout",`${t}/${e.label}`]);let i=(Math.ceil(r.shutdownGraceMs/1000)+10)*1000;for(let s=0,a=100;;a=Math.min(a*2,2000)){if(n.command("/bin/launchctl",["bootstrap",t,e.definition])===0)return!0;if(s>=i)return!1;n.sleep(a),s+=a}}function Wr(r,e,n){let t=Ye(r,e,n);if(!t)return null;let i=e.insideService?.(t.label)===!0;if(e.platform==="darwin"&&!i)Pe(t.definition,e);let s=f(r,e,n);if(s&&t.label!==s.label&&!i)return W(s.definition,p(t.definition,"utf8").replaceAll(t.label,s.label)),le(r,e,s,t),s;let a=e.platform==="darwin"&&i,o;if(e.platform==="win32")ae(t,e,!i),o=e.command("schtasks",["/Run","/TN",t.label])===0;else if(a)o=e.command("/bin/launchctl",["kickstart","-k",`${k(e)}/${t.label}`])===0;else if(e.platform==="darwin")o=ce(r,t,e);else e.command("systemctl",["--user","enable",`${t.label}.service`]),o=e.command("systemctl",["--user","restart",`${t.label}.service`])===0;if(!o)throw new J(`Could not restart the background service ${t.label}.`,"worker_service_restart_failed");if(s&&t.label===s.label)is(r,e,n);return t}function Vs(r,e,n,t){let i=Ye(r,n,t),s=f(e,n,t);if(n.platform!=="darwin"||!i||!s)return;let a=`<string>${d(i.logs)}</string>`,o=p(i.definition,"utf8");if(o.includes(a))W(i.definition,o.replaceAll(a,`<string>${d(s.logs)}</string>`))}function Gs(r,e,n="serve"){let t=ne(r,e,n);for(let i of t){if(e.platform==="win32"){v(i,e,e.insideService?.(i.label,!1)!==!0);continue}if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);u(i.definition,{force:!0});continue}e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}return t[0]??null}
|
|
105
|
+
export{qr,xe,J,Jn,Hs,Ao,zs,Ye,is,Zn,qs,Ws,Wr,Vs,Gs};
|