@reason-machines/cli-linux-x64 0.2.559 → 0.2.561

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/agent-network-kk36zca7.js +2 -0
  3. package/bin/vm-hands/api-credentials-mtfdk175.js +2 -0
  4. package/bin/vm-hands/api-w6w7vfp3.js +2 -0
  5. package/bin/vm-hands/ask-relay-xx0rzpch.js +5 -0
  6. package/bin/vm-hands/connect-cli-dmwph620.js +2 -0
  7. package/bin/vm-hands/credentials-s7ps7y6s.js +2 -0
  8. package/bin/vm-hands/custom-endpoint-device-3xnrp33e.js +2 -0
  9. package/bin/vm-hands/desktop-account-eg8thn79.js +2 -0
  10. package/bin/vm-hands/device-workspace-h5rsecq8.js +2 -0
  11. package/bin/vm-hands/{fsevents-fev1pxw2.js → fsevents-vxv56sp5.js} +1 -1
  12. package/bin/vm-hands/hands-worker-source-vk664w8p.js +2 -0
  13. package/bin/vm-hands/{index-j6wffzfd.js → index-03p9c17x.js} +106 -106
  14. package/bin/vm-hands/install-receipt-j04hdw1k.js +2 -0
  15. package/bin/vm-hands/local-automation-vvt9d9xb.js +2 -0
  16. package/bin/vm-hands/local-capabilities-pwv76ns5.js +2 -0
  17. package/bin/vm-hands/local-desktop-users-sq4trh07.js +2 -0
  18. package/bin/vm-hands/local-display-mac-yxcxvg2z.js +2 -0
  19. package/bin/vm-hands/local-display-session-axh9mfdk.js +2 -0
  20. package/bin/vm-hands/local-display-video-pxhztqk7.js +2 -0
  21. package/bin/vm-hands/local-managed-process-4mgqn7tg.js +2 -0
  22. package/bin/vm-hands/local-pty-session-edd8ttf9.js +2 -0
  23. package/bin/vm-hands/managed-runtime-pcagtyfz.js +2 -0
  24. package/bin/vm-hands/network-auto-update-wkzb91qz.js +3 -0
  25. package/bin/vm-hands/network-contract-8mxtma3w.js +2 -0
  26. package/bin/vm-hands/network-sign-in-61gmpmaa.js +3 -0
  27. package/bin/vm-hands/package-vwvzjtn0.js +2 -0
  28. package/bin/vm-hands/permissions-348prrcx.js +2 -0
  29. package/bin/vm-hands/reason-hands-protocol-1nkpw1v3.js +2 -0
  30. package/bin/vm-hands/serve-service-3dkyznay.js +2 -0
  31. package/bin/vm-hands/status-khqk4cjw.js +96 -0
  32. package/bin/vm-hands/version-c1hen0wn.js +2 -0
  33. package/bin/vm-hands/vm-hands-entry-lite-0wb1n769.js +9 -0
  34. package/bin/vm-hands/{vm-hands-entry-lite-506b6pcz.js → vm-hands-entry-lite-2dak7e1h.js} +5 -5
  35. package/bin/vm-hands/{vm-hands-entry-lite-a3p6xz53.js → vm-hands-entry-lite-2rgf8866.js} +2 -2
  36. package/bin/vm-hands/vm-hands-entry-lite-52qz0n30.js +7 -0
  37. package/bin/vm-hands/vm-hands-entry-lite-57ajjwmh.js +2 -0
  38. package/bin/vm-hands/vm-hands-entry-lite-5y4phfv1.js +4 -0
  39. package/bin/vm-hands/vm-hands-entry-lite-6jxshhps.js +9 -0
  40. package/bin/vm-hands/vm-hands-entry-lite-71ebge0c.js +42 -0
  41. package/bin/vm-hands/vm-hands-entry-lite-7pfhwxn5.js +2 -0
  42. package/bin/vm-hands/vm-hands-entry-lite-84mc1f7h.js +3 -0
  43. package/bin/vm-hands/vm-hands-entry-lite-8xv6c0rm.js +3 -0
  44. package/bin/vm-hands/vm-hands-entry-lite-9g52kxyj.js +3 -0
  45. package/bin/vm-hands/{vm-hands-entry-lite-8rmbdm6c.js → vm-hands-entry-lite-9yfmkd1f.js} +2 -2
  46. package/bin/vm-hands/vm-hands-entry-lite-a6ss0ges.js +3 -0
  47. package/bin/vm-hands/vm-hands-entry-lite-a7bf7xr7.js +5 -0
  48. package/bin/vm-hands/vm-hands-entry-lite-ab1pq3xg.js +3 -0
  49. package/bin/vm-hands/vm-hands-entry-lite-bj3w2ven.js +3 -0
  50. package/bin/vm-hands/{vm-hands-entry-lite-q1yvw4xz.js → vm-hands-entry-lite-e3fn8ys2.js} +2 -2
  51. package/bin/vm-hands/vm-hands-entry-lite-gxpw14jv.js +11 -0
  52. package/bin/vm-hands/vm-hands-entry-lite-h7nk2848.js +539 -0
  53. package/bin/vm-hands/vm-hands-entry-lite-hjjbjpd7.js +4 -0
  54. package/bin/vm-hands/vm-hands-entry-lite-hn9pq7zj.js +127 -0
  55. package/bin/vm-hands/vm-hands-entry-lite-hs6sdn60.js +3 -0
  56. package/bin/vm-hands/vm-hands-entry-lite-ht6hzkgj.js +3 -0
  57. package/bin/vm-hands/vm-hands-entry-lite-hxfxs7r9.js +3 -0
  58. package/bin/vm-hands/{vm-hands-entry-lite-2v4zh9ze.js → vm-hands-entry-lite-j10cw3d9.js} +9 -9
  59. package/bin/vm-hands/vm-hands-entry-lite-jgk5z8zc.js +10 -0
  60. package/bin/vm-hands/vm-hands-entry-lite-jpvmkce5.js +2 -0
  61. package/bin/vm-hands/vm-hands-entry-lite-k5ytpgzz.js +65 -0
  62. package/bin/vm-hands/{vm-hands-entry-lite-s85p7tqp.js → vm-hands-entry-lite-krpqqx12.js} +2 -2
  63. package/bin/vm-hands/vm-hands-entry-lite-m1we91g4.js +105 -0
  64. package/bin/vm-hands/{vm-hands-entry-lite-q2h781jg.js → vm-hands-entry-lite-ms99mzp0.js} +3 -3
  65. package/bin/vm-hands/vm-hands-entry-lite-nn6zcvmp.js +3 -0
  66. package/bin/vm-hands/{vm-hands-entry-lite-46pwqvpf.js → vm-hands-entry-lite-ptycjmkc.js} +2 -2
  67. package/bin/vm-hands/vm-hands-entry-lite-pxtycfdv.js +5 -0
  68. package/bin/vm-hands/vm-hands-entry-lite-q9djb28r.js +4 -0
  69. package/bin/vm-hands/vm-hands-entry-lite-q9s1e2y1.js +3 -0
  70. package/bin/vm-hands/{vm-hands-entry-lite-pzj5s203.js → vm-hands-entry-lite-qf990rxw.js} +2 -2
  71. package/bin/vm-hands/vm-hands-entry-lite-sy7dcccg.js +2 -0
  72. package/bin/vm-hands/vm-hands-entry-lite-tcmye5ny.js +3 -0
  73. package/bin/vm-hands/{vm-hands-entry-lite-1yv5qqew.js → vm-hands-entry-lite-v4hr9x9h.js} +45 -45
  74. package/bin/vm-hands/vm-hands-entry-lite-vdv4nm5f.js +3 -0
  75. package/bin/vm-hands/vm-hands-entry-lite-vkhacd00.js +452 -0
  76. package/bin/vm-hands/vm-hands-entry-lite-wcgm41jq.js +52 -0
  77. package/bin/vm-hands/vm-hands-entry-lite-weqam12f.js +6 -0
  78. package/bin/vm-hands/{vm-hands-entry-lite-jrce7v4r.js → vm-hands-entry-lite-xvccy3z4.js} +2 -2
  79. package/bin/vm-hands/vm-hands-entry-lite-y3nz20wb.js +345 -0
  80. package/bin/vm-hands/vm-hands-entry-lite-yvws5zpx.js +4 -0
  81. package/bin/vm-hands/{vm-hands-entry-lite-qd46yhvz.js → vm-hands-entry-lite-z0ht62s4.js} +3 -3
  82. package/bin/vm-hands/vm-hands-entry-lite-z213y4pj.js +150 -0
  83. package/bin/vm-hands/vm-hands-entry-lite-zawytz09.js +3 -0
  84. package/bin/vm-hands/{vm-hands-entry-lite-h2rq71rj.js → vm-hands-entry-lite-zh6ncdjn.js} +2 -2
  85. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  86. package/bin/vm-hands/{vm-hands-executor-p2jvbq5w.js → vm-hands-executor-csdtg7kj.js} +8 -8
  87. package/bin/vm-hands/vm-hands-op-runner-z7tsd84c.js +2 -0
  88. package/bin/vm-hands/{vm-hands-runtime-889hfy4p.js → vm-hands-runtime-1qxf96z7.js} +3 -3
  89. package/bin/vm-hands/worker-preview-readiness-06tygyjs.js +2 -0
  90. package/bin/vm-hands/worker-sandbox-e1cpkzfz.js +2 -0
  91. package/package.json +1 -1
  92. package/bin/vm-hands/api-credentials-x30e4ezb.js +0 -2
  93. package/bin/vm-hands/api-y6v8wdsq.js +0 -2
  94. package/bin/vm-hands/connect-cli-32wrv6sw.js +0 -2
  95. package/bin/vm-hands/credentials-sbza33ac.js +0 -2
  96. package/bin/vm-hands/custom-endpoint-device-mydksbg8.js +0 -2
  97. package/bin/vm-hands/desktop-account-t0afsge2.js +0 -2
  98. package/bin/vm-hands/device-workspace-b534qy2c.js +0 -2
  99. package/bin/vm-hands/hands-worker-source-qj7s9dk5.js +0 -2
  100. package/bin/vm-hands/install-receipt-zv1bjbgh.js +0 -2
  101. package/bin/vm-hands/local-automation-pwwqrnt7.js +0 -2
  102. package/bin/vm-hands/local-capabilities-scnpxe96.js +0 -2
  103. package/bin/vm-hands/local-desktop-users-5scb9930.js +0 -2
  104. package/bin/vm-hands/local-display-mac-pft73te9.js +0 -2
  105. package/bin/vm-hands/local-display-session-9362hqsn.js +0 -2
  106. package/bin/vm-hands/local-display-video-dndhr5v1.js +0 -2
  107. package/bin/vm-hands/local-managed-process-zm639p1g.js +0 -2
  108. package/bin/vm-hands/local-pty-session-njd0tprg.js +0 -2
  109. package/bin/vm-hands/managed-runtime-cqkw2mtn.js +0 -2
  110. package/bin/vm-hands/network-contract-kx0hz3wt.js +0 -2
  111. package/bin/vm-hands/package-way7qesn.js +0 -2
  112. package/bin/vm-hands/permissions-jxycbgay.js +0 -2
  113. package/bin/vm-hands/reason-hands-protocol-g54rtrhd.js +0 -2
  114. package/bin/vm-hands/serve-service-byvya1ym.js +0 -2
  115. package/bin/vm-hands/status-f1k1qmck.js +0 -10
  116. package/bin/vm-hands/version-czwf27v3.js +0 -2
  117. package/bin/vm-hands/vm-hands-entry-lite-04x5xjt6.js +0 -5
  118. package/bin/vm-hands/vm-hands-entry-lite-07apxfh8.js +0 -42
  119. package/bin/vm-hands/vm-hands-entry-lite-0wsr8edk.js +0 -3
  120. package/bin/vm-hands/vm-hands-entry-lite-1tgxze8w.js +0 -3
  121. package/bin/vm-hands/vm-hands-entry-lite-2twtpxmp.js +0 -9
  122. package/bin/vm-hands/vm-hands-entry-lite-3gbf905c.js +0 -3
  123. package/bin/vm-hands/vm-hands-entry-lite-48rphbjm.js +0 -3
  124. package/bin/vm-hands/vm-hands-entry-lite-4anjdcth.js +0 -3
  125. package/bin/vm-hands/vm-hands-entry-lite-73f4cgkf.js +0 -3
  126. package/bin/vm-hands/vm-hands-entry-lite-8dfw96ym.js +0 -3
  127. package/bin/vm-hands/vm-hands-entry-lite-ak0hd94p.js +0 -7
  128. package/bin/vm-hands/vm-hands-entry-lite-bpamn7ny.js +0 -9
  129. package/bin/vm-hands/vm-hands-entry-lite-dgfx0rbn.js +0 -5
  130. package/bin/vm-hands/vm-hands-entry-lite-ecz6fzds.js +0 -126
  131. package/bin/vm-hands/vm-hands-entry-lite-frd7e74y.js +0 -5
  132. package/bin/vm-hands/vm-hands-entry-lite-fxzadxz4.js +0 -2
  133. package/bin/vm-hands/vm-hands-entry-lite-gje7xvy9.js +0 -6
  134. package/bin/vm-hands/vm-hands-entry-lite-h1qjggz0.js +0 -4
  135. package/bin/vm-hands/vm-hands-entry-lite-j3fw7x65.js +0 -14
  136. package/bin/vm-hands/vm-hands-entry-lite-jydpev8e.js +0 -452
  137. package/bin/vm-hands/vm-hands-entry-lite-k84zsash.js +0 -2
  138. package/bin/vm-hands/vm-hands-entry-lite-kf2jgke1.js +0 -150
  139. package/bin/vm-hands/vm-hands-entry-lite-m0gsez4t.js +0 -539
  140. package/bin/vm-hands/vm-hands-entry-lite-n7bd44rm.js +0 -2
  141. package/bin/vm-hands/vm-hands-entry-lite-p5ny1pw4.js +0 -4
  142. package/bin/vm-hands/vm-hands-entry-lite-qcktp8d9.js +0 -52
  143. package/bin/vm-hands/vm-hands-entry-lite-ravxhygk.js +0 -3
  144. package/bin/vm-hands/vm-hands-entry-lite-s0rx4fm8.js +0 -105
  145. package/bin/vm-hands/vm-hands-entry-lite-tyem93c1.js +0 -3
  146. package/bin/vm-hands/vm-hands-entry-lite-vj7xzb3y.js +0 -2
  147. package/bin/vm-hands/vm-hands-entry-lite-wghmyfba.js +0 -4
  148. package/bin/vm-hands/vm-hands-entry-lite-wzv13c8k.js +0 -65
  149. package/bin/vm-hands/vm-hands-entry-lite-yptpy066.js +0 -3
  150. package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +0 -3
  151. package/bin/vm-hands/vm-hands-entry-lite-zf0h0qjy.js +0 -2
  152. package/bin/vm-hands/vm-hands-op-runner-2bfbyj4e.js +0 -2
  153. package/bin/vm-hands/worker-preview-readiness-gy36ejp9.js +0 -2
  154. package/bin/vm-hands/worker-sandbox-f1tfb3y0.js +0 -2
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{te}from"./vm-hands-entry-lite-9g52kxyj.js";import{U,H,R}from"./vm-hands-entry-lite-v4hr9x9h.js";import{ge,Lt,ti,ko,xo,ur}from"./vm-hands-entry-lite-vkhacd00.js";import{mt}from"./vm-hands-entry-lite-pxtycfdv.js";import{v,dr,Co,pt,ht}from"./vm-hands-entry-lite-0wb1n769.js";import{b,m}from"./vm-hands-entry-lite-yvws5zpx.js";import{s,St,Mc}from"./vm-hands-entry-lite-zawytz09.js";import{Vi,I,t,V,o,_,tl,Pt,ca,d,n,we,A,$e,c,i,Gi}from"./vm-hands-entry-lite-k5ytpgzz.js";import{Xe,G}from"./vm-hands-entry-lite-8xv6c0rm.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{randomUUID as X}from"crypto";import{spawn as ke}from"child_process";import{existsSync as Y,lstatSync as de,mkdirSync as Oe,readFileSync as Me,realpathSync as q,rmSync as Te,writeFileSync as je}from"fs";import{dirname as Le,join as k,relative as We,sep as Ne}from"path";var he=["process.run.v1","process.full.v1"],be=600000,ve=1800000,ye=20000,re="process.cancel.v1",oe=n({action:i("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:c(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(ve).default(be).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),B={device_id:t().uuid(),root_id:t().uuid()},Se=A("action",[oe.extend(B),n({...B,action:i("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(ye).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),n({...B,action:i("cancel"),process_id:t().uuid()}).strict()]),qe=Vi(Se,{io:"input"}),Je=oe.extend({process_brain_fence:t().uuid(),process_expires_at:I.datetime()}).strict(),W=n({version:i(1),process_id:t().uuid(),state:c(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:_(),observed_at:I.datetime(),output:d(n({cursor:o().int().min(1),stream:c(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let p=e.first_cursor-1;for(let l of e.output){if(l.cursor<=p||l.cursor>e.next_cursor)return!1;p=l.cursor}return!0});function Jn(e){return he.includes(e)}var ze=n({operation_constraints:$e(t(),Pt())}),Ge=n({ready:i(!0),version:i(1),execution_mode:c(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var xe=n({version:i(1),process_id:t().uuid(),state:c(["queued","cancelled_before_start","not_started"]),exit_code:tl(),output:d(ca()).length(0),first_cursor:i(0),next_cursor:i(0),truncated:i(!1),cancellation_requested:i(!1),reason_code:c(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:I.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),Pe=n({...W.shape,state:c(["queued","starting","running","exited","cancelled","expired","uncertain","cancelled_before_start","not_started"]),observed_at:I.datetime().optional(),expires_at:I.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it."),cancellation_requested:_(),reason_code:t().nullable().optional(),execution_authority:i("lost").optional().describe("Historical receipt only; the current Brain cannot control this older-generation process."),recovery:n({cause:i("brain_generation_changed"),terminal_confirmed:_(),next_step:c(["inspect_until_terminal","reconcile_effects_before_new_intent"])}).strict().optional().describe("Historical process recovery only. An unconfirmed outcome forbids replay. A confirmed terminal observation proves the old process stopped, not that its command had no effects. Reconcile the result; only restart still-needed, safely repeatable work with a new request_id and current authority. Respect user cancellation."),last_observed_state:W.shape.state.or(i("cancelled_before_start")).nullable().optional().describe("Last saved observation before authority was lost; a running observation does not establish current child liveness.")}).strict(),Be=Vi(Pe),Fe=we([W,xe.refine((e)=>e.state==="cancelled_before_start")]),F=n({version:i(1),process_id:t().uuid(),state:c(["exited","cancelled","expired"]),exit_code:o().int().min(0).max(255),observed_at:I.datetime()}).strict().refine((e)=>(e.state!=="cancelled"||e.exit_code===130)&&(e.state!=="expired"||e.exit_code===124)),Ee=n({process_terminal_observation:F}).strict();function Ra(e,a){let p=Ee.safeParse(e);return p.success&&p.data.process_terminal_observation.process_id===a?p.data:null}var Ta="preview.serve.v1",Ia=43200000;var Da=3,ne="preview.open.v1",se=1,fo="gid_proxy_v1",Oa="egress",mo=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Re=n({version:i(fo),allowed_domains:d(t().max(260).regex(mo)).max(1024)}).strict(),Ie=Gi((e)=>te(e)!==null,"invalid workspace"),De=n({version:i(1),request_id:V(),session_id:V(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),port:o().int().min(1024).max(65535),workspace:Ie,egress:Re.optional()}).strict(),Na=De.extend({expires_at:I.datetime()}).strict();var Ce=4,Ae=5000;function K(e,a,p){let l=null;try{l=dr(e)}catch{}Co({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:a,port:l?.binding.port??0,reason:l?p:"binding_invalid"})}function ie(e){let a=new Map;return{open(p){let l=(w)=>K(p,e.claim.operation_id,w),P;try{P=dr(p)}catch{return l("binding_invalid")}let{binding:h,deviceRelayUrl:N}=P,S=e.claim.owner;if(!S||h.organizationId!==S.organization_id||h.userId!==S.user_id||h.deviceId!==S.device_id||h.rootId!==e.claim.root_id||h.jobId!==e.claim.operation_id||h.fenceId!==e.claim.operation_id||h.generation!==se||h.expiresAtMs>Math.min(Date.now()+v.lifetimeMs+Ae,e.expiresAtMs))return l("binding_mismatch");if(h.expiresAtMs<=Date.now())return l("binding_expired");if(a.get(h.port)?.abort(),a.delete(h.port),a.size>=Ce)return l("preview_capacity");let O=new AbortController;a.set(h.port,O);let y=ht({binding:h,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(O.signal.aborted)return null;let w=await e.inspect();return w?{binding:h,executorLaunchId:e.executorLaunchId,job:w}:null}});pt({binding:h,deviceRelayUrl:N,port:y,signal:O.signal}).then((w)=>w.closed,(w)=>{let x=w instanceof Error?w.message:"preview_failed";if(x!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:h.jobId,port:h.port,reason_code:x})}
3
+ `)}).finally(()=>{if(a.get(h.port)===O)a.delete(h.port)})},dispose(){for(let p of a.values())p.abort();a.clear()}}}class lr extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var le=256,J=new Map,pe="preview.serve.v1",T=new Map;function ue(e){let a=T.get(e.operation_id);if(a){if(a.claim!==e)throw D("process_authority_lost");return a}if(T.size>=le)throw D("process_journal_capacity");let p={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return T.set(e.operation_id,p),p}function ae(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ce=(e)=>new Promise((a)=>setTimeout(a,e)),D=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function Ve(e=s(),a=He()){let p=Le(mt({},e)),l=We(St(e),p),[P,...h]=l.split(Ne);return{directory:k(a,l,"processes"),previous:[k(p,"processes"),...P==="reason"?[k(a,"ara",...h,"processes")]:[]]}}function He(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Mc();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function Xn(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw D("process_authority_lost");let a=ue(e.claim);if(a.executing)throw D("process_busy");if(a.executing=!0,a.cancelRequested)return a.phase="settling",ae(e.claim.operation_id);a.phase="starting";let p=e.journals??Ve();Oe(p.directory,{recursive:!0,mode:448});let l=Lt({runtimeDirectory:q(p.directory),previousRuntimeDirectories:(p.previous??[]).filter((u)=>Y(u)).map((u)=>q(u)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:le,folders:[e.root,e.cwd]});try{for(let u of[e.root,e.cwd])if(!ge(q(u),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(u){throw l.disposeSocket(),u}let P=de(l.journalDirectory),h=e.claim.capability===pe,N=()=>J.set(e.claim.operation_id,{path:l.journalDirectory,ino:P.ino,dev:P.dev,anyCompletion:h}),S=l.launchDirectory,O=k(S,"config.json"),y={url:"",transport:"local_job_ipc",directShell:{mode:e.mode,executable:e.shell,jobId:e.claim.operation_id},workerVersion:U,protocolVersion:2,workerArtifactSha256:R,workerEntrypoint:H,targetGeneration:1,fenceId:X(),...process.platform==="win32"?{bashExecutable:Xe()}:{},workRoot:e.root,workspaceAliasPath:e.root,repoPath:e.cwd,jobEnvPath:k(S,"unused.env"),replSocketPath:k(S,"unused.sock"),readyPath:k(S,"ready.json"),directTerminalReceiptPath:k(S,"terminal.json"),launchId:X(),expiresAtMs:e.expiresAtMs+5000,bashTimeoutMs:60000,replTimeoutMs:1000,allowedTools:["bash"],managedJobs:{journalDirectory:l.journalDirectory,scopeId:l.scopeId},jobControlSocketPath:l.socketPath,...e.prefix?{bashCommandPrefix:e.prefix}:{},...e.jobsUser?{jobsUser:e.jobsUser}:{}},w;try{je(O,JSON.stringify(y),{mode:384});let u=ko({configPath:O,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:S});w=e.spawnWorker?.(O,y)??ke(u.command,u.args,{...u.options,env:e.environment,stdio:[xo,"ignore","ignore"]})}catch(u){throw l.disposeSocket(),u}let x=!1,z=new Promise((u,g)=>{w.once("exit",(f)=>{x=!0,u(f)}),w.once("error",(f)=>{x=!0,g(f)})});z.catch(()=>{});let me={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:y.fenceId,executorLaunchId:y.launchId,expiresAtMs:y.expiresAtMs},M=async(u)=>{let g=await ti(me,{type:"job",version:2,generation:1,id:X(),jobId:e.claim.operation_id,...u==="start"?{action:u,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:u==="inspect"?{action:u,input:{after:0}}:u==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:u,input:{}}},new AbortController().signal);if(!g.ok)throw D(g.error);return g.job},j=!1,L=!1,Q,Z=()=>{j=!0,ur(w,"SIGTERM")};e.signal.addEventListener("abort",Z,{once:!0});let C,ee=0,_e=async(u)=>{let g=[...u.output],f={version:1,process_id:e.claim.operation_id,state:u.state,exit_code:u.exitCode,first_cursor:u.firstCursor,next_cursor:u.nextCursor,truncated:u.truncated,output:g,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&g.length)g.shift(),f.truncated=!0,f.first_cursor=g[0]?.cursor??f.next_cursor+1;C=W.parse(f),await e.emit(C),ee=Date.now()};try{let u=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Y(y.readyPath)){if(x)throw new r("process_start_failed","The managed process supervisor exited before accepting a command; no command was dispatched.");if(e.signal.aborted||Date.now()>=u)throw D("process_start_unconfirmed");await ce(25)}let g=JSON.parse(Me(y.readyPath,"utf8"));if(g.launchId!==y.launchId||g.fenceId!==y.fenceId||g.workerArtifactSha256!==R)throw D();if(e.signal.throwIfAborted(),a.cancelRequested)return ae(e.claim.operation_id);let f;try{L=!0,f=await M("start")}catch(E){if(!(E instanceof r)||E.code!=="hands_job_result_unknown")throw E;f=await M("inspect")}if(a.phase="running",a.cancel=async()=>{await M("cancel")},h&&e.preview)a.tunnels=ie({claim:e.claim,executorLaunchId:y.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>a.phase==="running"&&!x?await M("probe"):null});if(a.cancelRequested)await a.cancel(),f=await M("inspect");for(;;){if(!["starting","running"].includes(f.state))a.phase="settling",a.cancel=void 0;if(!C||C.state!==f.state||C.next_cursor!==f.nextCursor&&Date.now()-ee>=5000)await _e(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||x)throw D();await ce(1000);try{f=await M("inspect"),Q=void 0}catch(E){if(!(E instanceof r)||E.code!=="hands_job_result_unknown"||e.signal.aborted||x||Date.now()-(Q??=Date.now())>120000)throw E}}if(!C||C.state==="uncertain")throw D();return C}finally{if(a.phase="settling",a.cancel=void 0,a.tunnels?.dispose(),a.tunnels=void 0,await a.cancelInFlight?.catch(()=>{}),e.signal.removeEventListener("abort",Z),!x&&!j)ur(w,"SIGTERM");let u,g=await Promise.race([z.then((f)=>({code:f})),new Promise((f)=>{u=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(u)});if(!g){try{ur(w,"SIGKILL")}catch{}try{await z}finally{if(x)l.disposeSocket()}throw D("process_cleanup_unconfirmed")}try{if((j||e.signal.aborted)&&g.code===0&&L){b(S);let f=JSON.parse(m(y.directTerminalReceiptPath)),E=F.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===y.launchId&&f.fence_id===y.fenceId&&f.scope_id===l.scopeId&&E.success&&E.data.process_id===e.claim.operation_id){if(h)N();throw new lr(E.data)}}}catch(f){if(f instanceof lr)throw f}finally{if(x)l.disposeSocket()}if(g.code!==0&&!j&&L)throw D("process_cleanup_unconfirmed");if(!j&&g.code===0&&(C&&["exited","cancelled","expired"].includes(C.state)||!L&&a.cancelRequested)||h&&g.code===0&&!L)N()}}async function go(e,a){if(a.kind===ne&&e.capability===pe){let P=T.get(e.operation_id);if(P?.claim===e&&P.tunnels)P.tunnels.open(a.payload);else K(a.payload,e.operation_id,"server_not_running");return!0}if(a.kind!==re||!Jn(e.capability)||!e.owner||a.payload.process_id!==e.operation_id)return!1;let p=T.get(e.operation_id);if(p&&p.claim!==e)return!1;let l=ue(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Yn(e,a){T.delete(e);let p=J.get(e);if(!p||a!=="succeeded"&&!p.anyCompletion)return J.delete(e),!1;try{let l=de(p.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==p.ino||l.dev!==p.dev||!G(l)||q(p.path)!==p.path||Y(k(p.path,"owner.lock")))return!1;return Te(p.path,{recursive:!0}),J.delete(e),!0}catch{return!1}}
4
+ export{Jn,Ra,Ta,Ia,Da,fo,Oa,mo,Na,lr,Xn,go,Yn};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import{g}from"./vm-hands-entry-lite-bj3w2ven.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var ss="so.ara.cli",w=[ss,"com.reasonmachines.cli"],$i="5LJFSBRY2F";function Mi(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${$i}"`}var Y="ReasonBackgroundIdentity",Ic="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=Mi([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=Mi(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${$i}"`;class vt extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var Tn="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function ot(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=ot(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function as(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
3
+ `)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!W.test(i)&&H.has(o)){let a=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
+ `).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function cs(e){if(K(e.home),!d(e.sourceApp))throw new vt("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=ot(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new vt("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(Tn,["-f",e])!==0)throw new vt("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
+ `)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(Tn,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(Tn,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function ls(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(ot(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=ot(e),n=O(e);if(!d(t)||!N(t))try{Bi({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
+ `?[i,"--spawn"]:[]}var U=new Map;function kr(e=s()){let t=ls(e),n=t[0];if(!n)return[];let r=U.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
+ `,U.set(n,r)}return r?t:[]}function In(e=kr(),t=s()){if(e.length>0)return null;if(Yt(t)===null)return"computer_use_identity_missing";return as(g,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Bi(e={}){K(e.home);let t=ot(e.home);if(e.skipWhenSettled&&d(t)&&N(t)&&X(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return cs({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return q(t,e),!0}var Dn="REASON_WORKER_IDENTITY_APP";function Dc(e,t=process.env,n=s()){let r=t[Dn];return r&&r===ot(n)?r:e}function Oc(e,t){if(process.platform!=="darwin")return null;let n=ot(e),r=u(n,"Contents","MacOS",Y),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{ss,$i,Mi,Ic,vt,Tn,ot,Yt,as,cs,ls,kr,In,Bi,Dn,Dc,Oc};
@@ -0,0 +1,42 @@
1
+ // @bun
2
+ import{rr,Nr}from"./vm-hands-entry-lite-57ajjwmh.js";import{t,$r,V,o,_,d,h,A,$e,c,i}from"./vm-hands-entry-lite-k5ytpgzz.js";var I=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((n)=>n!=="."&&n!=="..")),b=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")),L=t().regex(/^[a-f0-9]{40}$/),O=o().int().positive(),T=t().min(1).max(256),k=t().max(60000),y={version:i(1),repoFullName:I},C=d(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),j=h({expectedTrailers:C,missingFromHead:C}),G=A("action",[h({action:i("edit"),title:T.optional(),body:k.optional(),base:b.optional()}),h({action:c(["ready","draft","close"])}),h({action:i("metadata"),field:c(["reviewer","assignee","label"]),change:c(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),xt=A("kind",[h({...y,kind:i("read"),path:t().min(1).max(2048),accept:c(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),h({...y,kind:i("pr_review_context"),number:O,after:t().min(1).max(1024).optional()}),h({...y,kind:i("prepare"),branch:b,baseSha:L,defaultBranch:b,diagnosticsVersion:i(1).optional()}),h({...y,kind:i("publish"),branch:b,defaultBranch:b,baseSha:L,remoteHeadSha:L.nullable(),contributorTrailers:C.optional()}),h({...y,kind:i("pr_create"),head:b,base:b,title:T,body:k,draft:_()}),h({...y,kind:i("pr_mutation"),number:O,mutation:G}),h({...y,kind:i("pr_merge"),number:O,expectedHeadSha:L,expectedBaseRef:b,method:c(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),z=["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 B(e){return z.some((n)=>n===e)}class Ln extends Error{code;constructor(e){super(e);this.code=e}}function ds(e,n,r){let p=xt.safeParse(e);return n==="failed"&&p.success&&p.data.kind==="prepare"&&p.data.diagnosticsVersion===1&&B(r)}var Ar=245760,Fc=A("kind",[h({kind:i("pr_review_context"),body:t().max(Ar)}),h({kind:i("prepare"),headSha:L}),h({kind:i("read"),status:o().int().min(200).max(599),headers:$e(t(),t().max(8192)).refine((e)=>Object.keys(e).every((n)=>n==="link"||n==="content-type")),body:t().max(Ar)}),h({kind:i("publish"),headSha:L,scannedObjectCount:o().int().min(0).max(5000),attribution:j.optional()}),h({kind:i("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),h({kind:i("pr_mutation"),number:O,applied:i(!0)}),h({kind:i("pr_merge"),number:O,merged:i(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=Ar,"local_device_gh_result_too_large"),F=h({source:c(["agent","human"]),operationId:V()}),Ke=h({version:i(1),userId:$r(),deviceId:$r(),rootId:$r(),runId:$r(),merge:F.optional(),contributorRefresh:$r().optional(),repoFullName:I.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:_(),generation:o().int().positive().nullable(),fenceId:$r().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function w(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((n)=>n!=="."&&n!=="..")}function jc(e,n,r={},p="read"){if(w(e)&&(n==="/search/issues"||n.startsWith("/search/issues?")))return Y(e,n,r);if(!w(e)||!n.startsWith(`/repos/${e}/`)&&n!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(n)||/%(?:2e|5c|00)/i.test(n))throw Error("local_device_gh_path_denied");let m=new URL(n,"https://api.github.com");if(m.pathname!==n.split("?")[0]||m.username||m.password)throw Error("local_device_gh_path_denied");let R;try{R=decodeURIComponent(m.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(R.includes("%")||R.split("/").some((s)=>s==="."||s===".."))throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.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((s)=>s.test(R)))throw Error("local_device_gh_path_denied");if(m.searchParams.forEach((s,f)=>{if(f==="per_page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(f==="page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(R==="/pulls"&&f==="state"&&["open","closed","all"].includes(s))return;if(R==="/pulls"&&f==="sort"&&s==="updated")return;if(R==="/pulls"&&f==="direction"&&s==="desc")return;if(R==="/pulls"&&["head","base"].includes(f)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(s))return;throw Error("local_device_gh_query_denied")}),r.headers)new Headers(r.headers).forEach((f,q)=>{if(q!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(f))throw Error("local_device_gh_header_denied")})}function Y(e,n,r){if(/[\\#\u0000-\u001f]/.test(n))throw Error("local_device_gh_path_denied");let p=new URL(n,"https://api.github.com");if(p.pathname!=="/search/issues"||p.username||p.password)throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.body!=null)throw Error("local_device_gh_mutation_not_admitted");let m=null;p.searchParams.forEach((g,s)=>{if(s==="q"&&m===null){m=g;return}if(s==="per_page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;if(s==="page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;throw Error("local_device_gh_query_denied")});let R=`repo:${e.toLowerCase()} `,x=m?.toLowerCase()??"";if(x.length>512||!(x+" ").startsWith(R)||/(?:^|\s)(?:repo|org|user):/.test(x.slice(R.length)))throw Error("local_device_gh_query_denied");if(r.headers)new Headers(r.headers).forEach((g,s)=>{if(s!=="accept"||g!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var Hc=`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 Qt(e){return e.kind==="read"||e.kind==="pr_review_context"}var Pr=["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 er=2,v="/app/local-runtime",Je=262144,ps="x-reason-relay-host-alias",hs="v1";function l(e,n){return{path:`${v}${e}`,routerPath:e,auth:n}}function E(e,n){return{...l(e,"device_proof"),forOperation(r){return l(`/operations/${encodeURIComponent(r)}${n}`,"device_proof")}}}var M={register:l("/register","registration_bearer"),enroll:l("/enroll","none"),authChallenge:l("/auth/challenge","none"),identity:l("/identity","device_proof"),heartbeat:l("/heartbeat","device_proof"),rootsSync:l("/roots/sync","device_proof"),disconnect:l("/disconnect","device_proof"),lifecycle:l("/lifecycle","device_proof"),localSubscription:l("/local-subscription","device_proof"),ownerWorkspaces:l("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:l("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:l("/session-worktrees","device_proof"),operationClaim:l("/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")},Ct=`${v}/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 fs(e){return J.some((n)=>n.test(e))}var $n=60000;var ms="hands_control_v1",Rr="environment.deliver",gs="vm_hands_workspace_deferred",_s="vm_hands.workspace_grant",ys="hands.unbind_unverified",bs="claim_v1",vs="environment_at_claim",Ss="ready_v1",Es="workspace_check",ks="rebind_v1",xs="resident_rebind",Cs="hands.rebind",As="snapshot_v1",Ps="cloud_access",Rs="playwright_v1",Ts="headless_browser",Is="v1",Ds="job_env_large_values",at="srt_root_v1",Le="hands_confinement",At="gid_v1",xe="model_jobs_egress",Os="setpriv_v1",Ns="jobs_user",Ls="spawning_attempt_v1",pe="hands_session_group";var $s="session_cap",Ms="none",Bs="same_launch_v1",Fs="exit_v1",js="start_wait",Tr="user_chrome",Hs="cloud_sessions";function N(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let n=/^[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((r)=>typeof e[r]==="string"&&n.test(e[r]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function S(e){if(!a(e)||Object.keys(e).length!==6)return!1;let n=/^[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"&&n.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"&&n.test(e.target_fence_id)}var Us=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],tr=86400000;var W=["production","staging"];function D(e){if(!a(e)||Object.keys(e).length!==3)return!1;let n=/^[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((r)=>Object.hasOwn(e,r)&&typeof e[r]==="string"&&n.test(e[r])&&e[r]!=="00000000-0000-0000-0000-000000000000")}var K="DEVICE-PROOF-V2";function Ir(e,n=K){let r=e.method.toUpperCase();if(!/^[A-Z]+$/.test(r)||!e.pathAndQuery.startsWith(`${v}/`)||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([n,r,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 Z(e,n){return typeof e==="string"&&n.some((r)=>r===e)}function P(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function X(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 u(e){throw Error(e)}function zs(e,n){let r=a(e)?e:{},p=typeof r.error==="string"?r.error:`http_${n}`,m=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:`Reason Device request failed (${n})`;return{code:p,message:m}}function zi(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)))u("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function H(e,n){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!==er||!Array.isArray(e.roots)||!e.roots.every(P)||n&&typeof e.organization_id!=="string"||e.device_credential!==void 0)u(n?"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:er,roots:e.roots},auth_scheme:"p256"}}function qs(e){return H(e,!1)}function Ws(e){let n=H(e,!0);if(typeof n.organization_id!=="string")return u("Reason returned an invalid Device enrollment.");return{...n,organization_id:n.organization_id}}function Vs(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return u("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}:{},...ee(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var Q=["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(Q.filter((n)=>e[n]===!0).map((n)=>[n,!0]))}function Mn(e){if(!a(e))return;try{return{...zi(e),...U(e)}}catch{return}}function ee(e){if(!a(e))return{};let n={};for(let r of W){let p=e[r];if(typeof p==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(p))n[r]=p}return Object.keys(n).length>0?{latest_cli_versions:n}:{}}function Gs(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(P))return u("Reason returned an invalid Device root sync.");return{roots:e.roots}}function Ks(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 u("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 Js(e){if(!a(e)||e.disconnected!==!0)return u("Reason did not disconnect this Device.");let n=e.sessions_moved;return typeof n==="number"&&Number.isSafeInteger(n)&&n>=0?{disconnected:!0,sessions_moved:n}:{disconnected:!0}}function Xs(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 u("Reason did not answer the local login hand-over.")}function Ys(e){if(!a(e)||e.accepted!==!0)return u("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function te(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Zs(e,n=Pr){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&&!D(e.owner)||!Z(e.capability,n)||!a(e.payload)||e.protocol_version!==er||te(e.payload)>(e.capability===rr?Nr:Je)||e.authority!==void 0&&!S(e.authority)||e.local_github_authority!==void 0&&!Ke.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!Ke.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!N(e.recording_authority)||e.capability==="browser.recording.v1"&&(!N(e.recording_authority)||!D(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return u("Reason returned an invalid Device operation claim.");let r={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,...S(e.authority)?{authority:e.authority}:{},...N(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:Ke.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&S(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:er};if(e.owner!==void 0)r.owner=Object.freeze({...e.owner});return r}function Qs(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(X)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return u("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 ea(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 u("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 ta(e){if(!a(e)||!a(e.payload)||!S(e.authority))return u("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function oe(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function ra(e){if(!a(e)||!oe(e.status)||typeof e.idempotent!=="boolean")return u("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
42
+ export{xt,Ln,ds,Ar,Fc,Ke,jc,Hc,Qt,Pr,er,Je,ps,hs,M,Ct,fs,$n,ms,Rr,gs,_s,ys,bs,vs,Ss,Es,ks,xs,Cs,As,Ps,Rs,Ts,Is,Ds,at,Le,At,xe,Os,Ns,Ls,pe,$s,Ms,Bs,Fs,js,Tr,Hs,Us,tr,Ir,zs,zi,qs,Ws,Vs,Mn,Gs,Ks,Js,Xs,Ys,Zs,Qs,ea,ta,ra};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w,We}from"./vm-hands-entry-lite-q9s1e2y1.js";import{be,C}from"./vm-hands-entry-lite-ht6hzkgj.js";import{q}from"./vm-hands-entry-lite-a6ss0ges.js";function lt(e,i){let t=P(e,"REASON_API_URL")?.trim();if(!t)return We(i);let n=new URL(t);if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(n.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return n.origin}function Gc(e){return P(e,"REASON_API_URL")?.trim()?lt(e,"production"):void 0}function Un(e){return P(e,"REASON_API_KEY")?.trim()||void 0}async function ir(e,i){let t=e.env??process.env,n=Un(t);if(!n)return(e.getCredentials??be)({apiOrigin:Gc(t),signal:i});let a=lt(t,e.channel??w({env:t})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+n,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),r=q(p)?p:{};if(!o.ok){let s=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:"API key authentication failed ("+o.status+")";throw new C(o.status,typeof r.error==="string"?r.error:"api_key_auth_failed",s)}if(typeof r.org_id!=="string"||!r.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let l=Array.isArray(r.scopes)?r.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:n,orgId:r.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:l}}export{lt,Gc,Un,ir};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{t,o,_,d,n,we,A,i}from"./vm-hands-entry-lite-k5ytpgzz.js";var zn=25,e=1e5,a=/^[0-9a-f]{64}$/,to=n({day:t().regex(/^\d{4}-\d{2}-\d{2}$/),sent:o().int().min(0).max(e),received:o().int().min(0).max(e)}),s=20,r=n({name:t().min(1).max(100),address:t().min(1).max(300).optional()}),m=n({name:t().min(1).max(100),agent:t().min(1).max(100)}),h=n({machine:t().min(1).max(200),person:t().min(1).max(200),team:t().min(1).max(200),team_id:t().min(1).max(200).optional(),workspace:_().optional(),version:t().max(64).optional(),wait_seconds:o().int().min(0).max(zn).optional(),message_counts:d(to).max(14).optional().catch(void 0),endpoint:t().regex(a).optional().catch(void 0),hosted:d(r).max(50).optional().catch(void 0)}),l=A("kind",[n({id:t(),kind:i("who"),all:_().optional()}),n({id:t(),kind:i("send"),to:t(),body:t(),from_name:t(),from_agent:t(),wake:_(),reply_to:t().max(100).optional(),notify:_().optional()})]),ba=n({job:l.nullable(),retry_after_seconds:o().optional(),hosted:d(m).max(s).optional().catch(void 0)}),p=n({address:t(),person:t(),machine:t(),agent:t(),repo:t().nullable(),branch:t().nullable(),status:t(),since:o().nullable(),doing:t().nullable(),worker:_(),tier:t().max(10).optional()}),c=n({person:t(),machine:t(),online:_()}),y=n({team:t().nullable(),sessions:d(p).max(2000),machines:d(c).max(500),all:_().optional()}),x=n({address:t().max(300),state:t().max(40),note:t().max(500)}),S=we([n({who:y}),n({sent:n({ids:d(t().max(100)).max(500),recipients:d(t().max(300)).max(500),from:t().max(300),deliveries:d(x).max(500).optional()})}),n({error:t().min(1).max(2000)})]),g=n({id:t().max(100),from:t().max(300),from_agent:t().max(100).nullable(),to:t().max(300),reply_to:t().max(100).nullable(),body:t().max(64000),sent_at:o()}),f=n({messages:d(g).max(100),team:t().min(1).max(200).optional(),team_id:t().min(1).max(200).optional(),workspace:_().optional(),session:t().min(1).max(100).optional().catch(void 0),machine:t().min(1).max(200).optional().catch(void 0)});
3
+ export{zn,to,ba};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Fn}from"./vm-hands-entry-lite-krpqqx12.js";import{Dt}from"./vm-hands-entry-lite-ab1pq3xg.js";import{execFileSync as p}from"child_process";import{realpathSync as S,statSync as w}from"fs";import{tmpdir as P}from"os";import{createRequire as b}from"module";import{win32 as r}from"path";var h=["/bin/bash","/usr/bin/bash"],ha="Git Bash was not found. Install Git for Windows (https://git-scm.com/download/win), then run `reason connect`.";function c(o){try{return w(o).isFile()}catch{return!1}}var i=(o)=>[r.join(o,"bin","bash.exe"),r.join(o,"usr","bin","bash.exe")];function g(o,e){let t=r.normalize(o).toLowerCase(),s=(e.SystemRoot??e.SYSTEMROOT??"C:\\Windows").toLowerCase();return t.startsWith(r.join(s,"system32").toLowerCase()+"\\")||t.startsWith(r.join(s,"sysnative").toLowerCase()+"\\")||t.includes("\\windowsapps\\")}function f(o=process.env,e=c){let t=[];for(let s of(o.PATH??o.Path??"").split(";"))if(s&&r.isAbsolute(s))t.push(r.join(s,"git.exe"));for(let s of[o.ProgramW6432,o.ProgramFiles,o["ProgramFiles(x86)"]])if(s)t.push(r.join(s,"Git","cmd","git.exe"));if(o.LOCALAPPDATA)t.push(r.join(o.LOCALAPPDATA,"Programs","Git","cmd","git.exe"));return t.find(e)??null}var a;function Wc(o=process.platform){if(o!=="win32")return"git";return a??=f(),a}function x(o){let e=process.platform==="win32"?f(o):"git";if(!e)return null;try{return p(e,["--exec-path"],{encoding:"utf8",timeout:5000,windowsHide:!0,stdio:["ignore","pipe","ignore"],env:o}).trim()||null}catch{return null}}function J(o=process.env,e=x,t=c){let s=[],l=e(o);if(l)s.push(...i(r.resolve(l,"..","..","..")));for(let n of[o.ProgramW6432,o.ProgramFiles,o["ProgramFiles(x86)"]])if(n)s.push(...i(r.join(n,"Git")));if(o.LOCALAPPDATA)s.push(...i(r.join(o.LOCALAPPDATA,"Programs","Git")));for(let n of(o.PATH??o.Path??"").split(";"))if(n&&r.isAbsolute(n))s.push(r.join(n,"bash.exe"));return s.find((n)=>!g(n,o)&&t(n))??null}var d;function Y(o=process.platform){if(o!=="win32")return h.find(c)??null;return d??=J(),d}function Xe(o=process.platform){let e=Y(o);if(!e)throw Error(o==="win32"?ha:"bash_unavailable");return e}function fa(o=process.platform){return S(o==="win32"?P():"/tmp")}function Rt(o=process.platform,e=process.env){if(o!=="win32")return"/usr/bin:/bin";let t=e.SystemRoot??e.SYSTEMROOT??"C:\\Windows";return[r.join(t,"System32"),t,r.join(t,"System32","Wbem"),r.join(t,"System32","WindowsPowerShell","v1.0")].join(";")}function B(o,e=process.platform){if(e!=="win32"||/[\\/]/.test(o))return o;let t=/\.exe$/i.test(o)?o:`${o}.exe`,s=Rt(e).split(";");return r.join(t.toLowerCase()==="powershell.exe"?s[3]:s[0],t)}function Tt(o=process.platform,e=process.env){if(o!=="win32")return{PATH:Rt(o)};let t=e.SystemRoot??e.SYSTEMROOT??"C:\\Windows";return{PATH:Rt(o,e),SystemRoot:t,WINDIR:t}}function Me(o=process.platform){return o==="win32"?{windowsHide:!0}:{detached:!0}}var u;function m(){if(u===void 0)u=Dt(Fn)(b(import.meta.url));return u}function It(o,e=process.platform){let t=o.pid;if(e!=="win32"||t===void 0)return;let s=m();if(s?.track(t))o.once("close",()=>s.release(t))}function Be(o,e="SIGTERM",t=process.platform){if(t!=="win32"){process.kill(-o,e);return}if(e===0){process.kill(o,0);return}if(m()?.terminate(o))return;p(B("taskkill",t),["/PID",String(o),"/T","/F"],{stdio:"ignore",timeout:1e4,windowsHide:!0})}function G(o,e=63,t=process.platform){return t==="win32"||o.uid===process.getuid?.()&&(o.mode&e)===0}var y=/^(?:con|prn|aux|nul|com[0-9\u00b9\u00b2\u00b3]|lpt[0-9\u00b9\u00b2\u00b3]|conin\$|conout\$)(?:\..*)?$|:|[. ]$/i;function Ki(o){return o!=="."&&o!==".."&&y.test(o)}
3
+ export{ha,Wc,Y,Xe,fa,Rt,B,Tt,Me,It,Be,G,Ki};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var st=".reason/workspace",Et="workspace_base",Oe="sessions",kt="workspace_layout",Ge=".reason/workspace/sessions",Cr=/^[0-9a-f]{8}$/;function Zt(t){if(!Ne(t))return!1;let e=".reason/workspace/sessions/";if(!t.startsWith(e))return!1;let n=t.slice(e.length).split("/");return n.length===2&&Cr.test(n[0])}var i=4096,S="workspaces/pi";function Ne(t){if(typeof t!=="string"||!t||t.length>i)return!1;if(t.startsWith("/")||t.includes("\x00")||t.includes("\\"))return!1;return t.split("/").every((e)=>e!==""&&e!=="."&&e!=="..")}function X(t){if(t.kind==="root"){if(t.path===void 0)return".";if(!Ne(t.path))throw Error("invalid_device_workspace_identity");return t.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(t.workspaceId)||t.workspaceId==="."||t.workspaceId==="..")throw Error("invalid_device_workspace_identity");let e=t.layout==="sessions"?"sessions":S;return`${t.base?`${t.base}/`:""}${e}/${t.workspaceId}/repo`}function te(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.kind==="root"&&Object.keys(e).length===1)return{kind:"root"};if(e.kind==="root"&&Object.keys(e).length===2&&Ne(e.path))return{kind:"root",path:e.path};if(e.kind!=="managed"||typeof e.workspaceId!=="string"||Object.keys(e).length!==2+(e.base===void 0?0:1)+(e.layout===void 0?0:1)||e.base!==void 0&&e.base!==".reason/workspace"||e.layout!==void 0&&e.layout!=="sessions")return null;let n={kind:"managed",workspaceId:e.workspaceId,...e.base===".reason/workspace"?{base:".reason/workspace"}:{},...e.layout==="sessions"?{layout:"sessions"}:{}};try{return X(n),n}catch{return null}}var c="/home/runner";var Fi="/run/reason/sessions",O=/^(?:\/[A-Za-z0-9._-]+)+$/,ji=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,Hi=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function a(t){return ji.exec(t)?.[1]??Hi.exec(t)?.[1]??t}var Nn=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/;function _(t,e=c,n="sessions"){if(!O.test(e)||e.split("/").some((s)=>s==="."||s===".."))throw Error("invalid_cloud_payload_home");let r=`${e}/${X({kind:"managed",workspaceId:t,base:".reason/workspace",...n?{layout:n}:{}})}`,o=`${Fi}/${a(t)}`;return{home:e,root:r.slice(0,-5),checkout:r,control:o,jobEnv:`${o}/job.env`,cloudAccess:`${o}/cloud-access`,logs:`${o}/logs`,pin:`${o}/ws`}}function E(t){return Nn.exec(t.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function Ui(t){let e=Nn.exec(t.replace(/\/+$/,""));if(!e)return null;try{let n=_(e[3],e[1],E(t));return n.root===t.replace(/\/+$/,"")?n:null}catch{return null}}
3
+ export{st,Et,Oe,kt,Ge,Cr,Zt,Ne,X,te,Fi,ji,Hi,Nn,Ui};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var ur="--vm-hands-op-runner-kind=person",dr="--vm-hands-op-runner-kind=surface",Rt="--vm-hands-surface-uid=",Tt="--vm-hands-surface-dir=",It=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-pwwqrnt7.js"),import("./local-display-session-9362hqsn.js"),import("./local-display-video-dndhr5v1.js"),import("./worker-preview-readiness-gy36ejp9.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function vs(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-scnpxe96.js"),import("./local-pty-session-njd0tprg.js"),import("./desktop-account-t0afsge2.js"),import("./worker-sandbox-f1tfb3y0.js")]);y();let i=process.argv.includes(ur),s=process.argv.includes(dr),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(Rt))?.slice(Rt.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-zm639p1g.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-zm639p1g.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(It.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(Tt))?.slice(Tt.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
3
- export{ur,dr,Rt,Tt,It,vs};
2
+ import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var jn="--vm-hands-op-runner-kind=person",Hn="--vm-hands-op-runner-kind=surface",Fr="--vm-hands-surface-uid=",jr="--vm-hands-surface-dir=",Hr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-vvt9d9xb.js"),import("./local-display-session-axh9mfdk.js"),import("./local-display-video-pxhztqk7.js"),import("./worker-preview-readiness-06tygyjs.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function sl(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-pwv76ns5.js"),import("./local-pty-session-edd8ttf9.js"),import("./desktop-account-eg8thn79.js"),import("./worker-sandbox-e1cpkzfz.js")]);y();let i=process.argv.includes(jn),s=process.argv.includes(Hn),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(Fr))?.slice(Fr.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-4mgqn7tg.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-4mgqn7tg.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(Hr.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(jr))?.slice(jr.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
3
+ export{jn,Hn,Fr,jr,Hr,sl};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ function q(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}
3
+ export{q};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{w,ye}from"./vm-hands-entry-lite-q9s1e2y1.js";import{yt}from"./vm-hands-entry-lite-hs6sdn60.js";import{randomBytes as f}from"crypto";import{chmodSync as c,existsSync as a,lstatSync as p,mkdirSync as u,readFileSync as g,renameSync as m,unlinkSync as l,writeFileSync as d}from"fs";import{homedir as y}from"os";import{dirname as S,join as o}from"path";function Q(r=process.env,n=y()){let e=r.XDG_CONFIG_HOME?.trim()||o(n,".config"),t=w({env:r})==="staging"?["staging"]:[];return o(yt(e,...t),"credentials.json")}function ro(r,n=Q()){return u(S(n),{recursive:!0,mode:448}),d(n,`${JSON.stringify(r,null,2)}
3
+ `,{mode:384}),c(n,384),n}function ve(r=Q()){if(!a(r))return null;try{let n=g(r,"utf8"),e=JSON.parse(n);if(typeof e.apiOrigin!=="string"||typeof e.clientId!=="string"||typeof e.accessToken!=="string"||typeof e.refreshToken!=="string"||typeof e.expiresAt!=="string"||typeof e.orgId!=="string"||!Array.isArray(e.scopes))return null;let i=new URL(e.apiOrigin).origin,t=ye(i);if(t!==i)k(r,n,t);return{apiOrigin:t,clientId:e.clientId,accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes.filter((s)=>typeof s==="string"),orgId:e.orgId}}catch{return null}}function k(r,n,e){let i=`${r}.${process.pid}.${f(6).toString("hex")}.tmp`;try{let t=p(r);if(!t.isFile()||process.platform!=="win32"&&t.uid!==process.geteuid?.())return;let s=JSON.parse(n);if(d(i,`${JSON.stringify({...s,apiOrigin:e},null,2)}
4
+ `,{mode:384,flag:"wx"}),c(i,384),g(r,"utf8")!==n)throw Error("credentials_changed");m(i,r)}catch{try{l(i)}catch{}}}function no(r=Q()){if(!a(r))return!1;return l(r),!0}
5
+ export{Q,ro,ve,no};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ function Dt(n){return Function("return ("+n+")")()}
3
+ export{Dt};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{On}from"./vm-hands-entry-lite-xvccy3z4.js";var g=On.version,xr=`reason-cli/${g}`,Nc=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function El(r,c){if(!Nc.test(r)||!Nc.test(c))throw Error("cannot compare invalid CLI versions");let f=(t)=>{let e=t.indexOf("-");return e===-1?[t,void 0]:[t.slice(0,e),t.slice(e+1)]},[h,i]=f(r),[x,s]=f(c),u=h.split(".").map(BigInt),d=x.split(".").map(BigInt);for(let t=0;t<3;t+=1){if(u[t]===d[t])continue;return u[t]<d[t]?-1:1}if(i===void 0||s===void 0){if(i===s)return 0;return i===void 0?1:-1}let l=i.split("."),a=s.split("."),C=Math.max(l.length,a.length);for(let t=0;t<C;t+=1){let e=l[t],n=a[t];if(e===void 0||n===void 0){if(e===n)return 0;return e===void 0?-1:1}if(e===n)continue;let o=/^\d+$/.test(e),p=/^\d+$/.test(n);if(o&&p){let I=BigInt(e),m=BigInt(n);if(I===m)continue;return I<m?-1:1}if(o!==p)return o?-1:1;return e<n?-1:1}return 0}function us(r=Bun.main){return r.startsWith("/$bunfs/")||/^B:[\\/]~BUN[\\/]/i.test(r)}
3
+ export{g,xr,Nc,El,us};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{he}from"./vm-hands-entry-lite-pzj5s203.js";var hn=he(function(t,e){e.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{hn};
2
+ import{ct}from"./vm-hands-entry-lite-qf990rxw.js";var oo=ct(function(t,e){e.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{oo};
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{$i,Mi,vt,Yt,as,cs}from"./vm-hands-entry-lite-6jxshhps.js";import{rc,nc}from"./vm-hands-entry-lite-tcmye5ny.js";import{Ai,Pi,mn,yr,l,ac,Ri,cc,gn,Vt,_n}from"./vm-hands-entry-lite-vdv4nm5f.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{G}from"./vm-hands-entry-lite-8xv6c0rm.js";import{randomUUID as p}from"crypto";import{chmodSync as Z,closeSync as J,constants as C,existsSync as A,fstatSync as ke,lstatSync as h,mkdirSync as q,openSync as Ie,readFileSync as K,readdirSync as re,readlinkSync as w,realpathSync as T,renameSync as S,rmSync as I,statSync as V,symlinkSync as Q,unlinkSync as R,writeFileSync as U}from"fs";import{basename as H,dirname as E,isAbsolute as We,join as m,relative as Xe,resolve as M,sep as me}from"path";import{spawnSync as ee}from"child_process";import{createRequire as Te}from"module";var ae=1,xe=1,Ze=128,Qe=65536,Vc="https://reasonmachines.com/api/runtime-manifest-v2",et=30000,tt=600000,Ee=1e4,nt=60000,rt=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var Me=/^[a-z0-9_.-]{1,80}$/,it=64,at="so.ara.device-broker",Pe=[at,"com.reasonmachines.device-broker"],An=Mi(Pe),we=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory"],ot=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function W(e){if(e?.aborted)throw new l("update_cancelled","Managed runtime update request was cancelled.")}function fe(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function ge(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function b(e){return typeof e==="string"&&rt.test(e)}function De(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function st(e){return yr.includes(e)}function x(e){q(e,{recursive:!0,mode:448}),Z(e,448)}function Oe(e,t){x(E(e));let n=`${e}.${process.pid}.${p()}.tmp`;try{U(n,t,{mode:384,flag:"wx"}),Z(n,384),S(n,e)}finally{if(A(n))R(n)}}function Nt(e={}){if((e.platform??process.platform)!=="darwin")throw new l("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=P(n,"REASON_CLI_CHANNEL")==="staging",i=r?P(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&We(i))?null:m(e.home??s(),"Library","Application Support"),c=e.root??(o?m(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:c,...o?{legacyRoot:m(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:m(c,"versions"),current:m(c,"current"),previous:m(c,"previous"),brokerLock:m(c,"broker.lock"),transitionLock:m(c,"transition.lock"),lifecycleEvents:m(c,"lifecycle-events")}}function hl(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:m(t,"versions"),current:m(t,"current"),previous:m(t,"previous"),brokerLock:m(t,"broker.lock"),transitionLock:m(t,"transition.lock"),lifecycleEvents:m(t,"lifecycle-events")}}function F(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let n=m(e.versions,t,"ara");if(!e.executableName)return n;let r=m(e.versions,t,e.executableName),i=(c)=>{try{return h(c),!0}catch(d){if(d.code==="ENOENT")return!1;throw d}},a=i(n),o=i(r);if(a&&o)throw new l("installed_artifact_mismatch","Ambiguous managed runtime executable layout.");return a?n:r}function oe(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");return _e(F(e,t))}function _e(e){return m(E(e),H(e)==="reason"?Pi:Ai)}function Ce(e,t){if(!b(e)||!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let[n,r]=e.split("-",2),[i,a]=t.split("-",2),o=n.split(".").map(Number),c=i.split(".").map(Number);for(let _=0;_<3;_+=1){let g=o[_]-c[_];if(g!==0)return g<0?-1:1}if(r===void 0||a===void 0){if(r===a)return 0;return r===void 0?1:-1}let d=r.split("."),u=a.split("."),f=Math.max(d.length,u.length);for(let _=0;_<f;_+=1){let g=d[_],y=u[_];if(g===void 0||y===void 0){if(g===y)return 0;return g===void 0?-1:1}if(g===y)continue;let v=/^\d+$/.test(g),L=/^\d+$/.test(y);if(v&&L)return Number(g)<Number(y)?-1:1;if(v!==L)return v?-1:1;return g<y?-1:1}return 0}function ct(e=process.arch){let t=`darwin-${e}`;if(!st(t))throw new l("unsupported_architecture","The managed Reason runtime supports only Apple Silicon and Intel Macs.");return t}function Re(e){return[...e.matchAll(/<key>\s*([^<]+?)\s*<\/key>/g)].map((t)=>t[1].trim())}function pe(e){let t=e.match(/^CodeDirectory .*$/gm)??[];return t.length>0&&t.every((n)=>(/ flags=0x[0-9a-f]+\(([^)]*)\)(?: |$)/.exec(n)?.[1]?.split(/[ ,]+/).filter(Boolean)??[]).includes("runtime"))}function lt(e){let t=`TeamIdentifier=${$i}`,n=Pe.map((a)=>`Identifier=${a}`),r=Re(e.brokerEntitlements),i=Re(e.credentialLibraryEntitlements);if(!e.brokerDetail.split(`
3
+ `).includes(t)||!e.brokerDetail.split(`
4
+ `).some((a)=>n.includes(a))||!pe(e.brokerDetail)||r.length!==we.length||we.some((a)=>!new RegExp(`<key>\\s*${a.replaceAll(".","\\.")}\\s*</key>\\s*<true\\s*/>`).test(e.brokerEntitlements)))throw new l("invalid_code_signature","Managed runtime broker has an invalid Reason signature, identifier, or entitlement set.");if(!e.credentialLibraryDetail.split(`
5
+ `).includes(t)||!pe(e.credentialLibraryDetail)||i.length!==0)throw new l("invalid_code_signature","Managed runtime credential library has an invalid signature or entitlement.")}function D(e,t){let n=ee("/usr/bin/codesign",e,{stdio:["ignore","pipe","pipe"]});if(n.status!==0)throw new l("invalid_code_signature",t);return[new TextDecoder().decode(n.stdout??new Uint8Array),new TextDecoder().decode(n.stderr??new Uint8Array)].join("")}var ye=(e,t)=>{D(["--verify","--strict","--verbose=2",e],"Managed runtime broker code signature is invalid."),D(["--verify","--strict","--verbose=2",t],"Managed runtime credential library code signature is invalid."),lt({brokerDetail:D(["-d","--verbose=4",e],"Managed runtime broker signer could not be inspected."),brokerEntitlements:D(["-d","--entitlements",":-",e],"Managed runtime broker entitlements could not be inspected."),credentialLibraryDetail:D(["-d","--verbose=4",t],"Managed runtime credential library signer could not be inspected."),credentialLibraryEntitlements:D(["-d","--entitlements",":-",t],"Managed runtime credential library entitlements could not be inspected.")})};async function dt(e,t,n){let r=e.headers.get("content-length");if(r!==null){let f=Number(r);if(!Number.isSafeInteger(f)||f<0||f>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.")}if(!e.body){let f=new Uint8Array(await e.arrayBuffer());if(f.byteLength>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.");return f}let i=e.body.getReader(),a=[],o=0,c=()=>{if(!n)return i.read();return new Promise((f,_)=>{let g=()=>{n.removeEventListener("abort",g),i.cancel(n.reason).catch(()=>{}),_(n.reason??new DOMException("Aborted","AbortError"))};if(n.aborted){g();return}n.addEventListener("abort",g,{once:!0}),i.read().then((y)=>{n.removeEventListener("abort",g),f(y)},(y)=>{n.removeEventListener("abort",g),_(y)})})};try{while(!0){let f=await c();if(f.done)break;if(o+=f.value.byteLength,o>t)throw await i.cancel(),new l("response_too_large","Managed runtime response exceeded its size limit.");a.push(f.value)}}finally{try{i.releaseLock()}catch{}}let d=new Uint8Array(o),u=0;for(let f of a)d.set(f,u),u+=f.byteLength;return d}async function Wr(e){let t;try{t=new URL(e.url)}catch{throw new l("invalid_update_url","Managed runtime update URL is invalid.")}if(t.protocol!=="https:"||t.username||t.password||t.hash)throw new l("invalid_update_url","Managed runtime update URL must use HTTPS.");let n=new AbortController,r,i=()=>{r??="caller",n.abort(e.signal?.reason)};if(e.signal?.aborted)i();else e.signal?.addEventListener("abort",i,{once:!0});let a=setTimeout(()=>{r??="timeout",n.abort(Error("managed runtime fetch timed out"))},e.timeoutMs),o=(c,d)=>{if(c instanceof l)return c;if(r==="caller")return new l("update_cancelled","Managed runtime update request was cancelled.");if(r==="timeout")return new l("update_fetch_timeout","Managed runtime update request timed out.");return new l("update_fetch_failed",d)};try{let c;try{if(c=await e.fetchImpl(t,{headers:{accept:e.accept},signal:n.signal}),n.signal.aborted)throw o(n.signal.reason,"Managed runtime update request was cancelled.")}catch(d){throw o(d,"Managed runtime update request failed.")}if(!c.ok)throw new l("update_http_error","Managed runtime update request was rejected.");if(c.url&&new URL(c.url).protocol!=="https:")throw new l("insecure_redirect","Managed runtime update redirected to an insecure URL.");try{let d=await dt(c,e.maximumBytes,n.signal);if(n.signal.aborted)throw o(n.signal.reason,"Managed runtime update response was cancelled.");return d}catch(d){throw o(d,"Managed runtime update response failed.")}}finally{clearTimeout(a),e.signal?.removeEventListener("abort",i)}}async function Ve(e,t,n=Ee,r){let i=typeof n==="number"?n:Ee,a=typeof n==="number"?r:n;if(a?.aborted)return!1;let o=await rc([e,"--version"],{timeoutMs:i,...a?{signal:a}:{}});return o.exitCode===0&&o.stdout.trim().replace(/^v/,"")===t}async function ut(e){let t=!1,n=null,r=null,i=(a)=>{try{N(e.paths,a,{now:e.now})}catch{}};try{let a=e.home??s();if(!as(e.manifest.version,a))return{status:"current"};r=Yt(a);let o=await Wr({url:new URL(ac,e.manifest.artifacts[e.target].broker.url).toString(),maximumBytes:mn,fetchImpl:async(g,y)=>{let v=await e.fetchImpl(g,y);return t=v.status===404,v},timeoutMs:e.timeoutMs,accept:"application/json",signal:e.signal}),{manifest:c}=cc(new TextDecoder().decode(o),e.trustedKeys);if(c.version!==e.manifest.version||c.published_at!==e.manifest.published_at)throw new l("identity_manifest_mismatch","Background identity manifest names another release.");let d=c.artifacts[e.target],u=await Wr({url:d.url,maximumBytes:d.size_bytes,fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs,accept:"application/octet-stream",signal:e.signal});Vt(u,d),x(e.workDirectory),n=m(e.workDirectory,`.identity-${process.pid}-${p()}`),q(n,{mode:448});let f=m(n,"identity.tgz");if(U(f,u,{mode:384,flag:"wx"}),ee("/usr/bin/tar",["-xzf",f,"-C",n],{stdio:"ignore",timeout:60000}).status!==0)throw new l("identity_extract_failed","Background identity archive could not be extracted.");return cs({sourceApp:m(n,"Reason.app"),home:a,releaseSigned:!0,...e.command?{command:e.command}:{}}),i({event:"identity.refresh_completed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version}),{status:"installed"}}catch(a){if(t)return{status:"unpublished"};let o=a instanceof l||a instanceof vt?a.code:"identity_install_failed";return process.stderr.write(`Reason background identity: identity_update_failed (${o})
6
+ `),i({event:"identity.refresh_failed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version,reason_code:o}),{status:"failed",code:o}}finally{if(n)I(n,{recursive:!0,force:!0})}}async function fl(e){if(!b(e.currentVersion))throw new l("invalid_version","Invalid current managed runtime version.");let t=e.paths??Nt(),n=e.target??ct(),r=e.fetchImpl??fetch,i=e.timeoutMs??et,a=e.timeoutMs??tt,o=e.healthCheck??((_,g,y)=>Ve(_,g,nt,y)),c=e.verifyCodeSignatures??ye,d=e.now?.()??new Date,u,f=!1;N(t,{event:"update.check_started",runtime_version:e.currentVersion,from_version:e.currentVersion},{now:()=>d});try{await pt({paths:t,verifyCodeSignatures:c,healthCheck:o});let _=await Wr({url:e.manifestUrl??Vc,maximumBytes:mn,fetchImpl:r,timeoutMs:i,accept:"application/json",signal:e.signal}),g=Ri(new TextDecoder().decode(_),e.trustedKeys);u=g.manifest.version;let y=()=>ut({paths:t,...e.now?{now:e.now}:{},manifest:g.manifest,target:n,trustedKeys:e.trustedKeys,fetchImpl:r,timeoutMs:a,workDirectory:t.versions,...e.home?{home:e.home}:{},...e.identityCommand?{command:e.identityCommand}:{},...e.signal?{signal:e.signal}:{}});if(Ce(u,e.currentVersion)<=0)return N(t,{event:"update.not_available",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),Ae(t,e.home),{status:"not_available",currentVersion:e.currentVersion,offeredVersion:u,...u===e.currentVersion?{identity:await y()}:{}};let v=g.manifest.artifacts[n];N(t,{event:"update.download_started",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now});let L=await Wr({url:v.broker.url,maximumBytes:v.broker.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Vt(L,v.broker),W(e.signal);let j=await Wr({url:v.credential_library.url,maximumBytes:v.credential_library.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Vt(j,v.credential_library),N(t,{event:"update.downloaded",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),N(t,{event:"update.verified",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),W(e.signal);let he=mt({paths:t,version:u,artifact:v.broker,bytes:L,credentialLibraryArtifact:v.credential_library,credentialLibraryBytes:j,verifyCodeSignatures:c}),be;try{be=await o(he.executablePath,u,e.signal)}catch(B){throw W(e.signal),B}if(W(e.signal),!be)throw new l("pre_activation_health_failed","Managed runtime preflight failed.");let k=Et(t,u);if(!k.changed&&k.toVersion!==u)return N(t,{event:"update.not_available",runtime_version:k.toVersion,from_version:k.toVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"not_available",currentVersion:k.toVersion,offeredVersion:u};if(f=k.changed,!await o(t.current,u)){if(k.fromVersion){let B=Ge(t,u);N(t,{event:"update.rollback",runtime_version:B.toVersion,from_version:B.fromVersion,to_version:B.toVersion,reason_code:"post_activation_health_failed"},{now:e.now})}else Je(t,u);throw O(t),f=!1,new l("post_activation_health_failed","Managed runtime activation failed.")}return O(t),Ae(t,e.home),N(t,{event:"update.activated",runtime_version:u,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"activated",fromVersion:e.currentVersion,toVersion:u,installed:he.installed,identity:await y()}}catch(_){throw N(t,{event:"update.failed",runtime_version:f?u??e.currentVersion:e.currentVersion,from_version:e.currentVersion,...u?{to_version:u}:{},reason_code:_ instanceof l?_.code:"update_failed",duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),_}}function Le(e,t,n){try{let r=h(E(e));if(!r.isDirectory()||r.isSymbolicLink())return!1;let i=h(e);if(!i.isFile()||i.isSymbolicLink()||i.size!==t.size_bytes)return!1;let a=_e(e),o=h(a);return o.isFile()&&!o.isSymbolicLink()&&o.size===n.size_bytes&&gn(K(e))===t.sha256&&gn(K(a))===n.sha256}catch{return!1}}function mt(e){let t=F(e.paths,e.version);Vt(e.bytes,e.artifact),Vt(e.credentialLibraryBytes,e.credentialLibraryArtifact);let n=e.verifyCodeSignatures??ye;if(x(e.paths.root),x(e.paths.versions),A(E(t))){if(!Le(t,e.artifact,e.credentialLibraryArtifact))throw new l("installed_artifact_mismatch","The installed runtime version does not match the verified artifact.");return n(t,oe(e.paths,e.version)),{installed:!1,executablePath:t}}let r=m(e.paths.versions,`.install-${e.version}-${process.pid}-${p()}`),i=m(r,H(t)),a=_e(i);q(r,{mode:448});try{U(i,e.bytes,{mode:448,flag:"wx"}),Z(i,448),U(a,e.credentialLibraryBytes,{mode:448,flag:"wx"}),Z(a,448),n(i,a);try{S(r,E(t))}catch(o){if(!Le(t,e.artifact,e.credentialLibraryArtifact))throw o;return{installed:!1,executablePath:t}}return{installed:!0,executablePath:t}}finally{I(r,{recursive:!0,force:!0})}}function ft(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");return`versions/${t}/${H(F(e,t))}`}function te(e,t){x(E(e));let n=`${e}.${process.pid}.${p()}.tmp`;try{Q(t,n),S(n,e)}finally{if(A(n))R(n)}}var Ue=/^\.(?:ara|reason)-worker-(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)-(darwin-(?:arm64|x64))\.([0-9A-Za-z]{6})$/,gt=new Set(["reason","ara"]);function Fe(e,t){let n=E(e),r=M(n,t),i=E(r),a=Ue.exec(H(i));if(!gt.has(H(r))||E(i)!==n||!a||!b(a[1])||!yr.includes(a[2]))return!1;try{return h(i).isDirectory()&&E(T(i))===T(n)&&h(r).isFile()&&h(_n(i)).isFile()}catch(o){if(o.code==="ENOENT")return!1;throw o}}function Be(e,t,n){try{if(w(e)!==t)return!1;R(e)}catch(r){if(r.code==="ENOENT")return!1;throw r}try{return Q(n,e),!0}catch(r){if(r.code==="EEXIST")return!1;try{Q(t,e)}catch(i){if(i.code!=="EEXIST")throw i}throw r}}function _t(e,t){if(!e.legacyRoot)return!1;let n;try{if(!h(t).isSymbolicLink())return!1;n=w(t)}catch(i){if(i.code==="ENOENT")return!1;throw i}if(M(E(t),n)!==m(e.legacyRoot,"current"))return!1;if(!Be(t,n,e.current))return!1;let r=Ye(e);if(r)N(e,{event:"service.launcher_adopted",runtime_version:r,to_version:r,reason_code:"legacy_runtime_root"});return!0}function yt(e,t){let n=m(e,".local","bin"),r=m(n,"ara"),i=m(n,"reason"),a=h(r,{throwIfNoEntry:!1});if(a?.isSymbolicLink()&&w(r)==="reason")return i;if(a||!h(i,{throwIfNoEntry:!1})?.isSymbolicLink())return r;let o=w(i);return o===t.current||Fe(i,o)?i:r}function ml(e){let t=e.launcherPath??yt(e.home??s(),e.paths);try{if(h(t).isSymbolicLink()){let r=w(t);if(r===e.paths.current)return"managed";if(Fe(t,r)&&Be(t,r,e.paths.current)){let i=se(e.paths.current,e.paths.executableName)??"unknown";return N(e.paths,{event:"service.launcher_adopted",runtime_version:i,to_version:i,reason_code:"legacy_curl_entrypoint"}),"adopted"}if(_t(e.paths,t))return"adopted"}return"conflict"}catch(n){if(n.code!=="ENOENT")throw n}q(E(t),{recursive:!0,mode:448});for(let n=0;n<4;n+=1)try{return Q(e.paths.current,t),"created"}catch(r){if(r.code!=="EEXIST")throw r;try{return h(t).isSymbolicLink()&&w(t)===e.paths.current?"managed":"conflict"}catch(i){if(i.code!=="ENOENT")throw i}}return"conflict"}function se(e,t){let n;try{if(!h(e).isSymbolicLink())return null;n=w(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Ye(e){return se(e.current,e.executableName)}function ne(e,t,n){let i=Xe(t,e).split(me);return i.length===2&&b(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function $e(e,t){try{return h(t).isSymbolicLink()&&M(E(t),w(t))===M(e.current)}catch{return!1}}function gl(e,t=process.execPath){try{return ne(T(t),T(e.versions),e.executableName)!==null}catch{let n=M(t);return n===M(e.current)||$e(e,n)||ne(n,M(e.versions),e.executableName)!==null}}function _l(e,t=process.execPath){try{return ne(T(t),T(e.versions),e.executableName)}catch{let n=M(t);if(n===M(e.current)||$e(e,n))return Ye(e);return ne(n,M(e.versions),e.executableName)}}function ht(e,t,n=!1){let r=Ye(e);if(!r)return null;if(r===t)return{changed:!1,fromVersion:r,toVersion:r};if(!n&&Ce(t,r)<=0&&!(/^\d+\.\d+\.\d+-desktop\.v1\.\d+\.\d+\.\d+$/.test(t)&&/^\d+\.\d+\.\d+-desktopdev\./.test(r)))return{changed:!1,fromVersion:r,toVersion:r};return null}function bt(e,t,n,r=!1){let i=ht(e,t,r);if(i)return i;let a=Ye(e);if(n?.(a),a)te(e.previous,w(e.current));else if(A(e.previous))R(e.previous);return te(e.current,ft(e,t)),{changed:!0,fromVersion:a,toVersion:t}}function Et(e,t){let n=F(e,t),r=oe(e,t);if(!A(n)||!V(n).isFile()||!A(r)||!V(r).isFile())throw new l("runtime_not_installed","Managed Reason runtime version is not installed.");return ce(e,t,()=>bt(e,t,(i)=>{Rt(e,{schema_version:ae,from_version:i,to_version:t})}))}function Ge(e,t){return ce(e,t,()=>{if(Ye(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");let n=se(e.previous,e.executableName);if(!n||n===t)throw new l("rollback_unavailable","No previous managed runtime is available.");let r=F(e,n),i=oe(e,n);if(!A(r)||!V(r).isFile()||!A(i)||!V(i).isFile())throw new l("rollback_unavailable","Previous managed runtime is not installed.");let a=w(e.previous),o=w(e.current);if(M(E(e.previous),a)!==M(r))throw new l("rollback_fence_failed","Previous runtime pointer does not match its installed layout.");return te(e.current,a),te(e.previous,o),{fromVersion:t,toVersion:n}})}function ze(){let e=ee("/bin/ps",["-axww","-o","args="],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000,maxBuffer:16777216});if(e.status!==0||typeof e.stdout!=="string")return null;let t=ee("/usr/sbin/lsof",["-nP","-w","-d","txt","-Fn"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:20000,maxBuffer:67108864});if(t.error||t.status!==0&&t.status!==1||!t.stdout)return null;return`${e.stdout}
7
+ ${t.stdout}`}function Ae(e,t){let n=[];Mt(e,t??s());try{let r=Ye(e);if(!r||de(e))return n;let i=re(e.versions).filter((o)=>b(o));if(i.length<=2)return n;let a=ze();if(a===null)return n;ce(e,r,()=>{let o=new Set([Ye(e),se(e.previous,e.executableName)]);if(de(e))return;for(let c of i){if(o.has(c))continue;let d=m(e.versions,c);if(a.includes(`${d}${me}`))continue;try{I(d,{recursive:!0,force:!0}),n.push(c)}catch{}}})}catch{}return n}function Mt(e,t){try{let n=le(m(t,".local","bin"));if(!n)return;let r=["reason","ara"].flatMap((c)=>{try{return[M(n,w(m(n,c)))]}catch{return[]}}),i=le(e.current);if(!i||!r.some((c)=>le(c)===i))return;let a=re(n).filter((c)=>Ue.test(c)).map((c)=>m(n,c)).filter((c)=>!r.some((d)=>E(d)===c)).filter((c)=>Date.now()-h(c).mtimeMs>3600000);if(a.length===0)return;let o=ze();if(o===null)return;for(let c of a){if(o.includes(`${c}${me}`))continue;try{I(c,{recursive:!0,force:!0})}catch{}}}catch{}}function le(e){try{return T(e)}catch{return null}}function Je(e,t){ce(e,t,()=>{if(Ye(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");R(e.current)})}function ve(e){return e.activationState??m(e.root,"activation.json")}function wt(e){return fe(e)&&ge(e,["schema_version","from_version","to_version"])&&e.schema_version===ae&&(e.from_version===null||b(e.from_version))&&b(e.to_version)}function de(e){try{let t=ve(e),n=h(t);if(!n.isFile()||n.isSymbolicLink()||n.nlink!==1||(n.mode&63)!==0||n.size>4096)throw new l("invalid_activation_state","Managed runtime activation state is invalid.");let r=JSON.parse(K(t,"utf8"));if(!wt(r))throw new l("invalid_activation_state","Managed runtime activation state is invalid.");return r}catch(t){if(t instanceof l)throw t;if(t.code==="ENOENT")return null;throw new l("invalid_activation_state","Managed runtime activation state is invalid.")}}function Rt(e,t){Oe(ve(e),JSON.stringify(t)+`
8
+ `)}function O(e){try{R(ve(e))}catch(t){if(t.code!=="ENOENT")throw t}}async function pt(e){let t=de(e.paths);if(!t)return"none";let n=Ye(e.paths);if(n===t.from_version)return O(e.paths),"cleared";if(n!==t.to_version)throw new l("rollback_fence_failed","Managed runtime changed before activation recovery could be applied.");let r=e.verifyCodeSignatures??ye,i=e.healthCheck??Ve,a=!1;try{let o=F(e.paths,t.to_version);r(o,oe(e.paths,t.to_version)),a=await i(o,t.to_version)}catch{a=!1}if(a)return O(e.paths),N(e.paths,{event:"update.activated",runtime_version:t.to_version,...t.from_version?{from_version:t.from_version}:{},to_version:t.to_version,reason_code:"restart_recovery"}),"committed";if(t.from_version){let o=Ge(e.paths,t.to_version);return O(e.paths),N(e.paths,{event:"update.rollback",runtime_version:o.toVersion,from_version:o.fromVersion,to_version:o.toVersion,reason_code:"restart_recovery"}),"rolled_back"}return Je(e.paths,t.to_version),O(e.paths),N(e.paths,{event:"update.rollback",runtime_version:t.to_version,from_version:t.to_version,reason_code:"restart_recovery"}),"rolled_back"}function Lt(e){return fe(e)&&ge(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===ae&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&De(e.started_at)&&b(e.runtime_version)}function Ke(e,t){try{let n=h(e);if(!n.isDirectory()||!G(n))return null;let r=Ie(m(e,t),C.O_RDONLY|C.O_NOFOLLOW|C.O_NONBLOCK);try{let i=ke(r);if(!i.isFile()||i.nlink!==1||!G(i)||i.size>4096)return null;return K(r,"utf8")}finally{J(r)}}catch{return null}}function ue(e){try{let t=JSON.parse(Ke(e,"owner.json")??"null");return Lt(t)?t:null}catch{return null}}function He(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var Ne="lease",At=2,St=4,Y;function kt(){if(Y!==void 0)return Y;if(Y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=Te(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),a=i.symbols[t]();if(a===null)continue;return Y={flock:(o,c)=>i.symbols.flock(o,c),errno:()=>e.read.i32(a),wouldBlock:process.platform==="darwin"?35:11},Y}catch{}return null}var z,It=3221225472,Tt=4,xt=128,Pt=32;function Dt(e){if(z===void 0){z=null;try{let a=Te(import.meta.url)("bun:ffi"),{FFIType:o}=a;z={kernel:a.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(d)=>a.ptr(d)}}catch{return null}}if(!z)return null;let{kernel:t,ptr:n}=z,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),It,0,null,Tt,xt,null);if(Number(i)===-1)return t.GetLastError()===Pt?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Ot(e){if(process.platform==="win32")return Dt(`${e}.lease`);let t=kt();if(!t)return null;let n=Ie(`${e}.lease`,C.O_RDWR|C.O_CREAT|C.O_NOFOLLOW,384);try{let r=ke(n);if(!r.isFile()||r.nlink!==1||!G(r))return J(n),"busy";if(t.flock(n,At|St)===0)return{release:()=>J(n)};let i=t.errno();return J(n),i===t.wouldBlock?"busy":null}catch(r){throw J(n),r}}function ie(e){x(E(e.path));let t=Ot(e.path);if(t==="busy")return{acquired:!1,owner:ue(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ct(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ct(e,t){let n=e.alive??He,r=!1;for(let i=0;i<4;i+=1){let a={schema_version:ae,pid:e.pid??process.pid,nonce:e.nonce?.()??p(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${p()}`,c=!1;try{if(q(o,{mode:448}),U(m(o,"owner.json"),`${JSON.stringify(a)}
9
+ `,{mode:384,flag:"wx"}),t!==null)U(m(o,Ne),`flock
10
+ `,{mode:384,flag:"wx"});e.beforePublish?.();try{throw h(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(u){if(u.code!=="ENOENT")throw u}S(o,e.path),c=!0;let d=!1;return{acquired:!0,owner:a,recoveredStaleOwner:r,release(){if(d)return;if(d=!0,ue(e.path)?.nonce===a.nonce)I(e.path,{recursive:!0,force:!0});t?.release()}}}catch(d){let u=d.code;if(!["EEXIST","ENOTEMPTY"].includes(u??""))throw d;let f=ue(e.path),_=(e.now?.()??new Date).getTime(),g=f&&e.staleAfterMs!==void 0?_-Date.parse(f.started_at)<e.staleAfterMs:!1,y=f!==null&&!(t!==null&&Ke(e.path,Ne)!==null)&&n(f.pid);if(!f||y||g)return{acquired:!1,owner:f,recoveredStaleOwner:!1};let v=`${e.path}.stale-${process.pid}-${p()}`;try{S(e.path,v),I(v,{recursive:!0,force:!0}),r=!0}catch(L){let j=L.code;if(!["ENOENT","EEXIST"].includes(j??""))throw L}}finally{if(!c)I(o,{recursive:!0,force:!0})}}throw new l("lock_unavailable","Could not acquire the managed Reason runtime lock.")}var Ut=20000;function ce(e,t,n){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let r=Date.now()+Ut,i=ie({path:e.transitionLock,runtimeVersion:t,staleAfterMs:60000});while(!i.acquired&&Date.now()<r)nc(100),i=ie({path:e.transitionLock,runtimeVersion:t,staleAfterMs:60000});if(!i.acquired)throw new l("transition_busy","Another managed Reason runtime transition is in progress.");try{return n()}finally{i.release()}}function yl(e){if(!b(e.runtimeVersion))throw new l("invalid_version","Invalid managed Reason runtime version.");let t=e.paths??Nt();return ie({path:t.brokerLock,runtimeVersion:e.runtimeVersion,...e.pid===void 0?{}:{pid:e.pid},...e.now===void 0?{}:{now:e.now},...e.nonce===void 0?{}:{nonce:e.nonce},...e.alive===void 0?{}:{alive:e.alive},...e.beforePublish===void 0?{}:{beforePublish:e.beforePublish}})}function qe(e){return fe(e)&&ge(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===xe&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&De(e.occurred_at)&&typeof e.event==="string"&&ot.includes(e.event)&&b(e.runtime_version)&&(e.from_version===void 0||b(e.from_version))&&(e.to_version===void 0||b(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&Me.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=it&&e.capabilities.every((t)=>typeof t==="string"&&Me.test(t)))}var Ft=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Bt=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,$t=300000,X=0n;function Gt(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return X=t>X?t:X+1n,`${String(X).padStart(22,"0")}-${e.event_id}.json`}function je(e){try{return re(e.lifecycleEvents).filter((t)=>Ft.test(t)).sort()}catch{return[]}}function Se(e){try{let t=JSON.parse(K(e,"utf8"));return qe(t)?t:null}catch{return null}}function zt(e,t=He,n=Date.now()){let r;try{r=re(e.lifecycleEvents)}catch{return}for(let i of r){let a=i.match(Bt);if(!a)continue;let o=m(e.lifecycleEvents,i),c=m(e.lifecycleEvents,a[1]),d=!t(Number(a[2]));if(!d)try{d=n-V(o).mtimeMs>=$t}catch{continue}if(!d)continue;try{S(o,c)}catch(u){let f=u.code;if(f==="EEXIST")R(o);else if(f!=="ENOENT")throw u}}}function Jt(e){let n=je(e).flatMap((i)=>{try{return[{name:i,size:V(m(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,a)=>i+a.size,0);while(n.length>Ze||r>Qe){let i=n.shift();if(!i)break;try{R(m(e.lifecycleEvents,i.name)),r-=i.size}catch(a){if(a.code!=="ENOENT")throw a}}}function N(e,t,n={}){let r={schema_version:xe,event_id:n.eventId?.()??p(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!qe(r))throw new l("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return x(e.lifecycleEvents),Oe(m(e.lifecycleEvents,Gt(r)),`${JSON.stringify(r)}
11
+ `),Jt(e),r}async function Qi(e,t,n){zt(e);let r=0;for(let i of je(e)){let a=m(e.lifecycleEvents,i);if(n){let d=Se(a);if(!d||!n(d))continue}let o=`${a}.sending-${process.pid}-${p()}`;try{S(a,o)}catch(d){if(d.code==="ENOENT")continue;throw d}let c=Se(o);if(!c){R(o);continue}try{await t(c),R(o),r+=1}catch{try{S(o,a)}catch(d){if(d.code!=="ENOENT")throw d}break}}return r}export{Vc,Nt,hl,Wr,fl,ml,Ye,gl,_l,ie,yl,N,Qi};