@reason-machines/cli-linux-x64 0.2.504 → 0.2.505

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.
Files changed (167) hide show
  1. package/THIRD_PARTY_NOTICES.txt +7 -8
  2. package/bin/reason +2 -2
  3. package/bin/runtime/srt/sandbox-runtime.mjs +52 -52
  4. package/bin/vm-hands/api-credentials-23k36ayh.js +2 -0
  5. package/bin/vm-hands/api-jd29p2kc.js +2 -0
  6. package/bin/vm-hands/ask-relay-zpp0rkhg.js +4 -0
  7. package/bin/vm-hands/connect-cli-xyxgcg6z.js +2 -0
  8. package/bin/vm-hands/credentials-byna24dv.js +2 -0
  9. package/bin/vm-hands/custom-endpoint-device-p2agcsk0.js +2 -0
  10. package/bin/vm-hands/desktop-account-z16mmkxg.js +2 -0
  11. package/bin/vm-hands/device-workspace-y0tk3ne8.js +2 -0
  12. package/bin/vm-hands/hands-worker-source-0qa16xzj.js +2 -0
  13. package/bin/vm-hands/index-h6xkz48h.js +12818 -0
  14. package/bin/vm-hands/install-receipt-nnragt7p.js +2 -0
  15. package/bin/vm-hands/local-automation-xbpca0f3.js +2 -0
  16. package/bin/vm-hands/local-capabilities-30m8pzpv.js +2 -0
  17. package/bin/vm-hands/local-desktop-users-gxfywsan.js +2 -0
  18. package/bin/vm-hands/local-display-mac-n236gkpe.js +2 -0
  19. package/bin/vm-hands/local-display-session-ddafdm8k.js +2 -0
  20. package/bin/vm-hands/local-display-video-gha54xwa.js +2 -0
  21. package/bin/vm-hands/local-managed-process-0zwxyqxd.js +2 -0
  22. package/bin/vm-hands/local-pty-session-w1yrmjm0.js +2 -0
  23. package/bin/vm-hands/managed-runtime-8y90twae.js +2 -0
  24. package/bin/vm-hands/network-contract-v0fkg94d.js +2 -0
  25. package/bin/vm-hands/network-sign-in-3dkdkh3a.js +34 -0
  26. package/bin/vm-hands/package-z2dk6xva.js +2 -0
  27. package/bin/vm-hands/permissions-ga1ax8wd.js +2 -0
  28. package/bin/vm-hands/reason-hands-protocol-vzgxd159.js +2 -0
  29. package/bin/vm-hands/serve-service-42nqanvr.js +2 -0
  30. package/bin/vm-hands/status-m0g7k47a.js +96 -0
  31. package/bin/vm-hands/version-ye6800p2.js +2 -0
  32. package/bin/vm-hands/vm-hands-entry-lite-00y3kn86.js +7 -0
  33. package/bin/vm-hands/vm-hands-entry-lite-0572m6cr.js +344 -0
  34. package/bin/vm-hands/vm-hands-entry-lite-07q2xvk1.js +5 -0
  35. package/bin/vm-hands/vm-hands-entry-lite-0a4cy8gw.js +5 -0
  36. package/bin/vm-hands/vm-hands-entry-lite-1nj03gbj.js +4 -0
  37. package/bin/vm-hands/vm-hands-entry-lite-26xb026c.js +3 -0
  38. package/bin/vm-hands/vm-hands-entry-lite-33h8294z.js +3 -0
  39. package/bin/vm-hands/vm-hands-entry-lite-3882raa5.js +3 -0
  40. package/bin/vm-hands/vm-hands-entry-lite-3rg3znp8.js +3 -0
  41. package/bin/vm-hands/vm-hands-entry-lite-4swa18qz.js +10 -0
  42. package/bin/vm-hands/vm-hands-entry-lite-56v9haps.js +3 -0
  43. package/bin/vm-hands/vm-hands-entry-lite-6x5pj2y0.js +4 -0
  44. package/bin/vm-hands/{vm-hands-entry-lite-fcvf8md1.js → vm-hands-entry-lite-8p8hz0j1.js} +2 -2
  45. package/bin/vm-hands/vm-hands-entry-lite-8twscwtw.js +112 -0
  46. package/bin/vm-hands/vm-hands-entry-lite-8xe0wzp9.js +3 -0
  47. package/bin/vm-hands/vm-hands-entry-lite-ah2ep922.js +4 -0
  48. package/bin/vm-hands/vm-hands-entry-lite-b0p8f295.js +52 -0
  49. package/bin/vm-hands/{vm-hands-entry-lite-77j164ps.js → vm-hands-entry-lite-b7wy89y0.js} +54 -54
  50. package/bin/vm-hands/vm-hands-entry-lite-c5gt0086.js +3 -0
  51. package/bin/vm-hands/{vm-hands-entry-lite-wrvz9jxy.js → vm-hands-entry-lite-c8bf82tx.js} +2 -2
  52. package/bin/vm-hands/vm-hands-entry-lite-dgmap6z4.js +5 -0
  53. package/bin/vm-hands/vm-hands-entry-lite-dhqmbqsh.js +9 -0
  54. package/bin/vm-hands/vm-hands-entry-lite-e1xjfj57.js +3 -0
  55. package/bin/vm-hands/vm-hands-entry-lite-e4hwb89r.js +66 -0
  56. package/bin/vm-hands/vm-hands-entry-lite-g6r5xrk0.js +105 -0
  57. package/bin/vm-hands/vm-hands-entry-lite-ghhpgt3v.js +3 -0
  58. package/bin/vm-hands/vm-hands-entry-lite-h5smacqn.js +3 -0
  59. package/bin/vm-hands/vm-hands-entry-lite-jd31as70.js +3 -0
  60. package/bin/vm-hands/vm-hands-entry-lite-k9n1pk42.js +4 -0
  61. package/bin/vm-hands/vm-hands-entry-lite-kqbats5n.js +3 -0
  62. package/bin/vm-hands/vm-hands-entry-lite-p9fwt68c.js +42 -0
  63. package/bin/vm-hands/vm-hands-entry-lite-pkk555dx.js +3 -0
  64. package/bin/vm-hands/vm-hands-entry-lite-pmw3ycgc.js +5 -0
  65. package/bin/vm-hands/vm-hands-entry-lite-q9g11dbj.js +3 -0
  66. package/bin/vm-hands/vm-hands-entry-lite-r374pchj.js +9 -0
  67. package/bin/vm-hands/vm-hands-entry-lite-r665z809.js +4 -0
  68. package/bin/vm-hands/vm-hands-entry-lite-rck5h8fr.js +3 -0
  69. package/bin/vm-hands/vm-hands-entry-lite-rj8yq6gp.js +3 -0
  70. package/bin/vm-hands/{vm-hands-entry-lite-c11fg8gx.js → vm-hands-entry-lite-s8ty42st.js} +9 -5
  71. package/bin/vm-hands/vm-hands-entry-lite-s8zfzv0k.js +6 -0
  72. package/bin/vm-hands/vm-hands-entry-lite-tafgty5k.js +4 -0
  73. package/bin/vm-hands/vm-hands-entry-lite-tbdcmq09.js +3 -0
  74. package/bin/vm-hands/vm-hands-entry-lite-td309c1y.js +5 -0
  75. package/bin/vm-hands/vm-hands-entry-lite-v0bp1v66.js +128 -0
  76. package/bin/vm-hands/vm-hands-entry-lite-v0k8b768.js +452 -0
  77. package/bin/vm-hands/vm-hands-entry-lite-v4r1fggm.js +3 -0
  78. package/bin/vm-hands/vm-hands-entry-lite-vqr3zrqr.js +539 -0
  79. package/bin/vm-hands/vm-hands-entry-lite-wbfmc0xn.js +3 -0
  80. package/bin/vm-hands/vm-hands-entry-lite-x3pbyg92.js +3 -0
  81. package/bin/vm-hands/{vm-hands-entry-lite-rfz60hb3.js → vm-hands-entry-lite-xd2dn3n8.js} +2 -2
  82. package/bin/vm-hands/vm-hands-entry-lite-yqn8h1p0.js +3 -0
  83. package/bin/vm-hands/vm-hands-entry-lite-zj3hb5jk.js +127 -0
  84. package/bin/vm-hands/vm-hands-entry-lite-zz8tr0bm.js +12 -0
  85. package/bin/vm-hands/vm-hands-entry-lite.js +1 -3
  86. package/bin/vm-hands/vm-hands-executor-6tncheya.js +12 -0
  87. package/bin/vm-hands/vm-hands-op-runner-s1ghsym7.js +2 -0
  88. package/bin/vm-hands/vm-hands-runtime-k6egwk2t.js +4 -0
  89. package/bin/vm-hands/worker-preview-readiness-wh0yg1dz.js +2 -0
  90. package/bin/vm-hands/worker-sandbox-s054x4zw.js +2 -0
  91. package/package.json +1 -1
  92. package/bin/vm-hands/api-credentials-gnefpvc1.js +0 -2
  93. package/bin/vm-hands/api-mjzanhf1.js +0 -2
  94. package/bin/vm-hands/connect-cli-dy7mdehx.js +0 -2
  95. package/bin/vm-hands/credentials-drj5ktpt.js +0 -2
  96. package/bin/vm-hands/custom-endpoint-device-j1x988g0.js +0 -2
  97. package/bin/vm-hands/desktop-account-4525j7h3.js +0 -2
  98. package/bin/vm-hands/device-workspace-pt07525s.js +0 -2
  99. package/bin/vm-hands/fsevents-8zxmv89w.js +0 -2
  100. package/bin/vm-hands/hands-worker-source-atg5dc7b.js +0 -2
  101. package/bin/vm-hands/index-ttmxy9nd.js +0 -12818
  102. package/bin/vm-hands/install-receipt-6v65enmf.js +0 -2
  103. package/bin/vm-hands/local-automation-wfa3dpbs.js +0 -2
  104. package/bin/vm-hands/local-capabilities-3v7x217d.js +0 -2
  105. package/bin/vm-hands/local-desktop-users-ar6xpadb.js +0 -2
  106. package/bin/vm-hands/local-display-mac-fnp3317m.js +0 -2
  107. package/bin/vm-hands/local-display-session-2064d8k8.js +0 -2
  108. package/bin/vm-hands/local-display-video-1hxqy3xj.js +0 -2
  109. package/bin/vm-hands/local-managed-process-trmeeyh2.js +0 -2
  110. package/bin/vm-hands/local-pty-session-5yh2a63r.js +0 -2
  111. package/bin/vm-hands/managed-runtime-hhk63f61.js +0 -2
  112. package/bin/vm-hands/network-contract-rzw769gw.js +0 -2
  113. package/bin/vm-hands/package-r7sgmw4t.js +0 -2
  114. package/bin/vm-hands/permissions-xwyhbnjc.js +0 -2
  115. package/bin/vm-hands/reason-hands-protocol-8fgk2s53.js +0 -2
  116. package/bin/vm-hands/serve-service-aye42qtb.js +0 -2
  117. package/bin/vm-hands/status-qtm9gb55.js +0 -10
  118. package/bin/vm-hands/version-gnb213c3.js +0 -2
  119. package/bin/vm-hands/vm-hands-entry-lite-0y9n06b6.js +0 -14
  120. package/bin/vm-hands/vm-hands-entry-lite-38g65s5x.js +0 -3
  121. package/bin/vm-hands/vm-hands-entry-lite-3sjkzhf6.js +0 -3
  122. package/bin/vm-hands/vm-hands-entry-lite-545m8hm0.js +0 -3
  123. package/bin/vm-hands/vm-hands-entry-lite-57v7y0km.js +0 -105
  124. package/bin/vm-hands/vm-hands-entry-lite-5gevvgec.js +0 -2
  125. package/bin/vm-hands/vm-hands-entry-lite-5tbntcyq.js +0 -42
  126. package/bin/vm-hands/vm-hands-entry-lite-61y11rrd.js +0 -3
  127. package/bin/vm-hands/vm-hands-entry-lite-6x1an7es.js +0 -7
  128. package/bin/vm-hands/vm-hands-entry-lite-7777m86y.js +0 -3
  129. package/bin/vm-hands/vm-hands-entry-lite-87vmbt38.js +0 -3
  130. package/bin/vm-hands/vm-hands-entry-lite-8e5djf5y.js +0 -5
  131. package/bin/vm-hands/vm-hands-entry-lite-8wcyveeh.js +0 -2
  132. package/bin/vm-hands/vm-hands-entry-lite-e1z3y9rs.js +0 -4
  133. package/bin/vm-hands/vm-hands-entry-lite-eabever7.js +0 -112
  134. package/bin/vm-hands/vm-hands-entry-lite-ewr54tpc.js +0 -3
  135. package/bin/vm-hands/vm-hands-entry-lite-ex69qn9q.js +0 -2
  136. package/bin/vm-hands/vm-hands-entry-lite-f62fvme8.js +0 -5
  137. package/bin/vm-hands/vm-hands-entry-lite-f69t48dj.js +0 -4
  138. package/bin/vm-hands/vm-hands-entry-lite-gvjffc5t.js +0 -65
  139. package/bin/vm-hands/vm-hands-entry-lite-hmaazqdr.js +0 -2
  140. package/bin/vm-hands/vm-hands-entry-lite-kq7hrjch.js +0 -128
  141. package/bin/vm-hands/vm-hands-entry-lite-mcjca0ez.js +0 -3
  142. package/bin/vm-hands/vm-hands-entry-lite-mk5ayds8.js +0 -3
  143. package/bin/vm-hands/vm-hands-entry-lite-mqzr55mw.js +0 -126
  144. package/bin/vm-hands/vm-hands-entry-lite-ncbzy69k.js +0 -4
  145. package/bin/vm-hands/vm-hands-entry-lite-np07qyeq.js +0 -3
  146. package/bin/vm-hands/vm-hands-entry-lite-nqdstx24.js +0 -3
  147. package/bin/vm-hands/vm-hands-entry-lite-psywfz8m.js +0 -9
  148. package/bin/vm-hands/vm-hands-entry-lite-pydgnx8a.js +0 -539
  149. package/bin/vm-hands/vm-hands-entry-lite-qpdpzg8g.js +0 -3
  150. package/bin/vm-hands/vm-hands-entry-lite-qt71vz32.js +0 -52
  151. package/bin/vm-hands/vm-hands-entry-lite-qxsqx6hz.js +0 -2
  152. package/bin/vm-hands/vm-hands-entry-lite-qy9xg6em.js +0 -3
  153. package/bin/vm-hands/vm-hands-entry-lite-rmabryke.js +0 -452
  154. package/bin/vm-hands/vm-hands-entry-lite-rzr2ncf5.js +0 -5
  155. package/bin/vm-hands/vm-hands-entry-lite-sss0m3yn.js +0 -3
  156. package/bin/vm-hands/vm-hands-entry-lite-swrymqj9.js +0 -3
  157. package/bin/vm-hands/vm-hands-entry-lite-tebh7dcm.js +0 -6
  158. package/bin/vm-hands/vm-hands-entry-lite-txd50spx.js +0 -3
  159. package/bin/vm-hands/vm-hands-entry-lite-wg0cykk2.js +0 -9
  160. package/bin/vm-hands/vm-hands-entry-lite-x39tmj7j.js +0 -5
  161. package/bin/vm-hands/vm-hands-entry-lite-xdjrdkh2.js +0 -4
  162. package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +0 -3
  163. package/bin/vm-hands/vm-hands-executor-8c542krk.js +0 -12
  164. package/bin/vm-hands/vm-hands-op-runner-88e10ptt.js +0 -2
  165. package/bin/vm-hands/vm-hands-runtime-njh3th64.js +0 -4
  166. package/bin/vm-hands/worker-preview-readiness-7xtgxsar.js +0 -2
  167. package/bin/vm-hands/worker-sandbox-s9pyac8p.js +0 -2
