@reason-machines/cli-linux-x64 0.2.416 → 0.2.419

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 (153) 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-s4897qxy.js +2 -0
  5. package/bin/vm-hands/api-m73x3da5.js +2 -0
  6. package/bin/vm-hands/ask-relay-4kwcx2b7.js +8 -0
  7. package/bin/vm-hands/connect-cli-34b18gjs.js +2 -0
  8. package/bin/vm-hands/custom-endpoint-device-j012b4bd.js +2 -0
  9. package/bin/vm-hands/desktop-account-0q0arpzk.js +2 -0
  10. package/bin/vm-hands/device-workspace-3jxhs54b.js +2 -0
  11. package/bin/vm-hands/hands-worker-source-y64axsw3.js +2 -0
  12. package/bin/vm-hands/index-194s4vz0.js +12818 -0
  13. package/bin/vm-hands/install-receipt-1g68b446.js +2 -0
  14. package/bin/vm-hands/local-automation-k2w46hn2.js +2 -0
  15. package/bin/vm-hands/local-capabilities-tdzbqmrb.js +2 -0
  16. package/bin/vm-hands/local-desktop-users-6thzvydd.js +2 -0
  17. package/bin/vm-hands/local-display-mac-59ma7sxa.js +2 -0
  18. package/bin/vm-hands/local-display-session-4833qq7h.js +2 -0
  19. package/bin/vm-hands/local-display-video-c1143mz6.js +2 -0
  20. package/bin/vm-hands/local-managed-process-mr0zpk7c.js +2 -0
  21. package/bin/vm-hands/local-pty-session-bwarwpsd.js +2 -0
  22. package/bin/vm-hands/managed-runtime-vz1wqwwg.js +2 -0
  23. package/bin/vm-hands/network-contract-gprc37sw.js +2 -0
  24. package/bin/vm-hands/package-ej9snd47.js +2 -0
  25. package/bin/vm-hands/permissions-7sfghef4.js +2 -0
  26. package/bin/vm-hands/reason-hands-protocol-jsrkawe2.js +2 -0
  27. package/bin/vm-hands/serve-service-kngyzh74.js +2 -0
  28. package/bin/vm-hands/status-jz29fb95.js +96 -0
  29. package/bin/vm-hands/version-g29vt13t.js +2 -0
  30. package/bin/vm-hands/vm-hands-entry-lite-0h4qmgm2.js +9 -0
  31. package/bin/vm-hands/vm-hands-entry-lite-0k13wmzm.js +3 -0
  32. package/bin/vm-hands/vm-hands-entry-lite-1exfjv79.js +52 -0
  33. package/bin/vm-hands/vm-hands-entry-lite-26q3hbdc.js +3 -0
  34. package/bin/vm-hands/vm-hands-entry-lite-28s7v15d.js +4 -0
  35. package/bin/vm-hands/vm-hands-entry-lite-2m5dwrdf.js +6 -0
  36. package/bin/vm-hands/vm-hands-entry-lite-37hvds7z.js +5 -0
  37. package/bin/vm-hands/vm-hands-entry-lite-3rqdzqhk.js +112 -0
  38. package/bin/vm-hands/vm-hands-entry-lite-4gh5kfr4.js +3 -0
  39. package/bin/vm-hands/{vm-hands-entry-lite-t7an5zg2.js → vm-hands-entry-lite-4k4h9rcq.js} +2 -2
  40. package/bin/vm-hands/vm-hands-entry-lite-6nwbqg37.js +3 -0
  41. package/bin/vm-hands/{vm-hands-entry-lite-m11j0f9q.js → vm-hands-entry-lite-6y6pz2yw.js} +2 -2
  42. package/bin/vm-hands/vm-hands-entry-lite-714wspqb.js +3 -0
  43. package/bin/vm-hands/vm-hands-entry-lite-7zk0r3p9.js +5 -0
  44. package/bin/vm-hands/vm-hands-entry-lite-9qep7pka.js +4 -0
  45. package/bin/vm-hands/{vm-hands-entry-lite-bdhjpv7g.js → vm-hands-entry-lite-agsp101y.js} +2 -2
  46. package/bin/vm-hands/vm-hands-entry-lite-am6kj1n1.js +3 -0
  47. package/bin/vm-hands/vm-hands-entry-lite-as1tkffn.js +5 -0
  48. package/bin/vm-hands/vm-hands-entry-lite-bxt4n1nj.js +3 -0
  49. package/bin/vm-hands/vm-hands-entry-lite-c2g3wmkp.js +3 -0
  50. package/bin/vm-hands/vm-hands-entry-lite-d2w8tghq.js +3 -0
  51. package/bin/vm-hands/vm-hands-entry-lite-d98m00b8.js +3 -0
  52. package/bin/vm-hands/vm-hands-entry-lite-daxcxjze.js +344 -0
  53. package/bin/vm-hands/vm-hands-entry-lite-dcnyve97.js +3 -0
  54. package/bin/vm-hands/vm-hands-entry-lite-e1b89x66.js +3 -0
  55. package/bin/vm-hands/vm-hands-entry-lite-ej5ffjck.js +105 -0
  56. package/bin/vm-hands/vm-hands-entry-lite-ejkba2nk.js +3 -0
  57. package/bin/vm-hands/vm-hands-entry-lite-f3wh0dza.js +5 -0
  58. package/bin/vm-hands/vm-hands-entry-lite-f5xb489y.js +4 -0
  59. package/bin/vm-hands/vm-hands-entry-lite-feybcq63.js +3 -0
  60. package/bin/vm-hands/vm-hands-entry-lite-fpp2bs9y.js +452 -0
  61. package/bin/vm-hands/{vm-hands-entry-lite-cs5t8eyd.js → vm-hands-entry-lite-fzkfajew.js} +9 -5
  62. package/bin/vm-hands/vm-hands-entry-lite-gt497d5x.js +3 -0
  63. package/bin/vm-hands/vm-hands-entry-lite-gxper06w.js +3 -0
  64. package/bin/vm-hands/vm-hands-entry-lite-j2ng164q.js +9 -0
  65. package/bin/vm-hands/vm-hands-entry-lite-jp9q2vsx.js +127 -0
  66. package/bin/vm-hands/vm-hands-entry-lite-magmzx9c.js +3 -0
  67. package/bin/vm-hands/vm-hands-entry-lite-ntx8fdyq.js +5 -0
  68. package/bin/vm-hands/vm-hands-entry-lite-pfzczmaa.js +4 -0
  69. package/bin/vm-hands/vm-hands-entry-lite-pkc4ry5x.js +539 -0
  70. package/bin/vm-hands/vm-hands-entry-lite-pp7jfqzr.js +3 -0
  71. package/bin/vm-hands/vm-hands-entry-lite-q8wkrzer.js +66 -0
  72. package/bin/vm-hands/vm-hands-entry-lite-s823n1q9.js +3 -0
  73. package/bin/vm-hands/vm-hands-entry-lite-s9xf5z69.js +7 -0
  74. package/bin/vm-hands/vm-hands-entry-lite-tchc7z17.js +128 -0
  75. package/bin/vm-hands/vm-hands-entry-lite-tytfs183.js +42 -0
  76. package/bin/vm-hands/vm-hands-entry-lite-v4jtxgaj.js +4 -0
  77. package/bin/vm-hands/vm-hands-entry-lite-vgpt2n1v.js +11 -0
  78. package/bin/vm-hands/{vm-hands-entry-lite-9c95p6n9.js → vm-hands-entry-lite-vsa7t6m9.js} +54 -54
  79. package/bin/vm-hands/vm-hands-entry-lite-xp3qzxk5.js +3 -0
  80. package/bin/vm-hands/vm-hands-entry-lite.js +1 -3
  81. package/bin/vm-hands/vm-hands-executor-epyhpjv3.js +11 -0
  82. package/bin/vm-hands/vm-hands-op-runner-fn1qph82.js +2 -0
  83. package/bin/vm-hands/vm-hands-runtime-8vt9etvv.js +4 -0
  84. package/bin/vm-hands/worker-preview-readiness-yfjgban2.js +2 -0
  85. package/bin/vm-hands/worker-sandbox-z0t69av8.js +2 -0
  86. package/package.json +1 -1
  87. package/bin/vm-hands/api-cjv8m2zy.js +0 -2
  88. package/bin/vm-hands/api-credentials-m5akr9fv.js +0 -2
  89. package/bin/vm-hands/connect-cli-pcfvh00f.js +0 -2
  90. package/bin/vm-hands/custom-endpoint-device-dkqb4rqy.js +0 -2
  91. package/bin/vm-hands/desktop-account-5v7x0ajx.js +0 -2
  92. package/bin/vm-hands/device-workspace-p9q9dckg.js +0 -2
  93. package/bin/vm-hands/fsevents-ekt70rcc.js +0 -2
  94. package/bin/vm-hands/hands-worker-source-cgrpm21b.js +0 -2
  95. package/bin/vm-hands/index-k8kcz8a3.js +0 -12818
  96. package/bin/vm-hands/install-receipt-7vt2y2vh.js +0 -2
  97. package/bin/vm-hands/local-automation-zj5h05b9.js +0 -2
  98. package/bin/vm-hands/local-capabilities-gkdh1z5z.js +0 -2
  99. package/bin/vm-hands/local-desktop-users-q886k0mm.js +0 -2
  100. package/bin/vm-hands/local-display-mac-w85956f1.js +0 -2
  101. package/bin/vm-hands/local-display-session-m6an1hqp.js +0 -2
  102. package/bin/vm-hands/local-pty-session-5f50sqq0.js +0 -2
  103. package/bin/vm-hands/managed-runtime-esfmzn6z.js +0 -2
  104. package/bin/vm-hands/network-contract-9x9kc5vv.js +0 -2
  105. package/bin/vm-hands/package-78fkast4.js +0 -2
  106. package/bin/vm-hands/permissions-bvfecyb8.js +0 -2
  107. package/bin/vm-hands/reason-hands-protocol-2tnghj3b.js +0 -2
  108. package/bin/vm-hands/serve-service-mr4mkymv.js +0 -2
  109. package/bin/vm-hands/status-7m9d0yek.js +0 -10
  110. package/bin/vm-hands/version-4bsjs55h.js +0 -2
  111. package/bin/vm-hands/vm-hands-entry-lite-09m2cdkw.js +0 -4
  112. package/bin/vm-hands/vm-hands-entry-lite-0xrsph3r.js +0 -3
  113. package/bin/vm-hands/vm-hands-entry-lite-1cwqa4jr.js +0 -3
  114. package/bin/vm-hands/vm-hands-entry-lite-1rrb66r9.js +0 -3
  115. package/bin/vm-hands/vm-hands-entry-lite-1rtkf2xm.js +0 -3
  116. package/bin/vm-hands/vm-hands-entry-lite-22kfyvnk.js +0 -2
  117. package/bin/vm-hands/vm-hands-entry-lite-6aeea05q.js +0 -3
  118. package/bin/vm-hands/vm-hands-entry-lite-6sgfhegd.js +0 -5
  119. package/bin/vm-hands/vm-hands-entry-lite-7n60veqy.js +0 -458
  120. package/bin/vm-hands/vm-hands-entry-lite-88swf2qr.js +0 -6
  121. package/bin/vm-hands/vm-hands-entry-lite-89z488gz.js +0 -3
  122. package/bin/vm-hands/vm-hands-entry-lite-8ns59paz.js +0 -3
  123. package/bin/vm-hands/vm-hands-entry-lite-8t9xssf9.js +0 -3
  124. package/bin/vm-hands/vm-hands-entry-lite-8vfd0kez.js +0 -250
  125. package/bin/vm-hands/vm-hands-entry-lite-907pa7f9.js +0 -65
  126. package/bin/vm-hands/vm-hands-entry-lite-9ay6f56v.js +0 -3
  127. package/bin/vm-hands/vm-hands-entry-lite-ab2m9erf.js +0 -2
  128. package/bin/vm-hands/vm-hands-entry-lite-b885gwfh.js +0 -7
  129. package/bin/vm-hands/vm-hands-entry-lite-ckv17tn8.js +0 -3
  130. package/bin/vm-hands/vm-hands-entry-lite-dqd4p5kw.js +0 -105
  131. package/bin/vm-hands/vm-hands-entry-lite-enah5gv4.js +0 -14
  132. package/bin/vm-hands/vm-hands-entry-lite-eqgj4acy.js +0 -112
  133. package/bin/vm-hands/vm-hands-entry-lite-f5e3dbgk.js +0 -4
  134. package/bin/vm-hands/vm-hands-entry-lite-gvwdy3rf.js +0 -4
  135. package/bin/vm-hands/vm-hands-entry-lite-hj8n59y9.js +0 -3
  136. package/bin/vm-hands/vm-hands-entry-lite-k278g9kj.js +0 -42
  137. package/bin/vm-hands/vm-hands-entry-lite-pgb514h0.js +0 -3
  138. package/bin/vm-hands/vm-hands-entry-lite-pmcz7j7t.js +0 -3
  139. package/bin/vm-hands/vm-hands-entry-lite-q0k6kx6d.js +0 -5
  140. package/bin/vm-hands/vm-hands-entry-lite-qk4kexta.js +0 -9
  141. package/bin/vm-hands/vm-hands-entry-lite-qy9xg6em.js +0 -3
  142. package/bin/vm-hands/vm-hands-entry-lite-qysyf65v.js +0 -2
  143. package/bin/vm-hands/vm-hands-entry-lite-sm5nkxpw.js +0 -540
  144. package/bin/vm-hands/vm-hands-entry-lite-t7n6t3j9.js +0 -2
  145. package/bin/vm-hands/vm-hands-entry-lite-vq14wv7h.js +0 -52
  146. package/bin/vm-hands/vm-hands-entry-lite-vrqzr15t.js +0 -3
  147. package/bin/vm-hands/vm-hands-entry-lite-zg36myyf.js +0 -5
  148. package/bin/vm-hands/vm-hands-entry-lite-zjn2nsth.js +0 -3
  149. package/bin/vm-hands/vm-hands-entry-lite-zybbbegw.js +0 -3
  150. package/bin/vm-hands/vm-hands-executor-a7aqej5n.js +0 -11
  151. package/bin/vm-hands/vm-hands-op-runner-k4n3zrqb.js +0 -2
  152. package/bin/vm-hands/vm-hands-runtime-z6ydmvqc.js +0 -4
  153. package/bin/vm-hands/worker-sandbox-smqj3mbe.js +0 -2