@@ -0,0 +1,105 @@
1
+ // @bun
2
+ import{$e as Zz,Xe as Qz,bf as R,ef as $z}from"./vm-hands-entry-lite-dgmap6z4.js";import{Pj as e,ck as V,ek as zz}from"./vm-hands-entry-lite-r374pchj.js";import{Tk as Jz}from"./vm-hands-entry-lite-e1xjfj57.js";import{bl as Hz}from"./vm-hands-entry-lite-8p8hz0j1.js";import{sl as X}from"./vm-hands-entry-lite-kqbats5n.js";import{spawnSync as C}from"child_process";import{createHash as Iz,randomUUID as Wz}from"crypto";import{chmodSync as bz,existsSync as y,mkdirSync as Sz,readdirSync as wz,readFileSync as L,renameSync as _z,rmSync as Y,statSync as xz,writeFileSync as Rz}from"fs";import{dirname as yz,isAbsolute as Bz,join as N}from"path";import{spawnSync as Oz}from"child_process";import{readFileSync as Cz}from"fs";import{userInfo as v}from"os";import{join as Kz}from"path";var Vz="REASON_SCHEDULED_TASK";function l(H){return Kz(H,"AppData","Local","Reason","Tasks")}function A(H){if(/[\0-\x1f\x7f"%]/.test(H))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${H}`);return`'${H.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function a(H){if(!/^[A-Za-z0-9._-]+$/.test(H))throw Error(`Invalid Windows Scheduled Task name: ${H}`);return`$env:${Vz}=${A(H)};`}function c(H){let z=Object.entries(H.environment).map(([Q,Z])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(Q))throw Error(`Invalid Windows Scheduled Task environment name: ${Q}`);return`$env:${Q}=${A(Z)};`}),J=`$global:LASTEXITCODE=1; & ${[H.program,...H.args].map(A).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${A(H.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[a(H.name),...z,"$ErrorActionPreference='Continue';",H.keepAlive?`do { ${J} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${J} exit $c`].join(" ")}function S(H){return H.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Pz(){let H=process.env.USERDOMAIN?.trim();return H?`${H}\\${v().username}`:v().username}function h(H){let z=S(H.user??Pz()),J=H.schedule==="logon",Q=H.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${z}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${H.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,Z=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${H.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>${S(H.description)}</Description>
6
+ </RegistrationInfo>
7
+ <Triggers>
8
+ ${Q}
9
+ </Triggers>
10
+ <Principals>
11
+ <Principal id="Author">
12
+ <UserId>${z}</UserId>
13
+ <LogonType>InteractiveToken</LogonType>
14
+ <RunLevel>LeastPrivilege</RunLevel>
15
+ </Principal>
16
+ </Principals>
17
+ <Settings>
18
+ <MultipleInstancesPolicy>${J?"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>${J?"PT0S":"PT1H"}</ExecutionTimeLimit>
27
+ <Priority>${J?5:7}</Priority>
28
+ </Settings>
29
+ <Actions Context="Author">
30
+ <Exec>
31
+ <Command>%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe</Command>
32
+ <Arguments>${S(Z)}</Arguments>
33
+ </Exec>
34
+ </Actions>
35
+ </Task>
36
+ `}function n(H){return Buffer.concat([Buffer.from([255,254]),Buffer.from(H.replaceAll(`\r
37
+ `,`
38
+ `).replaceAll(`
39
+ `,`\r
40
+ `),"utf16le")])}function r(H){let z=Cz(H);return(z[0]===255&&z[1]===254?z.subarray(2).toString("utf16le"):z.toString("utf8")).replaceAll(`\r
41
+ `,`
42
+ `)}function i(H,z){return["/Create","/TN",H,"/XML",z,"/F"]}function w(H){return["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(H,"utf16le").toString("base64")]}function _(H){return`'*${a(H).replaceAll("'","''")}*'`}function x(H,z){return w(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${_(H)} })`,...z.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 ${z.tree?"/T ":""}/PID $_.ProcessId | Out-Null } }`].join(`
43
+ `))}function s(H){return w(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${_(H)} })`,"foreach ($w in $wrappers) { if ($all | ? { $_.ParentProcessId -eq $w.ProcessId -and $_.Name -ne 'conhost.exe' }) { 'running'; exit 0 } }","exit 1"].join(`
44
+ `))}function t(H,z=process.pid){let J=Oz(X("powershell.exe"),w(["$all = @{}; Get-CimInstance Win32_Process | % { $all[[int]$_.ProcessId] = $_ }",`$p = $all[${Math.trunc(z)}]`,"for ($i = 0; $p -and $i -lt 64; $i++) {",` if ($p.CommandLine -like ${_(H)}) { 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 J.status===10?!0:J.status===11?!1:null}var P="REASON_WORKER_SERVICE",kz="worker_identity_unavailable";function qH(H){return{platform:process.platform,home:H,uid:process.getuid?.(),command:(z,J)=>C(X(z),[...J],{stdio:"ignore"}).status??1,read:(z,J)=>{let Q=C(X(z),[...J],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return Q.status===0?Q.stdout:null},sleep:(z)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,z),workerIdentity:(z)=>zz(H,z),insideService:(z,J)=>Ez(z,process.platform,process.getuid?.(),J)}}function Ez(H,z,J,Q=!0){if(process.env[P]===H||process.env.XPC_SERVICE_NAME===H)return!0;if(z==="linux")try{return L("/proc/self/cgroup","utf8").includes(`/${H}.service`)}catch{return!0}if(z==="win32")return t(H)??Q;if(z!=="darwin")return!1;if(typeof J!=="number")return!0;let Z=C("/bin/launchctl",["print",`gui/${J}/${H}`],{encoding:"utf8",timeout:5000});if(Z.status===fz)return!1;if(Z.error||Z.status!==0)return!0;let B=Number(/^\s*pid = (\d+)$/m.exec(Z.stdout??"")?.[1]??0);if(!B)return!1;let q=process.pid;for(let $=0;$<64&&q>1;$+=1){if(q===B)return!0;let j=C("/bin/ps",["-o","ppid=","-p",String(q)],{encoding:"utf8",timeout:5000}),G=Number(j.stdout?.trim());if(j.error||j.status!==0||!Number.isSafeInteger(G)||G<=0)return!0;if(G===q)return!1;q=G}return q>1}var fz=113;class M extends Error{code;constructor(H,z){super(H);this.code=z}}function jH(H,z){if(!u(H.home,H.platform))throw new M(Mz);if(H.platform==="darwin")F(H);let J=$z(Qz(z,H.home)),Q=Jz({env:z})==="staging",Z=Q?"ara-staging":"ara",B=[J?Zz(J):null,Hz(z,"REASON_CLI_LAUNCHER_PATH")?.trim(),H.platform==="win32"?N(H.home,"AppData","Local","Reason",...Q?["staging"]:[],"bin",Q?"reason-staging.exe":"reason.exe"):N(H.home,".local","bin",Z)];for(let q of B)try{if(q&&Bz(q)&&xz(q).isFile())return R(q)}catch{}throw new M(`A background service runs the installed Reason launcher, which was not found. Install Reason with: ${H.platform==="win32"?"irm https://reasonmachines.com/install.ps1 | iex":"curl -fsSL https://reasonmachines.com/install | sh"}`,"worker_launcher_missing")}var k=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,O=new RegExp(`(\\n\\s*<key>${V}</key>\\s*<string>)[^<]*(</string>)`),mz=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function uz(H){return H.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&amp;","&")}function E(H){let z=[...(k.exec(H)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((Q)=>uz(Q[1])),J=z[1]==="--run-worker"?z.slice(2):z;return J[0]?{launcher:J[0],args:J.slice(1)}:null}function GH(H,z){if(!pz(z))return null;try{return E(L(N(H,"Library","LaunchAgents",`${z}.plist`),"utf8"))?.launcher??null}catch{return null}}function qz(H,z,J){let Q=J.workerIdentity?.(H)??null;return{program:Q?[Q.executable,"--run-worker",H,...z]:[H,...z],identity:Q}}function f(H){return H.map((z)=>` <string>${D(z)}</string>`).join(`
46
+ `)}function jz(H,z){let J;try{J=L(H,"utf8")}catch{return null}let Q=E(J);if(!Q)return null;let Z=Bz(Q.launcher)?R(Q.launcher):Q.launcher,{program:B,identity:q}=qz(Z,Q.args,z),$=J.replace(k,(j,G,U,g)=>`${G}${f(B)}
47
+ ${g}`);if(!q)$=$.replace(O,"");else if(O.test($))$=$.replace(O,(j,G,U)=>`${G}${D(q.app)}${U}`);else $=$.replace(mz,(j,G,U)=>`${G}
48
+ <key>${V}</key>
49
+ <string>${D(q.app)}</string>${U}`);return $===J?null:$}function dz(H,z){let J=jz(H,z);if(J!==null)b(H,J)}function MH(H,z,J){if(z.platform!=="darwin")return!1;let Q=d(H,z,J);return Q!==null&&jz(Q.definition,z)!==null}var I="com.reasonmachines.worker.",m="so.reason.worker.",W=[I,m];function pz(H){return W.some((z)=>H.startsWith(z)&&/^[A-Za-z0-9._-]+$/.test(H.slice(z.length)))}function Gz(H,z=I){return`${z}connect${H==="production"?"":`.${H}`}`}function YH(H,z){return W.some((J)=>H===Gz(z,J))}function gz(H,z,J){if(z==="connect")return Gz(H.channel,J);let Q=Iz("sha256").update(H.workspaceRoot).digest("hex").slice(0,8);return`${J}${H.name.toLowerCase()}.${Q}`}var Mz="A background service needs macOS (launchd), Linux (systemd --user) or Windows (Task Scheduler).";function u(H,z){if(z==="darwin")return{directory:N(H,"Library","LaunchAgents"),suffix:".plist"};if(z==="linux")return{directory:N(H,".config","systemd","user"),suffix:".service"};if(z==="win32")return{directory:l(H),suffix:".xml"};return null}function T(H,z,J,Q=I){let Z=gz(H,J,Q),B=u(z.home,z.platform);if(!B)return null;return{label:Z,definition:N(B.directory,`${Z}${B.suffix}`),logs:z.platform==="linux"?`journalctl --user -u ${Z}.service`:N(H.stateDirectory,"service.log")}}function DH(H,z){let J=u(H,z);if(!J)return[];try{return wz(J.directory).filter((Q)=>W.some((Z)=>Q.startsWith(Z))&&Q.endsWith(J.suffix)).sort().map((Q)=>N(J.directory,Q))}catch{return[]}}function d(H,z,J="serve"){return Yz(H,z,J)[0]??null}function Yz(H,z,J){return W.map((Q)=>T(H,z,J,Q)).filter((Q)=>Q!==null&&y(Q.definition))}function Dz(H,z,J){let Q=T(H,z,J,m);return Q&&y(Q.definition)?Q:null}function vz(H,z,J){let Q=T(H,z,J),Z=Dz(H,z,J);if(!Q||!Z||!y(Q.definition)||z.insideService?.(Z.label))return null;if(!lz(Q,z))return"current_not_running";if(z.platform==="darwin"){if(typeof z.uid==="number"&&z.uid>0)z.command("/bin/launchctl",["bootout",`gui/${z.uid}/${Z.label}`]);return Y(Z.definition,{force:!0}),"retired"}if(z.platform==="win32")return K(Z,z,!0),"retired";return z.command("systemctl",["--user","disable","--now",`${Z.label}.service`]),Y(Z.definition,{force:!0}),z.command("systemctl",["--user","daemon-reload"]),"retired"}function lz(H,z){if(z.platform==="darwin")return typeof z.uid==="number"&&z.uid>0&&z.command("/bin/launchctl",["print",`gui/${z.uid}/${H.label}`])===0;if(z.platform==="win32")return z.command("schtasks",["/Query","/TN",H.label])===0;let J=`${H.label}.service`;return z.command("systemctl",["--user","is-enabled","--quiet",J])===0&&az.has(z.read("systemctl",["--user","show","--property=ActiveState","--value",J])?.trim()??"")}var az=new Set(["active","activating","reloading"]);function UH(H,z){if(z.platform==="darwin"){if(typeof z.uid!=="number"||z.uid<=0)return!1;let J=z.read("/bin/launchctl",["print",`gui/${z.uid}/${H.label}`]);return Number(/^\s*pid = (\d+)$/m.exec(J??"")?.[1]??0)>0}if(z.platform==="win32")return z.read("powershell.exe",s(H.label))?.trim()==="running";return Number(z.read("systemctl",["--user","show","--property=MainPID","--value",`${H.label}.service`])?.trim()??0)>0}function NH(H){let{config:z,launcher:J,host:Q,kind:Z}=H,B=T(z,Q,Z);if(!B)return!1;let q;try{q=Q.platform==="win32"?r(B.definition):L(B.definition,"utf8")}catch{return!1}if(Q.platform==="win32")return q===Tz(z,Z,B,J);if(Q.platform!=="darwin")return q===Nz(z,Z,B,J,Q.home,H.path);let $=E(q);return q.replace(O,"").replace(k,(G,U,g,Az)=>`${U}${$?`${f([$.launcher,...$.args])}
50
+ `:""}${Az}`)===Uz(z,Z,B,J,{...Q,workerIdentity:()=>null},H.path).plist}function p(H,z){if(z==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:H.channel},description:"Reason connection of this computer"};return{args:["serve",H.name,"--dir",H.workspaceRoot,...H.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${H.name} worker`}}function D(H){return H.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function o(H,z=!1){if(/[\0-\x1f\x7f]/.test(H))throw new M("A background service cannot use a path with control characters.");let J=H.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${z?J.replaceAll("$","$$$$"):J}"`}function Uz(H,z,J,Q,Z,B){let q=p(H,z),$=qz(Q,q.args,Z),j={HOME:Z.home,PATH:B,[P]:J.label,...q.environment,...$.identity?{[V]:$.identity.app}:{}};return{identity:$.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(J.label)}</string>
56
+ <key>AssociatedBundleIdentifiers</key>
57
+ <array>
58
+ <string>${e}</string>
59
+ </array>
60
+ <key>ProgramArguments</key>
61
+ <array>
62
+ ${f($.program)}
63
+ </array>
64
+ <key>EnvironmentVariables</key>
65
+ <dict>
66
+ ${Object.entries(j).map(([G,U])=>` <key>${G}</key>
67
+ <string>${D(U)}</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(H.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(J.logs)}</string>
87
+ <key>StandardErrorPath</key>
88
+ <string>${D(J.logs)}</string>
89
+ </dict>
90
+ </plist>
91
+ `}}function Nz(H,z,J,Q,Z,B){let q=p(H,z);return`[Unit]
92
+ Description=${q.description}
93
+
94
+ [Service]
95
+ ExecStart=${[Q,...q.args].map(($)=>o($,!0)).join(" ")}
96
+ Environment=${[`HOME=${Z}`,`PATH=${B}`,`${P}=${J.label}`,...Object.entries(q.environment).map(([$,j])=>`${$}=${j}`)].map(($)=>o($)).join(" ")}
97
+ Restart=on-failure
98
+ RestartSec=10
99
+ TimeoutStopSec=${Math.ceil(H.shutdownGraceMs/1000)+10}
100
+ UMask=0077
101
+
102
+ [Install]
103
+ WantedBy=default.target
104
+ `}function Tz(H,z,J,Q){let Z=p(H,z);return h({description:Z.description,schedule:"logon",script:c({name:J.label,program:Q,args:Z.args,environment:{[P]:J.label,...Z.environment},log:J.logs,keepAlive:!0})})}function Lz(H,z,J){z.command("powershell.exe",x(H.label,{tree:J,keepWrapper:!J}))}function K(H,z,J){z.command("schtasks",["/Delete","/F","/TN",H.label]),z.command("powershell.exe",x(H.label,{tree:J,keepWrapper:!1})),Y(H.definition,{force:!0})}function b(H,z){Sz(yz(H),{recursive:!0,mode:448});let J=`${H}.${Wz()}.tmp`;try{Rz(J,z,{mode:384,flag:"wx"}),bz(J,384),_z(J,H)}finally{Y(J,{force:!0})}}function F(H){if(typeof H.uid!=="number"||!Number.isSafeInteger(H.uid)||H.uid<=0)throw new M("Set up a background service as your own user, not with sudo.","worker_service_root_user");return`gui/${H.uid}`}function TH(H){let{config:z,launcher:J,host:Q}=H,Z=H.kind??"serve",B=Dz(z,Q,Z),q=B!==null&&Q.insideService?.(B.label)===!0,$=T(z,Q,Z,q?m:I);if(!$)throw new M(Mz);if(Q.platform==="darwin")F(Q);if(Q.platform==="linux"&&Q.command("systemctl",["--user","show-environment"])!==0)throw new M("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let j=Q.platform==="darwin"?Uz(z,Z,$,J,Q,H.path):null;if(b($.definition,j?j.plist:Q.platform==="win32"?n(Tz(z,Z,$,J)):Nz(z,Z,$,J,Q.home,H.path)),Xz(z,Q,$,q?null:B),j)return j.identity?$:{...$,identityProblem:kz};if(Q.platform==="win32")return $;return{...$,lingering:Q.command("loginctl",["enable-linger"])===0}}function Xz(H,z,J,Q){if(z.platform==="darwin"){let q=F(z);if(Q)z.command("/bin/launchctl",["bootout",`${q}/${Q.label}`]);if(Fz(H,J,z)){if(Q)Y(Q.definition,{force:!0});return}if(Y(J.definition,{force:!0}),Q)z.command("/bin/launchctl",["bootstrap",q,Q.definition]);throw new M("Could not start the background service (launchctl bootstrap failed).","worker_service_start_failed")}if(z.platform==="win32"){if(Q)K(Q,z,!0);if(z.command("schtasks",i(J.label,J.definition))===0){if(Lz(J,z,z.insideService?.(J.label)!==!0),z.command("schtasks",["/Run","/TN",J.label])===0)return}throw K(J,z,!0),new M("Could not start the background service (schtasks failed).")}let Z=`${J.label}.service`,B=Q?`${Q.label}.service`:null;if(z.command("systemctl",["--user","daemon-reload"])!==0||B!==null&&z.command("systemctl",["--user","disable","--now",B])!==0||z.command("systemctl",["--user","enable",Z])!==0||z.command("systemctl",["--user","restart",Z])!==0){if(z.command("systemctl",["--user","disable",Z]),Y(J.definition,{force:!0}),z.command("systemctl",["--user","daemon-reload"]),B)z.command("systemctl",["--user","enable","--now",B]);throw new M("Could not start the background service (systemctl --user failed).","worker_service_start_failed")}if(Q)Y(Q.definition,{force:!0}),z.command("systemctl",["--user","daemon-reload"])}function Fz(H,z,J){let Q=F(J);J.command("/bin/launchctl",["bootout",`${Q}/${z.label}`]);let Z=(Math.ceil(H.shutdownGraceMs/1000)+10)*1000;for(let B=0,q=100;;q=Math.min(q*2,2000)){if(J.command("/bin/launchctl",["bootstrap",Q,z.definition])===0)return!0;if(B>=Z)return!1;J.sleep(q),B+=q}}function LH(H,z,J){let Q=d(H,z,J);if(!Q)return null;let Z=z.insideService?.(Q.label)===!0;if(z.platform==="darwin"&&!Z)dz(Q.definition,z);let B=T(H,z,J);if(B&&Q.label!==B.label&&!Z)return b(B.definition,L(Q.definition,"utf8").replaceAll(Q.label,B.label)),Xz(H,z,B,Q),B;let q=z.platform==="darwin"&&Z,$;if(z.platform==="win32")Lz(Q,z,!Z),$=z.command("schtasks",["/Run","/TN",Q.label])===0;else if(q)$=z.command("/bin/launchctl",["kickstart","-k",`${F(z)}/${Q.label}`])===0;else if(z.platform==="darwin")$=Fz(H,Q,z);else z.command("systemctl",["--user","enable",`${Q.label}.service`]),$=z.command("systemctl",["--user","restart",`${Q.label}.service`])===0;if(!$)throw new M(`Could not restart the background service ${Q.label}.`,"worker_service_restart_failed");if(B&&Q.label===B.label)vz(H,z,J);return Q}function XH(H,z,J,Q){let Z=d(H,J,Q),B=T(z,J,Q);if(J.platform!=="darwin"||!Z||!B)return;let q=`<string>${D(Z.logs)}</string>`,$=L(Z.definition,"utf8");if($.includes(q))b(Z.definition,$.replaceAll(q,`<string>${D(B.logs)}</string>`))}function FH(H,z,J="serve"){let Q=Yz(H,z,J);for(let Z of Q){if(z.platform==="win32"){K(Z,z,z.insideService?.(Z.label,!1)!==!0);continue}if(z.platform==="darwin"){if(typeof z.uid==="number"&&z.uid>0)z.command("/bin/launchctl",["bootout",`gui/${z.uid}/${Z.label}`]);Y(Z.definition,{force:!0});continue}z.command("systemctl",["--user","disable","--now",`${Z.label}.service`]),Y(Z.definition,{force:!0}),z.command("systemctl",["--user","daemon-reload"])}return Q[0]??null}
105
+ export{l as xe,P as ye,kz as ze,qH as Ae,M as Be,jH as Ce,GH as De,MH as Ee,Gz as Fe,YH as Ge,DH as He,d as Ie,vz as Je,UH as Ke,NH as Le,TH as Me,LH as Ne,XH as Oe,FH as Pe};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ function t(e){return Function("return ("+e+")")()}
3
+ export{t as Al};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Dl as e}from"./vm-hands-entry-lite-pkk555dx.js";var i=e((o,t)=>{t.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
3
+ export{i as Wa};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var U=".reason/workspace",T="workspace_base",y="sessions",W="workspace_layout",g=".reason/workspace/sessions",B=/^[0-9a-f]{8}$/;function C(j){if(!J(j))return!1;let q=".reason/workspace/sessions/";if(!j.startsWith(q))return!1;let z=j.slice(q.length).split("/");return z.length===2&&B.test(z[0])}var G=4096,X="workspaces/pi";function J(j){if(typeof j!=="string"||!j||j.length>G)return!1;if(j.startsWith("/")||j.includes("\x00")||j.includes("\\"))return!1;return j.split("/").every((q)=>q!==""&&q!=="."&&q!=="..")}function Z(j){if(j.kind==="root"){if(j.path===void 0)return".";if(!J(j.path))throw Error("invalid_device_workspace_identity");return j.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(j.workspaceId)||j.workspaceId==="."||j.workspaceId==="..")throw Error("invalid_device_workspace_identity");let q=j.layout==="sessions"?"sessions":X;return`${j.base?`${j.base}/`:""}${q}/${j.workspaceId}/repo`}function L(j){if(!j||typeof j!=="object"||Array.isArray(j))return null;let q=j;if(q.kind==="root"&&Object.keys(q).length===1)return{kind:"root"};if(q.kind==="root"&&Object.keys(q).length===2&&J(q.path))return{kind:"root",path:q.path};if(q.kind!=="managed"||typeof q.workspaceId!=="string"||Object.keys(q).length!==2+(q.base===void 0?0:1)+(q.layout===void 0?0:1)||q.base!==void 0&&q.base!==".reason/workspace"||q.layout!==void 0&&q.layout!=="sessions")return null;let z={kind:"managed",workspaceId:q.workspaceId,...q.base===".reason/workspace"?{base:".reason/workspace"}:{},...q.layout==="sessions"?{layout:"sessions"}:{}};try{return Z(z),z}catch{return null}}var b="/home/runner",P=10001,x="/run/reason/sessions",f=/^(?:\/[A-Za-z0-9._-]+)+$/,M=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,H=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function K(j){return M.exec(j)?.[1]??H.exec(j)?.[1]??j}var $=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/,A="*/.reason/workspace/workspaces/pi/*|*/.reason/workspace/sessions/*";function N(j,q=b,z="sessions"){if(!f.test(q)||q.split("/").some((V)=>V==="."||V===".."))throw Error("invalid_cloud_payload_home");let Q=`${q}/${Z({kind:"managed",workspaceId:j,base:".reason/workspace",...z?{layout:z}:{}})}`,F=`${x}/${K(j)}`;return{home:q,root:Q.slice(0,-5),checkout:Q,control:F,jobEnv:`${F}/job.env`,cloudAccess:`${F}/cloud-access`,logs:`${F}/logs`,pin:`${F}/ws`}}function Y(j){return $.exec(j.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function D(j){return{kind:"managed",workspaceId:j,layout:"sessions"}}function R(j){let q=$.exec(j.replace(/\/+$/,""));if(!q)return null;try{let z=N(q[3],q[1],Y(j));return z.root===j.replace(/\/+$/,"")?z:null}catch{return null}}
3
+ export{U as rk,T as sk,y as tk,W as uk,g as vk,B as wk,C as xk,J as yk,Z as zk,L as Ak,b as Bk,P as Ck,x as Dk,M as Ek,H as Fk,$ as Gk,A as Hk,N as Ik,Y as Jk,D as Kk,R as Lk};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{mk as J}from"./vm-hands-entry-lite-56v9haps.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
3
+ `)){let j=I.split(":");if(j.length<7||Number(j[2])!==q||!/^\d+$/.test(j[2])||!/^\d+$/.test(j[3]))continue;let x=j[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(j[0])||!M(x)||Q(x)!==x||x==="/")return null;return{username:j[0],uid:q,gid:Number(j[3]),home:x}}return null}function b(q={}){let B="value"in q?q.value:process.env[W];if(G=null,B===void 0||B==="")return null;let I=q.platform??process.platform,j="euid"in q?q.euid:process.geteuid?.(),x=/^[1-9]\d{0,9}$/.test(B)?Number(B):NaN,C=I==="linux"&&j===0&&Number.isSafeInteger(x)?X(x,(q.passwd??(()=>L("/etc/passwd","utf8")))()):null;if(!C||C.gid===0)throw Error("worker_desktop_user_invalid");return G=C,C}function k(){return G}function y(){return G?.home??J()}
4
+ export{W as sj,X as tj,b as uj,k as vj,y as wj};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{zl as M}from"./vm-hands-entry-lite-xd2dn3n8.js";import{Al as D}from"./vm-hands-entry-lite-ghhpgt3v.js";import{execFileSync as A}from"child_process";import{realpathSync as U,statSync as F}from"fs";import{tmpdir as j}from"os";import{createRequire as I}from"module";import{win32 as Z}from"path";var J=["/bin/bash","/usr/bin/bash"],u="Git Bash was not found. Install Git for Windows (https://git-scm.com/download/win), then run `reason connect`.";function k(K){try{return F(K).isFile()}catch{return!1}}var q=(K)=>[Z.join(K,"bin","bash.exe"),Z.join(K,"usr","bin","bash.exe")];function O(K,Q){let L=Z.normalize(K).toLowerCase(),Y=(Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows").toLowerCase();return L.startsWith(Z.join(Y,"system32").toLowerCase()+"\\")||L.startsWith(Z.join(Y,"sysnative").toLowerCase()+"\\")||L.includes("\\windowsapps\\")}function C(K=process.env,Q=k){let L=[];for(let Y of(K.PATH??K.Path??"").split(";"))if(Y&&Z.isAbsolute(Y))L.push(Z.join(Y,"git.exe"));for(let Y of[K.ProgramW6432,K.ProgramFiles,K["ProgramFiles(x86)"]])if(Y)L.push(Z.join(Y,"Git","cmd","git.exe"));if(K.LOCALAPPDATA)L.push(Z.join(K.LOCALAPPDATA,"Programs","Git","cmd","git.exe"));return L.find(Q)??null}var T;function w(K=process.platform){if(K!=="win32")return"git";return T??=C(),T}function P(K){let Q=process.platform==="win32"?C(K):"git";if(!Q)return null;try{return A(Q,["--exec-path"],{encoding:"utf8",timeout:5000,windowsHide:!0,stdio:["ignore","pipe","ignore"],env:K}).trim()||null}catch{return null}}function G(K=process.env,Q=P,L=k){let Y=[],H=Q(K);if(H)Y.push(...q(Z.resolve(H,"..","..","..")));for(let $ of[K.ProgramW6432,K.ProgramFiles,K["ProgramFiles(x86)"]])if($)Y.push(...q(Z.join($,"Git")));if(K.LOCALAPPDATA)Y.push(...q(Z.join(K.LOCALAPPDATA,"Programs","Git")));for(let $ of(K.PATH??K.Path??"").split(";"))if($&&Z.isAbsolute($))Y.push(Z.join($,"bash.exe"));return Y.find(($)=>!O($,K)&&L($))??null}var z;function W(K=process.platform){if(K!=="win32")return J.find(k)??null;return z??=G(),z}function f(K=process.platform){let Q=W(K);if(!Q)throw Error(K==="win32"?u:"bash_unavailable");return Q}function h(K=process.platform){return U(K==="win32"?j():"/tmp")}function X(K=process.platform,Q=process.env){if(K!=="win32")return"/usr/bin:/bin";let L=Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows";return[Z.join(L,"System32"),L,Z.join(L,"System32","Wbem"),Z.join(L,"System32","WindowsPowerShell","v1.0")].join(";")}function _(K,Q=process.platform){if(Q!=="win32"||/[\\/]/.test(K))return K;let L=/\.exe$/i.test(K)?K:`${K}.exe`,Y=X(Q).split(";");return Z.join(L.toLowerCase()==="powershell.exe"?Y[3]:Y[0],L)}function v(K=process.platform,Q=process.env){if(K!=="win32")return{PATH:X(K)};let L=Q.SystemRoot??Q.SYSTEMROOT??"C:\\Windows";return{PATH:X(K,Q),SystemRoot:L,WINDIR:L}}function c(K=process.platform){return K==="win32"?{windowsHide:!0}:{detached:!0}}var V;function N(){if(V===void 0)V=D(M)(I(import.meta.url));return V}function p(K,Q=process.platform){let L=K.pid;if(Q!=="win32"||L===void 0)return;let Y=N();if(Y?.track(L))K.once("close",()=>Y.release(L))}function l(K,Q="SIGTERM",L=process.platform){if(L!=="win32"){process.kill(-K,Q);return}if(Q===0){process.kill(K,0);return}if(N()?.terminate(K))return;A(_("taskkill",L),["/PID",String(K),"/T","/F"],{stdio:"ignore",timeout:1e4,windowsHide:!0})}function d(K,Q=63,L=process.platform){return L==="win32"||K.uid===process.getuid?.()&&(K.mode&Q)===0}var x=/^(?:con|prn|aux|nul|com[0-9\u00b9\u00b2\u00b3]|lpt[0-9\u00b9\u00b2\u00b3]|conin\$|conout\$)(?:\..*)?$|:|[. ]$/i;function s(K){return K!=="."&&K!==".."&&x.test(K)}
3
+ export{u as ml,w as nl,W as ol,f as pl,h as ql,X as rl,_ as sl,v as tl,c as ul,p as vl,l as wl,d as xl,s as yl};
@@ -0,0 +1,42 @@
1
+ // @bun
2
+ import{dl as W}from"./vm-hands-entry-lite-e4hwb89r.js";var T=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),M=W.string().regex(/^[a-f0-9]{40}$/),q=W.number().int().positive(),C=W.string().min(1).max(256),A=W.string().max(60000),B={version:W.literal(1),repoFullName:T},J=W.array(W.string().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),c=W.strictObject({expectedTrailers:J,missingFromHead:J}),y=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:C.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),d=W.discriminatedUnion("kind",[W.strictObject({...B,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...B,kind:W.literal("pr_review_context"),number:q,after:W.string().min(1).max(1024).optional()}),W.strictObject({...B,kind:W.literal("prepare"),branch:G,baseSha:M,defaultBranch:G,diagnosticsVersion:W.literal(1).optional()}),W.strictObject({...B,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:M,remoteHeadSha:M.nullable(),contributorTrailers:J.optional()}),W.strictObject({...B,kind:W.literal("pr_create"),head:G,base:G,title:C,body:A,draft:W.boolean()}),W.strictObject({...B,kind:W.literal("pr_mutation"),number:q,mutation:y}),W.strictObject({...B,kind:W.literal("pr_merge"),number:q,expectedHeadSha:M,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),O=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function h(Q){return O.some((Z)=>Z===Q)}class R extends Error{code;constructor(Q){super(Q);this.code=Q}}function ZQ(Q,Z,$){let z=d.safeParse(Q);return Z==="failed"&&z.success&&z.data.kind==="prepare"&&z.data.diagnosticsVersion===1&&h($)}var x=245760,$Q=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(x)}),W.strictObject({kind:W.literal("prepare"),headSha:M}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(x)}),W.strictObject({kind:W.literal("publish"),headSha:M,scannedObjectCount:W.number().int().min(0).max(5000),attribution:c.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:q,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:q,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=x,"local_device_gh_result_too_large"),r=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),m=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:r.optional(),contributorRefresh:W.guid().optional(),repoFullName:T.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function P(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function KQ(Q,Z,$={},z="read"){if(P(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return p(Q,Z,$);if(!P(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((D)=>D==="."||D===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((D)=>D.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((D,X)=>{if(X==="per_page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(X==="page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(Y==="/pulls"&&X==="state"&&["open","closed","all"].includes(D))return;if(Y==="/pulls"&&X==="sort"&&D==="updated")return;if(Y==="/pulls"&&X==="direction"&&D==="desc")return;if(Y==="/pulls"&&["head","base"].includes(X)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(D))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((X,_)=>{if(_!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(X))throw Error("local_device_gh_header_denied")})}function p(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let z=new URL(Z,"https://api.github.com");if(z.pathname!=="/search/issues"||z.username||z.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;z.searchParams.forEach((H,D)=>{if(D==="q"&&V===null){V=H;return}if(D==="per_page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;if(D==="page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,N=V?.toLowerCase()??"";if(N.length>512||!(N+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(N.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((H,D)=>{if(D!=="accept"||H!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var DQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
3
+ repository(owner: $owner, name: $repo) {
4
+ nameWithOwner
5
+ pullRequest(number: $number) {
6
+ number
7
+ reviewDecision
8
+ headRefOid
9
+ baseRefOid
10
+ baseRef {
11
+ branchProtectionRule {
12
+ requiresApprovingReviews
13
+ requiredApprovingReviewCount
14
+ requiresStatusChecks
15
+ requiredStatusCheckContexts
16
+ requiresConversationResolution
17
+ dismissesStaleReviews
18
+ }
19
+ }
20
+ reviewThreads(first: 100, after: $after) {
21
+ nodes {
22
+ id isResolved isOutdated viewerCanResolve viewerCanUnresolve
23
+ path line originalLine startLine originalStartLine diffSide startDiffSide
24
+ comments(first: 100) {
25
+ nodes {
26
+ id databaseId body createdAt updatedAt url
27
+ author { __typename login }
28
+ replyTo { databaseId }
29
+ }
30
+ pageInfo { hasNextPage }
31
+ }
32
+ }
33
+ pageInfo { hasNextPage endCursor }
34
+ }
35
+ }
36
+ }
37
+ }`;function zQ(Q){return Q.kind==="read"||Q.kind==="pr_review_context"}var b=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var j=2,I="/app/local-runtime",n=262144,HQ="x-reason-relay-host-alias",XQ="v1";function F(Q,Z){return{path:`${I}${Q}`,routerPath:Q,auth:Z}}function g(Q,Z){return{...F(Q,"device_proof"),forOperation($){return F(`/operations/${encodeURIComponent($)}${Z}`,"device_proof")}}}var GQ={register:F("/register","registration_bearer"),enroll:F("/enroll","none"),authChallenge:F("/auth/challenge","none"),identity:F("/identity","device_proof"),heartbeat:F("/heartbeat","device_proof"),rootsSync:F("/roots/sync","device_proof"),disconnect:F("/disconnect","device_proof"),lifecycle:F("/lifecycle","device_proof"),localSubscription:F("/local-subscription","device_proof"),ownerWorkspaces:F("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:F("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:F("/session-worktrees","device_proof"),operationClaim:F("/operations/claim","device_proof"),operationHeartbeat:g("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:g("/operations/:operationId/events","/events"),operationComplete:g("/operations/:operationId/complete","/complete"),operationEnvironment:g("/operations/:operationId/environment","/environment"),operationEnvironmentAck:g("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:g("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},BQ=`${I}/session`,MQ=4096,gQ=5000,o=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function qQ(Q){return o.some((Z)=>Z.test(Q))}var NQ="vm_hands_v1",mQ=60000,UQ={unauthenticated:4401,unavailable:4404,overloaded:4429,serviceRestart:1012},jQ="hands_control_v1",xQ="environment.deliver",JQ="vm_hands_workspace_deferred",SQ="vm_hands.workspace_grant",IQ="hands.unbind_unverified",PQ="claim_v1",TQ="environment_at_claim",CQ="ready_v1",AQ="workspace_check",bQ="rebind_v1",EQ="resident_rebind",kQ="hands.rebind",LQ="snapshot_v1",fQ="cloud_access",_Q="playwright_v1",cQ="headless_browser",yQ="v1",dQ="job_env_large_values",OQ="srt_root_v1",hQ="hands_confinement",RQ="gid_v1",rQ="model_jobs_egress",pQ="setpriv_v1",nQ="jobs_user",oQ="spawning_attempt_v1",sQ="hands_session_group",iQ="session_uid_v1",tQ="hands_session_account",vQ="session_cap",lQ="none",uQ="same_launch_v1",aQ="exit_v1",eQ="start_wait",QW="user_chrome",WW="cloud_sessions";function S(Q){if(!K(Q)||Object.keys(Q).length!==5||Q.version!==1)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["boot_generation","recording_operation_id","recording_attempt_id"].every(($)=>typeof Q[$]==="string"&&Z.test(Q[$]))&&typeof Q.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(Q.root_version)}function U(Q){if(!K(Q)||Object.keys(Q).length!==6)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof Q.device_id==="string"&&Z.test(Q.device_id)&&(Q.binding==="workspace_source"||Q.binding==="mcp_control")&&Number.isSafeInteger(Q.target_revision)&&Number(Q.target_revision)>=0&&Number.isSafeInteger(Q.root_grant_revision)&&Number(Q.root_grant_revision)>0&&Number.isSafeInteger(Q.target_generation)&&Number(Q.target_generation)>0&&typeof Q.target_fence_id==="string"&&Z.test(Q.target_fence_id)}var ZW=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],$W=86400000,KW=["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"],s=["production","staging"];function E(Q){if(!K(Q)||Object.keys(Q).length!==3)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["organization_id","user_id","device_id"].every(($)=>Object.hasOwn(Q,$)&&typeof Q[$]==="string"&&Z.test(Q[$])&&Q[$]!=="00000000-0000-0000-0000-000000000000")}var i="DEVICE-PROOF-V2",DW="ARA-DEVICE-V1";function zW(Q,Z=i){let $=Q.method.toUpperCase();if(!/^[A-Z]+$/.test($)||!Q.pathAndQuery.startsWith(`${I}/`)||Q.pathAndQuery.includes(`
38
+ `)||!/^[0-9]{1,20}$/.test(Q.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(Q.nonce)||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
39
+ `)||!/^[a-f0-9]{64}$/.test(Q.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([Z,$,Q.pathAndQuery,Q.timestamp,Q.nonce,Q.challenge,Q.bodySha256].join(`
40
+ `),"utf8")}function K(Q){return Boolean(Q)&&typeof Q==="object"&&!Array.isArray(Q)}function t(Q,Z){return typeof Q==="string"&&Z.some(($)=>$===Q)}function k(Q){return K(Q)&&typeof Q.id==="string"&&typeof Q.label==="string"&&typeof Q.path_fingerprint==="string"}function v(Q){return K(Q)&&Number.isInteger(Q.seq)&&Number(Q.seq)>=0&&typeof Q.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(Q.kind)&&K(Q.payload)}function w(Q){throw Error(Q)}function FW(Q,Z){let $=K(Q)?Q:{},z=typeof $.error==="string"?$.error:`http_${Z}`,V=typeof $.detail==="string"?$.detail:typeof $.message==="string"?$.message:`Reason Device request failed (${Z})`;return{code:z,message:V}}function l(Q){if(!K(Q)||typeof Q.challenge!=="string"||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
41
+ `)||typeof Q.expires_at!=="string"||!Number.isFinite(Date.parse(Q.expires_at)))w("Reason returned an invalid Device proof challenge.");return{challenge:Q.challenge,expires_at:Q.expires_at}}function L(Q,Z){if(!K(Q)||typeof Q.device_id!=="string"||Q.auth_scheme!=="p256"||Q.organization_id!==void 0&&typeof Q.organization_id!=="string"||Q.protocol_version!==j||!Array.isArray(Q.roots)||!Q.roots.every(k)||Z&&typeof Q.organization_id!=="string"||Q.device_credential!==void 0)w(Z?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:Q.device_id,...typeof Q.organization_id==="string"?{organization_id:Q.organization_id}:{},protocol_version:j,roots:Q.roots},auth_scheme:"p256"}}function wW(Q){return L(Q,!1)}function VW(Q){let Z=L(Q,!0);if(typeof Z.organization_id!=="string")return w("Reason returned an invalid Device enrollment.");return{...Z,organization_id:Z.organization_id}}function YW(Q){if(!K(Q)||typeof Q.server_time!=="string"||typeof Q.drain!=="boolean")return w("Reason returned an invalid Device heartbeat.");return{server_time:Q.server_time,drain:Q.drain,...f(Q),...typeof Q.update_policy==="string"||Q.update_policy===null?{update_policy:Q.update_policy}:{},...typeof Q.supported_protocol_version==="number"?{supported_protocol_version:Q.supported_protocol_version}:{},...a(Q.latest_cli_versions),...Q.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var u=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function f(Q){return Object.fromEntries(u.filter((Z)=>Q[Z]===!0).map((Z)=>[Z,!0]))}function HW(Q){if(!K(Q))return;try{return{...l(Q),...f(Q)}}catch{return}}function a(Q){if(!K(Q))return{};let Z={};for(let $ of s){let z=Q[$];if(typeof z==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(z))Z[$]=z}return Object.keys(Z).length>0?{latest_cli_versions:Z}:{}}function XW(Q){if(!K(Q)||!Array.isArray(Q.roots)||!Q.roots.every(k))return w("Reason returned an invalid Device root sync.");return{roots:Q.roots}}function GW(Q){if(!K(Q)||Q.user_id!==void 0&&typeof Q.user_id!=="string"||typeof Q.organization_id!=="string"||typeof Q.organization_name!=="string"||typeof Q.organization_slug!=="string")return w("Reason returned an invalid Device identity.");return{...typeof Q.user_id==="string"?{user_id:Q.user_id}:{},organization_id:Q.organization_id,organization_name:Q.organization_name,organization_slug:Q.organization_slug}}function BW(Q){if(!K(Q)||Q.disconnected!==!0)return w("Reason did not disconnect this Device.");let Z=Q.sessions_moved;return typeof Z==="number"&&Number.isSafeInteger(Z)&&Z>=0?{disconnected:!0,sessions_moved:Z}:{disconnected:!0}}function MW(Q){if(K(Q)&&Q.ok===!0&&typeof Q.expires==="number")return{ok:!0,expires:Q.expires};if(K(Q)&&Q.ok===!1&&typeof Q.error==="string")return{ok:!1,error:Q.error};return w("Reason did not answer the local login hand-over.")}function gW(Q){if(!K(Q)||Q.accepted!==!0)return w("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function e(Q){return Buffer.byteLength(JSON.stringify(Q),"utf8")}function qW(Q,Z=b){if(!K(Q)||typeof Q.operation_id!=="string"||typeof Q.attempt_id!=="string"||typeof Q.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(Q.attempt_token)||typeof Q.lease_until!=="string"||typeof Q.run_id!=="string"||typeof Q.root_id!=="string"||Q.owner!==void 0&&!E(Q.owner)||!t(Q.capability,Z)||!K(Q.payload)||Q.protocol_version!==j||e(Q.payload)>n||Q.authority!==void 0&&!U(Q.authority)||Q.local_github_authority!==void 0&&!m.safeParse(Q.local_github_authority).success||Q.capability==="github.local.v1"&&!m.safeParse(Q.local_github_authority).success||Q.recording_authority!==void 0&&!S(Q.recording_authority)||Q.capability==="browser.recording.v1"&&(!S(Q.recording_authority)||!E(Q.owner))||Q.capability!=="browser.recording.v1"&&Q.recording_authority!==void 0)return w("Reason returned an invalid Device operation claim.");let $={operation_id:Q.operation_id,attempt_id:Q.attempt_id,attempt_token:Q.attempt_token,lease_until:Q.lease_until,run_id:Q.run_id,root_id:Q.root_id,capability:Q.capability,payload:Q.payload,...U(Q.authority)?{authority:Q.authority}:{},...S(Q.recording_authority)?{recording_authority:Object.freeze({...Q.recording_authority})}:{},...Q.local_github_authority!==void 0?{local_github_authority:m.parse(Q.local_github_authority)}:{},...Q.capability==="hands.connect"&&K(Q.environment)&&K(Q.environment.payload)&&U(Q.environment.authority)?{environment:{payload:Q.environment.payload,authority:Q.environment.authority}}:{},protocol_version:j};if(Q.owner!==void 0)$.owner=Object.freeze({...Q.owner});return $}function NW(Q){if(!K(Q)||typeof Q.lease_until!=="string"||!Array.isArray(Q.controls)||!Q.controls.every(v)||!Number.isInteger(Q.next_control_seq)||Number(Q.next_control_seq)<0)return w("Reason returned an invalid Device operation heartbeat.");return{lease_until:Q.lease_until,controls:Q.controls,next_control_seq:Number(Q.next_control_seq)}}function mW(Q){if(!K(Q)||!Number.isInteger(Q.next_event_seq)||Number(Q.next_event_seq)<0||typeof Q.duplicate!=="boolean"||!Number.isInteger(Q.accepted_count)||Number(Q.accepted_count)<0)return w("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(Q.next_event_seq),duplicate:Q.duplicate,accepted_count:Number(Q.accepted_count)}}function UW(Q){if(!K(Q)||!K(Q.payload)||!U(Q.authority))return w("Reason returned an invalid Device environment delivery.");return{payload:Q.payload,authority:Q.authority}}function QQ(Q){return Q==="succeeded"||Q==="failed"||Q==="cancelled"||Q==="expired"}function jW(Q){if(!K(Q)||!QQ(Q.status)||typeof Q.idempotent!=="boolean")return w("Reason returned an invalid Device operation completion.");return{status:Q.status,idempotent:Q.idempotent}}
42
+ export{d as kf,R as lf,ZQ as mf,x as nf,$Q as of,m as pf,KQ as qf,DQ as rf,zQ as sf,b as tf,j as uf,I as vf,n as wf,HQ as xf,XQ as yf,GQ as zf,BQ as Af,MQ as Bf,gQ as Cf,qQ as Df,NQ as Ef,mQ as Ff,UQ as Gf,jQ as Hf,xQ as If,JQ as Jf,SQ as Kf,IQ as Lf,PQ as Mf,TQ as Nf,CQ as Of,AQ as Pf,bQ as Qf,EQ as Rf,kQ as Sf,LQ as Tf,fQ as Uf,_Q as Vf,cQ as Wf,yQ as Xf,dQ as Yf,OQ as Zf,hQ as _f,RQ as $f,rQ as ag,pQ as bg,nQ as cg,oQ as dg,sQ as eg,iQ as fg,tQ as gg,vQ as hg,lQ as ig,uQ as jg,aQ as kg,eQ as lg,QW as mg,WW as ng,ZW as og,$W as pg,KW as qg,i as rg,DW as sg,zW as tg,FW as ug,l as vg,wW as wg,VW as xg,YW as yg,HW as zg,XW as Ag,GW as Bg,BW as Cg,MW as Dg,gW as Eg,qW as Fg,NW as Gg,mW as Hg,UW as Ig,jW as Jg};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var n=Object.create;var{getPrototypeOf:o,defineProperty:e,getOwnPropertyNames:k,getOwnPropertyDescriptor:p}=Object,l=Object.prototype.hasOwnProperty;function m(a){return this[a]}var q,r,u=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var h=b?q??=new WeakMap:r??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?n(o(a)):{};let f=b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c;for(let g of k(a))if(!l.call(f,g))e(f,g,{get:m.bind(a,g),enumerable:!0});if(d)h.set(a,f);return f},v=(a)=>{var b=(j??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of k(a))if(!l.call(b,d))e(b,d,{get:m.bind(a,d),enumerable:!(c=p(a,d))||c.enumerable})}return j.set(a,b),b},j,w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=(a)=>a;function t(a,b){this[a]=s.bind(null,b)}var x=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:t.bind(b,c)})};var y=(a,b)=>()=>(a&&(b=a(a=0)),b);var z=import.meta.require;
3
+ export{u as Bl,v as Cl,w as Dl,x as El,y as Fl,z as Gl};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Bd as L,Cd as S,Gd as f}from"./vm-hands-entry-lite-dhqmbqsh.js";import{tl as R,ul as E,vl as W}from"./vm-hands-entry-lite-kqbats5n.js";import{spawn as x}from"child_process";import{randomUUID as J}from"crypto";import{basename as k}from"path";import{fileURLToPath as m}from"url";function g(){let $=k(process.execPath).startsWith("bun");return{command:process.execPath,args:[...$?["--no-env-file",m(new URL("./worker-candidate-entry.ts",import.meta.url))]:[],"worker","__preview-probe"]}}async function d($,Q,H=g()){if(Q.aborted||!["darwin","linux","win32"].includes(process.platform)||process.platform==="win32"&&!S())return!1;let F=new AbortController,C=()=>F.abort();Q.addEventListener("abort",C,{once:!0});let T=setTimeout(C,5000),B=x(H.command,H.args,{cwd:$,...E(),stdio:["pipe","pipe","ignore"],env:R()});W(B);let Z=!1,N=new Promise((j)=>B.once("close",()=>{Z=!0,j()}));B.on("error",C);let O,V,D=new Promise((j)=>{O=j}),P=new Promise((j)=>{V=j}),_=new Promise((j)=>F.signal.addEventListener("abort",()=>j(null),{once:!0})),K="",A=0,G=!1;B.stdout.setEncoding("utf8"),B.stdout.on("data",(j)=>{if(A+=Buffer.byteLength(j),K+=j,A>512){C();return}while(K.includes(`
3
+ `)){let X=K.indexOf(`
4
+ `),Y=K.slice(0,X);K=K.slice(X+1);try{if(!G){let z=JSON.parse(Y);if(!z||Object.keys(z).length!==2||!Number.isInteger(z.port)||z.port<1024||z.port>65535||typeof z.token!=="string"||!/^[a-zA-Z0-9_-]{43}$/.test(z.token))throw Error("probe_receipt_invalid");G=!0,O({port:z.port,token:z.token})}else if(Y==="ready")V(!0);else C()}catch{C()}}}),N.then(C);let M,q=!1;try{let j=await Promise.race([D,_]);if(!j||!B.pid||F.signal.aborted||Q.aborted)return!1;let X=Date.now()+4500,Y=J(),z={organizationId:J(),userId:J(),runId:J(),deviceId:J(),rootId:J(),attachmentRevision:0,grantRevision:1,jobId:"readiness",generation:1,fenceId:J(),port:j.port,expiresAtMs:X},y={binding:z,executorLaunchId:Y,job:{jobId:z.jobId,state:"running",startedAtMs:Date.now(),finishedAtMs:null,leaseExpiresAtMs:X,exitCode:null,inputSequence:0,output:[],firstCursor:1,nextCursor:0,truncated:!1,process:{pid:B.pid,processGroupId:B.pid,executorLaunchId:Y}}},I=f({binding:z,deniedPorts:new Set,readCurrentJob:async()=>!Z&&!F.signal.aborted?y:null});M=await L({binding:z,deviceRelayUrl:`ws://127.0.0.1:${j.port}/device/readiness/${j.token}`,port:I,signal:F.signal}),q=await Promise.race([P,_])===!0&&!F.signal.aborted&&!Q.aborted}catch{q=!1}finally{if(clearTimeout(T),Q.removeEventListener("abort",C),M?.close(),F.abort(),B.stdin.destroy(),!Z)B.kill("SIGKILL");await N}return q&&Z}
5
+ export{d as z};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Rk as $}from"./vm-hands-entry-lite-c5gt0086.js";var k=$.version,O=`reason-cli/${k}`,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function b(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
3
+ export{k as Mk,O as Nk,Z as Ok,S as Pk,b as Qk};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import{mk as w}from"./vm-hands-entry-lite-56v9haps.js";import{Mk as h}from"./vm-hands-entry-lite-q9g11dbj.js";import{randomUUID as d}from"crypto";import{spawnSync as F}from"child_process";import{chmodSync as Kj,cpSync as Nj,existsSync as I,lstatSync as H,mkdirSync as s,readdirSync as Qj,readFileSync as S,readlinkSync as Uj,realpathSync as B,renameSync as A,rmdirSync as Vj,rmSync as D,symlinkSync as y,writeFileSync as Wj}from"fs";import{dirname as G,join as V,relative as Xj,resolve as Yj}from"path";var Zj="so.ara.cli",E=[Zj,"com.reasonmachines.cli"],m="5LJFSBRY2F";function u(j){return`(${j.map((z)=>`identifier "${z}"`).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] = "${m}"`}var $j="Background/Reason.app",l="ReasonBackgroundIdentity",yj="Contents/Helpers/ReasonPermissionTile",wj="so.ara.cli.permission-tile",xj=u([wj,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",Dj="Reason",gj=u(E),Pj=`anchor apple generic and (${E.map((j)=>`identifier "${j}"`).join(" or ")}) and certificate leaf[subject.OU] = "${m}"`;class C extends Error{code;constructor(j,z){super(z);this.code=j;this.name="MacOSBackgroundIdentityError"}}var M="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function L(j=w()){return V(j,"Library","Application Support","Reason","Background","Reason.app")}function O(j=w()){return V(j,"Library","Application Support","Ara","Background","Ara.app")}function bj(j=process.execPath){return V(G(B(j)),$j)}function qj(j){try{return H(j).isFile()}catch{return!1}}function f(j){return[l,k].map((z)=>V(j,"Contents","MacOS",z)).find(qj)??null}function Y(j){try{if(!H(j).isDirectory())return!1;let z=S(V(j,"Contents","Info.plist"),"utf8");return E.some((J)=>z.includes(`<string>${J}</string>`))&&(z.includes(`<string>${Dj}</string>`)||z.includes("<string>Ara</string>"))&&f(j)!==null}catch{return!1}}function c(j=w()){let z=L(j);if(!Y(z))return null;try{let J=S(V(z,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(J)?.[1]??null}catch{return null}}function Aj(j,z=w()){let J=c(z);return J===null||t(v(J.split(".")),v(j.split(/[.-]/).slice(0,3)))}var Gj=1e4;function i(j,z){return F(j,[...z],{stdio:"ignore",timeout:Gj}).status??1}var o=new Set;function r(j){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let z=(J)=>{try{return B(J)}catch{return Yj(J)}};if(j!==void 0&&z(j)!==z(w()))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 n=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,p=new Set(["ara","ara.exe","reason","reason.exe"]);function v(j){return j.map((z)=>Number(z))}function t(j,z){for(let J=0;J<3;J+=1)if(j[J]!==z[J])return j[J]<z[J];return!1}var Lj=[0,2,161];function Tj(j){if(j===null)return!0;let z=Lj,J=null;try{J=B(process.execPath)}catch{}return j.some((K)=>{let N=n.exec(K);if(N){let Z=N[1]===void 0?N.slice(4,7):N.slice(1,4);return t(v(Z),z)}let Q=K.slice(K.lastIndexOf("/")+1);return p.has(Q)&&K!==J&&K!==process.execPath})}function _j(){let j=F("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(j.status!==0)return null;let z=[];for(let J of j.stdout.split(`
3
+ `)){let K=/^\s*(\d+)\s+(\S.*)$/.exec(J);if(!K||Number(K[1])===process.pid)continue;let N=K[2].trimEnd(),Q=N.slice(N.lastIndexOf("/")+1);if(!n.test(N)&&p.has(Q)){let W=F("/usr/sbin/lsof",["-a","-p",K[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
+ `).find((X)=>X.startsWith("n/"));if(W)N=W.slice(1)}z.push(N)}return z}function Cj(j){if(r(j.home),!Y(j.sourceApp))throw new C("identity_invalid","The packaged Reason background identity is missing or invalid.");let z=j.command??i,J=L(j.home),K=G(J);s(K,{recursive:!0,mode:448}),Kj(K,448);let N=B(j.sourceApp),Q=null;try{Q=B(J)}catch{}if(N!==Q){let Z=`${process.pid}.${d()}`,W=V(K,`.Reason.app.${Z}.tmp`),X=V(K,`.Reason.app.${Z}.old`),P=!1;try{if(Nj(N,W,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!Y(W))throw new C("identity_invalid","The copied Reason background identity is invalid.");let T=j.releaseSigned?["--test-requirement",`=${Pj}`]:[];if(z("/usr/bin/codesign",["--verify","--strict",...T,W])!==0)throw new C("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let _=!1;for(let $=0;$<4;$+=1){let q=!1;try{A(J,X),q=!0,P=!0}catch(U){if(U.code!=="ENOENT")throw U}if($===0)j.beforePublish?.();try{A(W,J),_=!0}catch(U){let Jj=U.code;if(!["EEXIST","ENOTEMPTY"].includes(Jj??""))throw U;if(q)D(X,{recursive:!0,force:!0}),P=!1;if($===3)throw U;continue}if(q)D(X,{recursive:!0,force:!0}),P=!1;break}if(!_)throw Error("Could not publish Reason's background identity.")}catch(T){if(P&&!I(J)&&I(X))A(X,J);throw T}finally{D(W,{recursive:!0,force:!0}),D(X,{recursive:!0,force:!0})}}return zj(J,j,{verified:N!==Q}),J}function a(j){return V(G(j),".Reason.app.registered")}function e(j){try{let z=H(j);return z.isDirectory()?`${z.ino}:${z.birthtimeMs}`:null}catch{return null}}function R(j){let z=e(j);try{return z!==null&&S(a(j),"utf8")===z}catch{return!1}}function jj(j){if(Y(j))return"bundle";try{if(H(V(j,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return H(V(j,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function zj(j,z,J={}){let K=z.command??i;if(!J.verified&&K("/usr/bin/codesign",["--verify","--strict",j])!==0)throw new C("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(K(M,["-f",j])!==0)throw new C("identity_register_failed","Could not register Reason's macOS background identity.");let N=e(j);try{if(N)Wj(a(j),N,{mode:384})}catch{}try{Fj(j,z.home,K,z.runningExecutables??_j)}catch(Q){let Z=Q.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${Z})
5
+ `)}}function Fj(j,z,J,K){let N=f(j);if(!N)return;let Q=O(z),Z=G(Q),W=(U)=>V(U,"Contents","MacOS",k),X=Xj(G(W(Q)),N),P=`${process.pid}.${d()}`,T=jj(Q);if(T===null)return;let _=T==="bundle";if(_)J(M,["-u",Q]);let $=V(Z,`.Ara.app.${P}.old`);if(!o.has(Q)&&!Tj(K())){if(!_)J(M,["-u",Q]);try{A(Q,$)}catch(U){if(U.code==="ENOENT")return;throw U}D($,{recursive:!0,force:!0}),Hj(Z);return}if(!_){if(Uj(W(Q))===X)return;let U=`${W(Q)}.${P}`;y(X,U);try{A(U,W(Q))}finally{D(U,{force:!0})}return}let q=V(Z,`.Ara.app.${P}.shim`);s(G(W(q)),{recursive:!0}),y(X,W(q));try{try{A(Q,$)}catch(U){if(U.code==="ENOENT")return;throw U}try{A(q,Q)}catch(U){if(I(Q))return;throw A($,Q),U}}finally{D(q,{recursive:!0,force:!0}),D($,{recursive:!0,force:!0})}}function Hj(j){try{if(Qj(j).some((J)=>J!==".DS_Store"))return;D(V(j,".DS_Store"),{force:!0}),Vj(j)}catch{}}var x=new Map;function Bj(j=w()){let z=x.get(j);if(z)return z;if(process.platform!=="darwin")return[];let J=g(j);if(J===null&&I(G(L(j))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),J=g(j);if(J===null)return[];return x.set(j,J),J}function g(j){let z=L(j),J=O(j);if(!Y(z)||!R(z))try{Oj({home:j,skipWhenSettled:!0})}catch{}let K=Y(z)&&(R(z)||!Y(J))?z:Y(J)?J:null,N=K?f(K):null;if(!N)return null;if(K===J)o.add(J);let Q=F(N,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return Q.status===0&&Q.stdout===`spawn
6
+ `?[N,"--spawn"]:[]}var b=new Map;function Ij(j=w()){let z=Bj(j),J=z[0];if(!J)return[];let K=b.get(J);if(K===void 0){let N=F(J,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});K=N.status===0&&N.stdout===`spawn
7
+ `,b.set(J,K)}return K?z:[]}function hj(j=Ij(),z=w()){if(j.length>0)return null;if(c(z)===null)return"computer_use_identity_missing";return Aj(h,z)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Oj(j={}){r(j.home);let z=L(j.home);if(j.skipWhenSettled&&Y(z)&&R(z)&&jj(O(j.home))===null)return!0;if(!Y(z)){let J=O(j.home);if(!Y(J))return!1;try{return Cj({...j,sourceApp:J}),!0}catch(K){if(!Y(z))throw K}}return zj(z,j),!0}var Mj="REASON_WORKER_IDENTITY_APP";function dj(j,z=process.env,J=w()){let K=z[Mj];return K&&K===L(J)?K:j}function sj(j,z){if(process.platform!=="darwin")return null;let J=L(j),K=V(J,"Contents","MacOS",l),N=F(K,["--can-run-worker",z],{env:{},timeout:2000,encoding:"utf8"});return N.status===0&&N.stdout===`run-worker
8
+ `?{app:J,executable:K}:null}
9
+ export{Zj as Pj,m as Qj,u as Rj,yj as Sj,C as Tj,M as Uj,L as Vj,bj as Wj,c as Xj,Aj as Yj,Cj as Zj,Bj as _j,Ij as $j,hj as ak,Oj as bk,Mj as ck,dj as dk,sj as ek};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{ll as L}from"./vm-hands-entry-lite-v4r1fggm.js";import{sl as O}from"./vm-hands-entry-lite-kqbats5n.js";import{execFileSync as K}from"child_process";import{mkdirSync as j,readdirSync as f,readFileSync as v,rmSync as R,statSync as A,writeFileSync as C}from"fs";import{join as $,sep as F}from"path";import{setTimeout as M}from"timers/promises";var k=3000,Y=null;function W(z){return $(z,"users")}function h(z){if(Y?.root===z.root)return;let J=W(z.root);j(J,{recursive:!0,mode:448}),C($(J,String(process.pid)),"",{mode:384}),Y=z}function y(){if(!Y)return;R($(W(Y.root),String(process.pid)),{force:!0}),Y=null}function G(z){try{return process.kill(z,0),!0}catch(J){return J instanceof Error&&"code"in J&&J.code==="EPERM"}}function P(){let z=process.getuid?.();if(process.platform==="linux")return f("/proc").flatMap((N)=>{if(!/^\d+$/.test(N))return[];try{if(A(`/proc/${N}`).uid!==z)return[];let Q=v(`/proc/${N}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return Q?[{pid:Number(N),command:Q}]:[]}catch{return[]}});if(process.platform==="win32")return K(O("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((Q)=>{let X=/^(\d+) (.+)$/.exec(Q.trim());return X?[{pid:Number(X[1]),command:X[2]}]:[]});return K("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
+ `).flatMap((N)=>{let Q=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(N);return Q&&Number(Q[2])===z?[{pid:Number(Q[1]),command:Q[3]}]:[]})}async function u(){let z=Y;if(!z)return{released:"unused",stopped:0};let J=W(z.root);R($(J,String(process.pid)),{force:!0}),Y=null;let N=!1;for(let H of f(J)){let V=Number(H);if(Number.isSafeInteger(V)&&V>0&&G(V))N=!0;else R($(J,H),{force:!0})}if(N)return{released:"shared",stopped:0};let Q=P().filter((H)=>H.pid!==process.pid&&(H.command.includes(`${z.root}${F}`)||H.command.includes(`${z.automation}${F}`)||H.command.includes(z.extensionDir))),X=(H,V)=>{try{process.kill(H,V)}catch{}};for(let H of Q)X(H.pid,"SIGTERM");for(let H=Date.now()+k;Date.now()<H&&Q.some((V)=>G(V.pid));)await new Promise((V)=>setTimeout(V,100));for(let H of Q)if(G(H.pid))X(H.pid,"SIGKILL");return{released:"stopped",stopped:Q.length}}var T=20000,b=30000,D=100,Z=new Map,U=null,x=0,B=[];function c(z){Z.set(z,(Z.get(z)??0)+1);let J=!1;return()=>{if(J)return;J=!0;let N=(Z.get(z)??1)-1;if(N>0){Z.set(z,N);return}if(Z.delete(z),U?.run===z)U.idleUntil=0}}function E(){return new L("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function g(z,J){return U!==null&&U.run!==z&&(U.calls>0||J<U.idleUntil)}async function l(z,J,N=Date.now,Q="run"){let X=Symbol(z);B.push(X);try{let q=N()+b;for(;;){if(x===0&&!g(z,N())&&(U?.run===z||B[0]===X))break;if(N()>=q)throw E();await M(D,void 0,{signal:J}).catch(()=>J.throwIfAborted())}}finally{B.splice(B.indexOf(X),1)}if(Q==="call"&&!(U?.run===z&&(U.calls>0||N()<U.idleUntil))){x+=1;let q=!1;return()=>{if(q)return;q=!0,x-=1}}if(U?.run!==z)U={run:z,calls:0,idleUntil:0};let H=U;H.calls+=1;let V=!1;return()=>{if(V)return;V=!0,H.calls-=1,H.idleUntil=N()+T}}
4
+ export{h as el,y as fl,u as gl,T as hl,b as il,c as jl,l as kl};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{J as T,M as U}from"./vm-hands-entry-lite-6x5pj2y0.js";import{Hd as V}from"./vm-hands-entry-lite-3882raa5.js";import{Tk as M,Vk as Q}from"./vm-hands-entry-lite-e1xjfj57.js";import{bl as G}from"./vm-hands-entry-lite-8p8hz0j1.js";function W(j,B){let k=G(j,"REASON_API_URL")?.trim();if(!k)return Q(B);let z=new URL(k);if(z.protocol!=="https:"&&!(z.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(z.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return z.origin}function X(j){return G(j,"REASON_API_URL")?.trim()?W(j,"production"):void 0}function $(j){return G(j,"REASON_API_KEY")?.trim()||void 0}async function N(j,B){let k=j.env??process.env,z=$(k);if(!z)return(j.getCredentials??T)({apiOrigin:X(k),signal:B});let J=W(k,j.channel??M({env:k})),D=await(j.fetchImpl??fetch)(J+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+z,accept:"application/json"},signal:B}),L=await D.json().catch(()=>({})),w=V(L)?L:{};if(!D.ok){let H=typeof w.detail==="string"?w.detail:typeof w.message==="string"?w.message:"API key authentication failed ("+D.status+")";throw new U(D.status,typeof w.error==="string"?w.error:"api_key_auth_failed",H)}if(typeof w.org_id!=="string"||!w.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let Z=Array.isArray(w.scopes)?w.scopes.filter((H)=>typeof H==="string"):[];return{credentialKind:"api_key",apiOrigin:J,accessToken:z,orgId:w.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:Z}}async function P(j){let B=await N(j),k=X(j.env??process.env);if(!B)throw Error(k?`Not signed in to ${k}. Set REASON_API_KEY, or run \`reason login --api-url ${k}\`.`:"Not signed in. Run `reason login`, or set REASON_API_KEY.");return B}
3
+ export{W as A,X as B,$ as C,N as D,P as E};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{ti as d}from"./vm-hands-entry-lite-td309c1y.js";import{vi as h}from"./vm-hands-entry-lite-c8bf82tx.js";import{Di as p}from"./vm-hands-entry-lite-1nj03gbj.js";import{nk as s}from"./vm-hands-entry-lite-56v9haps.js";import{Ak as i}from"./vm-hands-entry-lite-jd31as70.js";import{ll as V}from"./vm-hands-entry-lite-v4r1fggm.js";import{Al as P}from"./vm-hands-entry-lite-ghhpgt3v.js";import{existsSync as U,realpathSync as l,statSync as e}from"fs";import{platform as f}from"os";import{isAbsolute as r,sep as zz}from"path";import{existsSync as n}from"fs";import{createRequire as t}from"module";var E=P(h)(()=>t(import.meta.url)("bun:ffi"),n);function m(){return process.platform==="win32"&&typeof globalThis.Bun<"u"&&E.available()}function w(z=process.env){return E.defaultShell(z)}function k(z){return E.shellArgs(z)}function v(z){let H=E.spawn({...z,env:z.environment});return H.exited.then(()=>H.close()),{write:(Q)=>H.write(Q),resize:(Q,J)=>H.resize(Q,J),kill:()=>H.close(),exited:H.exited}}var Hz=43200000,y=p,Jz=4,Qz=/^[A-Za-z0-9._:-]{1,160}$/,Vz=1000;function u(z){return Boolean(z)&&typeof z==="object"&&!Array.isArray(z)}function g(z,H){if(typeof z!=="number"||!Number.isFinite(z)||z<=0)return H;return Math.min(Vz,Math.max(1,Math.floor(z)))}function Zz(z,H=Date.now()){let Q=["relay_url","session_id","expires_at"],J=new Set([...Q,"cols","rows","cwd","workspace"]);if(!u(z)||Q.some((C)=>!(C in z))||Object.keys(z).some((C)=>!J.has(C)))throw new V("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:N,session_id:Y,expires_at:R}=z;if(typeof N!=="string")throw new V("invalid_pty_request","Reason terminal relay URL is missing.");let K;try{K=new URL(N)}catch{throw new V("invalid_pty_request","Reason terminal relay URL is invalid.")}if(K.protocol!=="wss:"&&K.protocol!=="ws:"||K.username||K.password)throw new V("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof Y!=="string"||!Qz.test(Y))throw new V("invalid_pty_request","Reason terminal session identity is invalid.");let D=typeof R==="string"?Date.parse(R):Number.NaN;if(!Number.isFinite(D)||D<=H)throw new V("invalid_pty_request","Reason terminal session has already expired.");if(z.cwd!==void 0&&typeof z.cwd!=="string")throw new V("invalid_pty_request","Reason terminal working directory is invalid.");let j=z.workspace===void 0?void 0:i(z.workspace);if(j===null||j&&z.cwd!==void 0)throw new V("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:N,session_id:Y,expires_at:new Date(Math.min(D,H+Hz)).toISOString(),cols:g(z.cols,80),rows:g(z.rows,24),...z.cwd===void 0?{}:{cwd:z.cwd},...j?{workspace:j}:{}}}function $z(z,H){if(f()==="win32")[z,H]=[z.toLowerCase(),H.toLowerCase()];return H===z||H.startsWith(z+zz)}function c(z,H){if(H===void 0)return z;if(!r(H))throw new V("pty_cwd_invalid","Reason terminal working directory must be absolute.");let Q;try{Q=l(H)}catch{throw new V("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!$z(z,Q))throw new V("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!e(Q).isDirectory())throw new V("pty_cwd_invalid","Reason terminal working directory is not a directory.");return Q}function jz(z=process.env){if(f()==="win32")return w(z);let H=z.SHELL;if(H&&r(H)&&U(H))return H;for(let Q of f()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(U(Q))return Q;return"/bin/sh"}function Gz(){let z=globalThis.Bun;if(!z)throw new V("pty_unavailable","Reason terminals require the Bun runtime.");return z.spawn}function Sz(){if(f()==="win32")return m();return typeof globalThis.Bun<"u"}var Nz=(z)=>{if(f()==="win32")try{return v({...z,file:z.shell,args:k(z.shell),environment:{...z.environment,TERM:"xterm-256color"}})}catch{throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}let H=Gz()({cmd:[z.shell,"-i","-l"],cwd:z.cwd,env:{...z.environment,TERM:"xterm-256color"},terminal:{cols:z.cols,rows:z.rows,data:(J,N)=>{z.onData(N)}}}),Q=H.terminal;if(!Q){try{H.kill()}catch{}throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(J)=>Q.write(J),resize:(J,N)=>Q.resize(J,N),kill:()=>{try{H.kill()}catch{}},exited:H.exited.then((J)=>typeof J==="number"?J:null,()=>null)}},Wz=(z,H)=>{return H===void 0?new WebSocket(z):new WebSocket(z,{proxy:H})},M=new Set;function Kz(z){if(M.size>=Jz||M.has(z))return null;M.add(z);let H=!1;return()=>{if(H)return;H=!0,M.delete(z)}}async function Tz(z,H={}){let Q=H.now??Date.now,J=Zz(z.payload,Q()),N=Kz(z.operationId);if(!N)throw new V("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let Y=Q(),R,K,D;try{let j=J.workspace?s(z.root,J.workspace):void 0;R=j?c(U(j.boundary)?l(j.boundary):j.boundary,j.path):c(z.root,J.cwd),K=H.environment??process.env,D=H.shellPath??jz(K)}catch(j){throw N(),j}return await new Promise((j,C)=>{let F=null,$=null,I=!1,B=!1,X=!1,_=null,b=0,x=0,O=[],S=0,T=null,G=(Z)=>{if(X)return;if(X=!0,T)clearTimeout(T);z.signal.removeEventListener("abort",A);try{F?.kill()}catch{}try{$?.close(1000,"pty_session_over")}catch{}if(N(),Z.kind==="rejected"){C(Z.error);return}let W={reason:Z.reason,exit_code:_,output_bytes:b,input_bytes:x,duration_ms:Math.max(0,Q()-Y)};z.emitEvent("pty.stopped",{...W}).catch(()=>{return}),j({...W})},A=()=>{let Z=z.signal.reason;G({kind:"rejected",error:Z instanceof V?Z:new V("cancelled","Reason closed the terminal session.")})};if(z.signal.aborted){A();return}z.signal.addEventListener("abort",A,{once:!0}),T=setTimeout(()=>G({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(J.expires_at)-Q()));let a=(Z)=>{if(b+=Z.byteLength,!I||!$){if(O.push(Z),S+=Z.byteLength,S>y)G({kind:"resolved",reason:"output_backpressure"});return}try{$.send(Z)}catch{G({kind:"resolved",reason:"relay_closed"});return}if($.bufferedAmount>y)G({kind:"resolved",reason:"output_backpressure"})};try{F=(H.spawnPty??Nz)({shell:D,args:["-i","-l"],cwd:R,cols:J.cols,rows:J.rows,environment:K,onData:(Z)=>{if(!X)a(Z)}})}catch(Z){G({kind:"rejected",error:Z instanceof V?Z:new V("pty_spawn_failed","Reason could not start the terminal shell.")});return}F.exited.then((Z)=>{if(X)return;if(_=Z,I&&$)try{$.send(JSON.stringify({t:"exit",code:Z}))}catch{}G({kind:"resolved",reason:"shell_exited"})});let o=(H.loadProxy??d)()?.url;try{$=(H.connect??Wz)(J.relay_url,o)}catch{G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}$.binaryType="arraybuffer",$.onopen=()=>{if(X||!$)return;I=!0;try{$.send(JSON.stringify({t:"open",cols:J.cols,rows:J.rows}));for(let Z of O.splice(0))$.send(Z);S=0}catch{G({kind:"resolved",reason:"relay_closed"});return}B=!0,z.emitEvent("pty.ready",{session_id:J.session_id,cols:J.cols,rows:J.rows}).catch(()=>{return})},$.onmessage=(Z)=>{if(X||!F)return;let W=Z.data;if(typeof W==="string"){let L;try{L=JSON.parse(W)}catch{return}if(!u(L))return;if(L.t==="resize"){try{F.resize(g(L.cols,J.cols),g(L.rows,J.rows))}catch{}return}if(L.t==="close")G({kind:"resolved",reason:"client_closed"});return}let q=W instanceof ArrayBuffer?new Uint8Array(W):ArrayBuffer.isView(W)?new Uint8Array(W.buffer,W.byteOffset,W.byteLength):null;if(!q||q.byteLength===0)return;x+=q.byteLength;try{F.write(q)}catch{}},$.onclose=()=>{if(X)return;if(!B){G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}G({kind:"resolved",reason:"relay_closed"})},$.onerror=()=>{if(X||B)return;G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}
3
+ export{m as Vh,Hz as Wh,y as Xh,Jz as Yh,Zz as Zh,c as _h,jz as $h,Sz as ai,Nz as bi,Wz as ci,Tz as di};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{We,uo,F,Ve,Ft,Tr,x}from"./vm-hands-entry-lite-mqzr55mw.js";import{K}from"./vm-hands-entry-lite-ncbzy69k.js";import{dt}from"./vm-hands-entry-lite-eabever7.js";import{mt}from"./vm-hands-entry-lite-wg0cykk2.js";import{Rr}from"./vm-hands-entry-lite-0y9n06b6.js";import{xt,$i}from"./vm-hands-entry-lite-xdjrdkh2.js";import{G,qe}from"./vm-hands-entry-lite-kq7hrjch.js";import{xe,Jn}from"./vm-hands-entry-lite-57v7y0km.js";import{vt}from"./vm-hands-entry-lite-5tbntcyq.js";import{a}from"./vm-hands-entry-lite-swrymqj9.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{C}from"./vm-hands-entry-lite-87vmbt38.js";import{spawn as R,spawnSync as st}from"child_process";import{createHash as it,randomUUID as ge}from"crypto";import{closeSync as at,copyFileSync as ae,existsSync as M,fstatSync as ct,mkdirSync as ce,openSync as lt,readdirSync as U,readFileSync as X,readlinkSync as ut,renameSync as he,rmSync as pt,statSync as ft,writeFileSync as gt}from"fs";import{connect as ht}from"net";import{tmpdir as L,userInfo as we}from"os";import{basename as le,delimiter as wt,dirname as B,join as f}from"path";var z=`import { spawn, execFileSync } from "node:child_process";
2
+ import{Ae as ce,Ce as le}from"./vm-hands-entry-lite-g6r5xrk0.js";import{mg as Se}from"./vm-hands-entry-lite-p9fwt68c.js";import{Pg as O,Qg as Ne}from"./vm-hands-entry-lite-v0bp1v66.js";import{Tg as W,Ug as se,Vg as L,Yg as Te,dh as j,eh as K,fh as T}from"./vm-hands-entry-lite-zj3hb5jk.js";import{jh as ne}from"./vm-hands-entry-lite-b0p8f295.js";import{Ph as Ie,Qh as ae}from"./vm-hands-entry-lite-8twscwtw.js";import{vj as ye}from"./vm-hands-entry-lite-k9n1pk42.js";import{$j as J}from"./vm-hands-entry-lite-r374pchj.js";import{mk as x}from"./vm-hands-entry-lite-56v9haps.js";import{el as Oe,kl as Re}from"./vm-hands-entry-lite-r665z809.js";import{ll as p}from"./vm-hands-entry-lite-v4r1fggm.js";import{sl as ve}from"./vm-hands-entry-lite-kqbats5n.js";import{spawn as S,spawnSync as ht}from"child_process";import{createHash as wt,randomUUID as Ae}from"crypto";import{closeSync as gt,copyFileSync as fe,existsSync as q,fstatSync as bt,mkdirSync as me,openSync as xt,readdirSync as D,readFileSync as X,readlinkSync as St,renameSync as $e,rmSync as yt,statSync as It,writeFileSync as vt}from"fs";import{connect as Ot}from"net";import{tmpdir as B,userInfo as ke}from"os";import{basename as _e,delimiter as Rt,dirname as F,join as f}from"path";var Z=`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";
@@ -854,7 +854,11 @@ if(process.env.REASON_CLOUD_GATEWAY_EXEC === "1") {
854
854
  process.stdout.write(JSON.stringify(cloudAutomationFailure(error))+"\\n");process.exitCode=1;
855
855
  }
856
856
  }
857
- `;import{spawn as Te}from"child_process";import{lstatSync as V,readFileSync as Z,rmSync as Ne}from"fs";import{basename as Pe}from"path";var De="__desktop-call",Me="/usr/bin/setpriv",Ue=27262976,Le=8192,$e=2000;function W(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Be(e){try{return JSON.parse(e)}catch{return null}}function Fe(){return[process.execPath,...Pe(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],De]}function Ge(e){let o=(i)=>{try{return V(i).uid}catch{return null}},t=V("/tmp/.X11-unix",{throwIfNoEntry:!1});if(!t?.isDirectory()||t.uid!==0)return;let n=["/tmp/.X99-lock","/tmp/.X11-unix/X99"].filter((i)=>{let u=o(i);return u!==null&&u!==e.uid});if(!n.length)return;let s="";try{let i=Z("/tmp/.X99-lock","utf8").trim();if(/^\d+$/.test(i))s=Z(`/proc/${i}/comm`,"utf8").trim()}catch{}if(/^X/.test(s))return;for(let i of n)Ne(i,{force:!0})}function Mt(e,o,t,n={}){if(t.throwIfAborted(),(o.op==="display"||o.op==="automation")&&process.platform==="linux"&&process.getuid?.()===0)try{Ge(e)}catch{}let s=n.command??Fe();return new Promise((i,u)=>{let c=(n.spawnProcess??Te)(Me,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...s],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),d=[],m=0,l="",p=null,g=!1,h,y=(_)=>{try{process.kill(-c.pid,_)}catch{c.kill(_)}},I=(_)=>{p??=_,y("SIGTERM"),h??=setTimeout(()=>y("SIGKILL"),$e)},S=()=>I(new r("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",S,{once:!0});let w=(_)=>{if(g)return;g=!0,clearTimeout(h),t.removeEventListener("abort",S),_()};if(c.stdout.on("data",(_)=>{if(m+=_.byteLength,m>Ue)I(new r("desktop_delegate_failed","Reason's desktop reply is too large."));else d.push(_)}),c.stderr.setEncoding("utf8").on("data",(_)=>{l=(l+_).slice(-Le)}),c.stdin.on("error",()=>{}),c.once("error",()=>w(()=>u(p??new r("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),c.once("close",(_,Ee)=>w(()=>{if(p)return u(p);let b=Be(Buffer.concat(d).toString("utf8"));if(W(b)&&b.ok===!0&&W(b.result))return i(b.result);let O=W(b)&&b.ok===!1&&typeof b.code==="string"&&typeof b.message==="string"?new r(b.code.slice(0,120),b.message.slice(0,2000)):null,J=`exited ${_??Ee}${O?"":" with no reply"}`,Y=l.trim().split(`
858
- `).at(-1)?.slice(-300)??"";if(!O||O.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${J}${l?`: ${l.trim().slice(-500)}`:""}
859
- `);if(O)return u(O);u(new r("desktop_delegate_failed",`Reason's desktop operation failed (${J}${Y?`: ${Y}`:""}).`))})),t.aborted)S();c.stdin.end(JSON.stringify(o))})}async function Q(e,o,t,n={}){let s=await Mt(e,{op:"automation",call:o},t,n);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new r("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as He,spawn as je}from"child_process";import{closeSync as Xe,mkdirSync as Ke,openSync as Je}from"fs";import{dirname as E,join as Ye}from"path";import{promisify as ze}from"util";var Ze=ze(He),ee="x-apple.systempreferences:com.apple.preference.security",Qe={accessibility:`${ee}?Privacy_Accessibility`,screen:`${ee}?Privacy_ScreenCapture`},et=64,A=new Map;function T(e,o){let t=A.get(e);if(t?.has(o))return!1;if(!t){if(A.size>=et)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(o),!0}function tt(){let e=a(),o=Jn(xe(e),process.env),t=Ye(e,".local","share","reason","desktop-install.log");Ke(E(t),{recursive:!0,mode:448});let n=Je(t,"a",384);try{let s=je(o,["desktop","install"],{detached:!0,stdio:["ignore",n,n],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{Xe(n)}}var N={open:async(e,o)=>{await Ze("/usr/bin/open",e,{signal:o,timeout:1e4,maxBuffer:8192})},request:(e,o)=>dt(e,o),tile:Rr,installDesktop:tt},te=!1;async function oe(e,o,t){try{await o.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await o.open([e],t)}}async function ne(e,o,t,n){if(await t.open([Qe[o]],n).catch(()=>{}),e[0]&&!n.aborted)t.tile(E(E(E(e[0]))),o)}async function ot(e,o,t,n,s){for(let i of t){if(!T(e,`grant:${i}`))continue;s.throwIfAborted(),await n.request(o,i).catch(()=>null),await ne(o,i,n,s)}}var rt={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function re(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function nt(e){if(typeof e!=="string")return null;try{let o=new URL(e);return o.protocol==="https:"||o.protocol==="http:"?o.href:null}catch{return null}}async function se(e,o=N){let{call:t,runId:n,signal:s}=e;if(t.kind==="browser"){if(t.operation==="discover")return re({result:{tools:[rt]}});if(t.operation!=="call")throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!te){te=!0;try{o.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&T(n,"grant:probe")){let c=await o.request(e.identity).catch(()=>null),d=c?[...c.accessibility?[]:["accessibility"],...c.screen?[]:["screen"]]:[];for(let m of d)T(n,`grant:${m}`);for(let m of d)await ne(e.identity,m,o,s)}throw new r("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(T(n,"page:chrome-extension"))await oe(uo,o,s).catch(()=>{});let i=t.arguments,u=t.operation==="call"&&t.tool==="open_tab"&&i&&typeof i==="object"&&!Array.isArray(i)?nt(i.url):null;if(!u)throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await oe(u,o,s),re({result:{content:[{type:"text",text:JSON.stringify({opened:u,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ie(e,o=N){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let n=t.permissions;if(!n||typeof n!=="object")return e.output;let s=n,i=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(i.length===0)return e.output;return await ot(e.runId,e.identity,i,o,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:i}))}}var j=172032,_t=18874368,yt=8192,bt=65536,St=55000,kt=60000,Rt=4,It=40000,Ot=/^[0-9a-f-]{36}$/,ue=z,At=ge();function P(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function D(){throw new r("invalid_automation_request","Reason automation request is malformed.")}function _e(e){let o=Object.keys(e).sort().join(",");if(o==="call"||o==="browser,call"){let t=e.call,n=o==="browser,call";if(!P(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||n&&(e.browser!==vt||t.kind!=="browser")||JSON.stringify(t).length>bt)D();return{call:t,userChrome:n}}if(o==="offset,output_id"){if(typeof e.output_id!=="string"||!Ot.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)D();return{output_id:e.output_id,offset:e.offset}}return D()}function Tn(e=process.platform,o=x){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&o()?.features.computer===!0}var Et="__computer-use";function Ns(e=x){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function ye(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:"ignore",windowsHide:!0}),u=setTimeout(()=>{i.kill("SIGKILL"),s(-1)},n);i.once("error",()=>{clearTimeout(u),s(-1)}),i.once("exit",(c)=>{clearTimeout(u),s(c??-1)})})}function Ct(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),u="";i.stdout.setEncoding("utf8").on("data",(d)=>{u+=d});let c=setTimeout(()=>{i.kill("SIGKILL"),s(null)},n);i.once("error",()=>{clearTimeout(c),s(null)}),i.once("close",(d)=>{clearTimeout(c),s(d===0?u:null)})})}function Tt(e){return v(e)?f(L(),"open-browser-use"):"/tmp/open-browser-use"}function v(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Nt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Pt=33554432;function Dt(e,o){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let n=P(t)&&P(t.result)?t.result.metadata:null;if(!P(n)||n.extensionId!==o)return null;return typeof n.extensionInstanceId==="string"&&Nt.test(n.extensionInstanceId)?n.extensionInstanceId:null}async function be(e,o,t){let n=t.storages.map((c)=>{try{return U(c).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>f(c,d))}catch{return[]}}),s;try{s=n.some((c)=>c.length>0)?U(t.socketDir).filter((c)=>c.endsWith(".sock")):[]}catch{return[]}let i=[];for(let c of s){let d=f(t.socketDir,c),m=Dt(await Ct(e,["info","--socket",d,"--timeout","2s"],o,5000),t.extensionId);if(m)i.push({instance:m,socket:d})}let u=[];for(let[c,d]of(i.length>0?n:[]).entries())for(let m of d)try{if(ft(m).size>Pt)continue;let l=X(m),p=i.find((g)=>l.includes(g.instance));if(p){u.push({storage:t.storages[c],...p});break}}catch{}return u}async function Ut(e,o,t){return(await be(e,o,t))[0]?.instance??null}function Se(e,o,t){return Ut(e.nativeHost,o,{socketDir:Tt(e),extensionId:F,storages:[f(t,"browser-profile","Default","Local Extension Settings",F)]})}var de=/^(Default|Profile ([0-9]+))$/;async function Lt(e,o,t=a(),n=Ft){let s=f(t,"Library","Application Support","Google","Chrome"),i=[];try{i=U(s)}catch(l){if(l.code==="EPERM")throw new r("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let u=(l)=>Number(de.exec(l)?.[2]??-1),c=i.filter((l)=>de.test(l)&&M(f(s,l,"Extensions",We))).sort((l,p)=>u(l)-u(p)),d=(l)=>f(s,l,"Local Extension Settings",We);return(await be(e,o,{socketDir:n,extensionId:We,storages:c.map(d)})).map(({storage:l,instance:p,socket:g})=>({profile:c.find((h)=>d(h)===l),instance:p,socket:g}))}async function $t(e,o,t=a(),n=Ft){let s=(await Lt(e,o,t,n))[0]?.instance;if(!s)throw new r("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function pe(e){return new Promise((o)=>{let t=ht({path:e}),n=(s)=>{t.destroy(),o(s)};t.setTimeout(1000,()=>n(!1)),t.once("error",()=>n(!1)),t.once("connect",()=>n(!0))})}async function ke(e,o){let t=Date.now()+o;while(Date.now()<t){if(await e())return!0;await new Promise((n)=>setTimeout(n,200))}return!1}var q=new Map;function H(e,o){let t=q.get(e);if(!t)t=o().finally(()=>q.delete(e)),q.set(e,t);return t}async function Bt(e,o){if(await pe(e))return;if(pt(e,{force:!0}),await ye("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],o,1e4)!==0||!await ke(()=>pe(e),5000))throw new r("automation_unavailable","Reason could not start the desktop session bus.")}async function me(e,o,t){let n=e.platform==="darwin-arm64"||v(e)?async()=>await Se(e,o,t)!==null:async()=>await ye(e.nativeHost,["info"],o,5000)===0;if(await n())return;let s=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],i,u=null,c=0;if(e.platform==="darwin-arm64"){let l=f(t,"browser-profile");G(l);let p=f(l,"NativeMessagingHosts");ce(p,{recursive:!0,mode:448});let g=Tr(e.platform).nativeHostManifests[0];ae(g,f(p,le(g)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),y=s.filter((I)=>I!=="about:blank").concat("--no-startup-window","--use-mock-keychain");i=R("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${l}`,...y],{env:o,stdio:"ignore"})}else if(v(e)){let l=f(t,"browser-profile");G(l),st(C("icacls"),[B(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let p=s.filter((g)=>g!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");i=R(e.browser,[`--user-data-dir=${l}`,...p],{detached:!0,stdio:"ignore",env:o})}else{let l=f(o.HOME,".config","google-chrome"),p=f(l,"NativeMessagingHosts");ce(p,{recursive:!0,mode:448});let g=Tr(e.platform).nativeHostManifests[0];ae(g,f(p,le(g)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];u=f(t,"browser.log");let y=lt(u,"a",384);c=ct(y).size,i=R(e.browser,[`--user-data-dir=${l}`,...s,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",y,y],env:{...o,ACCESSIBILITY_ENABLED:"1"}}),at(y)}let d=!1;i.once("error",()=>{d=!0}),i.once("exit",(l)=>{d||=l!==0}),i.unref();let m=!1;if(await ke(async()=>d||(m=await n()),It),!m){if(u&&X(u).subarray(c).toString("utf8").includes("No usable sandbox"))throw new r("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Ls(e){await ve(e,!0)}function Ms(e){return Re(e,Ie(e))}function Re(e,o){return e.platform==="darwin-arm64"||v(e)?f(o,"browser-profile"):f(o,"home",".config","google-chrome")}function Ie(e){let o=f(e.root,"automation");if(!M(o)||!Wt(e.automation))return e.automation;if(!qt(Re(e,o)))try{he(o,e.automation)}catch{}return M(o)?o:e.automation}function Wt(e){try{return U(e).length===0}catch(o){return o.code==="ENOENT"}}function qt(e){let o;try{o=ut(f(e,"SingletonLock"))}catch{return!1}let t=Number(o.slice(o.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function ve(e,o){xt({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=Ie(e);G(t);let n=we().username,s={USER:n,LOGNAME:n,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||v(e)){let l=v(e)?{...s,...Gt(),HOME:a()}:{...s,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:Et};if(!o)return l;await H("browser",()=>me(e,l,t));let p=await Se(e,l,t);if(!p)throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...l,REASON_AUTOMATION_OBU_INSTANCE:p,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let i=await qe(),u=f(t,"home"),c=f(t,"runtime");G(u),G(c);let d=f(t,"bus"),m={...s,HOME:u,PATH:`${B(e.node)}:/usr/bin:/bin`,DISPLAY:i.display,XAUTHORITY:i.xauthority,XDG_RUNTIME_DIR:c,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...i.sound?{PULSE_SERVER:Ve(i.sound)}:{}};if(await H("bus",()=>Bt(d,m)),o)await H("browser",()=>me(e,m,t));return m}function Gt(){let e=process.env.SystemRoot??"C:\\Windows",o=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((n)=>process.env[n]?[[n,process.env[n]]]:[])),t=f(e,"System32");return{...o,SystemRoot:e,windir:e,TEMP:L(),TMP:L(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(wt)}}async function Ht(e,o,t){let n=we().username,s={USER:n,LOGNAME:n,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:o,REASON_AUTOMATION_BACKGROUND_TABS:"1"},i=await $t(o,s);return t.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:i}}function jt(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let o=f(L(),`reason-automation-${it("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!M(o)||X(o,"utf8")!==e){let t=`${o}.${process.pid}.tmp`;gt(t,e,{mode:384}),he(t,o)}return[o]}function Oe(e,o,t,n){if(typeof ue!=="string")return Promise.reject(new r("automation_unavailable","This Reason build has no automation runtime."));let s=ue;return new Promise((i,u)=>{let c=R(e,jt(s),{env:{...o,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),d=[],m=0,l="",p=null,g=!1,h=(w)=>{if(p??=w,process.platform==="win32"&&c.pid){R(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(c.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>c.kill("SIGKILL"));return}try{process.kill(-c.pid,"SIGKILL")}catch{c.kill("SIGKILL")}},y=(w)=>{if(g)return;g=!0,clearTimeout(I),n.removeEventListener("abort",S),w()},I=setTimeout(()=>h(new r("automation_timed_out","Reason automation did not finish in time.")),St),S=()=>h(new r("cancelled","Reason cancelled the automation call."));if(n.addEventListener("abort",S,{once:!0}),c.stdout.on("data",(w)=>{if(m+=w.byteLength,m>_t)h(new r("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),c.stderr.setEncoding("utf8").on("data",(w)=>{l=(l+w).slice(-yt)}),c.stdin.on("error",()=>{}),c.once("error",()=>y(()=>u(p??new r("automation_unavailable","Reason could not start the automation runtime.")))),c.once("close",(w)=>y(()=>{if(p)u(p);else i({code:w??1,stdout:Buffer.concat(d),stderr:l})})),n.aborted)S();c.stdin.end(t)})}var k=new Map;function Xt(e,o,t){for(let[s,i]of k)if(i.expiresAt<=t)k.delete(s);while(k.size>=Rt)k.delete(k.keys().next().value);let n=ge();return k.set(n,{runId:e,bytes:o,expiresAt:t+kt}),n}async function Ae(e,o,t,n={}){let s=await(n.environment??ve)(e,o.kind==="browser");return t.throwIfAborted(),await(n.runtime??Oe)(e.node,s,JSON.stringify(o),t)}async function $s(e,o){let t=_e({call:e});if(!("call"in t))D();let n=x();if(!n?.features.computer||t.call.kind==="browser"&&!n.features.browser)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Ae(n,t.call,o)}function fe(e,o,t){let n=e.stdout.byteLength>j?Xt(o,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:At,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,j).toString("base64"),...n?{output_id:n}:{}}}async function Rn(e,o={}){let t=_e(e.payload),n=(o.now??Date.now)();if("output_id"in t){let h=k.get(t.output_id);if(!h||h.runId!==e.runId||h.expiresAt<=n||t.offset>h.bytes.byteLength)throw new r("automation_output_unavailable","Reason automation output expired.");return{chunk:h.bytes.subarray(t.offset,t.offset+j).toString("base64")}}let s=(o.components??x)(),i=(o.platform??process.platform)==="darwin",u=i?(o.macIdentity??mt)():[],c=o.macSetup??N,d=!s?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!s.features.browser;if(i&&(d||u.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return fe(await se({runId:e.runId,call:t.call,identity:u,desktopMissing:d,signal:e.signal},c),e.runId,n);if(!s?.features.computer)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let m=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!m)throw new r("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!m&&!s.features.browser)throw new r("automation_browser_not_installed",!s.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let l=await $i(e.runId,e.signal,o.now),p="account"in o?o.account??null:K(),g;try{if(m){let h=await(o.userChromeEnvironment??Ht)(s,m,e.signal);e.signal.throwIfAborted(),g=await(o.runtime??Oe)(s.node,h,JSON.stringify(t.call),e.signal)}else if(p)g=await(o.delegate??Q)(p,t.call,e.signal);else g=await Ae(s,t.call,e.signal,o)}finally{l()}if(i)g=await ie({runId:e.runId,call:t.call,identity:u,output:g,signal:e.signal},c);return fe(g,e.runId,n)}
860
- export{Mt,Tn,Ns,Ls,Ms,$s,Rn};
857
+ `;import{spawn as Ke}from"child_process";import{lstatSync as H,readFileSync as Q,rmSync as ze}from"fs";import{basename as Je}from"path";var je="__desktop-call",Xe="/usr/bin/setpriv",Ye=27262976,Ve=8192,Ze=2000;function M(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function He(e){try{return JSON.parse(e)}catch{return null}}function Qe(){return[process.execPath,...Je(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],je]}function et(e){let r=(s)=>{try{return H(s).uid}catch{return null}},t=H("/tmp/.X11-unix",{throwIfNoEntry:!1});if(!t?.isDirectory()||t.uid!==0)return;let i=["/tmp/.X99-lock","/tmp/.X11-unix/X99"].filter((s)=>{let c=r(s);return c!==null&&c!==e.uid});if(!i.length)return;let o="";try{let s=Q("/tmp/.X99-lock","utf8").trim();if(/^\d+$/.test(s))o=Q(`/proc/${s}/comm`,"utf8").trim()}catch{}if(/^X/.test(o))return;for(let s of i)ze(s,{force:!0})}function tt(e,r,t,i={}){if(t.throwIfAborted(),(r.op==="display"||r.op==="automation")&&process.platform==="linux"&&process.getuid?.()===0)try{et(e)}catch{}let o=i.command??Qe();return new Promise((s,c)=>{let a=(i.spawnProcess??Ke)(Xe,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...o],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),l=[],u=0,n="",d=null,m=!1,h,_=(g)=>{try{process.kill(-a.pid,g)}catch{a.kill(g)}},v=(g)=>{d??=g,_("SIGTERM"),h??=setTimeout(()=>_("SIGKILL"),Ze)},y=()=>v(new p("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",y,{once:!0});let w=(g)=>{if(m)return;m=!0,clearTimeout(h),t.removeEventListener("abort",y),g()};if(a.stdout.on("data",(g)=>{if(u+=g.byteLength,u>Ye)v(new p("desktop_delegate_failed","Reason's desktop reply is too large."));else l.push(g)}),a.stderr.setEncoding("utf8").on("data",(g)=>{n=(n+g).slice(-Ve)}),a.stdin.on("error",()=>{}),a.once("error",()=>w(()=>c(d??new p("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),a.once("close",(g,Ge)=>w(()=>{if(d)return c(d);let b=He(Buffer.concat(l).toString("utf8"));if(M(b)&&b.ok===!0&&M(b.result))return s(b.result);let N=M(b)&&b.ok===!1&&typeof b.code==="string"&&typeof b.message==="string"?new p(b.code.slice(0,120),b.message.slice(0,2000)):null,Y=`exited ${g??Ge}${N?"":" with no reply"}`,V=n.trim().split(`
858
+ `).at(-1)?.slice(-300)??"";if(!N||N.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${Y}${n?`: ${n.trim().slice(-500)}`:""}
859
+ `);if(N)return c(N);c(new p("desktop_delegate_failed",`Reason's desktop operation failed (${Y}${V?`: ${V}`:""}).`))})),t.aborted)y();a.stdin.end(JSON.stringify(r))})}async function ee(e,r,t,i={}){let o=await tt(e,{op:"automation",call:r},t,i);if(!Number.isSafeInteger(o.code)||typeof o.stdout!=="string"||typeof o.stderr!=="string")throw new p("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:o.code,stdout:Buffer.from(o.stdout,"base64"),stderr:o.stderr}}import{execFile as rt,spawn as it}from"child_process";import{closeSync as ot,mkdirSync as st,openSync as at}from"fs";import{dirname as $,join as nt}from"path";import{promisify as ct}from"util";var lt=ct(rt),te="x-apple.systempreferences:com.apple.preference.security",ut={accessibility:`${te}?Privacy_Accessibility`,screen:`${te}?Privacy_ScreenCapture`},dt=64,A=new Map;function k(e,r){let t=A.get(e);if(t?.has(r))return!1;if(!t){if(A.size>=dt)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(r),!0}function pt(){let e=x(),r=le(ce(e),process.env),t=nt(e,".local","share","reason","desktop-install.log");st($(t),{recursive:!0,mode:448});let i=at(t,"a",384);try{let o=it(r,["desktop","install"],{detached:!0,stdio:["ignore",i,i],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});o.on("error",()=>{return}),o.unref()}finally{ot(i)}}var P={open:async(e,r)=>{await lt("/usr/bin/open",e,{signal:r,timeout:1e4,maxBuffer:8192})},request:(e,r)=>ae(e,r),tile:ne,installDesktop:pt},re=!1;async function ie(e,r,t){try{await r.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await r.open([e],t)}}async function ue(e,r,t,i){if(await t.open([ut[r]],i).catch(()=>{}),e[0]&&!i.aborted)t.tile($($($(e[0]))),r)}async function ft(e,r,t,i,o){for(let s of t){if(!k(e,`grant:${s}`))continue;o.throwIfAborted(),await i.request(r,s).catch(()=>null),await ue(r,s,i,o)}}var mt={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function oe(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function _t(e){if(typeof e!=="string")return null;try{let r=new URL(e);return r.protocol==="https:"||r.protocol==="http:"?r.href:null}catch{return null}}async function de(e,r=P){let{call:t,runId:i,signal:o}=e;if(t.kind==="browser"){if(t.operation==="discover")return oe({result:{tools:[mt]}});if(t.operation!=="call")throw new p("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!re){re=!0;try{r.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&k(i,"grant:probe")){let a=await r.request(e.identity).catch(()=>null),l=a?[...a.accessibility?[]:["accessibility"],...a.screen?[]:["screen"]]:[];for(let u of l)k(i,`grant:${u}`);for(let u of l)await ue(e.identity,u,r,o)}throw new p("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(k(i,"page:chrome-extension"))await ie(se,r,o).catch(()=>{});let s=t.arguments,c=t.operation==="call"&&t.tool==="open_tab"&&s&&typeof s==="object"&&!Array.isArray(s)?_t(s.url):null;if(!c)throw new p("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await ie(c,r,o),oe({result:{content:[{type:"text",text:JSON.stringify({opened:c,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function pe(e,r=P){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let i=t.permissions;if(!i||typeof i!=="object")return e.output;let o=i,s=[...o.accessibility==="missing"?["accessibility"]:[],...o.screenRecording==="missing"?["screen"]:[]];if(s.length===0)return e.output;return await ft(e.runId,e.identity,s,r,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:s}))}}var z=172032,Tt=18874368,Nt=8192,At=65536,$t=55000,kt=60000,Pt=4,Wt=40000,Ct=/^[0-9a-f-]{36}$/,he=Z,Et=Ae();function C(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function E(){throw new p("invalid_automation_request","Reason automation request is malformed.")}function Pe(e){let r=Object.keys(e).sort().join(",");if(r==="call"||r==="browser,call"){let t=e.call,i=r==="browser,call";if(!C(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||i&&(e.browser!==Se||t.kind!=="browser")||JSON.stringify(t).length>At)E();return{call:t,userChrome:i}}if(r==="offset,output_id"){if(typeof e.output_id!=="string"||!Ct.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)E();return{output_id:e.output_id,offset:e.offset}}return E()}function Fr(e=process.platform,r=T){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&r()?.features.computer===!0}var qt="__computer-use";function Dt(e){let r=(t)=>t?"granted":"missing";return`Permissions: accessibility=${r(e.accessibility)}, screenRecording=${r(e.screen)}
860
+ `}function Bt(e,r,t,i={stdin:process.stdin,stdout:process.stdout}){return new Promise((o)=>{let s=S(e,r,{env:t,stdio:["pipe","pipe","inherit"]}),c=(n)=>{s.kill(n)},a=["SIGTERM","SIGINT","SIGHUP"];for(let n of a)process.on(n,c);i.stdin.pipe(s.stdin),s.stdin.on("error",()=>{return}),s.stdout.pipe(i.stdout,{end:!1});let l=!1,u=(n)=>{if(l)return;l=!0;for(let d of a)process.off(d,c);i.stdin.unpipe(s.stdin),i.stdout.write("",()=>o(n))};s.once("error",()=>u(127)),s.once("close",(n)=>u(n??1))})}async function Mr(e,r={}){let t=r.stderr??process.stderr,i=(r.identity??J)(),o=(r.components??T)();if(i.length===0||o?.platform!=="darwin-arm64")return t.write(`Reason computer use: Reason's background identity cannot run Open Computer Use here (computer_use_identity_unavailable)
861
+ `),1;if(e.length===1&&e[0]==="doctor"){let a=await(r.grants??Ie)(i);if(!a)return t.write(`Reason computer use: Reason's permissions could not be read (computer_use_permission_status_unavailable)
862
+ `),1;return(r.stdout??process.stdout).write(Dt(a)),0}if(e.length!==1||e[0]!=="mcp")return t.write(`Usage: reason __computer-use mcp|doctor
863
+ `),2;let[s,...c]=i;return(r.run??Bt)(s,[...c,o.ocu,"mcp"],{...process.env,OPEN_COMPUTER_USE_DISABLE_APP_AGENT_PROXY:"1"})}function Ur(e=T){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function We(e,r,t,i){return new Promise((o)=>{let s=S(e,r,{env:t,stdio:"ignore",windowsHide:!0}),c=setTimeout(()=>{s.kill("SIGKILL"),o(-1)},i);s.once("error",()=>{clearTimeout(c),o(-1)}),s.once("exit",(a)=>{clearTimeout(c),o(a??-1)})})}function Ft(e,r,t,i){return new Promise((o)=>{let s=S(e,r,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),c="";s.stdout.setEncoding("utf8").on("data",(l)=>{c+=l});let a=setTimeout(()=>{s.kill("SIGKILL"),o(null)},i);s.once("error",()=>{clearTimeout(a),o(null)}),s.once("close",(l)=>{clearTimeout(a),o(l===0?c:null)})})}function Mt(e){return R(e)?f(B(),"open-browser-use"):"/tmp/open-browser-use"}function R(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Ut=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Gt=33554432;function Lt(e,r){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let i=C(t)&&C(t.result)?t.result.metadata:null;if(!C(i)||i.extensionId!==r)return null;return typeof i.extensionInstanceId==="string"&&Ut.test(i.extensionInstanceId)?i.extensionInstanceId:null}async function Ce(e,r,t){let i=t.storages.map((a)=>{try{return D(a).filter((l)=>l.endsWith(".log")||l.endsWith(".ldb")).map((l)=>f(a,l))}catch{return[]}}),o;try{o=i.some((a)=>a.length>0)?D(t.socketDir).filter((a)=>a.endsWith(".sock")):[]}catch{return[]}let s=[];for(let a of o){let l=f(t.socketDir,a),u=Lt(await Ft(e,["info","--socket",l,"--timeout","2s"],r,5000),t.extensionId);if(u)s.push({instance:u,socket:l})}let c=[];for(let[a,l]of(s.length>0?i:[]).entries())for(let u of l)try{if(It(u).size>Gt)continue;let n=X(u),d=s.find((m)=>n.includes(m.instance));if(d){c.push({storage:t.storages[a],...d});break}}catch{}return c}async function Kt(e,r,t){return(await Ce(e,r,t))[0]?.instance??null}function Ee(e,r,t){return Kt(e.nativeHost,r,{socketDir:Mt(e),extensionId:L,storages:[f(t,"browser-profile","Default","Local Extension Settings",L)]})}var we=/^(Default|Profile ([0-9]+))$/;async function zt(e,r,t=x(),i=j){let o=f(t,"Library","Application Support","Google","Chrome"),s=[];try{s=D(o)}catch(n){if(n.code==="EPERM")throw new p("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let c=(n)=>Number(we.exec(n)?.[2]??-1),a=s.filter((n)=>we.test(n)&&q(f(o,n,"Extensions",W))).sort((n,d)=>c(n)-c(d)),l=(n)=>f(o,n,"Local Extension Settings",W);return(await Ce(e,r,{socketDir:i,extensionId:W,storages:a.map(l)})).map(({storage:n,instance:d,socket:m})=>({profile:a.find((h)=>l(h)===n),instance:d,socket:m}))}async function Jt(e,r,t=x(),i=j){let o=(await zt(e,r,t,i))[0]?.instance;if(!o)throw new p("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return o}function ge(e){return new Promise((r)=>{let t=Ot({path:e}),i=(o)=>{t.destroy(),r(o)};t.setTimeout(1000,()=>i(!1)),t.once("error",()=>i(!1)),t.once("connect",()=>i(!0))})}async function qe(e,r){let t=Date.now()+r;while(Date.now()<t){if(await e())return!0;await new Promise((i)=>setTimeout(i,200))}return!1}var U=new Map;function G(e,r){let t=U.get(e);if(!t)t=r().finally(()=>U.delete(e)),U.set(e,t);return t}async function jt(e,r){if(await ge(e))return;if(yt(e,{force:!0}),await We("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],r,1e4)!==0||!await qe(()=>ge(e),5000))throw new p("automation_unavailable","Reason could not start the desktop session bus.")}async function be(e,r,t){let i=e.platform==="darwin-arm64"||R(e)?async()=>await Ee(e,r,t)!==null:async()=>await We(e.nativeHost,["info"],r,5000)===0;if(await i())return;let o=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],s,c=null,a=0;if(e.platform==="darwin-arm64"){let n=f(t,"browser-profile");O(n);let d=f(n,"NativeMessagingHosts");me(d,{recursive:!0,mode:448});let m=K(e.platform).nativeHostManifests[0];fe(m,f(d,_e(m)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),_=o.filter((v)=>v!=="about:blank").concat("--no-startup-window","--use-mock-keychain");s=S("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${n}`,..._],{env:r,stdio:"ignore"})}else if(R(e)){let n=f(t,"browser-profile");O(n),ht(ve("icacls"),[F(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let d=o.filter((m)=>m!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");s=S(e.browser,[`--user-data-dir=${n}`,...d],{detached:!0,stdio:"ignore",env:r})}else{let n=f(r.HOME,".config","google-chrome"),d=f(n,"NativeMessagingHosts");me(d,{recursive:!0,mode:448});let m=K(e.platform).nativeHostManifests[0];fe(m,f(d,_e(m)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];c=f(t,"browser.log");let _=xt(c,"a",384);a=bt(_).size,s=S(e.browser,[`--user-data-dir=${n}`,...o,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",_,_],env:{...r,ACCESSIBILITY_ENABLED:"1"}}),gt(_)}let l=!1;s.once("error",()=>{l=!0}),s.once("exit",(n)=>{l||=n!==0}),s.unref();let u=!1;if(await qe(async()=>l||(u=await i()),Wt),!u){if(c&&X(c).subarray(a).toString("utf8").includes("No usable sandbox"))throw new p("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new p("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Gr(e){await Fe(e,!0)}function Lr(e){return De(e,Be(e))}function De(e,r){return e.platform==="darwin-arm64"||R(e)?f(r,"browser-profile"):f(r,"home",".config","google-chrome")}function Be(e){let r=f(e.root,"automation");if(!q(r)||!Xt(e.automation))return e.automation;if(!Yt(De(e,r)))try{$e(r,e.automation)}catch{}return q(r)?r:e.automation}function Xt(e){try{return D(e).length===0}catch(r){return r.code==="ENOENT"}}function Yt(e){let r;try{r=St(f(e,"SingletonLock"))}catch{return!1}let t=Number(r.slice(r.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(i){return i.code==="EPERM"}}async function Fe(e,r){Oe({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=Be(e);O(t);let i=ke().username,o={USER:i,LOGNAME:i,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||R(e)){let n=R(e)?{...o,...Vt(),HOME:x()}:{...o,HOME:x(),PATH:`${F(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:qt};if(!r)return n;await G("browser",()=>be(e,n,t));let d=await Ee(e,n,t);if(!d)throw new p("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...n,REASON_AUTOMATION_OBU_INSTANCE:d,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let s=await Ne(),c=f(t,"home"),a=f(t,"runtime");O(c),O(a);let l=f(t,"bus"),u={...o,HOME:c,PATH:`${F(e.node)}:/usr/bin:/bin`,DISPLAY:s.display,XAUTHORITY:s.xauthority,XDG_RUNTIME_DIR:a,DBUS_SESSION_BUS_ADDRESS:`unix:path=${l}`,...s.sound?{PULSE_SERVER:Te(s.sound)}:{}};if(await G("bus",()=>jt(l,u)),r)await G("browser",()=>be(e,u,t));return u}function Vt(){let e=process.env.SystemRoot??"C:\\Windows",r=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((i)=>process.env[i]?[[i,process.env[i]]]:[])),t=f(e,"System32");return{...r,SystemRoot:e,windir:e,TEMP:B(),TMP:B(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(Rt)}}async function Zt(e,r,t){let i=ke().username,o={USER:i,LOGNAME:i,HOME:x(),PATH:`${F(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:r,REASON_AUTOMATION_BACKGROUND_TABS:"1"},s=await Jt(r,o);return t.throwIfAborted(),{...o,REASON_AUTOMATION_OBU_INSTANCE:s}}function Ht(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let r=f(B(),`reason-automation-${wt("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!q(r)||X(r,"utf8")!==e){let t=`${r}.${process.pid}.tmp`;vt(t,e,{mode:384}),$e(t,r)}return[r]}function Me(e,r,t,i){if(typeof he!=="string")return Promise.reject(new p("automation_unavailable","This Reason build has no automation runtime."));let o=he;return new Promise((s,c)=>{let a=S(e,Ht(o),{env:{...r,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),l=[],u=0,n="",d=null,m=!1,h=(w)=>{if(d??=w,process.platform==="win32"&&a.pid){S(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(a.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>a.kill("SIGKILL"));return}try{process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},_=(w)=>{if(m)return;m=!0,clearTimeout(v),i.removeEventListener("abort",y),w()},v=setTimeout(()=>h(new p("automation_timed_out","Reason automation did not finish in time.")),$t),y=()=>h(new p("cancelled","Reason cancelled the automation call."));if(i.addEventListener("abort",y,{once:!0}),a.stdout.on("data",(w)=>{if(u+=w.byteLength,u>Tt)h(new p("automation_output_too_large","Reason automation output is too large."));else l.push(w)}),a.stderr.setEncoding("utf8").on("data",(w)=>{n=(n+w).slice(-Nt)}),a.stdin.on("error",()=>{}),a.once("error",()=>_(()=>c(d??new p("automation_unavailable","Reason could not start the automation runtime.")))),a.once("close",(w)=>_(()=>{if(d)c(d);else s({code:w??1,stdout:Buffer.concat(l),stderr:n})})),i.aborted)y();a.stdin.end(t)})}var I=new Map;function Qt(e,r,t){for(let[o,s]of I)if(s.expiresAt<=t)I.delete(o);while(I.size>=Pt)I.delete(I.keys().next().value);let i=Ae();return I.set(i,{runId:e,bytes:r,expiresAt:t+kt}),i}async function Ue(e,r,t,i={}){let o=await(i.environment??Fe)(e,r.kind==="browser");return t.throwIfAborted(),await(i.runtime??Me)(e.node,o,JSON.stringify(r),t)}async function Kr(e,r){let t=Pe({call:e});if(!("call"in t))E();let i=T();if(!i?.features.computer||t.call.kind==="browser"&&!i.features.browser)throw new p("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Ue(i,t.call,r)}function xe(e,r,t){let i=e.stdout.byteLength>z?Qt(r,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:Et,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,z).toString("base64"),...i?{output_id:i}:{}}}async function zr(e,r={}){let t=Pe(e.payload),i=(r.now??Date.now)();if("output_id"in t){let _=I.get(t.output_id);if(!_||_.runId!==e.runId||_.expiresAt<=i||t.offset>_.bytes.byteLength)throw new p("automation_output_unavailable","Reason automation output expired.");return{chunk:_.bytes.subarray(t.offset,t.offset+z).toString("base64")}}let o=(r.components??T)(),s=(r.platform??process.platform)==="darwin",c=s?(r.macIdentity??J)():[],a=r.macSetup??P,l=!o?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!o.features.browser;if(s&&(l||c.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return xe(await de({runId:e.runId,call:t.call,identity:c,desktopMissing:l,signal:e.signal},a),e.runId,i);if(!o?.features.computer)throw new p("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let u=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!u)throw new p("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!u&&!o.features.browser)throw new p("automation_browser_not_installed",!o.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let n=t.call.kind==="browser"&&t.call.operation!=="record_start"&&t.call.operation!=="record_stop",d=await Re(e.runId,e.signal,r.now,n?"call":"run"),m="account"in r?r.account??null:ye(),h;try{if(u){let _=await(r.userChromeEnvironment??Zt)(o,u,e.signal);e.signal.throwIfAborted(),h=await(r.runtime??Me)(o.node,_,JSON.stringify(t.call),e.signal)}else if(m)h=await(r.delegate??ee)(m,t.call,e.signal);else h=await Ue(o,t.call,e.signal,r)}finally{d()}if(s)h=await pe({runId:e.runId,call:t.call,identity:c,output:h,signal:e.signal},a);return xe(h,e.runId,i)}
864
+ export{tt as ke,z as le,Pe as me,Fr as ne,Bt as oe,Mr as pe,Ur as qe,zt as re,Jt as se,Gr as te,Lr as ue,Kr as ve,zr as we};
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{Ah as I}from"./vm-hands-entry-lite-26xb026c.js";import{ol as R,rl as U,ul as C,vl as O,wl as g}from"./vm-hands-entry-lite-kqbats5n.js";import{spawn as S}from"child_process";import{existsSync as x,mkdirSync as T,readFileSync as w,writeFileSync as E}from"fs";import{homedir as H}from"os";import{basename as L,delimiter as D,join as G,win32 as $}from"path";var N=process.platform==="win32"?U("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",b=N.split(D),_=5000,j=65536,k=new Set(["zsh","bash"]),f=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],P=(z,J)=>new Promise((B,Q)=>{let K;try{K=S(z,[...J],{...C(),stdio:["ignore","pipe","ignore"]}),O(K)}catch(X){Q(X);return}let W=[],V=0,Z=null,q=(X)=>{Z??=Error(X);try{if(K.pid!==void 0)g(K.pid,"SIGKILL")}catch{}},F=setTimeout(()=>q("login_shell_timeout"),_);K.stdout?.on("data",(X)=>{if(V+=X.length,V>j)q("login_shell_output_too_large");else W.push(X)}),K.once("error",(X)=>{clearTimeout(F),Q(X)}),K.once("close",(X)=>{if(clearTimeout(F),Z)Q(Z);else if(X!==0)Q(Error("login_shell_exit_nonzero"));else B(Buffer.concat(W).toString("utf8"))})});function v(z){return typeof z==="string"&&z.startsWith("/")&&!z.includes("\x00")&&k.has(L(z))}function M(z){let J=new Set,B=[];for(let Q of z){if(J.has(Q))continue;J.add(Q),B.push(Q)}return B}function A(z,J=process.platform){let B=J==="win32",Q=z.split(`
3
+ `).at(-1)??"",K=[];for(let W of Q.split(B?";":":")){let V=W.trim();if(B?!$.isAbsolute(V):!V.startsWith("/"))continue;if(V.includes("\x00"))continue;if(I(V))continue;K.push(V)}return M(K)}function y(z){let J=z?.home??H(),B=z?.directoryExists??x,Q=f.map((K)=>G(J,...K)).filter((K)=>{try{return B(K)}catch{return!1}});return M([...Q,...process.platform==="win32"?A(process.env.PATH??process.env.Path??""):[],...b]).join(D)}async function d(z){let J=z?.shell??process.env.SHELL,B=()=>({path:y({home:z?.home,directoryExists:z?.directoryExists}),source:"fallback"});if(process.platform==="win32"||!v(J))return B();let Q;try{Q=await(z?.runLoginShell??P)(J,["-lic",'printf %s "$PATH"'])}catch{return B()}if(Buffer.byteLength(Q,"utf8")>j)return B();let K=A(Q);if(K.length===0)return B();return{path:M([...K,...b]).join(":"),source:"login_shell"}}function n(z){let J=null;return()=>{return J??=d(z),J}}function Y(z){if(z===void 0||z.includes("\x00")||Buffer.byteLength(z,"utf8")>32768)return;return z}function r(z){let J=z.source??process.env,B={HOME:z.home,PATH:z.path??N,TMPDIR:z.temporaryDirectory,SHELL:Y(J.SHELL)??"/bin/zsh",LANG:Y(J.LANG)??"C.UTF-8",LC_ALL:Y(J.LC_ALL)??Y(J.LANG)??"C.UTF-8"},Q=Y(J.LC_CTYPE),K=Y(J.TERM),W=Y(J.COLORTERM);if(Q)B.LC_CTYPE=Q;if(K)B.TERM=K;if(W)B.COLORTERM=W;if(process.platform==="win32"){for(let V of h){let Z=Y(J[V]);if(Z)B[V]=Z}B.TEMP=B.TMP=z.temporaryDirectory,B.SHELL=R()??B.SHELL,B.PATH=m(B.PATH)}return B}function m(z,J=G(H(),".reason","python3")){let B=(W)=>z.split($.delimiter).filter((V)=>V&&!/[\\/]WindowsApps[\\/]?$/i.test(V)).map((V)=>$.join(V,W)).find((V)=>x(V)),Q=B("python.exe");if(B("python3.exe")||!Q)return z;let K=`#!/bin/sh
4
+ exec "${Q.replaceAll("\\","/")}" "$@"
5
+ `;try{let W=G(J,"python3");if(!x(W)||w(W,"utf8")!==K)T(J,{recursive:!0}),E(W,K)}catch{return z}return[J,z].join($.delimiter)}var h=["SystemRoot","SystemDrive","windir","ComSpec","PATHEXT","USERPROFILE","USERNAME","USERDOMAIN","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","CommonProgramFiles","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","OS"];
6
+ export{N as ad,A as bd,y as cd,n as dd,r as ed,m as fd};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{xl as N}from"./vm-hands-entry-lite-kqbats5n.js";import{randomUUID as K}from"crypto";import{closeSync as L,constants as V,fstatSync as M,lstatSync as Z,mkdirSync as $,openSync as O,readFileSync as T,realpathSync as b,renameSync as U,unlinkSync as X,writeFileSync as Y}from"fs";import{dirname as g,resolve as z}from"path";var A=65536;function J(j){try{return Z(j),!0}catch(q){if(q instanceof Error&&"code"in q&&q.code==="ENOENT")return!1;throw q}}function I(j,q=!1){if(!J(j)){if(!q)throw Error("worker_state_missing");D(j),$(j,{mode:448})}let C=Z(j);if(!C.isDirectory()||C.isSymbolicLink()||!N(C)||b(j)!==z(j))throw Error("worker_state_directory_not_private_or_canonical")}function D(j){let q=g(j);if(!J(q))D(q),$(q,{mode:448});if(b(q)!==z(q))throw Error("worker_parent_not_canonical")}function u(j,q=A){let C=O(j,V.O_RDONLY|V.O_NOFOLLOW);try{let G=M(C);if(!G.isFile()||G.nlink!==1||!N(G)||G.size>q)throw Error("worker_file_not_private");return T(C,"utf8")}finally{L(C)}}function f(j,q,C=A){let G=JSON.stringify(q);if(G===void 0)throw Error("worker_file_invalid");let Q=G+`
3
+ `;if(Buffer.byteLength(Q,"utf8")>C)throw Error("worker_file_too_large");if(I(g(j)),J(j))u(j,C);let H=`${j}.${K()}`;try{Y(H,Q,{mode:384,flag:"wx"}),U(H,j)}finally{if(J(H))X(H)}}
4
+ export{J as Ld,I as Md,u as Nd,f as Od};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{spawn as N}from"child_process";import{statSync as O}from"fs";import{delimiter as Q,join as R}from"path";function X(q,z=process.env.PATH??"",D=process.env,G=process.platform){let A=G==="win32",H=q.includes("/")||A&&q.includes("\\");if(!q||H||q.includes("\x00"))return!1;let I=A?["",...(D.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")]:[""];return z.split(Q).some((C)=>{if(!C)return!1;return I.some((E)=>{if(E===void 0)return!1;try{let J=O(R(C,`${q}${E}`));if(!J.isFile())return!1;return A||(J.mode&73)!==0}catch{return!1}})})}async function K(q){if(!q)return"";let z=[];try{for await(let D of q)z.push(Buffer.from(D))}catch{}return Buffer.concat(z).toString("utf8")}async function Y(q,z){let[D,...G]=q;if(!D)throw Error("A child process probe requires a program.");if(z.signal?.aborted)return{exitCode:-1,stdout:"",stderr:""};let A=N(D,G,{stdio:["ignore","pipe","pipe"],...z.env?{env:z.env}:{}}),H=K(A.stdout),I=K(A.stderr),C=()=>{try{A.kill()}catch{}};if(z.signal?.aborted)C();else z.signal?.addEventListener("abort",C,{once:!0});let E;try{return{exitCode:await Promise.race([new Promise((F)=>{A.once("error",()=>F(-1)),A.once("close",(M)=>F(M??-1))}),new Promise((F)=>{E=setTimeout(()=>{C(),F(-1)},z.timeoutMs)})]),stdout:await H,stderr:await I}}finally{if(E)clearTimeout(E);z.signal?.removeEventListener("abort",C)}}function Z(q){if(!(q>0))return;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,q)}
3
+ export{X as Id,Y as Jd,Z as Kd};