@@ -1,112 +0,0 @@
1
- // @bun
2
- import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ie,spawn as E}from"child_process";var Yi="h264_ws_v1",Qi="video",ot=["smooth","sharp","data_saver","balanced"];var eo="video_presets";var L=8388608,v=65536,to="control",ro="v1",J=200;function On(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t,n=(i)=>typeof i==="string"&&i.length>0&&i.length<=J;if(Object.keys(e).length!==2||!n(e.user_id)||!n(e.name))return null;return{user_id:e.user_id,name:e.name}}var no="windows",io="v1",m=200,z=(t)=>typeof t==="string"&&ot.includes(t);function oo(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(Object.keys(e).length!==2||e.format!=="h264_ws_v1"||!z(e.preset))return null;return{format:"h264_ws_v1",preset:e.preset}}var o={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class l extends Error{constructor(t){super(t);this.name="DisplayVideoProtocolError"}}var Z=new TextEncoder,Q=new TextDecoder("utf-8",{fatal:!0});function p(t,e){if(e.byteLength+1>L)throw new l("message_too_large");let n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,e.byteLength+1),i.setUint8(4,t),n.set(e,5),n}function y(t){let e=Z.encode(t);if(e.byteLength>v)throw new l("text_too_large");return e}function O(t,e){if(!Number.isInteger(t)||t<0||t>65535)throw new l(`invalid_${e}`);return t}function ee(t){if(!Number.isFinite(t))throw new l("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(t)))}function Fr(t){switch(t.type){case"hello":{let e=y(t.codec),n=new Uint8Array(6+e.byteLength),i=new DataView(n.buffer);return i.setUint16(0,O(t.width,"width")),i.setUint16(2,O(t.height,"height")),i.setUint8(4,Math.max(1,Math.min(240,Math.round(t.fps)))),i.setUint8(5,ot.indexOf(t.preset)),n.set(e,6),p(o.hello,n)}case"frame":{let e=new Uint8Array(13+t.data.byteLength),n=new DataView(e.buffer);return n.setUint8(0,t.key?1:0),n.setUint32(1,t.seq>>>0),n.setBigUint64(5,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,13),p(o.frame,e)}case"stats":return p(o.stats,y(JSON.stringify(t.stats)));case"pong":case"ping":{let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t.token),p(t.type==="ping"?o.ping:o.pong,e)}case"serverClipboard":return p(o.serverClipboard,y(t.text));case"clientClipboard":return p(o.clientClipboard,y(t.text));case"error":return p(o.error,y(t.code));case"pointer":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint16(0,O(t.x,"x")),n.setUint16(2,O(t.y,"y")),n.setUint8(4,t.buttons&255),p(o.pointer,e)}case"key":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint8(0,t.down?1:0),n.setUint32(1,t.keysym>>>0),p(o.key,e)}case"config":return p(o.config,Uint8Array.of(ot.indexOf(t.preset)));case"keyframeRequest":return p(o.keyframeRequest,new Uint8Array(0));case"audioHello":{let e=y(t.codec),n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,t.sampleRate>>>0),i.setUint8(4,t.channels&255),n.set(e,5),p(o.audioHello,n)}case"audio":{let e=new Uint8Array(8+t.data.byteLength);return new DataView(e.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,8),p(o.audio,e)}case"control":return p(o.control,y(JSON.stringify(t.control)));case"windows":{let e=t.bounds.slice(0,m),n=new Uint8Array(e.length*16),i=new DataView(n.buffer);return e.forEach((s,a)=>{[s.x,s.y,s.width,s.height].forEach((c,d)=>i.setInt32(a*16+d*4,ee(c)))}),p(o.windows,n)}case"audioEnable":return p(o.audioEnable,Uint8Array.of(t.on?1:0));case"ack":{let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t.seq>>>0),p(o.ack,e)}}}function M(t){let e=ot[t];if(!e)throw new l("invalid_preset");return e}function w(t,e){if(t.byteLength!==e)throw new l("invalid_length")}function S(t){if(t.byteLength>v)throw new l("text_too_large");try{return Q.decode(t)}catch{throw new l("invalid_text")}}function te(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_stats")}let n=e;if(!n||typeof n!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((s)=>typeof n[s]!=="number"||!Number.isFinite(n[s])))throw new l("invalid_stats");return{fps:n.fps,kbps:n.kbps,dropped:n.dropped,restarts:n.restarts,queued_bytes:n.queued_bytes}}function ne(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_control")}let n=e;if(!n||typeof n!=="object"||typeof n.you!=="boolean"||typeof n.same_user!=="boolean")throw new l("invalid_control");let i=n.holder===null?null:On(n.holder);if(i===null&&n.holder!==null)throw new l("invalid_control");return{holder:i,you:n.you,same_user:n.same_user}}function re(t,e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case o.hello:if(e.byteLength<6)throw new l("invalid_length");return{type:"hello",width:n.getUint16(0),height:n.getUint16(2),fps:n.getUint8(4),preset:M(n.getUint8(5)),codec:S(e.subarray(6))};case o.frame:if(e.byteLength<14)throw new l("invalid_length");if(n.getUint8(0)>1)throw new l("invalid_frame_flags");return{type:"frame",key:n.getUint8(0)===1,seq:n.getUint32(1),captureMicros:Number(n.getBigUint64(5)),data:e.subarray(13)};case o.stats:return{type:"stats",stats:te(e)};case o.ping:case o.pong:return w(e,8),{type:t===o.ping?"ping":"pong",token:n.getFloat64(0)};case o.serverClipboard:return{type:"serverClipboard",text:S(e)};case o.clientClipboard:return{type:"clientClipboard",text:S(e)};case o.error:return{type:"error",code:S(e)};case o.pointer:return w(e,5),{type:"pointer",x:n.getUint16(0),y:n.getUint16(2),buttons:n.getUint8(4)};case o.key:if(w(e,5),n.getUint8(0)>1)throw new l("invalid_key_flags");return{type:"key",down:n.getUint8(0)===1,keysym:n.getUint32(1)};case o.config:return w(e,1),{type:"config",preset:M(n.getUint8(0))};case o.keyframeRequest:return w(e,0),{type:"keyframeRequest"};case o.audioHello:if(e.byteLength<5)throw new l("invalid_length");return{type:"audioHello",sampleRate:n.getUint32(0),channels:n.getUint8(4),codec:S(e.subarray(5))};case o.audio:if(e.byteLength<9)throw new l("invalid_length");return{type:"audio",captureMicros:Number(n.getBigUint64(0)),data:e.subarray(8)};case o.audioEnable:if(w(e,1),n.getUint8(0)>1)throw new l("invalid_audio_flags");return{type:"audioEnable",on:n.getUint8(0)===1};case o.control:return{type:"control",control:ne(e)};case o.windows:{if(e.byteLength%16!==0||e.byteLength>m*16)throw new l("invalid_length");let i=[];for(let s=0;s<e.byteLength;s+=16)i.push({x:n.getInt32(s),y:n.getInt32(s+4),width:n.getInt32(s+8),height:n.getInt32(s+12)});return{type:"windows",bounds:i}}case o.ack:return w(e,4),{type:"ack",seq:n.getUint32(0)};default:return null}}class In{buffer=new Uint8Array(0);push(t){let e=new Uint8Array(this.buffer.byteLength+t.byteLength);e.set(this.buffer),e.set(t,this.buffer.byteLength);let n=[],i=0;while(e.byteLength-i>=4){let s=new DataView(e.buffer,e.byteOffset+i,4).getUint32(0);if(s<1||s>L)throw new l("invalid_message_length");if(e.byteLength-i-4<s)break;let a=e[i+4],c=e.slice(i+5,i+4+s),d=re(a,c);if(d)n.push(d);i+=4+s}return this.buffer=e.slice(i),n}}var Y="/usr/bin/osascript",se=5000,oe=1048576,ae=String.raw`
3
- ObjC.import("CoreGraphics");
4
- ObjC.import("ApplicationServices");
5
- ObjC.import("AppKit");
6
- ObjC.bindFunction("CGPreflightScreenCaptureAccess", ["bool", []]);
7
- ObjC.bindFunction("CGRequestScreenCaptureAccess", ["bool", []]);
8
- ObjC.bindFunction("getppid", ["int", []]);
9
- function run(argv) {
10
- const bounds = $.CGDisplayBounds($.CGMainDisplayID());
11
- const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
12
- const screen = $.CGPreflightScreenCaptureAccess(), accessibility = $.AXIsProcessTrusted();
13
- stdout.writeData($(JSON.stringify({ screen, accessibility,
14
- width: bounds.size.width, height: bounds.size.height }) + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
15
- if (argv[0] === "request") {
16
- if (!screen && argv[1] !== "accessibility") $.CGRequestScreenCaptureAccess();
17
- if (!accessibility && argv[1] !== "screen") $.AXIsProcessTrustedWithOptions($({ AXTrustedCheckOptionPrompt: true }));
18
- }
19
- if (argv[0] === "probe" || argv[0] === "request") return;
20
- if (argv[0] === "clipboard") {
21
- const parent = $.getppid(), clipboard = $.NSPasteboard.generalPasteboard;
22
- // Only changes made during this pairing: never export the initial pasteboard.
23
- let last = Number(clipboard.changeCount);
24
- while ($.getppid() === parent) {
25
- $.NSThread.sleepForTimeInterval(0.1);
26
- const count = Number(clipboard.changeCount);
27
- if (count === last) continue;
28
- last = count;
29
- const text = clipboard.stringForType($.NSPasteboardTypeString);
30
- if (!text) continue;
31
- const bytes = text.dataUsingEncoding($.NSUTF8StringEncoding);
32
- if (Number(bytes.length) > ${v}) continue;
33
- stdout.writeData($("c " + bytes.base64EncodedStringWithOptions(0).js + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
34
- }
35
- return;
36
- }
37
- const stdin = $.NSFileHandle.fileHandleWithStandardInput;
38
- let pending = "";
39
- for (;;) {
40
- const data = stdin.availableData;
41
- if (Number(data.length) === 0) return;
42
- pending += $.NSString.alloc.initWithDataEncoding(data, $.NSUTF8StringEncoding).js;
43
- for (let end = pending.indexOf("\n"); end >= 0; end = pending.indexOf("\n")) {
44
- const [kind, ...rest] = pending.slice(0, end).split(" ");
45
- pending = pending.slice(end + 1);
46
- const n = rest.map(Number);
47
- let event = null;
48
- if (kind === "m") {
49
- event = $.CGEventCreateMouseEvent($(), n[0], { x: n[1], y: n[2] }, n[3]);
50
- $.CGEventSetIntegerValueField(event, $.kCGMouseEventClickState, n[4]);
51
- } else if (kind === "w") {
52
- event = $.CGEventCreateScrollWheelEvent($(), $.kCGScrollEventUnitPixel, 2, n[0], n[1]);
53
- } else if (kind === "k") {
54
- event = $.CGEventCreateKeyboardEvent($(), n[0], n[1] === 1);
55
- } else if (kind === "u") {
56
- event = $.CGEventCreateKeyboardEvent($(), 0, n[0] === 1);
57
- const unit = Ref("unsigned short");
58
- unit[0] = n[1];
59
- $.CGEventKeyboardSetUnicodeString(event, 1, unit);
60
- } else if (kind === "c") {
61
- const bytes = $.NSData.alloc.initWithBase64EncodedStringOptions($(rest[0] || ""), 0);
62
- $.NSPasteboard.generalPasteboard.clearContents;
63
- $.NSPasteboard.generalPasteboard.setStringForType($.NSString.alloc.initWithDataEncoding(bytes, $.NSUTF8StringEncoding), $.NSPasteboardTypeString);
64
- }
65
- if (event) {
66
- $.CGEventSetFlags(event, n[n.length - 1]);
67
- $.CGEventPost($.kCGHIDEventTap, event);
68
- }
69
- }
70
- }
71
- }
72
- `;function q(t){let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!=="object")return null;let n=e,i=(c)=>typeof c==="number"&&Number.isFinite(c)?Math.min(65535,Math.round(c)):0;if(typeof n.screen!=="boolean"||typeof n.accessibility!=="boolean")return null;let s=i(n.width),a=i(n.height);return s>0&&a>0?{screen:n.screen,accessibility:n.accessibility,width:s,height:a}:null}function k(t,...e){let[n,...i]=[...t,Y,"-l","JavaScript","-e",ae,...e];return[n,i]}function H(t,...e){return new Promise((n)=>{ie(...k(t,...e),{env:{},timeout:se,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(i,s)=>n(i?null:q(s.split(`
73
- `)[0]??"")))})}function ze(t=[]){return H(t,"probe")}function st(t,e){return H(t,"request",...e?[e]:[])}var N=2,ce=8,ue=String.raw`
74
- ObjC.import("CoreGraphics");
75
- ObjC.import("Foundation");
76
- ObjC.bindFunction("getppid", ["int", []]);
77
- function run() {
78
- const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
79
- const parent = $.getppid();
80
- let last = "";
81
- let wait = ${N};
82
- // Ends with the worker that started it, even one that never got to kill it.
83
- while ($.getppid() === parent) {
84
- const list = ObjC.castRefToObject($.CGWindowListCopyWindowInfo($.kCGWindowListOptionOnScreenOnly | $.kCGWindowListExcludeDesktopElements, 0));
85
- const bounds = [];
86
- const count = Number(list.count);
87
- for (let i = 0; i < count && bounds.length < ${m}; i++) {
88
- const window = list.objectAtIndex(i);
89
- if (Number(window.objectForKey("kCGWindowLayer").js) !== 0) continue;
90
- const b = window.objectForKey("kCGWindowBounds");
91
- bounds.push(["X", "Y", "Width", "Height"].map((key) => Math.round(Number(b.objectForKey(key).js))));
92
- }
93
- const line = JSON.stringify(bounds);
94
- if (line !== last) {
95
- last = line;
96
- wait = ${N};
97
- stdout.writeData($(line + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
98
- } else {
99
- wait = Math.min(wait * 2, ${ce});
100
- }
101
- $.NSThread.sleepForTimeInterval(wait);
102
- }
103
- }
104
- `;function le(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e))return null;let n=[];for(let i of e.slice(0,m)){if(!Array.isArray(i)||i.length!==4||!i.every((u)=>typeof u==="number"&&Number.isFinite(u)))return null;let[s,a,c,d]=i.map(Math.round);if(c>0&&d>0)n.push({x:s,y:a,width:c,height:d})}return n}function Dn(t){let e=Date.now(),n=0,i=!1,s=(u,b={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:u,...b})}
105
- `)}catch{}},a=(u,b={})=>{if(i)return;i=!0,s(u,{updates:n,duration_ms:Date.now()-e,...b})},c=E(Y,["-l","JavaScript","-e",ue],{env:{},stdio:["ignore","pipe","ignore"]});s("started");let d="";return c.stdout.on("data",(u)=>{if(i)return;d+=u.toString("utf8");for(let b=d.indexOf(`
106
- `);b>=0;b=d.indexOf(`
107
- `)){let x=le(d.slice(0,b));if(d=d.slice(b+1),x)n++,t(x)}if(d.length>65536)d=""}),c.once("error",(u)=>a("failed",{code:u.code??"spawn_failed"})),c.once("exit",(u,b)=>a("failed",{code:"exited",exit_code:u,signal:b})),{close(){a("stopped"),c.kill("SIGKILL")}}}var T=5,R=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],de=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],P=50,fe=500,V=4,I=131072,W=262144,_=524288,F=1048576,B=new Map([[65505,[56,I]],[65506,[60,I]],[65507,[59,W]],[65508,[62,W]],[65511,[58,_]],[65512,[61,_]],[65513,[58,_]],[65514,[61,_]],[65027,[61,_]],[65515,[55,F]],[65516,[54,F]]]),pe=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((t,e)=>[65456+e,t]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((t,e)=>[65470+e,t])]),G="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",j='~!@#$%^&*()_+{}|:"<>?',be="`1234567890-=[]\\;',./",D=new Map;for(let t=0;t<G.length;t++){let e=G[t];if(e==="\x00")continue;if(D.set(e.charCodeAt(0),[t,!1]),e>="a"&&e<="z")D.set(e.toUpperCase().charCodeAt(0),[t,!0])}for(let t=0;t<j.length;t++)D.set(j.charCodeAt(t),[D.get(be.charCodeAt(t))[0],!0]);class K{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(t=()=>performance.now()){this.now=t}flags(){let t=0;for(let e of this.held)t|=B.get(e)[1];return t}mouse(t,e){return`m ${t} ${this.x} ${this.y} ${e} ${t===T?0:this.clicks} ${this.flags()}`}pointer(t,e,n){let i=[];if(t!==this.x||e!==this.y){this.x=t,this.y=e;let s=R.find((a)=>this.mask&a.bit);i.push(s?this.mouse(s.drag,s.button):this.mouse(T,0))}for(let s of R){let a=(this.mask&s.bit)!==0,c=(n&s.bit)!==0;if(!a&&c){let d=this.now(),u=this.lastDown;this.clicks=u&&u.button===s.button&&d-u.at<=fe&&Math.abs(t-u.x)<=V&&Math.abs(e-u.y)<=V?this.clicks+1:1,this.lastDown={button:s.button,at:d,x:t,y:e},i.push(this.mouse(s.down,s.button))}else if(a&&!c)i.push(this.mouse(s.up,s.button))}for(let[s,a,c]of de)if(!(this.mask&s)&&n&s)i.push(`w ${a*P} ${c*P} ${this.flags()}`);return this.mask=n,i}key(t,e){let n=t?1:0,i=B.get(e);if(i){if(t)this.held.add(e);else this.held.delete(e);return[`k ${i[0]} ${n} ${this.flags()}`]}let s=pe.get(e);if(s!==void 0)return[`k ${s} ${n} ${this.flags()}`];let a=e<256?e:(e&4278190080)===16777216?e&16777215:0,c=D.get(a);if(c)return[`k ${c[0]} ${n} ${this.flags()|(c[1]?I:0)}`];if(a<160||a>65535||a>=55296&&a<57344)return[];return[`u ${n} ${a} ${this.flags()}`]}}function Nn(t,e=[]){let n=E(...k(e),{env:{},stdio:["pipe","pipe","ignore"]}),i=new K,s="",a=!1,c=null,d=()=>{n.kill("SIGKILL"),c?.kill("SIGKILL")},u=(f)=>{if(a)return;a=!0,d(),t.end(f)},b=(f)=>u({error:new r("display_unavailable",f)}),x=(f)=>{if(a||f.length===0)return;if(n.stdin.write(f.map((g)=>`${g}
108
- `).join("")),n.stdin.writableLength>oe)u({reason:"input_backpressure"})},X=()=>{c=E(...k(e,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let f="";c.stdout?.on("data",(g)=>{if(a)return;f+=g.toString("ascii");for(let h=f.indexOf(`
109
- `);h>=0;h=f.indexOf(`
110
- `)){let C=f.slice(0,h);if(f=f.slice(h+1),!C.startsWith("c "))continue;let A=C.slice(2);if(A.length>Math.ceil(v/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(A)){u({reason:"display_protocol"});return}let U=Buffer.from(A,"base64");if(U.byteLength<=v)t.clipboard(U.toString("utf8"));if(a)return}if(f.length>Math.ceil(v/3)*4+2)u({reason:"display_protocol"})}),c.once("error",()=>b("Reason could not watch this Mac's desktop clipboard.")),c.once("exit",()=>{if(!a)b("Reason could not watch this Mac's desktop clipboard.")})};return n.stdout.on("data",(f)=>{if(a||s===null)return;s+=f.toString("utf8");let g=s.indexOf(`
111
- `);if(g<0){if(s.length>4096)u({reason:"display_protocol"});return}let h=q(s.slice(0,g));if(s=null,!h)u({reason:"display_protocol"});else if(!h.screen||!h.accessibility)b(e.length>0?"Reason's background worker needs Screen Recording and Accessibility on this Mac (its own Reason entry in System Settings > Privacy & Security, not the Reason app's): run `reason permissions allow` on this Mac.":"Allow Screen Recording and Accessibility for this Mac's Reason worker, then restart it.");else X(),t.ready({width:h.width,height:h.height})}),n.stdin.on("error",()=>{return}),n.once("error",()=>b("Reason could not start this Mac's desktop input.")),n.once("exit",()=>{if(s!==null)b("Reason could not start this Mac's desktop input.");else u({reason:"display_closed"})}),{pointer:(f,g,h)=>x(i.pointer(f,g,h)),key:(f,g)=>x(i.key(f,g)),clipboard:(f)=>x([`c ${Buffer.from(f,"utf8").toString("base64")}`]),close(){a=!0,d()}}}
112
- export{Yi,Qi,ot,eo,v,to,ro,On,no,io,oo,Fr,In,ze,st,Dn,Nn};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{a}from"./vm-hands-entry-lite-89z488gz.js";import{readFileSync as c}from"fs";import{isAbsolute as l,normalize as i}from"path";var m="REASON_WORKER_DESKTOP_USER",u=null;function p(t,o){for(let s of o.split(`
3
- `)){let e=s.split(":");if(e.length<7||Number(e[2])!==t||!/^\d+$/.test(e[2])||!/^\d+$/.test(e[3]))continue;let n=e[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(e[0])||!l(n)||i(n)!==n||n==="/")return null;return{username:e[0],uid:t,gid:Number(e[3]),home:n}}return null}function ds(t={}){let o="value"in t?t.value:process.env[m];if(u=null,o===void 0||o==="")return null;let s=t.platform??process.platform,e="euid"in t?t.euid:process.geteuid?.(),n=/^[1-9]\d{0,9}$/.test(o)?Number(o):NaN,r=s==="linux"&&e===0&&Number.isSafeInteger(n)?p(n,(t.passwd??(()=>c("/etc/passwd","utf8")))()):null;if(!r||r.gid===0)throw Error("worker_desktop_user_invalid");return u=r,r}function G(){return u}function kn(){return u?.home??a()}
4
- export{ds,G,kn};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{x}from"./vm-hands-entry-lite-9ay6f56v.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as b}from"child_process";import{mkdirSync as y,readdirSync as h,readFileSync as D,rmSync as f,statSync as k,writeFileSync as w}from"fs";import{join as p,sep as S}from"path";import{setTimeout as L}from"timers/promises";var _=3000,u=null;function g(e){return p(e,"users")}function gt(e){if(u?.root===e.root)return;let t=g(e.root);y(t,{recursive:!0,mode:448}),w(p(t,String(process.pid)),"",{mode:384}),u=e}function Us(){if(!u)return;f(p(g(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(t){return t instanceof Error&&"code"in t&&t.code==="EPERM"}}function P(){let e=process.getuid?.();if(process.platform==="linux")return h("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(k(`/proc/${n}`).uid!==e)return[];let s=D(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return b(x("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((s)=>{let c=/^(\d+) (.+)$/.exec(s.trim());return c?[{pid:Number(c[1]),command:c[2]}]:[]});return b("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
- `).flatMap((n)=>{let s=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(n);return s&&Number(s[2])===e?[{pid:Number(s[1]),command:s[3]}]:[]})}async function Hs(){let e=u;if(!e)return{released:"unused",stopped:0};let t=g(e.root);f(p(t,String(process.pid)),{force:!0}),u=null;let n=!1;for(let o of h(t)){let i=Number(o);if(Number.isSafeInteger(i)&&i>0&&m(i))n=!0;else f(p(t,o),{force:!0})}if(n)return{released:"shared",stopped:0};let s=P().filter((o)=>o.pid!==process.pid&&(o.command.includes(`${e.root}${S}`)||o.command.includes(`${e.automation}${S}`)||o.command.includes(e.extensionDir))),c=(o,i)=>{try{process.kill(o,i)}catch{}};for(let o of s)c(o.pid,"SIGTERM");for(let o=Date.now()+_;Date.now()<o&&s.some((i)=>m(i.pid));)await new Promise((i)=>setTimeout(i,100));for(let o of s)if(m(o.pid))c(o.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var E=20000,M=30000,N=100,a=new Map,l=null,d=[];function gi(e){a.set(e,(a.get(e)??0)+1);let t=!1;return()=>{if(t)return;t=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),l?.run===e)l.idleUntil=0}}function O(){return new r("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function T(e,t){return l!==null&&l.run!==e&&(l.calls>0||t<l.idleUntil)}async function _i(e,t,n=Date.now){let s=Symbol(e);d.push(s);try{let i=n()+M;for(;;){if(!T(e,n())&&(l?.run===e||d[0]===s))break;if(n()>=i)throw O();await L(N,void 0,{signal:t}).catch(()=>t.throwIfAborted())}}finally{d.splice(d.indexOf(s),1)}if(l?.run!==e)l={run:e,calls:0,idleUntil:0};let c=l;c.calls+=1;let o=!1;return()=>{if(o)return;o=!0,c.calls-=1,c.idleUntil=n()+E}}
4
- export{gt,Us,Hs,gi,_i};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{statSync as f}from"fs";import{delimiter as l,join as d}from"path";function Et(e,o=process.env.PATH??"",i=process.env,u=process.platform){let r=u==="win32",a=e.includes("/")||r&&e.includes("\\");if(!e||a||e.includes("\x00"))return!1;let c=r?["",...(i.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")]:[""];return o.split(l).some((t)=>{if(!t)return!1;return c.some((n)=>{if(n===void 0)return!1;try{let s=f(d(t,`${e}${n}`));if(!s.isFile())return!1;return r||(s.mode&73)!==0}catch{return!1}})})}
3
- export{Et};
@@ -1,42 +0,0 @@
1
- // @bun
2
- import{t,ft,A,o,d,u,c,_,oe,s,n}from"./vm-hands-entry-lite-907pa7f9.js";var T=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((r)=>r!=="."&&r!=="..")),y=t().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((e)=>!e.includes("..")&&!e.includes("//")&&!e.endsWith("/")&&!e.endsWith(".lock")),x=t().regex(/^[a-f0-9]{40}$/),O=o().int().positive(),k=t().min(1).max(256),D=t().max(60000),L={version:n(1),repoFullName:T},N=u(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),j=c({expectedTrailers:N,missingFromHead:N}),z=_("action",[c({action:n("edit"),title:k.optional(),body:D.optional(),base:y.optional()}),c({action:s(["ready","draft","close"])}),c({action:n("metadata"),field:s(["reviewer","assignee","label"]),change:s(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),ke=_("kind",[c({...L,kind:n("read"),path:t().min(1).max(2048),accept:s(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),c({...L,kind:n("pr_review_context"),number:O,after:t().min(1).max(1024).optional()}),c({...L,kind:n("prepare"),branch:y,baseSha:x,defaultBranch:y,diagnosticsVersion:n(1).optional()}),c({...L,kind:n("publish"),branch:y,defaultBranch:y,baseSha:x,remoteHeadSha:x.nullable(),contributorTrailers:N.optional()}),c({...L,kind:n("pr_create"),head:y,base:y,title:k,body:D,draft:d()}),c({...L,kind:n("pr_mutation"),number:O,mutation:z}),c({...L,kind:n("pr_merge"),number:O,expectedHeadSha:x,expectedBaseRef:y,method:s(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),V=["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 F(e){return V.some((r)=>r===e)}class Vt extends Error{code;constructor(e){super(e);this.code=e}}function $n(e,r,i){let l=ke.safeParse(e);return r==="failed"&&l.success&&l.data.kind==="prepare"&&l.data.diagnosticsVersion===1&&F(i)}var lt=245760,ho=_("kind",[c({kind:n("pr_review_context"),body:t().max(lt)}),c({kind:n("prepare"),headSha:x}),c({kind:n("read"),status:o().int().min(200).max(599),headers:oe(t(),t().max(8192)).refine((e)=>Object.keys(e).every((r)=>r==="link"||r==="content-type")),body:t().max(lt)}),c({kind:n("publish"),headSha:x,scannedObjectCount:o().int().min(0).max(5000),attribution:j.optional()}),c({kind:n("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),c({kind:n("pr_mutation"),number:O,applied:n(!0)}),c({kind:n("pr_merge"),number:O,merged:n(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=lt,"local_device_gh_result_too_large"),B=c({source:s(["agent","human"]),operationId:A()}),ie=c({version:n(1),userId:ft(),deviceId:ft(),rootId:ft(),runId:ft(),merge:B.optional(),contributorRefresh:ft().optional(),repoFullName:T.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:d(),generation:o().int().positive().nullable(),fenceId:ft().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function I(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((r)=>r!=="."&&r!=="..")}function fo(e,r,i={},l="read"){if(I(e)&&(r==="/search/issues"||r.startsWith("/search/issues?")))return W(e,r,i);if(!I(e)||!r.startsWith(`/repos/${e}/`)&&r!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(r)||/%(?:2e|5c|00)/i.test(r))throw Error("local_device_gh_path_denied");let g=new URL(r,"https://api.github.com");if(g.pathname!==r.split("?")[0]||g.username||g.password)throw Error("local_device_gh_path_denied");let h;try{h=decodeURIComponent(g.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(h.includes("%")||h.split("/").some((p)=>p==="."||p===".."))throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.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((p)=>p.test(h)))throw Error("local_device_gh_path_denied");if(g.searchParams.forEach((p,b)=>{if(b==="per_page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(b==="page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(h==="/pulls"&&b==="state"&&["open","closed","all"].includes(p))return;if(h==="/pulls"&&b==="sort"&&p==="updated")return;if(h==="/pulls"&&b==="direction"&&p==="desc")return;if(h==="/pulls"&&["head","base"].includes(b)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(p))return;throw Error("local_device_gh_query_denied")}),i.headers)new Headers(i.headers).forEach((b,G)=>{if(G!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(b))throw Error("local_device_gh_header_denied")})}function W(e,r,i){if(/[\\#\u0000-\u001f]/.test(r))throw Error("local_device_gh_path_denied");let l=new URL(r,"https://api.github.com");if(l.pathname!=="/search/issues"||l.username||l.password)throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.body!=null)throw Error("local_device_gh_mutation_not_admitted");let g=null;l.searchParams.forEach((f,p)=>{if(p==="q"&&g===null){g=f;return}if(p==="per_page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;if(p==="page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;throw Error("local_device_gh_query_denied")});let h=`repo:${e.toLowerCase()} `,S=g?.toLowerCase()??"";if(S.length>512||!(S+" ").startsWith(h)||/(?:^|\s)(?:repo|org|user):/.test(S.slice(h.length)))throw Error("local_device_gh_query_denied");if(i.headers)new Headers(i.headers).forEach((f,p)=>{if(p!=="accept"||f!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var mo=`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 Ve(e){return e.kind==="read"||e.kind==="pr_review_context"}var ut=["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 Ge=2,w="/app/local-runtime",Ce=262144,vs="x-reason-relay-host-alias",Ss="v1";function m(e,r){return{path:`${w}${e}`,routerPath:e,auth:r}}function E(e,r){return{...m(e,"device_proof"),forOperation(i){return m(`/operations/${encodeURIComponent(i)}${r}`,"device_proof")}}}var Es={register:m("/register","registration_bearer"),enroll:m("/enroll","none"),authChallenge:m("/auth/challenge","none"),identity:m("/identity","device_proof"),heartbeat:m("/heartbeat","device_proof"),rootsSync:m("/roots/sync","device_proof"),disconnect:m("/disconnect","device_proof"),lifecycle:m("/lifecycle","device_proof"),localSubscription:m("/local-subscription","device_proof"),ownerWorkspaces:m("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:m("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:m("/session-worktrees","device_proof"),operationClaim:m("/operations/claim","device_proof"),operationHeartbeat:E("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:E("/operations/:operationId/events","/events"),operationComplete:E("/operations/:operationId/complete","/complete"),operationEnvironment:E("/operations/:operationId/environment","/environment"),operationEnvironmentAck:E("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:E("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},Bn=`${w}/session`;var J=[/^\/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 xs(e){return J.some((r)=>r.test(e))}var Vr=60000;var Fn="hands_control_v1",dt="environment.deliver",Ae="vm_hands_workspace_deferred",pt="vm_hands.workspace_grant",jn="hands.unbind_unverified",Un="claim_v1",Hn="environment_at_claim",qn="ready_v1",zn="workspace_check",Wn="rebind_v1",Vn="grant_v1",Gn="workspace_grant",Kn="resident_rebind",Jn="hands.rebind",Zn="snapshot_v1",Xn="cloud_access",Yn="playwright_v1",Qn="headless_browser",ei="v1",ti="job_env_large_values",pe="srt_root_v1",X="hands_confinement",Pe="gid_v1",q="model_jobs_egress",ri="setpriv_v1",ni="jobs_user",ii="spawning_attempt_v1",Y="hands_session_group";var oi="session_cap",si="none",ai="same_launch_v1",ci="exit_v1",li="start_wait",ht="user_chrome",ui="cloud_sessions";function v(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let r=/^[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((i)=>typeof e[i]==="string"&&r.test(e[i]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function C(e){if(!a(e)||Object.keys(e).length!==6)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof e.device_id==="string"&&r.test(e.device_id)&&(e.binding==="workspace_source"||e.binding==="mcp_control")&&Number.isSafeInteger(e.target_revision)&&Number(e.target_revision)>=0&&Number.isSafeInteger(e.root_grant_revision)&&Number(e.root_grant_revision)>0&&Number.isSafeInteger(e.target_generation)&&Number(e.target_generation)>0&&typeof e.target_fence_id==="string"&&r.test(e.target_fence_id)}var ks=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],Gt=86400000;var K=["production","staging"];function P(e){if(!a(e)||Object.keys(e).length!==3)return!1;let r=/^[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((i)=>Object.hasOwn(e,i)&&typeof e[i]==="string"&&r.test(e[i])&&e[i]!=="00000000-0000-0000-0000-000000000000")}var Z="DEVICE-PROOF-V2";function di(e,r=Z){let i=e.method.toUpperCase();if(!/^[A-Z]+$/.test(i)||!e.pathAndQuery.startsWith(`${w}/`)||e.pathAndQuery.includes(`
38
- `)||!/^[0-9]{1,20}$/.test(e.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(e.nonce)||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
39
- `)||!/^[a-f0-9]{64}$/.test(e.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([r,i,e.pathAndQuery,e.timestamp,e.nonce,e.challenge,e.bodySha256].join(`
40
- `),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Q(e,r){return typeof e==="string"&&r.some((i)=>i===e)}function H(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function ee(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function R(e){throw Error(e)}function Cs(e,r){let i=a(e)?e:{},l=typeof i.error==="string"?i.error:`http_${r}`,g=typeof i.detail==="string"?i.detail:typeof i.message==="string"?i.message:`Reason Device request failed (${r})`;return{code:l,message:g}}function No(e){if(!a(e)||typeof e.challenge!=="string"||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
41
- `)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))R("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function M(e,r){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==Ge||!Array.isArray(e.roots)||!e.roots.every(H)||r&&typeof e.organization_id!=="string"||e.device_credential!==void 0)R(r?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:Ge,roots:e.roots},auth_scheme:"p256"}}function As(e){return M(e,!1)}function Ps(e){let r=M(e,!0);if(typeof r.organization_id!=="string")return R("Reason returned an invalid Device enrollment.");return{...r,organization_id:r.organization_id}}function Ts(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return R("Reason returned an invalid Device heartbeat.");return{server_time:e.server_time,drain:e.drain,...U(e),...typeof e.update_policy==="string"||e.update_policy===null?{update_policy:e.update_policy}:{},...typeof e.supported_protocol_version==="number"?{supported_protocol_version:e.supported_protocol_version}:{},...ne(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var te=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function U(e){return Object.fromEntries(te.filter((r)=>e[r]===!0).map((r)=>[r,!0]))}function Rs(e){if(!a(e))return;try{return{...No(e),...U(e)}}catch{return}}function ne(e){if(!a(e))return{};let r={};for(let i of K){let l=e[i];if(typeof l==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(l))r[i]=l}return Object.keys(r).length>0?{latest_cli_versions:r}:{}}function Os(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(H))return R("Reason returned an invalid Device root sync.");return{roots:e.roots}}function Is(e){if(!a(e)||e.user_id!==void 0&&typeof e.user_id!=="string"||typeof e.organization_id!=="string"||typeof e.organization_name!=="string"||typeof e.organization_slug!=="string")return R("Reason returned an invalid Device identity.");return{...typeof e.user_id==="string"?{user_id:e.user_id}:{},organization_id:e.organization_id,organization_name:e.organization_name,organization_slug:e.organization_slug}}function Ds(e){if(!a(e)||e.disconnected!==!0)return R("Reason did not disconnect this Device.");let r=e.sessions_moved;return typeof r==="number"&&Number.isSafeInteger(r)&&r>=0?{disconnected:!0,sessions_moved:r}:{disconnected:!0}}function Ns(e){if(a(e)&&e.ok===!0&&typeof e.expires==="number")return{ok:!0,expires:e.expires};if(a(e)&&e.ok===!1&&typeof e.error==="string")return{ok:!1,error:e.error};return R("Reason did not answer the local login hand-over.")}function Ls(e){if(!a(e)||e.accepted!==!0)return R("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function re(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ms(e,r=ut){if(!a(e)||typeof e.operation_id!=="string"||typeof e.attempt_id!=="string"||typeof e.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(e.attempt_token)||typeof e.lease_until!=="string"||typeof e.run_id!=="string"||typeof e.root_id!=="string"||e.owner!==void 0&&!P(e.owner)||!Q(e.capability,r)||!a(e.payload)||e.protocol_version!==Ge||re(e.payload)>Ce||e.authority!==void 0&&!C(e.authority)||e.local_github_authority!==void 0&&!ie.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!ie.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!v(e.recording_authority)||e.capability==="browser.recording.v1"&&(!v(e.recording_authority)||!P(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return R("Reason returned an invalid Device operation claim.");let i={operation_id:e.operation_id,attempt_id:e.attempt_id,attempt_token:e.attempt_token,lease_until:e.lease_until,run_id:e.run_id,root_id:e.root_id,capability:e.capability,payload:e.payload,...C(e.authority)?{authority:e.authority}:{},...v(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:ie.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&C(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:Ge};if(e.owner!==void 0)i.owner=Object.freeze({...e.owner});return i}function $s(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(ee)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return R("Reason returned an invalid Device operation heartbeat.");return{lease_until:e.lease_until,controls:e.controls,next_control_seq:Number(e.next_control_seq)}}function Bs(e){if(!a(e)||!Number.isInteger(e.next_event_seq)||Number(e.next_event_seq)<0||typeof e.duplicate!=="boolean"||!Number.isInteger(e.accepted_count)||Number(e.accepted_count)<0)return R("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(e.next_event_seq),duplicate:e.duplicate,accepted_count:Number(e.accepted_count)}}function Fs(e){if(!a(e)||!a(e.payload)||!C(e.authority))return R("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function ae(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function js(e){if(!a(e)||!ae(e.status)||typeof e.idempotent!=="boolean")return R("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
42
- export{ke,Vt,$n,lt,ho,ie,fo,mo,Ve,ut,Ge,Ce,vs,Ss,Es,Bn,xs,Vr,Fn,dt,Ae,pt,jn,Un,Hn,qn,zn,Wn,Vn,Gn,Kn,Jn,Zn,Xn,Yn,Qn,ei,ti,pe,X,Pe,q,ri,ni,ii,Y,oi,si,ai,ci,li,ht,ui,ks,Gt,di,Cs,No,As,Ps,Ts,Rs,Os,Is,Ds,Ns,Ls,Ms,$s,Bs,Fs,js};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{resolve as s,sep as i}from"path";var Se=[[".ssh"],[".gnupg"],[".aws"],[".azure"],[".kube"],[".docker"],[".infisical"],[".password-store"],[".terraform.d"],[".config","ara"],[".config","reason"],[".config","gh"],[".config","gcloud"],[".config","infisical"],[".config","op"],[".config","1password"],[".config","pass"],[".local","share","keyrings"],["library","keychains"],["library","application support","so.ara.desktop"],["appdata","roaming","github cli"],["appdata","roaming","gcloud"],["appdata","roaming","microsoft","credentials"],["appdata","local","microsoft","credentials"],["appdata","roaming","microsoft","protect"],["appdata","roaming","1password"],["appdata","local","1password"],["appdata","roaming","microsoft","windows","start menu","programs","startup"],["documents","windowspowershell"],["documents","powershell"],["appdata","local","reason"]],Bt=[[".codex","config.toml"],[".cursor","mcp.json"],[".claude","settings.json"],[".claude","settings.local.json"],[".cargo","credentials"],[".cargo","credentials.toml"],[".gem","credentials"],[".config","git","config"],[".config","git","credentials"],[".config","pip","pip.conf"]],Ft=new Set([".bash_login",".bash_profile",".bashrc",".bunfig.toml",".claude.json",".env",".envrc",".git-credentials",".gitconfig",".mcp.json",".netrc",".npmrc",".profile",".pypirc",".terraformrc",".yarnrc",".yarnrc.yml",".zlogin",".zlogout",".zprofile",".zshenv",".zshrc","auth.json","credentials.json","credentials.tfrc.json","local-daemon.json","local-device.json","mcp.json"]),jt=[".key",".p12",".pfx",".pem"];function t(n,a){if(n.length<a.length)return!1;for(let r=0;r<=n.length-a.length;r+=1)if(a.every((o,e)=>n[r+e]===o))return!0;return!1}function E(n){let a=s(n).split(i).filter(Boolean).map((o)=>o.toLowerCase());if(Se.some((o)=>t(a,o)))return!0;if(Bt.some((o)=>t(a,o)))return!0;let r=a.at(-1)??"";return Ft.has(r)||r.startsWith(".env.")||jt.some((o)=>r.endsWith(o))}
3
- export{Se,Bt,Ft,jt,E};
@@ -1,3 +0,0 @@
1
- // @bun
2
- function _e(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}
3
- export{_e};
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{g,$r,it,ve}from"./vm-hands-entry-lite-ckv17tn8.js";import{Vi}from"./vm-hands-entry-lite-1rrb66r9.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{t,i,s,n}from"./vm-hands-entry-lite-907pa7f9.js";import{createHmac as bt,createPublicKey as me,randomBytes as mt,randomUUID as he,verify as Se}from"crypto";import{chmodSync as L,existsSync as z,mkdirSync as Ie,readFileSync as ke,realpathSync as St,renameSync as De,statSync as kt,unlinkSync as Le,writeFileSync as we}from"fs";import{basename as Lt,dirname as w,isAbsolute as Ae,join as m,resolve as wt}from"path";var $e=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var Z="REASON_DESKTOP_RUNTIME",q="REASON_DESKTOP_RUNTIME_CHANNEL",Q="REASON_DESKTOP_RUNTIME_INSTANCE_ID",ee="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",We={[Z]:"ARA_DESKTOP_RUNTIME",[q]:"ARA_DESKTOP_RUNTIME_CHANNEL",[Q]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[ee]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function x(r){if(r===void 0)return;if(!/^[a-f0-9]{64}$/.test(r))throw Error("Invalid desktop workspace scope.");return r}import{chmodSync as h,existsSync as f,mkdirSync as S,readFileSync as N,realpathSync as te,renameSync as ne,unlinkSync as I,writeFileSync as k}from"fs";import{createPrivateKey as ie,createPublicKey as re,generateKeyPairSync as oe,randomUUID as ae,sign as se}from"crypto";import{createRequire as ce}from"module";import{homedir as le,platform as T}from"os";import{dirname as de,join as y}from"path";var O=1,ue=16384,v=65536,pe=128,ge=128,U=65536;class l extends Error{code;nativeStatus;constructor(r,e){super(`Reason Device proof boundary failed (${r}).${e===void 0?"":` Native status: ${e}.`}`);this.code=r;this.nativeStatus=e;this.name="LocalCredentialBoundaryError"}}var D=null;function F(){if(!D)try{D=ce(import.meta.url)("bun:ffi")}catch{throw new l("native_boundary_unavailable")}return D}function fe(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost"&&e.hostname!=="[::1]"&&e.hostname!=="::1")return null;return e.origin}catch{return null}}function ye(r){if(!r||typeof r!=="object"||Array.isArray(r))throw new l("invalid_credential_record");let e=r,o=fe(e.apiOrigin);if(e.version!==O||!o||typeof e.orgId!=="string"||e.orgId.length<1||e.orgId.length>160||typeof e.deviceId!=="string"||e.deviceId.length<1||e.deviceId.length>160||typeof e.credential!=="string"||!/^(?:reason|ara)_dev_/.test(e.credential)||e.credential.length>4096)throw new l("invalid_credential_record");return{version:O,apiOrigin:o,orgId:e.orgId,deviceId:e.deviceId,credential:e.credential}}function Rt(r=process.execPath){let e=r;try{e=te(r)}catch{}return Vi(de(e))}function u(r){return F().ptr(r)}function _e(r){if(!f(r))throw new l("native_boundary_unavailable");let{dlopen:e,FFIType:o}=F();try{return e(r,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(c){if(c instanceof l)throw c;throw new l("native_boundary_unavailable")}}function K(r){return Buffer.from(r).toString("base64url")}function _(r){if(typeof r!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(r))return!1;try{let e=Buffer.from(r,"base64url");return e.byteLength===65&&e[0]===4}catch{return!1}}function M(r){if(r.byteLength<8||r.byteLength>72||r[0]!==48)return!1;let e=r[1];return e!==void 0&&e<128&&e+2===r.byteLength}class Fe{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(r=Rt(),e=T(),o){this.libraryPath=r;this.runtimePlatform=e;this.workspaceScope=o;x(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new l("unsupported_platform");this.library??=_e(this.libraryPath);let r=new TextEncoder().encode(this.workspaceScope??""),e=this.library.symbols.ara_device_configure_scope(u(r.length?r:new Uint8Array(1)),BigInt(r.length));if(e!==0)throw new l("native_boundary_unavailable",e);return this.library.symbols}publicKey(r){let e=new Uint8Array(pe),o=new BigUint64Array(1),c=r==="load"?this.symbols().ara_device_key_load_public(u(e),BigInt(e.byteLength),u(o)):this.symbols().ara_device_key_create_fresh_public(u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l(r==="load"?"proof_key_read_failed":"proof_key_generation_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new l("invalid_public_key");let p=K(e.subarray(0,d));if(!_(p))throw new l("invalid_public_key");return p}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=new Uint8Array(ge),o=new BigUint64Array(1),c=this.symbols().ara_device_key_sign(u(r),BigInt(r.byteLength),u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l("proof_sign_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>e.byteLength)throw new l("invalid_signature");let p=e.subarray(0,d);if(!M(p))throw new l("invalid_signature");return K(p)}privateKeyIsNonExtractable(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_is_non_extractable(u(r));if(e!==0||r[0]!==1)throw new l("proof_key_read_failed",e);return!0}deleteKey(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_delete(u(r));if(e!==0)throw new l("proof_key_delete_failed",e);return r[0]===1}loadBinding(){let r=new Uint8Array(v),e=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("binding_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_binding");return r.slice(0,c)}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_create(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_create_failed",e)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_update(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_update_failed",e)}deleteBinding(){let r=new Uint8Array(1),e=this.symbols().ara_device_binding_delete(u(r));if(e!==0)throw new l("binding_delete_failed",e);return r[0]===1}loadLegacyCredential(){let r=new Uint8Array(ue),e=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("legacy_credential_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(r.subarray(0,c));return ye(JSON.parse(d))}catch(d){if(d instanceof l)throw d;throw new l("invalid_credential_record")}}deleteLegacyCredential(){let r=new Uint8Array(1),e=this.symbols().ara_device_keychain_delete(u(r));if(e!==0)throw new l("legacy_credential_delete_failed",e);return r[0]===1}}function C(r){let e=r.export({format:"jwk"});if(e.crv!=="P-256"||typeof e.x!=="string"||typeof e.y!=="string")throw new l("invalid_public_key");let o=Buffer.from(e.x,"base64url"),c=Buffer.from(e.y,"base64url");if(o.byteLength!==32||c.byteLength!==32)throw new l("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,c]).toString("base64url");if(!_(d))throw new l("invalid_public_key");return d}function be(){let r=process.env.XDG_CONFIG_HOME?.trim()||y(le(),".config");it(r);let e=y(r,"ara");return $r(e)?e:y(r,"reason")}class Sr{directory;constructor(r=be()){this.directory=r}keyPath(){return y(this.directory,"local-device.key")}bindingPath(){return y(this.directory,"local-device.binding")}loadPrivateKeyObject(){let r=this.keyPath();if(!f(r))throw new l("proof_key_read_failed");try{let e=N(r,"utf8");return ie({key:e,format:"pem"})}catch{throw new l("proof_key_read_failed")}}loadPublicKey(){let r=this.loadPrivateKeyObject(),e=re(r);return C(e)}createFreshPublicKey(){S(this.directory,{recursive:!0,mode:448});let{privateKey:r,publicKey:e}=oe("ec",{namedCurve:"P-256"}),o=r.export({type:"pkcs8",format:"pem"}),c=this.keyPath();return k(c,o,{mode:384}),h(c,384),C(e)}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=this.loadPrivateKeyObject(),o;try{o=se("sha256",r,e)}catch{throw new l("proof_sign_failed")}if(!M(o))throw new l("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let r=this.keyPath();if(!f(r))return!1;return I(r),!0}loadBinding(){let r=this.bindingPath();if(!f(r))return null;try{return new Uint8Array(N(r))}catch{return null}}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(f(e))throw new l("binding_create_failed");k(e,r,{mode:384}),h(e,384)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(!f(e))throw new l("binding_update_failed");let o=`${e}.${ae()}`;try{k(o,r,{mode:384,flag:"wx"}),h(o,384),ne(o,e)}finally{if(f(o))I(o)}}deleteBinding(){let r=this.bindingPath();if(!f(r))return!1;return I(r),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function V(){return T()==="darwin"?new Fe:new Sr}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),B=i({id:b,kind:n("permission_denied"),operation:s(["bash","read","write","edit"]),provenance:s(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var A=4;var P="macos-keychain-p256-v1",Pe=1,Ee=`ARA-DEVICE-BINDING-V1
3
- `;function Re(r){return r===void 0||typeof r==="number"&&Number.isInteger(r)&&r>=1&&r<=4}function G(r,e=Date.now()){let o=B.safeParse(r);if(!o.success)return!1;let c=o.data,d=typeof c.occurredAt==="string"?Date.parse(c.occurredAt):NaN,p=typeof c.expiresAt==="string"?Date.parse(c.expiresAt):NaN;return c.kind==="permission_denied"&&["bash","read","write","edit"].includes(c.operation)&&["sandbox_policy","os_permission_unknown"].includes(c.provenance)&&Number.isFinite(d)&&d<=e&&p>e&&p>d&&p-d<=600000}function Ot(r,e,o=Date.now()){if(!r||!e||r.state!=="connected"||r.deviceId!==e.deviceId)return null;let c=Date.parse(r.lastHeartbeatAt??""),d=r.permissionRecovery;if(!(o-c>=0&&o-c<30000)||!G(d,o)||d.deviceId!==e.deviceId||d.organizationId!==e.orgId)return null;try{process.kill(r.pid,0)}catch{return null}return d}function H(r={},e=a()){let o=g({env:{...process.env,...r}}),c=r.XDG_CONFIG_HOME?.trim()||m(e,".config");return ve(c,...o==="staging"?["staging"]:[])}function Er(r={},e=a()){return m(H(r,e),"local-device.json")}function xe(r={},e=a()){return m(H(r,e),"local-daemon.json")}function Ne(r,e){Ie(w(r),{recursive:!0,mode:448}),L(w(r),448);let o=`${r}.${process.pid}.${he()}.tmp`;try{we(o,`${JSON.stringify(e,null,2)}
4
- `,{mode:384,flag:"wx"}),L(o,384),De(o,r),L(r,384)}finally{if(z(o))Le(o)}return r}function E(r){if(!z(r))return null;try{return JSON.parse(ke(r,"utf8"))}catch{return null}}function Oe(r){if(!Array.isArray(r))return null;let e=[];for(let o of r){if(!o||typeof o!=="object")return null;let c=o;if(typeof c.id!=="string"||typeof c.label!=="string"||typeof c.path!=="string"||typeof c.pathFingerprint!=="string"||!c.permissions||typeof c.permissions.read!=="boolean"||typeof c.permissions.write!=="boolean"||typeof c.permissions.execute!=="boolean"||typeof c.permissions.discover_environment!=="boolean"||typeof c.permissions.expose_mcp!=="boolean")return null;e.push({id:c.id,label:c.label,path:c.path,pathFingerprint:c.pathFingerprint,permissions:c.permissions})}return e}function J(r,e,o=[]){let c=Object.keys(r);return e.every((d)=>Object.hasOwn(r,d))&&c.every((d)=>e.includes(d)||o.includes(d))}function Ke(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost")return null;return e.origin}catch{return null}}function Y(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r,o=Oe(e.roots),c=Ke(e.apiOrigin);if(!c||typeof e.orgId!=="string"||typeof e.deviceId!=="string"||typeof e.displayName!=="string"||typeof e.registeredAt!=="string"||!Re(e.handsSlots)||e.worker!==void 0&&(!e.worker||!/^[a-f0-9]{64}$/.test(e.worker.configDigest)||!["persistent","ephemeral"].includes(e.worker.lifetime)||!Number.isFinite(Date.parse(e.worker.expiresAt)))||!o)return null;return{apiOrigin:c,orgId:e.orgId,deviceId:e.deviceId,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:o}}function Ce(r){return{version:A,apiOrigin:r.apiOrigin,orgId:r.orgId,deviceId:r.deviceId,devicePublicKey:r.devicePublicKey,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:r.roots.map((e)=>({id:e.id,label:e.label,path:e.path,pathFingerprint:e.pathFingerprint,permissions:{read:e.permissions.read,write:e.permissions.write,execute:e.permissions.execute,discover_environment:e.permissions.discover_environment,expose_mcp:e.permissions.expose_mcp}})),credentialStorage:P}}function X(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r;if(!J(e,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Y(e);if(!o||e.version!==A||e.credentialStorage!==P||!_(e.devicePublicKey))return null;return{version:A,...o,devicePublicKey:e.devicePublicKey,credentialStorage:P}}function Te(r){return new TextEncoder().encode(`${Ee}${JSON.stringify(Ce(r))}`)}function Ue(r){let e=Buffer.from(r,"base64url");return me({format:"jwk",key:{kty:"EC",crv:"P-256",x:e.subarray(1,33).toString("base64url"),y:e.subarray(33,65).toString("base64url")}})}function Me(r){let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch{throw new l("invalid_binding")}if(!e||typeof e!=="object"||Array.isArray(e))throw new l("invalid_binding");let o=e;if(!J(o,["version","state","signature"])||o.version!==Pe||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new l("invalid_binding");let c=X(o.state);if(!c)throw new l("invalid_binding");let d=!1;try{d=Se("sha256",Te(c),Ue(c.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new l("invalid_binding");return c}function je(r){let{credentialStorage:e,...o}=r;return o}function xr(r=Er(),e={}){let o=E(r),c=e.proofStore??e.credentialStore??V(),d=c.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ve(o))return null;if(o!==null)throw new l("invalid_binding");return null}let p=Me(d),W=c.loadPublicKey();if(c.privateKeyIsNonExtractable(),W!==p.devicePublicKey)throw new l("invalid_public_key");let R=X(o);if(e.repair!==!1&&(!R||JSON.stringify(R)!==JSON.stringify(p)))Ne(r,p);return je(p)}function Ve(r){let e=r,o=Y(r);if(!o)return null;if(e.version===2){if(typeof e.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(e.deviceCredential)||e.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(e.version!==3||e.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in e)return null;return{state:o,credentialSource:"keychain-v3"}}function et(r=xe()){let e=E(r);if(!e||typeof e!=="object")return null;let o=e;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!G(o.permissionRecovery))delete o.permissionRecovery;return o}var It=1;function Be(r=Er()){return m(w(r),"local-device.proxy.json")}function j(r=Be()){let e=E(r);if(!e||typeof e!=="object"||Array.isArray(e))return null;let o=e;if(o.version!==It||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!Ae(o.caFile)))return null;return{version:It,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}
5
- export{l,Rt,Fe,Sr,Ot,Er,xr,et,It,j};
@@ -1,9 +0,0 @@
1
- // @bun
2
- import{ct}from"./vm-hands-entry-lite-t7n6t3j9.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Ln="so.ara.cli",k=[Ln,"com.reasonmachines.cli"],F="5LJFSBRY2F";function jr(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${F}"`}var G="ReasonBackgroundIdentity",so="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=jr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=jr(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Ur(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Ur(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))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 V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
3
- `)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!V.test(i)&&J.has(o)){let c=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
- `).find((l)=>l.startsWith("n/"));if(c)i=c.slice(1)}t.push(i)}return t}function _e(e){if(H(e.home),!d(e.sourceApp))throw new h("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??K,n=le(e.home),r=I(n);Y(r,{recursive:!0,mode:448}),ee(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${L()}`,c=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),y=!1;try{if(te(i,c,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(c))throw new h("identity_invalid","The copied Reason background identity is invalid.");let _=e.releaseSigned?["--test-requirement",`=${de}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",..._,c])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let S=!1;for(let p=0;p<4;p+=1){let m=!1;try{E(n,l),m=!0,y=!0}catch(s){if(s.code!=="ENOENT")throw s}if(p===0)e.beforePublish?.();try{E(c,n),S=!0}catch(s){let Z=s.code;if(!["EEXIST","ENOTEMPTY"].includes(Z??""))throw s;if(m)g(l,{recursive:!0,force:!0}),y=!1;if(p===3)throw s;continue}if(m)g(l,{recursive:!0,force:!0}),y=!1;break}if(!S)throw Error("Could not publish Reason's background identity.")}catch(_){if(y&&!x(n)&&x(l))E(l,n);throw _}finally{g(c,{recursive:!0,force:!0}),g(l,{recursive:!0,force:!0})}}return z(n,e,{verified:i!==o}),n}function X(e){return u(I(e),".Reason.app.registered")}function q(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function C(e){let t=q(e);try{return t!==null&&w(X(e),"utf8")===t}catch{return!1}}function Q(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",v)).isSymbolicLink()?"retired":null}catch{return null}}function z(e,t,n={}){let r=t.command??K;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(R,["-f",e])!==0)throw new h("identity_register_failed","Could not register Reason's macOS background identity.");let i=q(e);try{if(i)oe(X(e),i,{mode:384})}catch{}try{Se(e,t.home,r,t.runningExecutables??Ee)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
- `)}}function Se(e,t,n,r){let i=D(e);if(!i)return;let o=O(t),f=I(o),c=(s)=>u(s,"Contents","MacOS",v),l=se(I(c(o)),i),y=`${process.pid}.${L()}`,_=Q(o);if(_===null)return;let S=_==="bundle";if(S)n(R,["-u",o]);let p=u(f,`.Ara.app.${y}.old`);if(!W.has(o)&&!me(r())){if(!S)n(R,["-u",o]);try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}g(p,{recursive:!0,force:!0}),Ie(f);return}if(!S){if(re(c(o))===l)return;let s=`${c(o)}.${y}`;M(l,s);try{E(s,c(o))}finally{g(s,{force:!0})}return}let m=u(f,`.Ara.app.${y}.shim`);Y(I(c(m)),{recursive:!0}),M(l,c(m));try{try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}try{E(m,o)}catch(s){if(x(o))return;throw E(p,o),s}}finally{g(m,{recursive:!0,force:!0}),g(p,{recursive:!0,force:!0})}}function Ie(e){try{if(ne(e).some((n)=>n!==".DS_Store"))return;g(u(e,".DS_Store"),{force:!0}),ie(e)}catch{}}var B=new Map;function Mn(e=a()){let t=B.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=U(e);if(n===null&&x(I(le(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=U(e);if(n===null)return[];return B.set(e,n),n}function U(e){let t=le(e),n=O(e);if(!d(t)||!C(t))try{he({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(C(t)||!d(n))?t:d(n)?n:null,i=r?D(r):null;if(!i)return null;if(r===n)W.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
- `?[i,"--spawn"]:[]}var P=new Map;function at(e=a()){let t=Mn(e),n=t[0];if(!n)return[];let r=P.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
7
- `,P.set(n,r)}return r?t:[]}function ao(e=at(),t=a()){if(e.length>0)return null;if(Ur(t)===null)return"computer_use_identity_missing";return pe(ct,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function he(e={}){H(e.home);let t=le(e.home);if(e.skipWhenSettled&&d(t)&&C(t)&&Q(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return _e({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return z(t,e),!0}var Ut="REASON_WORKER_IDENTITY_APP";function co(e,t=process.env,n=a()){let r=t[Ut];return r&&r===le(n)?r:e}function lo(e,t){if(process.platform!=="darwin")return null;let n=le(e),r=u(n,"Contents","MacOS",G),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
8
- `?{app:n,executable:r}:null}
9
- export{Ln,jr,so,le,Ur,Mn,at,ao,Ut,co,lo};
@@ -1,3 +0,0 @@
1
- // @bun
2
- class r extends Error{code;constructor(a,o){super(o);this.code=a;this.name="LocalCapabilityError"}}
3
- export{r};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{nt,g,it}from"./vm-hands-entry-lite-ckv17tn8.js";import{chmodSync as Q,existsSync as C,mkdirSync as Z,readlinkSync as S,readFileSync as b,renameSync as nn,unlinkSync as tn,writeFileSync as en}from"fs";import{homedir as u}from"os";import{basename as _,dirname as h,isAbsolute as p,join as o,normalize as A,relative as O,resolve as N}from"path";var c=3,P=1,D=2,x=1,T=1,L="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",M="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",F=[M,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function B(n){return typeof n==="string"&&F.includes(n)}var U=["future_device","updates_only","cli_only"];function f(n){return typeof n==="string"&&U.some((t)=>t===n)}function V(n=process.env,t=u()){return n.XDG_CONFIG_HOME?.trim()||o(t,".config")}function Nr(n=process.env,t=u()){let r=g({env:n}),e=V(n,t);return o(e,it(e).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function a(n){return typeof n==="string"&&n.trim().length>0}var K=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function z(n){return typeof n==="string"&&K.test(n)}function l(n){return a(n)&&p(n)&&A(n)===n}function y(n){if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return l(t.path)&&(t.role==="launcher"&&(t.kind==="file"||t.kind==="symlink")||t.role==="worker_root"&&t.kind==="directory"||t.role==="alias"&&t.kind==="symlink"&&l(t.target))}function m(n){return n==="staging"?["reason-staging","ara-staging"]:["reason","ara"]}function Pn(n){let t=n.owned_paths.filter((e)=>e.role==="launcher").map((e)=>e.path),[r]=m(n.channel);return t.find((e)=>_(e)===r)??t[0]??null}function I(n){let[t,r]=m(n.channel==="staging"?"staging":"production"),e=[[t,r],[r,t]];return n.owned_paths?.every((i)=>i.role!=="alias"||n.installer==="shell"&&e.some(([s,R])=>i.path===o(n.install_dir,s)&&i.target===o(n.install_dir,R))&&n.owned_paths?.some((s)=>s.role==="launcher"&&s.path===i.target))??!1}function d(n,t){try{return N(h(n),S(n))===t}catch{return!1}}function Lr(n){let t=_(n),r=t==="ara"?"reason":t==="ara-staging"?"reason-staging":null;if(!r)return n;let e=o(h(n),r);return d(e,n)||d(n,e)?e:n}function w(n,t){let r=O(n,t);return r.length>0&&!r.startsWith("..")&&!p(r)}function E(n){if(n===null)return!0;if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return(t.kind==="shell_profile"||t.kind==="windows_user_path")&&a(t.location)&&a(t.value)&&(typeof t.added_by_installer==="boolean"||typeof t.added_by_ara==="boolean")&&(t.added_by_installer===void 0||typeof t.added_by_installer==="boolean")&&(t.added_by_ara===void 0||typeof t.added_by_ara==="boolean")}function k(n,t){if(t===null)return n==="cli_only";if(!t||typeof t!=="object"||Array.isArray(t))return!1;let r=t;if(r.version!==x||!a(r.recorded_at))return!1;if(n==="future_device")return r.decision==="authorized"&&B(r.scope);return r.scope===null&&r.decision===(n==="updates_only"?"ask":"disabled")}function G(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==P||!nt.includes(t.channel)||t.install_method!=="curl"||t.installer!=="shell"&&t.installer!=="powershell"||!a(t.installed_at)||!a(t.version)||!a(t.target)||!l(t.install_dir)||!Array.isArray(t.owned_paths)||!t.owned_paths.every(y)||!t.owned_paths.every((r)=>w(t.install_dir,r.path))||!I(t)||!E(t.path_entry))return null;return{...t,schema_version:c,installation_id:null,background_mode:"cli_only",device_consent:null}}function j(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==D||!v(t)||!f(t.background_mode)||!k(t.background_mode,t.device_consent))return null;return{...t,schema_version:c,installation_id:null}}function v(n){return nt.includes(n.channel)&&(n.install_method==="curl"&&(n.installer==="shell"||n.installer==="powershell")||n.install_method==="desktop"&&n.installer==="desktop"&&Array.isArray(n.owned_paths)&&n.owned_paths.length===0&&n.path_entry===null)&&a(n.installed_at)&&a(n.version)&&a(n.target)&&l(n.install_dir)&&Array.isArray(n.owned_paths)&&n.owned_paths.every(y)&&n.owned_paths.every((t)=>w(n.install_dir,t.path))&&I(n)&&E(n.path_entry)}function H(n){let t=G(n);if(t)return t;let r=j(n);if(r)return r;if(!n||typeof n!=="object"||Array.isArray(n))return null;let e=n;if(e.schema_version!==c||!z(e.installation_id)||!v(e)||!f(e.background_mode)||!k(e.background_mode,e.device_consent)||e.desktop_account_access!==void 0&&(e.desktop_account_access===null||typeof e.desktop_account_access!=="object"||Array.isArray(e.desktop_account_access)||e.desktop_account_access.version!==T||e.desktop_account_access.scope!==L||!a(e.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(e.desktop_account_access.recorded_at))))return null;return e}function Tn(n=Nr()){if(!C(n))return null;try{return H(JSON.parse(b(n,"utf8")))}catch{return null}}export{Nr,Pn,Lr,Tn};