@reason-machines/cli-linux-x64 0.2.408 → 0.2.410

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 (100) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/api-cjv8m2zy.js +2 -0
  3. package/bin/vm-hands/api-credentials-m5akr9fv.js +2 -0
  4. package/bin/vm-hands/connect-cli-nydbj6ae.js +2 -0
  5. package/bin/vm-hands/custom-endpoint-device-dkqb4rqy.js +2 -0
  6. package/bin/vm-hands/desktop-account-5v7x0ajx.js +2 -0
  7. package/bin/vm-hands/device-workspace-p9q9dckg.js +2 -0
  8. package/bin/vm-hands/{fsevents-vgg0dny6.js → fsevents-ekt70rcc.js} +1 -1
  9. package/bin/vm-hands/hands-worker-source-cgrpm21b.js +2 -0
  10. package/bin/vm-hands/{index-kx10kwyx.js → index-k8kcz8a3.js} +11 -11
  11. package/bin/vm-hands/install-receipt-7vt2y2vh.js +2 -0
  12. package/bin/vm-hands/local-automation-y9kx76wa.js +2 -0
  13. package/bin/vm-hands/local-capabilities-j6h63m79.js +2 -0
  14. package/bin/vm-hands/local-desktop-users-q886k0mm.js +2 -0
  15. package/bin/vm-hands/local-display-mac-w85956f1.js +2 -0
  16. package/bin/vm-hands/local-display-session-ftt74eb3.js +2 -0
  17. package/bin/vm-hands/local-pty-session-5f50sqq0.js +2 -0
  18. package/bin/vm-hands/managed-runtime-tjwpypgf.js +2 -0
  19. package/bin/vm-hands/network-contract-9x9kc5vv.js +2 -0
  20. package/bin/vm-hands/package-78fkast4.js +2 -0
  21. package/bin/vm-hands/permissions-byngw8v0.js +2 -0
  22. package/bin/vm-hands/reason-hands-protocol-2tnghj3b.js +2 -0
  23. package/bin/vm-hands/serve-service-j5wnq4bg.js +2 -0
  24. package/bin/vm-hands/status-8tjada6n.js +10 -0
  25. package/bin/vm-hands/version-5hrs2hvb.js +2 -0
  26. package/bin/vm-hands/{vm-hands-entry-lite-e5hbehqn.js → vm-hands-entry-lite-05rrh8yg.js} +16 -16
  27. package/bin/vm-hands/{vm-hands-entry-lite-wyh6dp1t.js → vm-hands-entry-lite-09m2cdkw.js} +2 -2
  28. package/bin/vm-hands/vm-hands-entry-lite-0g9xvgdy.js +2 -0
  29. package/bin/vm-hands/{vm-hands-entry-lite-4aejamqr.js → vm-hands-entry-lite-0xrsph3r.js} +2 -2
  30. package/bin/vm-hands/{vm-hands-entry-lite-wf7ksh4e.js → vm-hands-entry-lite-10sbjfzx.js} +5 -5
  31. package/bin/vm-hands/{vm-hands-entry-lite-fyjzrvj5.js → vm-hands-entry-lite-1cwqa4jr.js} +2 -2
  32. package/bin/vm-hands/{vm-hands-entry-lite-ppytc9k7.js → vm-hands-entry-lite-1rrb66r9.js} +2 -2
  33. package/bin/vm-hands/{vm-hands-entry-lite-pn92kh7b.js → vm-hands-entry-lite-1rtkf2xm.js} +2 -2
  34. package/bin/vm-hands/{vm-hands-entry-lite-4geps3jz.js → vm-hands-entry-lite-1sg8sdw5.js} +3 -3
  35. package/bin/vm-hands/{vm-hands-entry-lite-g3ja0c3y.js → vm-hands-entry-lite-22kfyvnk.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-hee1h411.js → vm-hands-entry-lite-46fkv5sp.js} +10 -10
  37. package/bin/vm-hands/{vm-hands-entry-lite-snmxxhza.js → vm-hands-entry-lite-66ctbcym.js} +2 -2
  38. package/bin/vm-hands/{vm-hands-entry-lite-hzn1hf0p.js → vm-hands-entry-lite-6aeea05q.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-et2bh990.js → vm-hands-entry-lite-70ba2bqj.js} +22 -22
  40. package/bin/vm-hands/{vm-hands-entry-lite-hfmydph9.js → vm-hands-entry-lite-80y72d0e.js} +4 -4
  41. package/bin/vm-hands/{vm-hands-entry-lite-mw0gzbds.js → vm-hands-entry-lite-88swf2qr.js} +3 -3
  42. package/bin/vm-hands/{vm-hands-entry-lite-dkcm3hyn.js → vm-hands-entry-lite-89z488gz.js} +2 -2
  43. package/bin/vm-hands/vm-hands-entry-lite-8ns59paz.js +3 -0
  44. package/bin/vm-hands/{vm-hands-entry-lite-mvx29q2q.js → vm-hands-entry-lite-8t9xssf9.js} +2 -2
  45. package/bin/vm-hands/{vm-hands-entry-lite-zn0v259d.js → vm-hands-entry-lite-907pa7f9.js} +4 -4
  46. package/bin/vm-hands/{vm-hands-entry-lite-zg3b0c08.js → vm-hands-entry-lite-9ay6f56v.js} +2 -2
  47. package/bin/vm-hands/{vm-hands-entry-lite-wd576mgy.js → vm-hands-entry-lite-9c95p6n9.js} +29 -29
  48. package/bin/vm-hands/{vm-hands-entry-lite-9ym3sx81.js → vm-hands-entry-lite-ab2m9erf.js} +1 -1
  49. package/bin/vm-hands/{vm-hands-entry-lite-79s23abx.js → vm-hands-entry-lite-b885gwfh.js} +4 -4
  50. package/bin/vm-hands/{vm-hands-entry-lite-51qvfk93.js → vm-hands-entry-lite-bdhjpv7g.js} +2 -2
  51. package/bin/vm-hands/vm-hands-entry-lite-bk6akkdt.js +540 -0
  52. package/bin/vm-hands/{vm-hands-entry-lite-5p5h1eng.js → vm-hands-entry-lite-ckv17tn8.js} +2 -2
  53. package/bin/vm-hands/{vm-hands-entry-lite-8evzzh7v.js → vm-hands-entry-lite-eqgj4acy.js} +5 -5
  54. package/bin/vm-hands/{vm-hands-entry-lite-v3xznxcw.js → vm-hands-entry-lite-f5e3dbgk.js} +3 -3
  55. package/bin/vm-hands/{vm-hands-entry-lite-saqdrc2w.js → vm-hands-entry-lite-grm1tqs7.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-8gtgr399.js → vm-hands-entry-lite-gvwdy3rf.js} +3 -3
  57. package/bin/vm-hands/{vm-hands-entry-lite-6p9c8nhf.js → vm-hands-entry-lite-hj8n59y9.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-ym1djztp.js → vm-hands-entry-lite-k278g9kj.js} +5 -5
  59. package/bin/vm-hands/{vm-hands-entry-lite-hcw5tk5d.js → vm-hands-entry-lite-m11j0f9q.js} +2 -2
  60. package/bin/vm-hands/{vm-hands-entry-lite-0n2f3kx7.js → vm-hands-entry-lite-pgb514h0.js} +2 -2
  61. package/bin/vm-hands/{vm-hands-entry-lite-dq1m5ykp.js → vm-hands-entry-lite-q0k6kx6d.js} +4 -4
  62. package/bin/vm-hands/{vm-hands-entry-lite-gc7c22pq.js → vm-hands-entry-lite-qysyf65v.js} +1 -1
  63. package/bin/vm-hands/{vm-hands-entry-lite-762fbns7.js → vm-hands-entry-lite-r29k28kb.js} +2 -2
  64. package/bin/vm-hands/vm-hands-entry-lite-vrqzr15t.js +3 -0
  65. package/bin/vm-hands/{vm-hands-entry-lite-6whxyzz2.js → vm-hands-entry-lite-w59z67hf.js} +5 -5
  66. package/bin/vm-hands/{vm-hands-entry-lite-w9ckj5k4.js → vm-hands-entry-lite-zg36myyf.js} +4 -4
  67. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  68. package/bin/vm-hands/{vm-hands-executor-79av9nam.js → vm-hands-executor-rdmj1wv4.js} +6 -6
  69. package/bin/vm-hands/vm-hands-op-runner-f2bjvb7v.js +2 -0
  70. package/bin/vm-hands/{vm-hands-runtime-yacvv937.js → vm-hands-runtime-aa4p4pqz.js} +3 -3
  71. package/bin/vm-hands/worker-sandbox-smqj3mbe.js +2 -0
  72. package/package.json +1 -1
  73. package/bin/vm-hands/api-8d760ppa.js +0 -2
  74. package/bin/vm-hands/api-credentials-eea1g4aw.js +0 -2
  75. package/bin/vm-hands/connect-cli-m8xafyn5.js +0 -2
  76. package/bin/vm-hands/custom-endpoint-device-nfjhs9fv.js +0 -2
  77. package/bin/vm-hands/desktop-account-rx4ajy2j.js +0 -2
  78. package/bin/vm-hands/device-workspace-n9tn4bzw.js +0 -2
  79. package/bin/vm-hands/hands-worker-source-yxsap3qk.js +0 -2
  80. package/bin/vm-hands/install-receipt-rmsjtfqy.js +0 -2
  81. package/bin/vm-hands/local-automation-7qcnytj6.js +0 -2
  82. package/bin/vm-hands/local-capabilities-hchsc804.js +0 -2
  83. package/bin/vm-hands/local-desktop-users-c6858avg.js +0 -2
  84. package/bin/vm-hands/local-display-mac-zmbp9z4c.js +0 -2
  85. package/bin/vm-hands/local-display-session-7bgp7gvf.js +0 -2
  86. package/bin/vm-hands/local-pty-session-8m175hqx.js +0 -2
  87. package/bin/vm-hands/managed-runtime-nkmg5s5h.js +0 -2
  88. package/bin/vm-hands/network-contract-qt2s82ap.js +0 -2
  89. package/bin/vm-hands/package-11mkdcmn.js +0 -2
  90. package/bin/vm-hands/permissions-67xv16a5.js +0 -2
  91. package/bin/vm-hands/reason-hands-protocol-r356wr4t.js +0 -2
  92. package/bin/vm-hands/serve-service-4n7e0b08.js +0 -2
  93. package/bin/vm-hands/status-e7r62q4e.js +0 -10
  94. package/bin/vm-hands/version-vdev7tyq.js +0 -2
  95. package/bin/vm-hands/vm-hands-entry-lite-8bzqc4xa.js +0 -2
  96. package/bin/vm-hands/vm-hands-entry-lite-qffs74x1.js +0 -540
  97. package/bin/vm-hands/vm-hands-entry-lite-rwr09j4w.js +0 -3
  98. package/bin/vm-hands/vm-hands-entry-lite-w8kc4jtb.js +0 -3
  99. package/bin/vm-hands/vm-hands-op-runner-kh1myd15.js +0 -2
  100. package/bin/vm-hands/worker-sandbox-x8dsz324.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Nr,Pn,Lr,Tn}from"./vm-hands-entry-lite-qysyf65v.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";export{Nr as installationReceiptPath,Lr as installerReasonAlias,Pn as installerReceiptLauncher,Tn as loadInstallationReceipt};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{mn,ss,as,cs,ls,gn}from"./vm-hands-entry-lite-80y72d0e.js";import"./vm-hands-entry-lite-05rrh8yg.js";import"./vm-hands-entry-lite-1rtkf2xm.js";import"./vm-hands-entry-lite-q0k6kx6d.js";import"./vm-hands-entry-lite-bdhjpv7g.js";import"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-f5e3dbgk.js";import"./vm-hands-entry-lite-46fkv5sp.js";import"./vm-hands-entry-lite-qysyf65v.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-r29k28kb.js";import"./vm-hands-entry-lite-eqgj4acy.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-k278g9kj.js";import"./vm-hands-entry-lite-gvwdy3rf.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";export{as as ensureLocalBrowser,mn as localAutomationAvailable,cs as localBrowserProfile,ss as localUserChromeHost,ls as runAutomationCallLocally,gn as runLocalAutomation};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xo,vi,en,ko,Co,es,ts,Ao,Po,rs,ns,is,os}from"./vm-hands-entry-lite-bk6akkdt.js";import"./vm-hands-entry-lite-70ba2bqj.js";import"./vm-hands-entry-lite-9c95p6n9.js";import"./vm-hands-entry-lite-b885gwfh.js";import"./vm-hands-entry-lite-88swf2qr.js";import"./vm-hands-entry-lite-09m2cdkw.js";import"./vm-hands-entry-lite-ab2m9erf.js";import"./vm-hands-entry-lite-80y72d0e.js";import"./vm-hands-entry-lite-05rrh8yg.js";import"./vm-hands-entry-lite-1rtkf2xm.js";import"./vm-hands-entry-lite-q0k6kx6d.js";import"./vm-hands-entry-lite-bdhjpv7g.js";import"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-f5e3dbgk.js";import"./vm-hands-entry-lite-46fkv5sp.js";import"./vm-hands-entry-lite-qysyf65v.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-r29k28kb.js";import"./vm-hands-entry-lite-eqgj4acy.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-k278g9kj.js";import"./vm-hands-entry-lite-gvwdy3rf.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";export{r as LocalCapabilityError,xo as SHORT_REQUEST_CAPABILITIES,rs as capabilityInventoryForRoots,vi as confinedExecutionShell,ko as defaultLocalCommandRunner,ns as deliverLocalHandsEnvironment,Po as enrolledRootPaths,os as executeLocalOperation,ts as grantLocalHandsWorkspaceControl,es as openHandsWorkspaceGrant,is as rebindLocalHandsControl,Co as runFileCapability,Ao as runTransferCapability,en as spawnCaptured};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{gt,Us,Hs,gi,_i}from"./vm-hands-entry-lite-gvwdy3rf.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";export{Us as forgetLocalDesktopUse,_i as holdLocalDesktop,gt as noteLocalDesktopUse,Hs as releaseLocalDesktop,gi as trackDesktopRun};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ze,st,Dn,Nn}from"./vm-hands-entry-lite-eqgj4acy.js";export{ze as macScreenStatus,Nn as openMacInput,Dn as openMacWindowBounds,st as requestMacScreenAccess};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{At,us,V,Be,Pt}from"./vm-hands-entry-lite-05rrh8yg.js";import"./vm-hands-entry-lite-1rtkf2xm.js";import"./vm-hands-entry-lite-q0k6kx6d.js";import"./vm-hands-entry-lite-bdhjpv7g.js";import"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-f5e3dbgk.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-r29k28kb.js";import"./vm-hands-entry-lite-eqgj4acy.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-gvwdy3rf.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";export{Be as ensureLinuxDesktop,At as localDisplayAvailable,us as localDisplayReady,V as privateDirectory,Pt as runLocalDisplayStream};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{wr,Tt,br,Ro,_n,vr,yn}from"./vm-hands-entry-lite-1rtkf2xm.js";import"./vm-hands-entry-lite-q0k6kx6d.js";import"./vm-hands-entry-lite-bdhjpv7g.js";import"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";export{Tt as LOCAL_PTY_MAX_BUFFERED_OUTPUT_BYTES,br as LOCAL_PTY_MAX_SESSIONS,wr as LOCAL_PTY_MAX_SESSION_MS,vr as defaultConnect,Ro as defaultLoginShell,_n as ptyRuntimeSupported,yn as runLocalPtySession};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Go,Ko,Jo,Zo,Xo,Yo,Qo}from"./vm-hands-entry-lite-1sg8sdw5.js";import"./vm-hands-entry-lite-09m2cdkw.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";export{Xo as acquireManagedRuntimeDirectoryLock,Jo as currentManagedRuntimeVersion,Qo as flushManagedRuntimeLifecycleEvents,Zo as isManagedRuntimeVersionExecutable,Ko as legacyManagedRuntimePaths,Go as managedRuntimePaths,Yo as recordManagedRuntimeLifecycle};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ge,Ce,vs,Ss,Es,Bn,xs,Vr,Fn,dt,Ae,pt,jn,Un,Hn,qn,zn,Wn,Vn,Gn,Kn,Jn,Zn,Xn,Yn,Qn,ei,ti,pe,X,Pe,q,ri,ni,ii,Y,oi,si,ai,ci,li,ht,ui,ks,Gt,di,Cs,No,As,Ps,Ts,Rs,Os,Is,Ds,Ns,Ls,Ms,$s,Bs,Fs,js}from"./vm-hands-entry-lite-k278g9kj.js";export{ui as AUTOMATION_CLOUD_SESSIONS,ht as AUTOMATION_USER_CHROME,Zn as HANDS_CLOUD_ACCESS,Xn as HANDS_CLOUD_ACCESS_KEY,pe as HANDS_CONFINEMENT,X as HANDS_CONFINEMENT_KEY,Un as HANDS_ENVIRONMENT_AT_CLAIM,Hn as HANDS_ENVIRONMENT_AT_CLAIM_KEY,Fn as HANDS_ENVIRONMENT_DELIVERY,dt as HANDS_ENVIRONMENT_DELIVER_CONTROL,Yn as HANDS_HEADLESS_BROWSER,Qn as HANDS_HEADLESS_BROWSER_KEY,ri as HANDS_JOBS_USER,ni as HANDS_JOBS_USER_KEY,ei as HANDS_LARGE_ENVIRONMENT,ti as HANDS_LARGE_ENVIRONMENT_KEY,Pe as HANDS_MODEL_JOBS_EGRESS,q as HANDS_MODEL_JOBS_EGRESS_KEY,Wn as HANDS_REBIND,Jn as HANDS_REBIND_CONTROL,Kn as HANDS_REBIND_KEY,oi as HANDS_SESSION_CAP_KEY,si as HANDS_SESSION_CAP_NONE,ii as HANDS_SESSION_GROUP,Y as HANDS_SESSION_GROUP_KEY,qn as HANDS_WORKSPACE_CHECK,zn as HANDS_WORKSPACE_CHECK_KEY,Vn as HANDS_WORKSPACE_GRANT,Gn as HANDS_WORKSPACE_GRANT_KEY,ci as JOBS_START_WAIT,li as JOBS_START_WAIT_KEY,Ce as LOCAL_OPERATION_MAX_BYTES,Ge as LOCAL_RUNTIME_PROTOCOL_VERSION,Es as LOCAL_RUNTIME_ROUTES,Vr as LOCAL_RUNTIME_SESSION_CLAIM_WAIT_MAX_MS,Bn as LOCAL_RUNTIME_SESSION_PATH,Gt as LOCAL_RUNTIME_WORKER_STARTUP_MAX_MS,vs as RELAY_HOST_ALIAS_HEADER,Ss as RELAY_HOST_ALIAS_VERSION,jn as VM_HANDS_UNBIND_UNVERIFIED_EVENT,Ae as VM_HANDS_WORKSPACE_DEFERRED_KEY,pt as VM_HANDS_WORKSPACE_GRANT_CONTROL,ai as WORKER_PREVIEW_CARRIED_JOBS,ks as WORKER_STARTUP_TIMING_STAGES,di as buildLocalRuntimeDeviceProofBytes,xs as localRuntimeSessionRoutable,Ds as parseLocalRuntimeDisconnectResponse,Ps as parseLocalRuntimeEnrollmentResponse,Cs as parseLocalRuntimeErrorEnvelope,Rs as parseLocalRuntimeFirstHeartbeat,Ts as parseLocalRuntimeHeartbeatResponse,Is as parseLocalRuntimeIdentityResponse,Ls as parseLocalRuntimeLifecycleResponse,Ns as parseLocalRuntimeLocalSubscriptionResponse,Ms as parseLocalRuntimeOperationClaim,js as parseLocalRuntimeOperationCompletionResponse,Fs as parseLocalRuntimeOperationEnvironmentResponse,Bs as parseLocalRuntimeOperationEventsResponse,$s as parseLocalRuntimeOperationHeartbeatResponse,No as parseLocalRuntimeProofChallenge,As as parseLocalRuntimeRegistrationResponse,Os as parseLocalRuntimeRootsSyncResponse};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Yr}from"./vm-hands-entry-lite-6aeea05q.js";export default Yr();
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Io,Do,ys,bs}from"./vm-hands-entry-lite-r29k28kb.js";import"./vm-hands-entry-lite-eqgj4acy.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";export{bs as allowMacPermissions,ys as permissionsSummary,Do as readMacPermissions,Io as reasonIdentity};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{k,kr,Cr,wn,tt,bn,Ar,je,ye,vn,Ue,Nt,te,He,Sn,we,Lt,Pr,Mt,Tr,En,ae,U,N,ce,Rr,Or,xn}from"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-8t9xssf9.js";export{Tr as REASON_HANDS_CLOSE_CODES,Ue as REASON_HANDS_JOB_CONTROL_MAX_FRAME_BYTES,Ar as REASON_HANDS_JOB_MAX_INPUT_CHARS,je as REASON_HANDS_JOB_MAX_OUTPUT_CHARS,ye as REASON_HANDS_JOB_MAX_OUTPUT_CHUNKS,vn as REASON_HANDS_JOB_MAX_RECORDS,bn as REASON_HANDS_MAX_ERROR_CHARS,kr as REASON_HANDS_MAX_FRAME_BYTES,Cr as REASON_HANDS_MAX_INPUT_CHARS,tt as REASON_HANDS_MAX_OUTPUT_CHARS,wn as REASON_HANDS_MAX_STRUCTURED_INPUT_CHARS,k as REASON_HANDS_PROTOCOL_VERSION,Pr as REASON_HANDS_PTY_ANCHOR_EXIT_MS,Mt as REASON_HANDS_PTY_CLEANUP_RECEIPT_MS,Lt as REASON_HANDS_PTY_CLEANUP_SWEEP_MS,we as REASON_HANDS_PTY_MAX_DIMENSION,te as REASON_HANDS_PTY_MAX_INPUT_BYTES,He as REASON_HANDS_PTY_MAX_OUTPUT_BYTES,Sn as REASON_HANDS_PTY_MAX_PENDING_INPUT_BYTES,Nt as REASON_HANDS_PTY_PROTOCOL_VERSION,En as REASON_HANDS_WORKSPACE_BEFORE_MAX_OUTPUT_CHARS,U as isReasonHandsGeneration,ce as isReasonHandsPtyJobId,ae as isReasonHandsRequestId,N as isReasonHandsUuid,Rr as parseReasonHandsJobRequest,Or as parseReasonHandsJobResult,xn as parseReasonHandsPtyReceipt};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ir,be,K,Cn,ps,Wi,hs,qe,Oo,An,fs,ms,Dr,gs,_s}from"./vm-hands-entry-lite-46fkv5sp.js";import"./vm-hands-entry-lite-qysyf65v.js";import"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-t7an5zg2.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-89z488gz.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-9ay6f56v.js";import"./vm-hands-entry-lite-m11j0f9q.js";export{Ir as WORKER_SERVICE_ENV,K as WorkerServiceError,Wi as connectServiceLabel,be as defaultWorkerServiceHost,ms as installWorkerService,qe as installedWorkerService,hs as isConnectServiceLabel,_s as removeWorkerService,Dr as restartWorkerService,gs as retargetWorkerServiceLogs,Oo as retireLegacyWorkerService,fs as workerServiceDefinitionCurrent,Cn as workerServiceLauncher,An as workerServiceProcessRunning,ps as workerServiceRetargetPending};
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ import"./vm-hands-entry-lite-zg36myyf.js";import"./vm-hands-entry-lite-t7an5zg2.js";import{g}from"./vm-hands-entry-lite-ckv17tn8.js";import"./vm-hands-entry-lite-8t9xssf9.js";import"./vm-hands-entry-lite-m11j0f9q.js";import"./vm-hands-entry-lite-1cwqa4jr.js";import{Ot,et}from"./vm-hands-entry-lite-q0k6kx6d.js";import{w,M,Xt,De,Ke}from"./vm-hands-entry-lite-w59z67hf.js";import"./vm-hands-entry-lite-k278g9kj.js";import"./vm-hands-entry-lite-bk6akkdt.js";import"./vm-hands-entry-lite-70ba2bqj.js";import"./vm-hands-entry-lite-0g9xvgdy.js";import"./vm-hands-entry-lite-88swf2qr.js";import"./vm-hands-entry-lite-b885gwfh.js";import"./vm-hands-entry-lite-vrqzr15t.js";import"./vm-hands-entry-lite-05rrh8yg.js";import"./vm-hands-entry-lite-eqgj4acy.js";import"./vm-hands-entry-lite-10sbjfzx.js";import"./vm-hands-entry-lite-r29k28kb.js";import"./vm-hands-entry-lite-f5e3dbgk.js";import"./vm-hands-entry-lite-1sg8sdw5.js";import"./vm-hands-entry-lite-qysyf65v.js";import"./vm-hands-entry-lite-46fkv5sp.js";import"./vm-hands-entry-lite-ab2m9erf.js";import"./vm-hands-entry-lite-22kfyvnk.js";import"./vm-hands-entry-lite-9c95p6n9.js";import"./vm-hands-entry-lite-bdhjpv7g.js";import"./vm-hands-entry-lite-gvwdy3rf.js";import"./vm-hands-entry-lite-1rtkf2xm.js";import"./vm-hands-entry-lite-80y72d0e.js";import"./vm-hands-entry-lite-09m2cdkw.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-907pa7f9.js";import"./vm-hands-entry-lite-9ay6f56v.js";import{readFileSync as me,realpathSync as k,renameSync as ge,unlinkSync as fe,writeFileSync as he}from"fs";import{dirname as ye,join as I}from"path";function h(e){return`claude mcp add --transport http reason ${e}`}function C(e){return`codex mcp add reason --url ${e}
3
+ codex mcp login reason`}var F=h("https://mcp.reasonmachines.com/mcp"),z=C("https://mcp.reasonmachines.com/mcp"),B=`https://claude.ai/settings/connectors?add=custom&url=${encodeURIComponent("https://mcp.reasonmachines.com/mcp")}`,H=`https://cursor.com/install-mcp?name=reason&config=${encodeURIComponent(btoa(JSON.stringify({url:"https://mcp.reasonmachines.com/mcp"})))}`;var b="https://github.com/reason-machines/reason-plugins",X=`Connect a coding agent to Reason over MCP
4
+
5
+ Usage:
6
+ reason mcp Show how to connect Claude Code, Codex, or another MCP client
7
+ reason mcp uninstall Remove only this machine's registrations of the earlier, retired server
8
+
9
+ Plugins for Claude Code and Codex: ${b}
10
+ `;var P=s(["granted","not_granted","unknown"]),y=i({status:P,checkedAt:o().finite(),executablePath:t().min(1)});var Oe=i({version:n(1),key:t(),at:o(),self:i({principal_type:t(),user_id:t().optional(),user_name:t().nullish(),email:t().nullish(),org_id:t(),organization_name:t().nullish(),organization_slug:t().nullish(),mcp_connections:u(i({client_id:t(),client_name:t(),last_used_at:t().nullable()})).optional()})});var x=30000;function L(e,c=Date.now(),R=null){let r=et(e),d=(()=>{if(r?.state!=="connected"&&r?.state!=="starting")return!1;try{return process.kill(r.pid,0),!0}catch{return!1}})(),S=d&&r?.state==="connected",p=(f)=>S&&c-f>=0&&c-f<x,l=y.safeParse(r?.fullDiskAccess),m=Ot(r,R,c);return{...m?{permission_recovery:m}:{},full_disk_access:l.success&&p(l.data.checkedAt)?l.data.status:"unknown",keep_awake:{enabled:Xt(e)==="battery_and_ac",holding:r?.idleSleepHold===!0&&p(Date.parse(r.lastHeartbeatAt??""))},executable:d&&l.success?l.data.executablePath:null}}function Ne(e=g()){if(process.platform!=="darwin")return null;let c=De(I(Ke(k(a()),e),"worker.json"));return c?L(w(c).daemon,Date.now(),M(c)):null}export{Ne as connectionMacState};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ct}from"./vm-hands-entry-lite-0g9xvgdy.js";export{ct as CLI_VERSION};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{v,Tn,no,$r,Rn,qe,On,In}from"./vm-hands-entry-lite-8evzzh7v.js";import{Nn}from"./vm-hands-entry-lite-wf7ksh4e.js";import{En}from"./vm-hands-entry-lite-v3xznxcw.js";import{ft}from"./vm-hands-entry-lite-8gtgr399.js";import{wr}from"./vm-hands-entry-lite-pn92kh7b.js";import{j}from"./vm-hands-entry-lite-dq1m5ykp.js";import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as Cs,spawn as kr}from"child_process";import{randomBytes as Ns}from"crypto";import{chmodSync as vs,existsSync as Xr,lstatSync as Ls,mkdirSync as Ms,readFileSync as Qs,rmSync as Us,writeFileSync as at}from"fs";import{connect as Os}from"net";import{join as X}from"path";var _t="./desktop-wallpaper-0pjhgyfk.jpg";var wt="./dock-browser-afp005mt.png";var Pt="./dock-files-rywdm96b.png";var qt="./dock-terminal-s41cj1jp.png";var Et=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
2
+ import{v,On,oo,Fr,In,ze,Dn,Nn}from"./vm-hands-entry-lite-eqgj4acy.js";import{Mn}from"./vm-hands-entry-lite-10sbjfzx.js";import{kn}from"./vm-hands-entry-lite-f5e3dbgk.js";import{gt}from"./vm-hands-entry-lite-gvwdy3rf.js";import{vr}from"./vm-hands-entry-lite-1rtkf2xm.js";import{j}from"./vm-hands-entry-lite-q0k6kx6d.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as Cs,spawn as Ar}from"child_process";import{randomBytes as Ns}from"crypto";import{chmodSync as vs,existsSync as kr,lstatSync as Ls,mkdirSync as Ms,readFileSync as Qs,rmSync as Us,writeFileSync as at}from"fs";import{connect as Os}from"net";import{join as X}from"path";var St="./desktop-wallpaper-0pjhgyfk.jpg";var _t="./dock-browser-afp005mt.png";var wt="./dock-files-rywdm96b.png";var qt="./dock-terminal-s41cj1jp.png";var Et=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
3
3
  # The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
4
4
  # python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
5
5
  # Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
@@ -118,9 +118,9 @@ Exec=bash -c "DISPLAY=:99 pcmanfm --no-desktop"
118
118
  Icon=/tmp/ara-dock-files.png
119
119
  Type=Application
120
120
  Categories=System;FileManager;
121
- `;var Tt={"wallpaper.jpg":_t,"dock-browser.png":wt,"dock-terminal.png":qt,"dock-files.png":Pt},en=Et,tn='set_wallpaper() { if command -v feh >/dev/null 2>&1; then feh --bg-fill "$1"; else python3 "$2" "$1"; fi; }';function Rt(e){let t=(p)=>p.replaceAll("DISPLAY=:99",`DISPLAY=${e.display}`).replaceAll("/tmp/ara-",`${e.root}/ara-`),n=new Set(e.absent??[]),o=Kr.split(`
121
+ `;var Tt={"wallpaper.jpg":St,"dock-browser.png":_t,"dock-terminal.png":qt,"dock-files.png":wt},en=Et,tn='set_wallpaper() { if command -v feh >/dev/null 2>&1; then feh --bg-fill "$1"; else python3 "$2" "$1"; fi; }';function Rt(e){let t=(p)=>p.replaceAll("DISPLAY=:99",`DISPLAY=${e.display}`).replaceAll("/tmp/ara-",`${e.root}/ara-`),n=new Set(e.absent??[]),o=Kr.split(`
122
122
  `).filter((p)=>!(n.has("terminal")&&p.endsWith("/ara-terminal.desktop"))&&!(n.has("files")&&p.endsWith("/ara-files.desktop"))).join(`
123
- `);return{files:{"openbox/rc.xml":Vr(e.screen),"tint2/tint2rc":t(o),"picom/picom.conf":Ir,...n.has("terminal")?{}:{"ara-terminal.desktop":t(zr)},...n.has("files")?{}:{"ara-files.desktop":t(Hr)},"ara-chromium.desktop":t(Yr).replace("chromium --no-sandbox %U",e.browserExec),"ara-set-root-wallpaper.py":en},start:['ticks() { line=$(cat "/proc/$1/stat" 2>/dev/null) || return 1; rest=${line##*) }; case $rest in Z*|X*) return 1;; esac; printf "%s" "$rest" | cut -d " " -f20; }','alive() { [ -f "$ROOT/$1.pid" ] || return 1; read -r pid start <"$ROOT/$1.pid"; current=$(ticks "$pid") || return 1; [ "$current" = "$start" ] && kill -0 "$pid" 2>/dev/null; }','launch() { name=$1; shift; "$@" 9>&- >"$ROOT/$name.log" 2>&1 & pid=$!; start=$(ticks "$pid"); printf "%s %s\\n" "$pid" "$start" >"$ROOT/$name.pid"; }',tn,'[ ! -f "$ROOT/ara-wallpaper.jpg" ] || set_wallpaper "$ROOT/ara-wallpaper.jpg" "$ROOT/ara-set-root-wallpaper.py" || true','if ! alive tint2 && command -v tint2 >/dev/null 2>&1; then launch tint2 tint2 -c "$ROOT/tint2/tint2rc"; fi','if ! alive picom && command -v picom >/dev/null 2>&1; then launch picom picom --config "$ROOT/picom/picom.conf"; fi']}}import{createHash as Ft}from"crypto";import{once as dn}from"events";import{createWriteStream as bn,existsSync as vo,mkdirSync as Lo,mkdtempSync as Mo,readFileSync as ye,readdirSync as Qo,renameSync as Uo,realpathSync as xn,rmSync as yn,statSync as Fe,writeFileSync as Oo}from"fs";import{delimiter as Jo,dirname as $t,join as g}from"path";import{finished as mn}from"stream/promises";var Me="omljlfpmafedpplnpkkahegadhkimdje",$i="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var U={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},J={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var ie={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${U.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${U.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${U.obu.version}/open-browser-use-chrome-extension-${U.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Ue}from"child_process";import{createRequire as rn}from"module";import{join as nn}from"path";var sn=30000,on=1048576;function Oe(){return process.env.SystemRoot??"C:\\Windows"}function an(){return nn(Oe(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var pn=String.raw`
123
+ `);return{files:{"openbox/rc.xml":Vr(e.screen),"tint2/tint2rc":t(o),"picom/picom.conf":Ir,...n.has("terminal")?{}:{"ara-terminal.desktop":t(zr)},...n.has("files")?{}:{"ara-files.desktop":t(Hr)},"ara-chromium.desktop":t(Yr).replace("chromium --no-sandbox %U",e.browserExec),"ara-set-root-wallpaper.py":en},start:['ticks() { line=$(cat "/proc/$1/stat" 2>/dev/null) || return 1; rest=${line##*) }; case $rest in Z*|X*) return 1;; esac; printf "%s" "$rest" | cut -d " " -f20; }','alive() { [ -f "$ROOT/$1.pid" ] || return 1; read -r pid start <"$ROOT/$1.pid"; current=$(ticks "$pid") || return 1; [ "$current" = "$start" ] && kill -0 "$pid" 2>/dev/null; }','launch() { name=$1; shift; "$@" 9>&- >"$ROOT/$name.log" 2>&1 & pid=$!; start=$(ticks "$pid"); printf "%s %s\\n" "$pid" "$start" >"$ROOT/$name.pid"; }',tn,'[ ! -f "$ROOT/ara-wallpaper.jpg" ] || set_wallpaper "$ROOT/ara-wallpaper.jpg" "$ROOT/ara-set-root-wallpaper.py" || true','if ! alive tint2 && command -v tint2 >/dev/null 2>&1; then launch tint2 tint2 -c "$ROOT/tint2/tint2rc"; fi','if ! alive picom && command -v picom >/dev/null 2>&1; then launch picom picom --config "$ROOT/picom/picom.conf"; fi']}}import{createHash as Ft}from"crypto";import{once as dn}from"events";import{createWriteStream as bn,existsSync as vo,mkdirSync as Lo,mkdtempSync as Mo,readFileSync as ye,readdirSync as Qo,renameSync as Uo,realpathSync as xn,rmSync as yn,statSync as Fe,writeFileSync as Oo}from"fs";import{delimiter as Jo,dirname as $t,join as g}from"path";import{finished as mn}from"stream/promises";var $e="omljlfpmafedpplnpkkahegadhkimdje",Fi="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var U={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},J={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var ie={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${U.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${U.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${U.obu.version}/open-browser-use-chrome-extension-${U.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as rn}from"module";import{join as nn}from"path";var sn=30000,on=1048576;function Ue(){return process.env.SystemRoot??"C:\\Windows"}function an(){return nn(Ue(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var pn=String.raw`
124
124
  $ErrorActionPreference = "Stop"
125
125
  Add-Type -TypeDefinition @"
126
126
  using System;
@@ -185,20 +185,20 @@ while ($null -ne ($line = [Console]::In.ReadLine())) {
185
185
  }
186
186
  } catch { [Console]::Error.WriteLine("input: $_") }
187
187
  }
188
- `;function Be(e){let t=pn.replace("__MODE__",e).replace("__PARENT__",String(process.pid)).replace("__MAX_TEXT_BYTES__",String(v));return[an(),["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(t,"utf16le").toString("base64")]]}var cn=["USERPROFILE","LOCALAPPDATA","APPDATA","TEMP","TMP","PSModuleAnalysisCachePath"];function Je(){let e=cn.flatMap((t)=>process.env[t]?[[t,process.env[t]]]:[]);return{...Object.fromEntries(e),SystemRoot:Oe(),windir:Oe()}}function Qt(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=="object")return null;let n=t,o=(s,i)=>typeof s==="number"&&Number.isSafeInteger(s)&&s>=i;return o(n.session,0)&&o(n.width,1)&&o(n.height,1)?{session:n.session,width:n.width,height:n.height}:null}function Ut(){return new Promise((e)=>{let t=Ue(...Be("probe"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0}),n="",o=setTimeout(()=>{t.kill("SIGKILL"),e(null)},sn);t.stdout.setEncoding("utf8").on("data",(s)=>{n+=s}),t.once("error",()=>{clearTimeout(o),e(null)}),t.once("close",()=>{clearTimeout(o),e(Qt(n.split(/\r?\n/)[0]??""))})})}var ae;function Ot(){if(ae!==void 0)return ae;if(process.platform!=="win32")return ae=!1;try{let e=rn(import.meta.url)("bun:ffi"),{symbols:t}=e.dlopen("kernel32.dll",{GetCurrentProcessId:{args:[],returns:e.FFIType.u32},ProcessIdToSessionId:{args:[e.FFIType.u32,e.FFIType.ptr],returns:e.FFIType.i32}}),n=new Uint32Array(1);return ae=t.ProcessIdToSessionId(t.GetCurrentProcessId(),n)!==0&&n[0]>0}catch{return ae=!1}}var At=[{bit:1,down:2,up:4},{bit:2,down:32,up:64},{bit:4,down:8,up:16}],Xt=2048,Nt=4096,ln=[[8,Xt,120],[16,Xt,-120],[32,Nt,-120],[64,Nt,120]],vt=1,Qe=2,un=4,fn=new Set([65505,65506]),Lt=new Set([65507,65508,65511,65512,65513,65514,65027,65515,65516]),Mt=new Map([[65505,[160,!1]],[65506,[161,!1]],[65507,[162,!1]],[65508,[163,!0]],[65511,[164,!1]],[65512,[165,!0]],[65513,[164,!1]],[65514,[165,!0]],[65027,[165,!0]],[65515,[91,!0]],[65516,[92,!0]],[65288,[8,!1]],[65289,[9,!1]],[65056,[9,!1]],[65293,[13,!1]],[65307,[27,!1]],[65535,[46,!0]],[65379,[45,!0]],[65360,[36,!0]],[65367,[35,!0]],[65365,[33,!0]],[65366,[34,!0]],[65361,[37,!0]],[65362,[38,!0]],[65363,[39,!0]],[65364,[40,!0]],[65383,[93,!0]],[65509,[20,!1]],[65299,[19,!1]],[65300,[145,!1]],[65377,[44,!0]],[65407,[144,!0]],[32,[32,!1]],[65421,[13,!0]],[65408,[32,!1]],[65450,[106,!1]],[65451,[107,!1]],[65452,[108,!1]],[65453,[109,!1]],[65454,[110,!1]],[65455,[111,!0]],[65429,[36,!1]],[65430,[37,!1]],[65431,[38,!1]],[65432,[39,!1]],[65433,[40,!1]],[65434,[33,!1]],[65435,[34,!1]],[65436,[35,!1]],[65438,[45,!1]],[65439,[46,!1]],...Array.from({length:10},(e,t)=>[65456+t,[96+t,!1]]),...Array.from({length:24},(e,t)=>[65470+t,[112+t,!1]])]);class Bt{x=-1;y=-1;mask=0;held=new Set;pressed=new Set;pointer(e,t,n){let o=[];if(e!==this.x||t!==this.y)this.x=e,this.y=t,o.push(`p ${e} ${t}`);for(let s of At){let i=(this.mask&s.bit)!==0,p=(n&s.bit)!==0;if(i!==p)o.push(`b ${p?s.down:s.up} 0`)}for(let[s,i,p]of ln)if(!(this.mask&s)&&n&s)o.push(`b ${i} ${p}`);return this.mask=n,o}key(e,t){let n=e?0:Qe;if(fn.has(t)||Lt.has(t))if(e)this.held.add(t);else this.held.delete(t);let o=Mt.get(t);if(o)return[`k ${o[0]} 0 ${n|(o[1]?vt:0)}`];let s=t<256?t:(t&4278190080)===16777216?t&16777215:0,i=String.fromCharCode(s),p=[...this.held].some((h)=>Lt.has(h)),l=/^[A-Za-z0-9]$/.test(i)?i.toUpperCase().charCodeAt(0):0;if(l&&(e?p:this.pressed.has(l))){if(e)this.pressed.add(l);else this.pressed.delete(l);return[`k ${l} 0 ${n}`]}if(s<33||s>=127&&s<160||s>65535||s>=55296&&s<57344)return[];return[`k 0 ${s} ${n|un}`]}release(){let e=At.filter((t)=>this.mask&t.bit).map((t)=>`b ${t.up} 0`);for(let t of this.pressed)e.push(`k ${t} 0 ${Qe}`);for(let t of this.held){let[n,o]=Mt.get(t);e.push(`k ${n} 0 ${Qe|(o?vt:0)}`)}return this.mask=0,this.pressed.clear(),this.held.clear(),e}}function Jt(e){let t=Ue(...Be("input"),{env:Je(),stdio:["pipe","pipe","ignore"],windowsHide:!0}),n=new Bt,o="",s=!1,i=null,p=()=>{if(i?.kill("SIGKILL"),t.exitCode!==null||t.signalCode!==null)return;t.stdin.end(n.release().map((u)=>`${u}
188
+ `;function Oe(e){let t=pn.replace("__MODE__",e).replace("__PARENT__",String(process.pid)).replace("__MAX_TEXT_BYTES__",String(v));return[an(),["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(t,"utf16le").toString("base64")]]}var cn=["USERPROFILE","LOCALAPPDATA","APPDATA","TEMP","TMP","PSModuleAnalysisCachePath"];function Je(){let e=cn.flatMap((t)=>process.env[t]?[[t,process.env[t]]]:[]);return{...Object.fromEntries(e),SystemRoot:Ue(),windir:Ue()}}function Qt(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=="object")return null;let n=t,o=(s,i)=>typeof s==="number"&&Number.isSafeInteger(s)&&s>=i;return o(n.session,0)&&o(n.width,1)&&o(n.height,1)?{session:n.session,width:n.width,height:n.height}:null}function Ut(){return new Promise((e)=>{let t=Me(...Oe("probe"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0}),n="",o=setTimeout(()=>{t.kill("SIGKILL"),e(null)},sn);t.stdout.setEncoding("utf8").on("data",(s)=>{n+=s}),t.once("error",()=>{clearTimeout(o),e(null)}),t.once("close",()=>{clearTimeout(o),e(Qt(n.split(/\r?\n/)[0]??""))})})}var ae;function Ot(){if(ae!==void 0)return ae;if(process.platform!=="win32")return ae=!1;try{let e=rn(import.meta.url)("bun:ffi"),{symbols:t}=e.dlopen("kernel32.dll",{GetCurrentProcessId:{args:[],returns:e.FFIType.u32},ProcessIdToSessionId:{args:[e.FFIType.u32,e.FFIType.ptr],returns:e.FFIType.i32}}),n=new Uint32Array(1);return ae=t.ProcessIdToSessionId(t.GetCurrentProcessId(),n)!==0&&n[0]>0}catch{return ae=!1}}var kt=[{bit:1,down:2,up:4},{bit:2,down:32,up:64},{bit:4,down:8,up:16}],Xt=2048,Nt=4096,ln=[[8,Xt,120],[16,Xt,-120],[32,Nt,-120],[64,Nt,120]],vt=1,Le=2,un=4,fn=new Set([65505,65506]),Lt=new Set([65507,65508,65511,65512,65513,65514,65027,65515,65516]),Mt=new Map([[65505,[160,!1]],[65506,[161,!1]],[65507,[162,!1]],[65508,[163,!0]],[65511,[164,!1]],[65512,[165,!0]],[65513,[164,!1]],[65514,[165,!0]],[65027,[165,!0]],[65515,[91,!0]],[65516,[92,!0]],[65288,[8,!1]],[65289,[9,!1]],[65056,[9,!1]],[65293,[13,!1]],[65307,[27,!1]],[65535,[46,!0]],[65379,[45,!0]],[65360,[36,!0]],[65367,[35,!0]],[65365,[33,!0]],[65366,[34,!0]],[65361,[37,!0]],[65362,[38,!0]],[65363,[39,!0]],[65364,[40,!0]],[65383,[93,!0]],[65509,[20,!1]],[65299,[19,!1]],[65300,[145,!1]],[65377,[44,!0]],[65407,[144,!0]],[32,[32,!1]],[65421,[13,!0]],[65408,[32,!1]],[65450,[106,!1]],[65451,[107,!1]],[65452,[108,!1]],[65453,[109,!1]],[65454,[110,!1]],[65455,[111,!0]],[65429,[36,!1]],[65430,[37,!1]],[65431,[38,!1]],[65432,[39,!1]],[65433,[40,!1]],[65434,[33,!1]],[65435,[34,!1]],[65436,[35,!1]],[65438,[45,!1]],[65439,[46,!1]],...Array.from({length:10},(e,t)=>[65456+t,[96+t,!1]]),...Array.from({length:24},(e,t)=>[65470+t,[112+t,!1]])]);class Bt{x=-1;y=-1;mask=0;held=new Set;pressed=new Set;pointer(e,t,n){let o=[];if(e!==this.x||t!==this.y)this.x=e,this.y=t,o.push(`p ${e} ${t}`);for(let s of kt){let i=(this.mask&s.bit)!==0,p=(n&s.bit)!==0;if(i!==p)o.push(`b ${p?s.down:s.up} 0`)}for(let[s,i,p]of ln)if(!(this.mask&s)&&n&s)o.push(`b ${i} ${p}`);return this.mask=n,o}key(e,t){let n=e?0:Le;if(fn.has(t)||Lt.has(t))if(e)this.held.add(t);else this.held.delete(t);let o=Mt.get(t);if(o)return[`k ${o[0]} 0 ${n|(o[1]?vt:0)}`];let s=t<256?t:(t&4278190080)===16777216?t&16777215:0,i=String.fromCharCode(s),p=[...this.held].some((h)=>Lt.has(h)),l=/^[A-Za-z0-9]$/.test(i)?i.toUpperCase().charCodeAt(0):0;if(l&&(e?p:this.pressed.has(l))){if(e)this.pressed.add(l);else this.pressed.delete(l);return[`k ${l} 0 ${n}`]}if(s<33||s>=127&&s<160||s>65535||s>=55296&&s<57344)return[];return[`k 0 ${s} ${n|un}`]}release(){let e=kt.filter((t)=>this.mask&t.bit).map((t)=>`b ${t.up} 0`);for(let t of this.pressed)e.push(`k ${t} 0 ${Le}`);for(let t of this.held){let[n,o]=Mt.get(t);e.push(`k ${n} 0 ${Le|(o?vt:0)}`)}return this.mask=0,this.pressed.clear(),this.held.clear(),e}}function Jt(e){let t=Me(...Oe("input"),{env:Je(),stdio:["pipe","pipe","ignore"],windowsHide:!0}),n=new Bt,o="",s=!1,i=null,p=()=>{if(i?.kill("SIGKILL"),t.exitCode!==null||t.signalCode!==null)return;t.stdin.end(n.release().map((u)=>`${u}
189
189
  `).join("")),setTimeout(()=>t.kill("SIGKILL"),2000).unref()},l=(u)=>{if(s)return;s=!0,p(),e.end(u)},h=(u)=>l({error:new r("display_unavailable",u)}),f=(u)=>{if(s||u.length===0)return;if(t.stdin.write(u.map((S)=>`${S}
190
- `).join("")),t.stdin.writableLength>on)l({reason:"input_backpressure"})},x=()=>{i=Ue(...Be("clipboard"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let u="";i.stdout?.on("data",(S)=>{if(s)return;u+=S.toString("ascii");for(let y=u.indexOf(`
190
+ `).join("")),t.stdin.writableLength>on)l({reason:"input_backpressure"})},x=()=>{i=Me(...Oe("clipboard"),{env:Je(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let u="";i.stdout?.on("data",(S)=>{if(s)return;u+=S.toString("ascii");for(let y=u.indexOf(`
191
191
  `);y>=0;y=u.indexOf(`
192
192
  `)){let A=u.slice(0,y).replace(/\r$/,"");if(u=u.slice(y+1),!A.startsWith("c "))continue;let q=A.slice(2);if(q.length>Math.ceil(v/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(q)){l({reason:"display_protocol"});return}let c=Buffer.from(q,"base64");if(c.byteLength<=v)e.clipboard(c.toString("utf8"));if(s)return}if(u.length>Math.ceil(v/3)*4+4)l({reason:"display_protocol"})}),i.once("error",()=>h("Reason could not watch this computer's desktop clipboard.")),i.once("exit",()=>{if(!s)h("Reason could not watch this computer's desktop clipboard.")})};return t.stdout.on("data",(u)=>{if(s||o===null)return;o+=u.toString("utf8");let S=o.indexOf(`
193
- `);if(S<0){if(o.length>4096)l({reason:"display_protocol"});return}let y=Qt(o.slice(0,S).trim());if(o=null,!y)l({reason:"display_protocol"});else if(y.session===0)h("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else x(),e.ready({width:y.width,height:y.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>h("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)h("Reason could not start this computer's desktop input.");else l({reason:"display_closed"})}),{pointer:(u,S,y)=>f(n.pointer(u,S,y)),key:(u,S)=>f(n.key(u,S)),clipboard:(u)=>f([`c ${Buffer.from(u,"utf8").toString("base64")}`]),close(){s=!0,p()}}}var hn=["none","standard","all"],xe="22.23.3",gn={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},je={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},Gt="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Vt="chrome-win64/chrome.exe",Y={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Sn={version:Y.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},We={version:Y.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${Y.version}/ffmpeg-${Y.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},jt=`ffmpeg-${We.version}-essentials_build/bin`,G="com.ifuryst.open_browser_use.extension",Kt="com.reasonmachines.browser_use.extension",xt="/tmp/reason-browser-use",Ge=["tint2","picom","xterm","pcmanfm"],It=["fonts-droid-fallback"],Zt=["pulseaudio"],_n=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...It,"galculator","chromium","ffmpeg","tmux",...Zt,...Ge],wn=new Set([...Ge,...It,...Zt]),Wt=_n.filter((e)=>e!=="chromium"&&!wn.has(e)),Pn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],be="/usr/bin/chromium",qn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function Dn(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function z(e){return e==="win32-x64"||e==="win32-arm64"}function Ve(e){return z(e)?`node-v${xe}-${e.replace("win32","win")}`:`node-v${xe}-${e}`}function me(e){return{node:{version:xe,url:`https://nodejs.org/dist/v${xe}/${Ve(e)}${z(e)?".zip":".tar.gz"}`,sha256:gn[e]},open_computer_use:{version:U.ocu.version,url:ie.ocu.url,sha256:ie.ocu.sha256},open_browser_use:{version:U.obu.version,url:ie.obu.url,sha256:ie.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:J.macArm64Sha256}}:z(e)?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/win64/chrome-win64.zip`,sha256:J.win64Sha256}}:{}}}function An(e){let t={extension:F};for(let[n,o]of Object.entries(me(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Yt(e){return g(e,".local","share","reason","desktop")}function gr(e,t=En()){let n=Yt(t),o=(u)=>g(n,u,me(e)[u]?.version??""),s=o("open_computer_use"),i=o("open_browser_use"),p=e==="darwin-arm64",l=z(e),h=g(t,"Library","Application Support"),f=g(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:g(t,"AppData","Local"),"OpenBrowserUse"),x=p?g(h,"Google","Chrome","NativeMessagingHosts",`${G}.json`):l?g(f,"NativeMessagingHosts",`${G}.json`):g(t,".config","google-chrome","NativeMessagingHosts",`${G}.json`);return{root:n,automation:g($t(n),"automation"),receipt:g(n,"receipt.json"),minimal:$n(t),node:l?g(o("node"),Ve(e),"node.exe"):g(o("node"),"bin","node"),ocuDir:s,ocu:g(s,je[e].ocu),ocuApp:p?g(s,"dist","Open Computer Use.app"):null,obuDir:i,obu:g(i,"cli","open-browser-use.js"),nativeHost:g(i,je[e].obu),extensionDir:p?g(h,"OpenBrowserUse","chrome-extension","release"):l?g(f,"chrome-extension","release"):g(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:x,nativeHostManifests:p?[x,g(h,"Google","ChromeForTesting","NativeMessagingHosts",`${G}.json`)]:l?[x]:[g(t,".config","chromium","NativeMessagingHosts",`${G}.json`),g(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${G}.json`)],browser:p?g(o("chrome_for_testing"),Gt):l?g(o("chrome_for_testing"),Vt):be,userChromeHost:p?g(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:p?g(h,"Google","Chrome","NativeMessagingHosts",`${Kt}.json`):null,ffmpegDir:g(n,"ffmpeg"),ffmpeg:p?g(n,"ffmpeg",Y.version,"ffmpeg"):l?g(n,"ffmpeg",We.version,jt,"ffmpeg.exe"):null,ffprobe:p?g(n,"ffprobe",Sn.version,"ffprobe"):l?g(n,"ffmpeg",We.version,jt,"ffprobe.exe"):null}}function kn(e){try{let t=JSON.parse(ye(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((s)=>typeof s==="string")||!hn.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((s)=>typeof s==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function O(e){try{return Fe(e).isFile()}catch{return!1}}function zt(e){try{let t=Fe(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function Xn(e){try{return ye(e,"utf8")}catch{return null}}function W(e){for(let t of qn){let n=g(t,e);try{let o=Fe(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Cn(e){try{let t=JSON.parse(ye(g(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function vn(e,t,n){let o=me(n)[e];if(!o)return!1;let s=z(n);if(e==="node")return O(s?g(t,Ve(n),"node.exe"):g(t,"bin","node"));if(e==="chrome_for_testing")return O(g(t,s?Vt:Gt));let i=je[n][e==="open_computer_use"?"ocu":"obu"];return Cn(t)===o.version&&O(g(t,i))&&(e==="open_computer_use"||O(g(t,"cli","open-browser-use.js")))}function Ln(e){return Ft("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function Ke(e){try{let t=JSON.parse(ye(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Mn(e){let t=Ke(g(e.extensionDir,"manifest.json"));return t!==null&&t.version===U.obu.version&&typeof t.key==="string"&&Ln(t.key)===F}function Qn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===G&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${F}/`&&(t===void 0||e.path===t)}function Un(e){return Mn(e)&&O(e.nativeHost)&&e.nativeHostManifests.every((t)=>Qn(Ke(t),e.nativeHost))}function Bn(e){return`#!/bin/sh
193
+ `);if(S<0){if(o.length>4096)l({reason:"display_protocol"});return}let y=Qt(o.slice(0,S).trim());if(o=null,!y)l({reason:"display_protocol"});else if(y.session===0)h("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else x(),e.ready({width:y.width,height:y.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>h("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)h("Reason could not start this computer's desktop input.");else l({reason:"display_closed"})}),{pointer:(u,S,y)=>f(n.pointer(u,S,y)),key:(u,S)=>f(n.key(u,S)),clipboard:(u)=>f([`c ${Buffer.from(u,"utf8").toString("base64")}`]),close(){s=!0,p()}}}var hn=["none","standard","all"],xe="22.23.3",gn={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},je={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},Gt="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Vt="chrome-win64/chrome.exe",Y={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Sn={version:Y.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},We={version:Y.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${Y.version}/ffmpeg-${Y.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},jt=`ffmpeg-${We.version}-essentials_build/bin`,G="com.ifuryst.open_browser_use.extension",Kt="com.reasonmachines.browser_use.extension",Ct="/tmp/reason-browser-use",Ge=["tint2","picom","xterm","pcmanfm"],It=["fonts-droid-fallback"],Zt=["pulseaudio"],_n=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...It,"galculator","chromium","ffmpeg","tmux",...Zt,...Ge],wn=new Set([...Ge,...It,...Zt]),Wt=_n.filter((e)=>e!=="chromium"&&!wn.has(e)),Pn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],be="/usr/bin/chromium",qn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function En(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function z(e){return e==="win32-x64"||e==="win32-arm64"}function Ve(e){return z(e)?`node-v${xe}-${e.replace("win32","win")}`:`node-v${xe}-${e}`}function me(e){return{node:{version:xe,url:`https://nodejs.org/dist/v${xe}/${Ve(e)}${z(e)?".zip":".tar.gz"}`,sha256:gn[e]},open_computer_use:{version:U.ocu.version,url:ie.ocu.url,sha256:ie.ocu.sha256},open_browser_use:{version:U.obu.version,url:ie.obu.url,sha256:ie.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:J.macArm64Sha256}}:z(e)?{chrome_for_testing:{version:J.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${J.version}/win64/chrome-win64.zip`,sha256:J.win64Sha256}}:{}}}function Tn(e){let t={extension:F};for(let[n,o]of Object.entries(me(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Yt(e){return g(e,".local","share","reason","desktop")}function yr(e,t=kn()){let n=Yt(t),o=(u)=>g(n,u,me(e)[u]?.version??""),s=o("open_computer_use"),i=o("open_browser_use"),p=e==="darwin-arm64",l=z(e),h=g(t,"Library","Application Support"),f=g(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:g(t,"AppData","Local"),"OpenBrowserUse"),x=p?g(h,"Google","Chrome","NativeMessagingHosts",`${G}.json`):l?g(f,"NativeMessagingHosts",`${G}.json`):g(t,".config","google-chrome","NativeMessagingHosts",`${G}.json`);return{root:n,automation:g($t(n),"automation"),receipt:g(n,"receipt.json"),minimal:$n(t),node:l?g(o("node"),Ve(e),"node.exe"):g(o("node"),"bin","node"),ocuDir:s,ocu:g(s,je[e].ocu),ocuApp:p?g(s,"dist","Open Computer Use.app"):null,obuDir:i,obu:g(i,"cli","open-browser-use.js"),nativeHost:g(i,je[e].obu),extensionDir:p?g(h,"OpenBrowserUse","chrome-extension","release"):l?g(f,"chrome-extension","release"):g(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:x,nativeHostManifests:p?[x,g(h,"Google","ChromeForTesting","NativeMessagingHosts",`${G}.json`)]:l?[x]:[g(t,".config","chromium","NativeMessagingHosts",`${G}.json`),g(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${G}.json`)],browser:p?g(o("chrome_for_testing"),Gt):l?g(o("chrome_for_testing"),Vt):be,userChromeHost:p?g(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:p?g(h,"Google","Chrome","NativeMessagingHosts",`${Kt}.json`):null,ffmpegDir:g(n,"ffmpeg"),ffmpeg:p?g(n,"ffmpeg",Y.version,"ffmpeg"):l?g(n,"ffmpeg",We.version,jt,"ffmpeg.exe"):null,ffprobe:p?g(n,"ffprobe",Sn.version,"ffprobe"):l?g(n,"ffmpeg",We.version,jt,"ffprobe.exe"):null}}function Rn(e){try{let t=JSON.parse(ye(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((s)=>typeof s==="string")||!hn.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((s)=>typeof s==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function O(e){try{return Fe(e).isFile()}catch{return!1}}function zt(e){try{let t=Fe(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function An(e){try{return ye(e,"utf8")}catch{return null}}function W(e){for(let t of qn){let n=g(t,e);try{let o=Fe(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Xn(e){try{let t=JSON.parse(ye(g(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function Cn(e,t,n){let o=me(n)[e];if(!o)return!1;let s=z(n);if(e==="node")return O(s?g(t,Ve(n),"node.exe"):g(t,"bin","node"));if(e==="chrome_for_testing")return O(g(t,s?Vt:Gt));let i=je[n][e==="open_computer_use"?"ocu":"obu"];return Xn(t)===o.version&&O(g(t,i))&&(e==="open_computer_use"||O(g(t,"cli","open-browser-use.js")))}function vn(e){return Ft("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function Ke(e){try{let t=JSON.parse(ye(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Ln(e){let t=Ke(g(e.extensionDir,"manifest.json"));return t!==null&&t.version===U.obu.version&&typeof t.key==="string"&&vn(t.key)===F}function Qn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===G&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${F}/`&&(t===void 0||e.path===t)}function Un(e){return Ln(e)&&O(e.nativeHost)&&e.nativeHostManifests.every((t)=>Qn(Ke(t),e.nativeHost))}function Bn(e){return`#!/bin/sh
194
194
  # Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
195
195
  obu=${`'${e.replaceAll("'","'\\''")}'`}
196
196
  case "$1" in
197
- chrome-extension://*) exec "$obu" host --socket-dir ${xt} ;;
198
- mcp) shift; exec "$obu" mcp --socket-dir ${xt} "$@" ;;
197
+ chrome-extension://*) exec "$obu" host --socket-dir ${Ct} ;;
198
+ mcp) shift; exec "$obu" mcp --socket-dir ${Ct} "$@" ;;
199
199
  esac
200
200
  exec "$obu" "$@"
201
- `}function Jn(e){let t=Ke(e),n=t?.allowed_origins;return t!==null&&t.name===Kt&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${Me}/`)&&typeof t.path==="string"&&zt(t.path)}function jn(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Xn(e.userChromeHost)!==Bn(e.nativeHost)||!zt(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return Jn(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var Wn={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function P(e={}){let t=e.platform===void 0?Dn():e.platform;if(!t)return null;let n=gr(t,e.home),o=kn(n.receipt),s=An(t),i=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(s).sort()),p=[],l=me(t);for(let c of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=l[c];if(!_)continue;let E=vn(c,g(n.root,c,_.version),t),D=o?.pins[c],N=E&&D===s[c]?"ready":D!==void 0&&D!==s[c]?"outdated":"missing";p.push({name:c,state:N,detail:_.version})}let h=o?.pins.extension===F&&Un(n);p.push({name:"browser_extension",state:h?"ready":"missing",detail:F});let f=W("Xvfb"),x=W("x11vnc"),u=W("openbox");if(z(t))p.push(Ot()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),p.push(n.ffmpeg&&O(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){p.push(O(be)?{name:"browser",state:"ready",detail:be}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${be}`});let c=f!==null&&x!==null&&u!==null;p.push({name:"display",state:c?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=Pn.filter((k)=>W(k)===null),E=(o?.missing_system_packages??Wt).filter((k)=>Wt.includes(k)),D=_.length===0&&E.length===0;p.push(D?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...E,..._])].join(" ")});let N=Ge.filter((k)=>W(k)===null);p.push(N.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:N.join(" ")})}let S=n.ffmpeg&&O(n.ffmpeg)?n.ffmpeg:W("ffmpeg"),y=!S?null:S===n.ffmpeg?n.ffprobe:g($t(xn(S)),"ffprobe"),A=i&&p.every((c)=>c.state==="ready"),q=(c)=>i&&p.every((_)=>!Wn[c].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:A,features:{display:q("display"),computer:q("computer"),browser:q("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:S,ffprobe:y&&O(y)?y:null,userChrome:jn(n,i&&["node","open_browser_use"].every((c)=>p.find((_)=>_.name===c)?.state==="ready")),pulseaudio:W("pulseaudio"),xvfb:f,x11vnc:x,openbox:u,components:p}}function Ht(e){return Fn(e)?Nn():[]}function Fn(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===g(e.root,"ffmpeg",Y.version,"ffmpeg")}async function Fi(e,t,n,o=fetch){try{let s=await o(e,{redirect:"follow"});if(!s.ok||!s.body)throw Error(`download failed (HTTP ${s.status}): ${e}`);let i=Ft("sha256"),p=bn(n,{mode:384});try{let h=s.body.getReader();for(let f=await h.read();!f.done;f=await h.read())if(i.update(f.value),!p.write(f.value))await dn(p,"drain")}finally{p.end(),await mn(p)}let l=i.digest("hex");if(l!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${l}`)}catch(s){throw yn(n,{force:!0}),s}}function $n(e){return g(Yt(e),"minimal.json")}import{execFile as is,spawn as rt}from"child_process";import{existsSync as as}from"fs";import{connect as ps}from"net";function Gn(){let e=new Set,t=null,n=(s)=>({holder:t?.viewer??null,you:t===s,same_user:Boolean(t?.viewer&&s.viewer&&t.viewer.user_id===s.viewer.user_id)}),o=()=>{for(let s of e)s.notify(n(s))};return{join(s){return e.add(s),s.notify(n(s)),()=>{if(!e.delete(s))return;if(t!==s)return;t=null,o()}},claim(s){if(t===s||!e.has(s))return;t=s,o()}}}var er=Gn();import{spawn as Vn}from"child_process";import{existsSync as Kn}from"fs";import{connect as Zn}from"net";import{join as he}from"path";var rr="reason_desktop",pe={sampleRate:48000,channels:2,codec:"opus"},Yn=5000,zn=107,Hn=262144,ze=(e)=>he(e,"native"),Ye=(e)=>`unix:${e}`;function Ie(e,t=1000){if(!Kn(e))return Promise.resolve(!1);return new Promise((n)=>{let o=Zn({path:e}),s=(i)=>{o.destroy(),n(i)};o.setTimeout(t,()=>s(!1)),o.once("error",()=>s(!1)),o.once("close",()=>s(!1)),o.once("connect",()=>s(!0))})}async function nr(e,t){if(!t)return null;let n=ze(e);if(Buffer.byteLength(n)>zn||/["'\\\s]/.test(n))return null;try{if(await Ie(n))return n;let o=Vn(t,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${he(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${rr} rate=${pe.sampleRate} channels=${pe.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:e,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:e,PULSE_RUNTIME_PATH:he(e,"runtime"),PULSE_STATE_PATH:he(e,"state")}}),s=!1;o.once("error",()=>{s=!0}),o.once("exit",()=>{s=!0}),o.unref();let i=Date.now()+Yn;while(Date.now()<i){if(await Ie(n))return n;if(s)return await Ie(n)?n:null;await new Promise((p)=>setTimeout(p,50))}if(!s)o.kill("SIGKILL");return null}catch{return null}}function sr(){let{sampleRate:e,channels:t}=pe;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(e),"-channels",String(t),"-fragment_size",String(e*t*2/50),"-i",`${rr}.monitor`,"-vn","-ac",String(t),"-ar",String(e),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var es=[79,103,103,83],ts=Buffer.from("OpusHead"),rs=Buffer.from("OpusTags"),tr=(e,t)=>e.byteLength>=t.byteLength&&t.every((n,o)=>e[o]===n);class Ze extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class He{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(e){let t=new Uint8Array(this.buffer.byteLength+e.byteLength);t.set(this.buffer),t.set(e,this.buffer.byteLength);let n=[],o=0;while(t.byteLength-o>=27){if(es.some((S,y)=>t[o+y]!==S)||t[o+4]!==0)throw new Ze("invalid_page");let s=(t[o+5]&1)!==0,i=t[o+26];if(t.byteLength-o<27+i)break;let p=t.subarray(o+27,o+27+i),l=p.reduce((S,y)=>S+y,0),h=27+i+l;if(t.byteLength-o<h)break;if(!s&&this.partialBytes>0)this.resetPartial();let f=s&&this.partialBytes===0,x=o+27+i,u=x;for(let S of p){if(x+=S,S===255)continue;if(this.appendPartial(t.subarray(u,x),f),u=x,!f){let y=this.takePartial();if(y.byteLength>0&&!tr(y,ts)&&!tr(y,rs))n.push(y)}f=!1,this.resetPartial()}if(u<x)this.appendPartial(t.subarray(u,x),f);o+=h}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>Hn)throw new Ze("packet_too_large");this.partial.push(e.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let e=new Uint8Array(this.partialBytes),t=0;for(let n of this.partial)e.set(n,t),t+=n.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as ns}from"child_process";var or=1048576,os=String.raw`
201
+ `}function Jn(e){let t=Ke(e),n=t?.allowed_origins;return t!==null&&t.name===Kt&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${$e}/`)&&typeof t.path==="string"&&zt(t.path)}function jn(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||An(e.userChromeHost)!==Bn(e.nativeHost)||!zt(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return Jn(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var Wn={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function P(e={}){let t=e.platform===void 0?En():e.platform;if(!t)return null;let n=yr(t,e.home),o=Rn(n.receipt),s=Tn(t),i=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(s).sort()),p=[],l=me(t);for(let c of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=l[c];if(!_)continue;let E=Cn(c,g(n.root,c,_.version),t),D=o?.pins[c],N=E&&D===s[c]?"ready":D!==void 0&&D!==s[c]?"outdated":"missing";p.push({name:c,state:N,detail:_.version})}let h=o?.pins.extension===F&&Un(n);p.push({name:"browser_extension",state:h?"ready":"missing",detail:F});let f=W("Xvfb"),x=W("x11vnc"),u=W("openbox");if(z(t))p.push(Ot()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),p.push(n.ffmpeg&&O(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){p.push(O(be)?{name:"browser",state:"ready",detail:be}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${be}`});let c=f!==null&&x!==null&&u!==null;p.push({name:"display",state:c?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=Pn.filter((k)=>W(k)===null),E=(o?.missing_system_packages??Wt).filter((k)=>Wt.includes(k)),D=_.length===0&&E.length===0;p.push(D?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...E,..._])].join(" ")});let N=Ge.filter((k)=>W(k)===null);p.push(N.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:N.join(" ")})}let S=n.ffmpeg&&O(n.ffmpeg)?n.ffmpeg:W("ffmpeg"),y=!S?null:S===n.ffmpeg?n.ffprobe:g($t(xn(S)),"ffprobe"),A=i&&p.every((c)=>c.state==="ready"),q=(c)=>i&&p.every((_)=>!Wn[c].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:A,features:{display:q("display"),computer:q("computer"),browser:q("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:S,ffprobe:y&&O(y)?y:null,userChrome:jn(n,i&&["node","open_browser_use"].every((c)=>p.find((_)=>_.name===c)?.state==="ready")),pulseaudio:W("pulseaudio"),xvfb:f,x11vnc:x,openbox:u,components:p}}function Ht(e){return Fn(e)?Mn():[]}function Fn(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===g(e.root,"ffmpeg",Y.version,"ffmpeg")}async function Ui(e,t,n,o=fetch){try{let s=await o(e,{redirect:"follow"});if(!s.ok||!s.body)throw Error(`download failed (HTTP ${s.status}): ${e}`);let i=Ft("sha256"),p=bn(n,{mode:384});try{let h=s.body.getReader();for(let f=await h.read();!f.done;f=await h.read())if(i.update(f.value),!p.write(f.value))await dn(p,"drain")}finally{p.end(),await mn(p)}let l=i.digest("hex");if(l!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${l}`)}catch(s){throw yn(n,{force:!0}),s}}function $n(e){return g(Yt(e),"minimal.json")}import{execFile as os,spawn as rt}from"child_process";import{existsSync as is}from"fs";import{connect as as}from"net";function Gn(){let e=new Set,t=null,n=(s)=>({holder:t?.viewer??null,you:t===s,same_user:Boolean(t?.viewer&&s.viewer&&t.viewer.user_id===s.viewer.user_id)}),o=()=>{for(let s of e)s.notify(n(s))};return{join(s){return e.add(s),s.notify(n(s)),()=>{if(!e.delete(s))return;if(t!==s)return;t=null,o()}},claim(s){if(t===s||!e.has(s))return;t=s,o()}}}var er=Gn();import{spawn as Vn}from"child_process";import{existsSync as Kn}from"fs";import{connect as Zn}from"net";import{join as he}from"path";var rr="reason_desktop",pe={sampleRate:48000,channels:2,codec:"opus"},Yn=5000,zn=107,Hn=262144,Ye=(e)=>he(e,"native"),Qe=(e)=>`unix:${e}`;function Ie(e,t=1000){if(!Kn(e))return Promise.resolve(!1);return new Promise((n)=>{let o=Zn({path:e}),s=(i)=>{o.destroy(),n(i)};o.setTimeout(t,()=>s(!1)),o.once("error",()=>s(!1)),o.once("close",()=>s(!1)),o.once("connect",()=>s(!0))})}async function nr(e,t){if(!t)return null;let n=Ye(e);if(Buffer.byteLength(n)>zn||/["'\\\s]/.test(n))return null;try{if(await Ie(n))return n;let o=Vn(t,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${he(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${rr} rate=${pe.sampleRate} channels=${pe.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:e,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:e,PULSE_RUNTIME_PATH:he(e,"runtime"),PULSE_STATE_PATH:he(e,"state")}}),s=!1;o.once("error",()=>{s=!0}),o.once("exit",()=>{s=!0}),o.unref();let i=Date.now()+Yn;while(Date.now()<i){if(await Ie(n))return n;if(s)return await Ie(n)?n:null;await new Promise((p)=>setTimeout(p,50))}if(!s)o.kill("SIGKILL");return null}catch{return null}}function sr(){let{sampleRate:e,channels:t}=pe;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(e),"-channels",String(t),"-fragment_size",String(e*t*2/50),"-i",`${rr}.monitor`,"-vn","-ac",String(t),"-ar",String(e),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var es=[79,103,103,83],ts=Buffer.from("OpusHead"),rs=Buffer.from("OpusTags"),tr=(e,t)=>e.byteLength>=t.byteLength&&t.every((n,o)=>e[o]===n);class Ze extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class He{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(e){let t=new Uint8Array(this.buffer.byteLength+e.byteLength);t.set(this.buffer),t.set(e,this.buffer.byteLength);let n=[],o=0;while(t.byteLength-o>=27){if(es.some((S,y)=>t[o+y]!==S)||t[o+4]!==0)throw new Ze("invalid_page");let s=(t[o+5]&1)!==0,i=t[o+26];if(t.byteLength-o<27+i)break;let p=t.subarray(o+27,o+27+i),l=p.reduce((S,y)=>S+y,0),h=27+i+l;if(t.byteLength-o<h)break;if(!s&&this.partialBytes>0)this.resetPartial();let f=s&&this.partialBytes===0,x=o+27+i,u=x;for(let S of p){if(x+=S,S===255)continue;if(this.appendPartial(t.subarray(u,x),f),u=x,!f){let y=this.takePartial();if(y.byteLength>0&&!tr(y,ts)&&!tr(y,rs))n.push(y)}f=!1,this.resetPartial()}if(u<x)this.appendPartial(t.subarray(u,x),f);o+=h}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>Hn)throw new Ze("packet_too_large");this.partial.push(e.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let e=new Uint8Array(this.partialBytes),t=0;for(let n of this.partial)e.set(n,t),t+=n.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as ns}from"child_process";var or=1048576,ss=String.raw`
202
202
  import gi, json, os, sys
203
203
  gi.require_version("Gtk", "3.0")
204
204
  from gi.repository import Gtk, Gdk, GLib
@@ -239,12 +239,12 @@ def input_ready(fd, condition):
239
239
  GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
240
240
  send("ready")
241
241
  Gtk.main()
242
- `;function ir(e,t){let n=ns("/usr/bin/python3",["-I","-u","-c",os],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),o=!1,s=!0,i="",p=0,l=[],h=setTimeout(()=>x(),5000),f=()=>{o=!0,clearTimeout(h),l.length=0,n.kill("SIGKILL")},x=()=>{if(o)return;f(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},u=(S,y=32)=>{if(o)return;if(!s){S();return}if(p+=y,p>or)f(),t.end({reason:"input_backpressure"});else l.push({apply:S,bytes:y})};return n.stdout.on("data",(S)=>{if(o)return;i+=S.toString("ascii");for(let y=i.indexOf(`
242
+ `;function ir(e,t){let n=ns("/usr/bin/python3",["-I","-u","-c",ss],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),o=!1,s=!0,i="",p=0,l=[],h=setTimeout(()=>x(),5000),f=()=>{o=!0,clearTimeout(h),l.length=0,n.kill("SIGKILL")},x=()=>{if(o)return;f(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},u=(S,y=32)=>{if(o)return;if(!s){S();return}if(p+=y,p>or)f(),t.end({reason:"input_backpressure"});else l.push({apply:S,bytes:y})};return n.stdout.on("data",(S)=>{if(o)return;i+=S.toString("ascii");for(let y=i.indexOf(`
243
243
  `);y>=0;y=i.indexOf(`
244
244
  `)){let A=i.slice(0,y);i=i.slice(y+1);let q;try{q=JSON.parse(A)}catch{x();return}if(q==="ready"||q==="ack"){clearTimeout(h),s=!1;while(!s&&!o&&l.length){let c=l.shift();p-=c.bytes,c.apply()}}else if(q&&typeof q==="object"&&"text"in q&&typeof q.text==="string"&&Buffer.byteLength(q.text)<=v)t.clipboard(q.text);else{x();return}if(o)return}if(i.length>v*6+32)x()}),n.stdin.on("error",x),n.once("error",x),n.once("exit",x),{apply:u,write(S){if(Buffer.byteLength(S)>v||S.includes("\x00")){x();return}let y=`${JSON.stringify(S)}
245
- `;u(()=>{if(s=!0,h=setTimeout(()=>x(),5000),n.stdin.write(y),n.stdin.writableLength>or)f(),t.end({reason:"input_backpressure"})},Buffer.byteLength(y))},close:f}}var H={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},cs="avc1.4D002A",ar={width:1920,height:1080},ls=262144,us=0.2,fs=250,ds=1e4,bs=1024,et=1e4,xs=500,ys=60,ms=1e4,hs=1000,pr=1048576,mr={kind:"mac_screen",sound:null},hr={kind:"windows_screen",sound:null},gs,cr=()=>gs??=P()?.ffmpeg??null,Se=(e,t,n)=>rt(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Ss,nt=()=>Ss??=Ht(P()),lr=(e,t,n)=>{let[o,...s]=[...nt(),e];return Se(o,[...s,...t],n)},ur=()=>Tr?.videotoolbox?"h264_videotoolbox":"libx264",_s=()=>Math.round(performance.now()*1000),tt=new Set,fr=!1;function Sr(e){if(tt.add(e),e.once("exit",()=>tt.delete(e)),fr)return;fr=!0,process.once("exit",()=>{for(let t of tt)try{t.kill("SIGKILL")}catch{}})}function _r(e){try{e.stdout?.destroy()}catch{}if(e.exitCode!==null||e.signalCode!==null)return;try{e.kill("SIGTERM")}catch{return}let t=setTimeout(()=>{if(e.exitCode===null&&e.signalCode===null)try{e.kill("SIGKILL")}catch{}},xs);e.once("exit",()=>clearTimeout(t))}function ws(e,t,n){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",n],size:t}}function Ps(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function qs(e,t){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(e),"-offset_x","0","-offset_y","0","-video_size",`${t.width}x${t.height}`,"-i","desktop"],size:t}}function Es(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Pr=1700000;function qr(e){return Math.min(1,Math.round(Math.sqrt(Pr/(e.width*e.height))*100)/100)}function Ds(e,t,n){let o=rt(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,qr(n.size)))],{stdio:["ignore","pipe","ignore"]}),s=rt(e,t,{env:{},stdio:["pipe","pipe","ignore"]});o.stdout.pipe(s.stdin),s.stdin.on("error",()=>{});let i=()=>{if(o.exitCode===null&&o.signalCode===null)o.kill("SIGTERM")};return s.once("exit",i),s.once("error",i),o.once("exit",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),o.once("error",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),s}function dr(e){let t=Math.min(1,ar.width/e.width,ar.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function ge(e,t,n,o="libx264"){let s=H[e],i=(u)=>Math.max(2,Math.floor(u/2)*2),p={width:i(n.width*s.scale),height:i(n.height*s.scale)},l=p.width!==t.size?.width||p.height!==t.size.height,h=Math.max(1,Math.round(s.kbps*2/s.fps)),f=["-g",String(s.fps*ys)],x=o==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...f,"-b:v",`${s.kbps}k`,"-maxrate",`${s.kbps}k`,"-bufsize",`${h}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",s.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...s.threads?["-threads",String(s.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...f,"-crf",String(s.crf),"-maxrate",`${s.kbps}k`,"-bufsize",`${h}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...l?["-vf",`scale=${p.width}:${p.height}:flags=fast_bilinear`]:[],...x,"-flush_packets","1","-f","h264","pipe:1"]}class Er{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let n=new Uint8Array(this.buffer.byteLength+e.byteLength);n.set(this.buffer),n.set(e,this.buffer.byteLength),this.buffer=n;let o=[],s=this.scanned;while(s+3<this.buffer.byteLength){if(this.buffer[s]!==0||this.buffer[s+1]!==0||this.buffer[s+2]!==1){s++;continue}let i=this.buffer[s+3]&31,p=s>0&&this.buffer[s-1]===0?s-1:s;if(i===9&&p>0)o.push({data:this.buffer.slice(0,p),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(p),this.key=!1,this.micros=t,s-=p;if(i===5)this.key=!0;s+=3}return this.scanned=s,o}}function Ts(e,t){let n=ps({path:e}),o=Buffer.alloc(0),s="version",i=0,p=!1,l=[],h=0,f=!1,x=(c)=>{if(f)return;f=!0,n.destroy(),t.end(c)},u=()=>x({reason:"display_protocol"}),S=(c)=>{if(f)return;if(!p){if(h+=c.byteLength,h>pr)x({reason:"input_backpressure"});else l.push(c);return}if(n.write(c),n.writableLength>pr)x({reason:"input_backpressure"})},y=(c)=>{o=o.subarray(c)},A=()=>{switch(s){case"version":{if(o.byteLength<12)return!1;let c=/^RFB (\d{3})\.(\d{3})\n$/.exec(o.subarray(0,12).toString("latin1"));if(!c||Number(c[1])*1000+Number(c[2])<3007)return u(),!1;return y(12),n.write(`RFB 003.007
246
- `),s="security",!0}case"security":{if(o.byteLength<1)return!1;let c=o[0];if(c===0)return u(),!1;if(o.byteLength<1+c)return!1;if(!o.subarray(1,1+c).includes(1))return u(),!1;return y(1+c),n.write(Buffer.from([1,1])),s="init",!0}case"init":{if(o.byteLength<24)return!1;let c=o.readUInt32BE(20);if(c>65536)return u(),!1;if(o.byteLength<24+c)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(y(24+c),_.width===0||_.height===0)return u(),!1;s="messages",p=!0;for(let E of l)n.write(E);return l=[],h=0,t.ready(_),!f}case"skip":{let c=Math.min(i,o.byteLength);if(y(c),i-=c,i>0)return!1;return s="messages",!0}case"messages":{if(o.byteLength<1)return!1;switch(o[0]){case 1:{if(o.byteLength<6)return!1;let c=6+o.readUInt16BE(4)*6;if(o.byteLength<c)return!1;return y(c),!0}case 2:return y(1),!0;case 3:{if(o.byteLength<8)return!1;let c=o.readUInt32BE(4);if(c>v/2)return y(8),s="skip",i=c,!0;if(o.byteLength<8+c)return!1;let _=o.subarray(8,8+c).toString("latin1");return y(8+c),t.clipboard(_),!f}default:return u(),!1}}}},q=!1;return n.once("connect",()=>{q=!0}),n.on("data",(c)=>{if(f)return;o=o.byteLength?Buffer.concat([o,c]):c;while(!f&&A());}),n.once("error",()=>{if(!q)x({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>x({reason:"display_closed"})),{pointer(c,_,E){let D=Buffer.alloc(6);D.writeUInt8(5,0),D.writeUInt8(E&255,1),D.writeUInt16BE(c,2),D.writeUInt16BE(_,4),S(D)},key(c,_){let E=Buffer.alloc(8);E.writeUInt8(4,0),E.writeUInt8(c?1:0,1),E.writeUInt32BE(_>>>0,4),S(E)},clipboard(c){if(Array.from(c).some((D)=>D.codePointAt(0)>255)){x({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(c,"latin1"),E=Buffer.alloc(8);E.writeUInt8(6,0),E.writeUInt32BE(_.byteLength,4),S(Buffer.concat([E,_]))},close(){f=!0,n.destroy()}}}class st{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,n,o){this.viewers.add(e),this.stop();let s;try{s=n()}catch{this.fail();return}Sr(s);let i={child:s,splitter:new Er};this.run=i;for(let l of[...this.viewers])l.started(t);s.stdout?.on("data",(l)=>{if(this.run!==i)return;for(let h of i.splitter.push(l,o()))for(let f of[...this.viewers])f.unit(h)});let p=()=>{if(this.run!==i)return;this.run=null,this.fail()};s.once("exit",p),s.once("error",p)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;_r(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var br=new WeakMap;function Rs(e){let t=br.get(e);if(!t)br.set(e,t=new st);return t}function Dr(e,t,n={}){let o=n.micros??_s,s=new Rn,i=t.request.preset,p=null,l=null,h=null,f=!1,x=null,u=!1,S=!1,y=null,A=0,q=0,c=!1,_=null,E=null,D=0,N=null,k=[],te=0,w=[],M=new Uint32Array(et+1),B=0,Pe=null,Ee=0,re=0,De=0,lt=0,ut=0,ce=null,Te=0,K={frames:0,bytes:0,since:o()},I=[],ne=0,Re,Ae=!1,vr=o(),C={},Z=()=>Math.round((o()-vr)/1000),dt=n.control??er,ke=null,Xe=null,L=(b)=>{let d=$r(b);return e.send(d),lt+=d.byteLength,d.byteLength},le=(b)=>{if(e.done)return;if(e.open)L({type:"error",code:b});e.end({reason:b})},ue=()=>Math.max(ls,H[i].kbps*1000/8*us),fe=()=>o()/1000,Lr=()=>{while(w.length>1&&w[0].atMs<fe()-ds)w.shift();return w[0]?.rttMs??null},bt=(b)=>{let d=Lr();if(d===null||k.length===0)return!1;let m=(d+fs)*b;return fe()-k[0].sentMs>m||te>m/1000*H[i].kbps*1000/8},Mr=(b)=>{if(D===0)return;let d=Math.min(b,D-1);if(N!==null&&d<=N)return;N=d;let m=fe();while(k.length&&k[0].seq<=d){let T=k.shift();if(te-=T.bytes,T.seq!==d)continue;let R=Math.max(0,m-T.sentMs);while(w.length&&w.at(-1).rttMs>=R)w.pop();w.push({atMs:m,rttMs:R}),M[Math.min(et,Math.round(R))]++,B++,Pe=Math.min(Pe??R,R)}},Qr=()=>{let b=0;for(let d=0;d<=et;d++)if(b+=M[d],b*2>=B)return d;return 0},Ur=()=>e.bufferedAmount<=ue()/2&&!bt(0.5),yt=()=>{Ae=!0,I=[],ne=0,x?.leave(Ce),x=null},mt=(b)=>{if(e.done)return;if(b.key)C.first_key_ms??=Z();if(!f){if(!x||I.length===0&&!b.key)return;if(I.push(b),ne+=b.data.byteLength,ne>ue())yt();return}if(c){re++;return}if(e.bufferedAmount>ue()||bt(1)){c=!0,re++,_=setInterval(()=>{if(e.done||!Ur())return;if(_)clearInterval(_);_=null,c=!1,ve()},n.drainPollMs??25);return}if(!u){if(!b.key){re++;return}if(L({type:"hello",width:l.width,height:l.height,fps:H[i].fps,preset:i,codec:cs}),u=!0,C.first_frame_ms??=Z(),!S&&p?.sound)L({type:"audioHello",...pe}),S=!0}let d=L({type:"frame",key:b.key,seq:D,captureMicros:b.micros,data:b.data});if(k.push({seq:D,sentMs:fe(),bytes:d}),te+=d,k.length>bs)te-=k.shift().bytes;D++,Ee++,ce??=b.micros,Te=b.micros,K.frames++,K.bytes+=d},Ce={started(b){i=b,u=!1,I=[],ne=0},unit:mt,failed:()=>le("encoder_failed")},Ne=()=>{let b=(n.ffmpeg??cr)();if(!p||!l){le("encoder_failed");return}let[d,m]=[p,l],T="kind"in d&&d.kind==="simulator"?d.stream:null;if(!b&&!T){le("encoder_failed");return}if(x??="kind"in d&&d.kind==="mac_screen"?Rs(n.spawn??lr):new st,C.encoder_ms===void 0)C.encoder_ms=Z(),C.encoder_shared=x.running;x.start(Ce,i,()=>{let R=H[i].fps;if(T)return T(R,H[i].kbps,Pr);if("kind"in d&&d.kind==="simulator"){let Q=Math.min(0.99,qr(d.size)),se={width:d.size.width*Q,height:d.size.height*Q};return Ds(b,ge(i,Es(Math.min(R,30)),se,(n.macEncoder??ur)()),d)}if("kind"in d&&d.kind==="windows_screen")return(n.spawn??Se)(b,ge(i,qs(R,m),dr(m)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in d?(n.spawn??lr)(b,ge(i,Ps(R),dr(m),(n.macEncoder??ur)()),{}):(n.spawn??Se)(b,ge(i,ws(R,m,d.display),m),{DISPLAY:d.display,XAUTHORITY:d.xauthority})},o)},de=()=>{if(!y)return;_r(y.child),y=null},Or=()=>{let b=(n.ffmpeg??cr)();if(y||e.done||!S||!p?.sound||!b)return;let d;try{d=(n.spawn??Se)(b,sr(),{PULSE_SERVER:Ye(p.sound)})}catch{return}Sr(d);let m={child:d,reader:new He};y=m,d.stdout?.on("data",(R)=>{if(y!==m||e.done)return;let Q;try{Q=m.reader.push(R)}catch{de();return}let se=o();for(let Br of Q){if(e.bufferedAmount>ue()){q++;continue}L({type:"audio",captureMicros:se,data:Br}),A++}});let T=()=>{if(y===m)de()};d.once("exit",T),d.once("error",T)},ve=()=>{if(!x||e.done)return;De++,Ne()},ht=()=>{if(e.done||!l)return;if(!f){if(x||Ae)return;Ne(),Re=setTimeout(()=>{if(!f)yt()},ms);return}if(clearTimeout(Re),C.encoder_early===void 0){if(C.encoder_early=x!==null,Ae)C.hold_lapsed=!0}if(!x)Ne();let b=I;I=[],ne=0;for(let d of b)mt(d);E??=setInterval(()=>{let d=o(),m=Math.max(0.001,(d-K.since)/1e6);L({type:"stats",stats:{fps:Math.round(K.frames/m*10)/10,kbps:Math.round(K.bytes*8/1000/m),dropped:re,restarts:De,queued_bytes:e.bufferedAmount}}),K={frames:0,bytes:0,since:d}},hs)};t.desktop.then((b)=>{if(e.done)return;p=b;let d={ready(m){l=m,C.desktop_ms??=Z(),ht()},clipboard(m){if(e.open&&Buffer.byteLength(m)<=v)L({type:"serverClipboard",text:m})},end(m){if("reason"in m&&e.open)L({type:"error",code:m.reason});e.end(m)}};if("kind"in b&&b.kind==="simulator")h=b.input,d.ready(b.points);else if("kind"in b&&b.kind==="windows_screen")h=(n.windowsInput??Jt)(d);else if("kind"in b)h=(n.macInput??((m)=>In(m,nt())))(d);else{let m=(n.linuxClipboard??ir)(b,d),T=Ts(b.rfbSocket,{...d,clipboard:(R)=>{if(!m)d.clipboard(R)}});h=m?{pointer:(R,Q,se)=>m.apply(()=>T.pointer(R,Q,se)),key:(R,Q)=>m.apply(()=>T.key(R,Q)),clipboard:(R)=>m.write(R),close(){m.close(),T.close()}}:T}gt()},(b)=>e.end({error:b}));function gt(){if(Xe||!t.viewerSameNetwork||!f||e.done||!p||!("kind"in p)||p.kind!=="mac_screen")return;Xe=(n.macWindows??On)((b)=>{if(e.open)L({type:"windows",bounds:b})})}let St={viewer:t.viewer??null,notify(b){if(e.open)L({type:"control",control:b})}},Le=(b)=>{if(!h)return;if(!p||!("kind"in p)||p.kind!=="simulator")dt.claim(St);b(h)};return{opened(){C.relay_ms??=Z()},received(b){ut+=b.byteLength;let d;try{d=s.push(b)}catch{le("viewer_protocol");return}for(let m of d){if(e.done)return;switch(m.type){case"ping":L({type:"pong",token:m.token});break;case"pointer":Le((T)=>T.pointer(m.x,m.y,m.buttons));break;case"key":Le((T)=>T.key(m.down,m.keysym));break;case"clientClipboard":Le((T)=>T.clipboard(m.text));break;case"config":if(m.preset!==i)i=m.preset,ve();break;case"keyframeRequest":if(u&&!c)ve();break;case"ack":Mr(m.seq);break;case"audioEnable":if(m.on)Or();else de();break;default:break}}if(!f&&!e.done){if(f=!0,C.viewer_ms=Z(),t.viewer)ke=dt.join(St);ht(),gt()}},close(){if(ke?.(),ke=null,Xe?.close(),_)clearInterval(_);if(E)clearInterval(E);clearTimeout(Re),x?.leave(Ce),de(),h?.close()},summary:()=>({output_bytes:lt,input_bytes:ut,video:{preset:i,frames:Ee,dropped:re,restarts:De,avg_fps:ce!==null&&Te>ce?Math.round((Ee-1)/((Te-ce)/1e6)*10)/10:0,min_rtt_ms:Math.round(Pe??0),p50_rtt_ms:B?Qr():0,audio_packets:A,audio_dropped:q,connect:C}})}}var xr=null,Tr=null,As=null,ks=null;function Xs(){let e=P();return e?.features.display?e.ffmpeg:null}function Rr(e){return xr??=new Promise((t)=>{is(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(n,o)=>{let s=(i)=>!n&&new RegExp(`^\\s*V\\S*\\s+${i}\\s`,"m").test(o);t(Tr={x264:s("libx264"),videotoolbox:s("h264_videotoolbox")})})}),xr}var yr=null;function Bi(){return yr??=(async()=>{let e=[P()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&as(n)));if(!e)return null;let t=await Rr(e);return t.videotoolbox||t.x264?e:null})(),yr}function ot(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Xs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??Rr)(n);if(e==="linux")return o.then((i)=>i.x264);if(e==="win32"){let i=t.windowsScreen?t.windowsScreen():ks??=Ut();return Promise.all([o,i]).then(([p,l])=>p.x264&&(l?.session??0)>0)}let s=t.macScreen?t.macScreen():As??=qe(nt());return Promise.all([o,s]).then(([i,p])=>(i.x264||i.videotoolbox)&&p?.screen===!0&&p.accessibility)}var Bs=43200000,_e=":99",Js=60000,we=15000,pt={width:1280,height:800},js=/^[A-Za-z0-9._:-]{1,160}$/;function Ws(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Fs=["video","viewer","viewer_same_network","viewer_network"];function $s(e,t=Date.now()){let n=["relay_url","session_id","expires_at"];if(!Ws(e)||n.some((l)=>!(l in e))||Object.keys(e).some((l)=>!n.includes(l)&&!Fs.includes(l)))throw new r("invalid_display_request","Reason desktop request is malformed.");let o="video"in e?no(e.video):void 0,s="viewer"in e?Tn(e.viewer):null;if(o===null)throw new r("invalid_display_request","Reason desktop video request is invalid.");let i=null;try{i=typeof e.relay_url==="string"?new URL(e.relay_url):null}catch{}if(!i||i.protocol!=="wss:"&&i.protocol!=="ws:"||i.username||i.password)throw new r("invalid_display_request","Reason desktop relay URL is invalid.");if(typeof e.session_id!=="string"||!js.test(e.session_id))throw new r("invalid_display_request","Reason desktop session identity is invalid.");let p=typeof e.expires_at==="string"?Date.parse(e.expires_at):Number.NaN;if(!Number.isFinite(p)||p<=t)throw new r("invalid_display_request","Reason desktop session has already expired.");return{relay_url:e.relay_url,session_id:e.session_id,expires_at:new Date(Math.min(p,t+Bs)).toISOString(),...o?{video:o}:{},...s?{viewer:s}:{},...o&&e.viewer_same_network===!0?{viewer_same_network:!0}:{}}}function kt(e=process.platform){return(e==="linux"||e==="darwin"||e==="win32")&&P()?.features.display===!0}async function ss(){if(process.platform==="win32")return kt()&&await ot();if(process.platform!=="darwin")return kt();return await ot()}function V(e){Ms(e,{recursive:!0,mode:448});let t=Ls(e);if(!t.isDirectory()||t.isSymbolicLink()||process.getuid&&t.uid!==process.getuid())throw new r("display_unavailable","Reason desktop state directory is not private.");vs(e,448)}function Gs(e,t){let n=(s)=>{let i=Buffer.alloc(2);return i.writeUInt16BE(s.length),Buffer.concat([i,s])},o=Buffer.from([255,255]);return Buffer.concat([o,n(Buffer.alloc(0)),n(Buffer.from(e)),n(Buffer.from("MIT-MAGIC-COOKIE-1")),n(t)])}function ee(e,t,n=2000){return new Promise((o)=>{let s=Os(e),i="",p=(l)=>{s.destroy(),o(l)};s.setTimeout(n,()=>p(!1)),s.once("error",()=>p(!1)),s.once("close",()=>p(!1)),s.once("connect",()=>{if(!t)p(!0)}),s.on("data",(l)=>{if(i+=l.toString("latin1"),i.length>=4)p(i.startsWith("RFB "))})})}async function Cr(e,t){let n=Date.now()+t;while(Date.now()<n){if(await e())return!0;await new Promise((o)=>setTimeout(o,100))}return!1}function ct(e,t,n){return new Promise((o)=>{let s=kr(e,t,{detached:!0,stdio:"ignore",env:n});s.once("error",()=>o(-1)),s.once("exit",(i)=>o(i)),s.unref(),setTimeout(()=>o(null),we).unref()})}var it=null;function $e(e=a()){return it??=Vs(e).finally(()=>{it=null}),it}async function Vs(e){let t=P({home:e});if(!t?.xvfb||!t.x11vnc||!t.openbox)throw new r("display_unavailable","Run `reason desktop install` on this machine to enable its desktop.");ft({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let n=X(t.root,"display");V(n);let o=await Is(e,n,t.x11vnc);if(o)return o;let s={display:_e,xauthority:X(n,"Xauthority"),rfbSocket:X(n,"rfb.sock")},i=X(n,"pulse"),p=(async()=>{try{V(i)}catch{return null}return await nr(i,t.pulseaudio)})(),l=X(n,"home");V(l);let h={HOME:l,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:s.display,XAUTHORITY:s.xauthority};if(t.pulseaudio)h.PULSE_SERVER=Ye(ze(i));let f=async()=>({...s,sound:await p});if(await ee({path:s.rfbSocket},!0))return await f();if(!Xr(s.xauthority))at(s.xauthority,Gs(_e.slice(1),Ns(16)),{mode:384,flag:"wx"});let x=Zs(X(n,"theme"),s.display),u={path:`/tmp/.X11-unix/X${_e.slice(1)}`};if(!await ee(u,!1)){if(ct(t.xvfb,[s.display,"-screen","0",`${pt.width}x${pt.height}x24`,"-nolisten","tcp","-auth",s.xauthority],h),!await Cr(()=>ee(u,!1),we))throw new r("display_unavailable","Reason could not start the virtual display.");ct(t.openbox,["--config-file",x.openboxConfig],h)}if(await Ys(x,h),!await Nr(t.x11vnc,s,n,"x11vnc.log",h))throw new r("display_unavailable","Reason could not start the desktop server.");return await f()}async function Nr(e,t,n,o,s){if(await ee({path:t.rfbSocket},!0))return!0;Us(t.rfbSocket,{force:!0});let i=await ct(e,["-display",t.display,"-auth",t.xauthority,"-rfbport","0","-rfbportv6","-1","-unixsock",t.rfbSocket,"-nopw","-forever","-shared","-noxdamage","-sb","0","-rfbversion","3.7","-quiet","-bg","-o",X(n,o)],s);if(i!==null&&i!==0)return!1;return await Cr(()=>ee({path:t.rfbSocket},!0),we)}async function Ks(){let e=["DISPLAY","XAUTHORITY","WAYLAND_DISPLAY","XDG_SESSION_TYPE"],t=(n)=>Object.fromEntries(e.flatMap((o)=>n[o]?[[o,n[o]]]:[]));if(process.env.DISPLAY)return t(process.env);try{let n=await new Promise((o,s)=>Cs("systemctl",["--user","show-environment"],{encoding:"utf8",timeout:2000},(i,p)=>i?s(i):o(p)));return t(Object.fromEntries(n.split(`
247
- `).flatMap((o)=>{let s=o.indexOf("=");return s>0?[[o.slice(0,s),o.slice(s+1)]]:[]})))}catch{return{}}}var Ar=new Set;async function Is(e,t,n){let o=await Ks(),s=/^:(\d+)(?:\.\d+)?$/.exec(o.DISPLAY??"")?.[1];if(!s||`:${s}`===_e||o.WAYLAND_DISPLAY||o.XDG_SESSION_TYPE==="wayland")return null;let i={display:`:${s}`,xauthority:o.XAUTHORITY??X(e,".Xauthority"),rfbSocket:X(t,`rfb-${s}.sock`)},p=`${i.display} ${i.xauthority}`;if(Ar.has(p)||!await ee({path:`/tmp/.X11-unix/X${s}`},!1))return null;let l={HOME:e,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:i.display,XAUTHORITY:i.xauthority};if(await Nr(n,i,t,`x11vnc-${s}.log`,l))return{...i,sound:null};return Ar.add(p),process.stderr.write(`Reason worker: your screen ${i.display} could not be served; using the virtual desktop
248
- `),null}function Zs(e,t){let n=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,o=[["terminal","xterm"],["files","pcmanfm"]].filter(([,i])=>!Xr(`/usr/bin/${i}`)).map(([i])=>i),s=Rt({root:e,display:t,screen:pt,browserExec:n,absent:o});for(let i of["","openbox","tint2","picom"])V(X(e,i));for(let[i,p]of Object.entries(s.files))at(X(e,i),p,{mode:384});for(let[i,p]of Object.entries(Tt))at(X(e,`ara-${i}`),Qs(p),{mode:384});return{root:e,openboxConfig:X(e,"openbox","rc.xml"),start:s.start}}async function Ys(e,t){let n=[`ROOT=${JSON.stringify(e.root)}`,...e.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
249
- `);await new Promise((o)=>{let s=kr("/bin/sh",["-c",n],{stdio:"ignore",env:{...t,PATH:"/usr/bin:/bin"}}),i=setTimeout(()=>{s.kill(),o()},we);s.once("error",()=>{clearTimeout(i),o()}),s.once("exit",()=>{clearTimeout(i),o()})})}async function Ct(e,t={}){let n=t.now??Date.now,o=$s(e.payload,n());if(e.signal.throwIfAborted(),!o.video)throw new r("display_video_required","Reason desktops stream as video now; this request came without it.");let s=t.platform??process.platform;if(s!=="linux"&&s!=="darwin"&&s!=="win32")throw new r("display_video_unsupported","This machine does not serve desktop video.");let i=o.video,p=(t.video?.desktop??(s==="darwin"?async()=>mr:s==="win32"?async()=>hr:$e))();return await zs(e.signal,o,t,n,(l)=>Dr(l,{request:i,desktop:p,...o.viewer?{viewer:o.viewer}:{},viewerSameNetwork:o.viewer_same_network===!0},t.video),(l)=>$r({type:"error",code:l}))}function zs(e,t,n,o,s,i){let p=o();return new Promise((l,h)=>{let f=null,x=!1,u=!1,S,y,A,q=!1,c=null,_=(w)=>{if(u)return;if(c)w=c;u=!0,clearTimeout(S),clearTimeout(y),e.removeEventListener("abort",D),A?.close();try{f?.close(1000,"display_session_over")}catch{}if("error"in w){h(w.error);return}l({reason:w.reason,...A?.summary(),duration_ms:Math.max(0,o()-p)})},E=()=>_({error:new r("display_relay_unavailable","Reason could not reach the desktop relay.")}),D=()=>{let w=e.reason;_({error:w instanceof r?w:new r("cancelled","Reason closed the desktop session.")})},N=()=>{if(!c||!f)return;let w=c.error;try{f.send(i(w instanceof r?w.code:"display_unavailable"))}catch{}_(c)};if(A=s({get done(){return u||c!==null},get open(){return x&&!u&&c===null},get bufferedAmount(){return f?.bufferedAmount??0},send(w){if(u||c||!x||!f)return;try{f.send(w)}catch{_({reason:"relay_closed"})}},end:(w)=>{if(u||c)return;if(!("error"in w)){_(w);return}if(c=w,q&&x)N()}}),u){A.close();return}if(e.aborted){D();return}e.addEventListener("abort",D,{once:!0}),S=setTimeout(()=>_({reason:"session_expired"}),Math.max(1,Date.parse(t.expires_at)-o())),y=setTimeout(()=>_({reason:"viewer_absent"}),n.viewerWaitMs??Js);try{f=(n.connect??wr)(t.relay_url,(n.loadProxy??j)()?.url)}catch{E();return}f.binaryType="arraybuffer",f.onopen=()=>{if(u||!f)return;x=!0,A?.opened()},f.onmessage=(w)=>{if(u)return;let M=w.data,B=M instanceof ArrayBuffer?new Uint8Array(M):ArrayBuffer.isView(M)?new Uint8Array(M.buffer,M.byteOffset,M.byteLength):null;if(!B||B.byteLength===0)return;if(clearTimeout(y),q=!0,c){N();return}A?.received(B)},f.onclose=()=>{if(u)return;if(!x){E();return}_({reason:"relay_closed"})},f.onerror=()=>{if(u||x)return;E()}})}
250
- export{Me,$i,F,Ye,Bi,xt,gr,P,Fi,kt,ss,V,$e,Ct};
245
+ `;u(()=>{if(s=!0,h=setTimeout(()=>x(),5000),n.stdin.write(y),n.stdin.writableLength>or)f(),t.end({reason:"input_backpressure"})},Buffer.byteLength(y))},close:f}}var H={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},ps="avc1.4D002A",ar={width:1920,height:1080},cs=262144,ls=0.2,fs=250,ds=1e4,bs=1024,et=1e4,xs=500,ys=60,ms=1e4,hs=1000,pr=1048576,hr={kind:"mac_screen",sound:null},gr={kind:"windows_screen",sound:null},gs,cr=()=>gs??=P()?.ffmpeg??null,Se=(e,t,n)=>rt(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Ss,nt=()=>Ss??=Ht(P()),lr=(e,t,n)=>{let[o,...s]=[...nt(),e];return Se(o,[...s,...t],n)},ur=()=>Dr?.videotoolbox?"h264_videotoolbox":"libx264",_s=()=>Math.round(performance.now()*1000),tt=new Set,fr=!1;function Sr(e){if(tt.add(e),e.once("exit",()=>tt.delete(e)),fr)return;fr=!0,process.once("exit",()=>{for(let t of tt)try{t.kill("SIGKILL")}catch{}})}function _r(e){try{e.stdout?.destroy()}catch{}if(e.exitCode!==null||e.signalCode!==null)return;try{e.kill("SIGTERM")}catch{return}let t=setTimeout(()=>{if(e.exitCode===null&&e.signalCode===null)try{e.kill("SIGKILL")}catch{}},xs);e.once("exit",()=>clearTimeout(t))}function ws(e,t,n){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",n],size:t}}function Ps(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function qs(e,t){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(e),"-offset_x","0","-offset_y","0","-video_size",`${t.width}x${t.height}`,"-i","desktop"],size:t}}function Es(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var wr=1700000;function Pr(e){return Math.min(1,Math.round(Math.sqrt(wr/(e.width*e.height))*100)/100)}function Ds(e,t,n){let o=rt(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,Pr(n.size)))],{stdio:["ignore","pipe","ignore"]}),s=rt(e,t,{env:{},stdio:["pipe","pipe","ignore"]});o.stdout.pipe(s.stdin),s.stdin.on("error",()=>{});let i=()=>{if(o.exitCode===null&&o.signalCode===null)o.kill("SIGTERM")};return s.once("exit",i),s.once("error",i),o.once("exit",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),o.once("error",()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGTERM")}),s}function dr(e){let t=Math.min(1,ar.width/e.width,ar.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function ge(e,t,n,o="libx264"){let s=H[e],i=(u)=>Math.max(2,Math.floor(u/2)*2),p={width:i(n.width*s.scale),height:i(n.height*s.scale)},l=p.width!==t.size?.width||p.height!==t.size.height,h=Math.max(1,Math.round(s.kbps*2/s.fps)),f=["-g",String(s.fps*ys)],x=o==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...f,"-b:v",`${s.kbps}k`,"-maxrate",`${s.kbps}k`,"-bufsize",`${h}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",s.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...s.threads?["-threads",String(s.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...f,"-crf",String(s.crf),"-maxrate",`${s.kbps}k`,"-bufsize",`${h}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...l?["-vf",`scale=${p.width}:${p.height}:flags=fast_bilinear`]:[],...x,"-flush_packets","1","-f","h264","pipe:1"]}class qr{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let n=new Uint8Array(this.buffer.byteLength+e.byteLength);n.set(this.buffer),n.set(e,this.buffer.byteLength),this.buffer=n;let o=[],s=this.scanned;while(s+3<this.buffer.byteLength){if(this.buffer[s]!==0||this.buffer[s+1]!==0||this.buffer[s+2]!==1){s++;continue}let i=this.buffer[s+3]&31,p=s>0&&this.buffer[s-1]===0?s-1:s;if(i===9&&p>0)o.push({data:this.buffer.slice(0,p),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(p),this.key=!1,this.micros=t,s-=p;if(i===5)this.key=!0;s+=3}return this.scanned=s,o}}function Ts(e,t){let n=as({path:e}),o=Buffer.alloc(0),s="version",i=0,p=!1,l=[],h=0,f=!1,x=(c)=>{if(f)return;f=!0,n.destroy(),t.end(c)},u=()=>x({reason:"display_protocol"}),S=(c)=>{if(f)return;if(!p){if(h+=c.byteLength,h>pr)x({reason:"input_backpressure"});else l.push(c);return}if(n.write(c),n.writableLength>pr)x({reason:"input_backpressure"})},y=(c)=>{o=o.subarray(c)},A=()=>{switch(s){case"version":{if(o.byteLength<12)return!1;let c=/^RFB (\d{3})\.(\d{3})\n$/.exec(o.subarray(0,12).toString("latin1"));if(!c||Number(c[1])*1000+Number(c[2])<3007)return u(),!1;return y(12),n.write(`RFB 003.007
246
+ `),s="security",!0}case"security":{if(o.byteLength<1)return!1;let c=o[0];if(c===0)return u(),!1;if(o.byteLength<1+c)return!1;if(!o.subarray(1,1+c).includes(1))return u(),!1;return y(1+c),n.write(Buffer.from([1,1])),s="init",!0}case"init":{if(o.byteLength<24)return!1;let c=o.readUInt32BE(20);if(c>65536)return u(),!1;if(o.byteLength<24+c)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(y(24+c),_.width===0||_.height===0)return u(),!1;s="messages",p=!0;for(let E of l)n.write(E);return l=[],h=0,t.ready(_),!f}case"skip":{let c=Math.min(i,o.byteLength);if(y(c),i-=c,i>0)return!1;return s="messages",!0}case"messages":{if(o.byteLength<1)return!1;switch(o[0]){case 1:{if(o.byteLength<6)return!1;let c=6+o.readUInt16BE(4)*6;if(o.byteLength<c)return!1;return y(c),!0}case 2:return y(1),!0;case 3:{if(o.byteLength<8)return!1;let c=o.readUInt32BE(4);if(c>v/2)return y(8),s="skip",i=c,!0;if(o.byteLength<8+c)return!1;let _=o.subarray(8,8+c).toString("latin1");return y(8+c),t.clipboard(_),!f}default:return u(),!1}}}},q=!1;return n.once("connect",()=>{q=!0}),n.on("data",(c)=>{if(f)return;o=o.byteLength?Buffer.concat([o,c]):c;while(!f&&A());}),n.once("error",()=>{if(!q)x({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>x({reason:"display_closed"})),{pointer(c,_,E){let D=Buffer.alloc(6);D.writeUInt8(5,0),D.writeUInt8(E&255,1),D.writeUInt16BE(c,2),D.writeUInt16BE(_,4),S(D)},key(c,_){let E=Buffer.alloc(8);E.writeUInt8(4,0),E.writeUInt8(c?1:0,1),E.writeUInt32BE(_>>>0,4),S(E)},clipboard(c){if(Array.from(c).some((D)=>D.codePointAt(0)>255)){x({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(c,"latin1"),E=Buffer.alloc(8);E.writeUInt8(6,0),E.writeUInt32BE(_.byteLength,4),S(Buffer.concat([E,_]))},close(){f=!0,n.destroy()}}}class st{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,n,o){this.viewers.add(e),this.stop();let s;try{s=n()}catch{this.fail();return}Sr(s);let i={child:s,splitter:new qr};this.run=i;for(let l of[...this.viewers])l.started(t);s.stdout?.on("data",(l)=>{if(this.run!==i)return;for(let h of i.splitter.push(l,o()))for(let f of[...this.viewers])f.unit(h)});let p=()=>{if(this.run!==i)return;this.run=null,this.fail()};s.once("exit",p),s.once("error",p)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;_r(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var br=new WeakMap;function Rs(e){let t=br.get(e);if(!t)br.set(e,t=new st);return t}function Er(e,t,n={}){let o=n.micros??_s,s=new In,i=t.request.preset,p=null,l=null,h=null,f=!1,x=null,u=!1,S=!1,y=null,A=0,q=0,c=!1,_=null,E=null,D=0,N=null,k=[],te=0,w=[],M=new Uint32Array(et+1),B=0,Pe=null,qe=0,re=0,Ee=0,lt=0,ut=0,ce=null,De=0,K={frames:0,bytes:0,since:o()},I=[],ne=0,Te,Re=!1,Nr=o(),C={},Z=()=>Math.round((o()-Nr)/1000),ft=n.control??er,Ae=null,ke=null,L=(b)=>{let d=Fr(b);return e.send(d),lt+=d.byteLength,d.byteLength},le=(b)=>{if(e.done)return;if(e.open)L({type:"error",code:b});e.end({reason:b})},ue=()=>Math.max(cs,H[i].kbps*1000/8*ls),fe=()=>o()/1000,Lr=()=>{while(w.length>1&&w[0].atMs<fe()-ds)w.shift();return w[0]?.rttMs??null},dt=(b)=>{let d=Lr();if(d===null||k.length===0)return!1;let m=(d+fs)*b;return fe()-k[0].sentMs>m||te>m/1000*H[i].kbps*1000/8},Mr=(b)=>{if(D===0)return;let d=Math.min(b,D-1);if(N!==null&&d<=N)return;N=d;let m=fe();while(k.length&&k[0].seq<=d){let T=k.shift();if(te-=T.bytes,T.seq!==d)continue;let R=Math.max(0,m-T.sentMs);while(w.length&&w.at(-1).rttMs>=R)w.pop();w.push({atMs:m,rttMs:R}),M[Math.min(et,Math.round(R))]++,B++,Pe=Math.min(Pe??R,R)}},Qr=()=>{let b=0;for(let d=0;d<=et;d++)if(b+=M[d],b*2>=B)return d;return 0},Ur=()=>e.bufferedAmount<=ue()/2&&!dt(0.5),bt=()=>{Re=!0,I=[],ne=0,x?.leave(Xe),x=null},xt=(b)=>{if(e.done)return;if(b.key)C.first_key_ms??=Z();if(!f){if(!x||I.length===0&&!b.key)return;if(I.push(b),ne+=b.data.byteLength,ne>ue())bt();return}if(c){re++;return}if(e.bufferedAmount>ue()||dt(1)){c=!0,re++,_=setInterval(()=>{if(e.done||!Ur())return;if(_)clearInterval(_);_=null,c=!1,Ne()},n.drainPollMs??25);return}if(!u){if(!b.key){re++;return}if(L({type:"hello",width:l.width,height:l.height,fps:H[i].fps,preset:i,codec:ps}),u=!0,C.first_frame_ms??=Z(),!S&&p?.sound)L({type:"audioHello",...pe}),S=!0}let d=L({type:"frame",key:b.key,seq:D,captureMicros:b.micros,data:b.data});if(k.push({seq:D,sentMs:fe(),bytes:d}),te+=d,k.length>bs)te-=k.shift().bytes;D++,qe++,ce??=b.micros,De=b.micros,K.frames++,K.bytes+=d},Xe={started(b){i=b,u=!1,I=[],ne=0},unit:xt,failed:()=>le("encoder_failed")},Ce=()=>{let b=(n.ffmpeg??cr)();if(!p||!l){le("encoder_failed");return}let[d,m]=[p,l],T="kind"in d&&d.kind==="simulator"?d.stream:null;if(!b&&!T){le("encoder_failed");return}if(x??="kind"in d&&d.kind==="mac_screen"?Rs(n.spawn??lr):new st,C.encoder_ms===void 0)C.encoder_ms=Z(),C.encoder_shared=x.running;x.start(Xe,i,()=>{let R=H[i].fps;if(T)return T(R,H[i].kbps,wr);if("kind"in d&&d.kind==="simulator"){let Q=Math.min(0.99,Pr(d.size)),se={width:d.size.width*Q,height:d.size.height*Q};return Ds(b,ge(i,Es(Math.min(R,30)),se,(n.macEncoder??ur)()),d)}if("kind"in d&&d.kind==="windows_screen")return(n.spawn??Se)(b,ge(i,qs(R,m),dr(m)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in d?(n.spawn??lr)(b,ge(i,Ps(R),dr(m),(n.macEncoder??ur)()),{}):(n.spawn??Se)(b,ge(i,ws(R,m,d.display),m),{DISPLAY:d.display,XAUTHORITY:d.xauthority})},o)},de=()=>{if(!y)return;_r(y.child),y=null},Or=()=>{let b=(n.ffmpeg??cr)();if(y||e.done||!S||!p?.sound||!b)return;let d;try{d=(n.spawn??Se)(b,sr(),{PULSE_SERVER:Qe(p.sound)})}catch{return}Sr(d);let m={child:d,reader:new He};y=m,d.stdout?.on("data",(R)=>{if(y!==m||e.done)return;let Q;try{Q=m.reader.push(R)}catch{de();return}let se=o();for(let Br of Q){if(e.bufferedAmount>ue()){q++;continue}L({type:"audio",captureMicros:se,data:Br}),A++}});let T=()=>{if(y===m)de()};d.once("exit",T),d.once("error",T)},Ne=()=>{if(!x||e.done)return;Ee++,Ce()},yt=()=>{if(e.done||!l)return;if(!f){if(x||Re)return;Ce(),Te=setTimeout(()=>{if(!f)bt()},ms);return}if(clearTimeout(Te),C.encoder_early===void 0){if(C.encoder_early=x!==null,Re)C.hold_lapsed=!0}if(!x)Ce();let b=I;I=[],ne=0;for(let d of b)xt(d);E??=setInterval(()=>{let d=o(),m=Math.max(0.001,(d-K.since)/1e6);L({type:"stats",stats:{fps:Math.round(K.frames/m*10)/10,kbps:Math.round(K.bytes*8/1000/m),dropped:re,restarts:Ee,queued_bytes:e.bufferedAmount}}),K={frames:0,bytes:0,since:d}},hs)};t.desktop.then((b)=>{if(e.done)return;p=b;let d={ready(m){l=m,C.desktop_ms??=Z(),yt()},clipboard(m){if(e.open&&Buffer.byteLength(m)<=v)L({type:"serverClipboard",text:m})},end(m){if("reason"in m&&e.open)L({type:"error",code:m.reason});e.end(m)}};if("kind"in b&&b.kind==="simulator")h=b.input,d.ready(b.points);else if("kind"in b&&b.kind==="windows_screen")h=(n.windowsInput??Jt)(d);else if("kind"in b)h=(n.macInput??((m)=>Nn(m,nt())))(d);else{let m=(n.linuxClipboard??ir)(b,d),T=Ts(b.rfbSocket,{...d,clipboard:(R)=>{if(!m)d.clipboard(R)}});h=m?{pointer:(R,Q,se)=>m.apply(()=>T.pointer(R,Q,se)),key:(R,Q)=>m.apply(()=>T.key(R,Q)),clipboard:(R)=>m.write(R),close(){m.close(),T.close()}}:T}mt()},(b)=>e.end({error:b}));function mt(){if(ke||!t.viewerSameNetwork||!f||e.done||!p||!("kind"in p)||p.kind!=="mac_screen")return;ke=(n.macWindows??Dn)((b)=>{if(e.open)L({type:"windows",bounds:b})})}let ht={viewer:t.viewer??null,notify(b){if(e.open)L({type:"control",control:b})}},ve=(b)=>{if(!h)return;if(!p||!("kind"in p)||p.kind!=="simulator")ft.claim(ht);b(h)};return{opened(){C.relay_ms??=Z()},received(b){ut+=b.byteLength;let d;try{d=s.push(b)}catch{le("viewer_protocol");return}for(let m of d){if(e.done)return;switch(m.type){case"ping":L({type:"pong",token:m.token});break;case"pointer":ve((T)=>T.pointer(m.x,m.y,m.buttons));break;case"key":ve((T)=>T.key(m.down,m.keysym));break;case"clientClipboard":ve((T)=>T.clipboard(m.text));break;case"config":if(m.preset!==i)i=m.preset,Ne();break;case"keyframeRequest":if(u&&!c)Ne();break;case"ack":Mr(m.seq);break;case"audioEnable":if(m.on)Or();else de();break;default:break}}if(!f&&!e.done){if(f=!0,C.viewer_ms=Z(),t.viewer)Ae=ft.join(ht);yt(),mt()}},close(){if(Ae?.(),Ae=null,ke?.close(),_)clearInterval(_);if(E)clearInterval(E);clearTimeout(Te),x?.leave(Xe),de(),h?.close()},summary:()=>({output_bytes:lt,input_bytes:ut,video:{preset:i,frames:qe,dropped:re,restarts:Ee,avg_fps:ce!==null&&De>ce?Math.round((qe-1)/((De-ce)/1e6)*10)/10:0,min_rtt_ms:Math.round(Pe??0),p50_rtt_ms:B?Qr():0,audio_packets:A,audio_dropped:q,connect:C}})}}var xr=null,Dr=null,As=null,ks=null;function Xs(){let e=P();return e?.features.display?e.ffmpeg:null}function Tr(e){return xr??=new Promise((t)=>{os(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(n,o)=>{let s=(i)=>!n&&new RegExp(`^\\s*V\\S*\\s+${i}\\s`,"m").test(o);t(Dr={x264:s("libx264"),videotoolbox:s("h264_videotoolbox")})})}),xr}var mr=null;function ji(){return mr??=(async()=>{let e=[P()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&is(n)));if(!e)return null;let t=await Tr(e);return t.videotoolbox||t.x264?e:null})(),mr}function ot(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Xs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??Tr)(n);if(e==="linux")return o.then((i)=>i.x264);if(e==="win32"){let i=t.windowsScreen?t.windowsScreen():ks??=Ut();return Promise.all([o,i]).then(([p,l])=>p.x264&&(l?.session??0)>0)}let s=t.macScreen?t.macScreen():As??=ze(nt());return Promise.all([o,s]).then(([i,p])=>(i.x264||i.videotoolbox)&&p?.screen===!0&&p.accessibility)}var Bs=43200000,_e=":99",Js=60000,we=15000,pt={width:1280,height:800},js=/^[A-Za-z0-9._:-]{1,160}$/;function Ws(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Fs=["video","viewer","viewer_same_network","viewer_network"];function $s(e,t=Date.now()){let n=["relay_url","session_id","expires_at"];if(!Ws(e)||n.some((l)=>!(l in e))||Object.keys(e).some((l)=>!n.includes(l)&&!Fs.includes(l)))throw new r("invalid_display_request","Reason desktop request is malformed.");let o="video"in e?oo(e.video):void 0,s="viewer"in e?On(e.viewer):null;if(o===null)throw new r("invalid_display_request","Reason desktop video request is invalid.");let i=null;try{i=typeof e.relay_url==="string"?new URL(e.relay_url):null}catch{}if(!i||i.protocol!=="wss:"&&i.protocol!=="ws:"||i.username||i.password)throw new r("invalid_display_request","Reason desktop relay URL is invalid.");if(typeof e.session_id!=="string"||!js.test(e.session_id))throw new r("invalid_display_request","Reason desktop session identity is invalid.");let p=typeof e.expires_at==="string"?Date.parse(e.expires_at):Number.NaN;if(!Number.isFinite(p)||p<=t)throw new r("invalid_display_request","Reason desktop session has already expired.");return{relay_url:e.relay_url,session_id:e.session_id,expires_at:new Date(Math.min(p,t+Bs)).toISOString(),...o?{video:o}:{},...s?{viewer:s}:{},...o&&e.viewer_same_network===!0?{viewer_same_network:!0}:{}}}function At(e=process.platform){return(e==="linux"||e==="darwin"||e==="win32")&&P()?.features.display===!0}async function us(){if(process.platform==="win32")return At()&&await ot();if(process.platform!=="darwin")return At();return await ot()}function V(e){Ms(e,{recursive:!0,mode:448});let t=Ls(e);if(!t.isDirectory()||t.isSymbolicLink()||process.getuid&&t.uid!==process.getuid())throw new r("display_unavailable","Reason desktop state directory is not private.");vs(e,448)}function Gs(e,t){let n=(s)=>{let i=Buffer.alloc(2);return i.writeUInt16BE(s.length),Buffer.concat([i,s])},o=Buffer.from([255,255]);return Buffer.concat([o,n(Buffer.alloc(0)),n(Buffer.from(e)),n(Buffer.from("MIT-MAGIC-COOKIE-1")),n(t)])}function ee(e,t,n=2000){return new Promise((o)=>{let s=Os(e),i="",p=(l)=>{s.destroy(),o(l)};s.setTimeout(n,()=>p(!1)),s.once("error",()=>p(!1)),s.once("close",()=>p(!1)),s.once("connect",()=>{if(!t)p(!0)}),s.on("data",(l)=>{if(i+=l.toString("latin1"),i.length>=4)p(i.startsWith("RFB "))})})}async function Xr(e,t){let n=Date.now()+t;while(Date.now()<n){if(await e())return!0;await new Promise((o)=>setTimeout(o,100))}return!1}function ct(e,t,n){return new Promise((o)=>{let s=Ar(e,t,{detached:!0,stdio:"ignore",env:n});s.once("error",()=>o(-1)),s.once("exit",(i)=>o(i)),s.unref(),setTimeout(()=>o(null),we).unref()})}var it=null;function Be(e=a()){return it??=Vs(e).finally(()=>{it=null}),it}async function Vs(e){let t=P({home:e});if(!t?.xvfb||!t.x11vnc||!t.openbox)throw new r("display_unavailable","Run `reason desktop install` on this machine to enable its desktop.");gt({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let n=X(t.root,"display");V(n);let o=await Is(e,n,t.x11vnc);if(o)return o;let s={display:_e,xauthority:X(n,"Xauthority"),rfbSocket:X(n,"rfb.sock")},i=X(n,"pulse"),p=(async()=>{try{V(i)}catch{return null}return await nr(i,t.pulseaudio)})(),l=X(n,"home");V(l);let h={HOME:l,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:s.display,XAUTHORITY:s.xauthority};if(t.pulseaudio)h.PULSE_SERVER=Qe(Ye(i));let f=async()=>({...s,sound:await p});if(await ee({path:s.rfbSocket},!0))return await f();if(!kr(s.xauthority))at(s.xauthority,Gs(_e.slice(1),Ns(16)),{mode:384,flag:"wx"});let x=Zs(X(n,"theme"),s.display),u={path:`/tmp/.X11-unix/X${_e.slice(1)}`};if(!await ee(u,!1)){if(ct(t.xvfb,[s.display,"-screen","0",`${pt.width}x${pt.height}x24`,"-nolisten","tcp","-auth",s.xauthority],h),!await Xr(()=>ee(u,!1),we))throw new r("display_unavailable","Reason could not start the virtual display.");ct(t.openbox,["--config-file",x.openboxConfig],h)}if(await Ys(x,h),!await Cr(t.x11vnc,s,n,"x11vnc.log",h))throw new r("display_unavailable","Reason could not start the desktop server.");return await f()}async function Cr(e,t,n,o,s){if(await ee({path:t.rfbSocket},!0))return!0;Us(t.rfbSocket,{force:!0});let i=await ct(e,["-display",t.display,"-auth",t.xauthority,"-rfbport","0","-rfbportv6","-1","-unixsock",t.rfbSocket,"-nopw","-forever","-shared","-noxdamage","-sb","0","-rfbversion","3.7","-quiet","-bg","-o",X(n,o)],s);if(i!==null&&i!==0)return!1;return await Xr(()=>ee({path:t.rfbSocket},!0),we)}async function Ks(){let e=["DISPLAY","XAUTHORITY","WAYLAND_DISPLAY","XDG_SESSION_TYPE"],t=(n)=>Object.fromEntries(e.flatMap((o)=>n[o]?[[o,n[o]]]:[]));if(process.env.DISPLAY)return t(process.env);try{let n=await new Promise((o,s)=>Cs("systemctl",["--user","show-environment"],{encoding:"utf8",timeout:2000},(i,p)=>i?s(i):o(p)));return t(Object.fromEntries(n.split(`
247
+ `).flatMap((o)=>{let s=o.indexOf("=");return s>0?[[o.slice(0,s),o.slice(s+1)]]:[]})))}catch{return{}}}var Rr=new Set;async function Is(e,t,n){let o=await Ks(),s=/^:(\d+)(?:\.\d+)?$/.exec(o.DISPLAY??"")?.[1];if(!s||`:${s}`===_e||o.WAYLAND_DISPLAY||o.XDG_SESSION_TYPE==="wayland")return null;let i={display:`:${s}`,xauthority:o.XAUTHORITY??X(e,".Xauthority"),rfbSocket:X(t,`rfb-${s}.sock`)},p=`${i.display} ${i.xauthority}`;if(Rr.has(p)||!await ee({path:`/tmp/.X11-unix/X${s}`},!1))return null;let l={HOME:e,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:i.display,XAUTHORITY:i.xauthority};if(await Cr(n,i,t,`x11vnc-${s}.log`,l))return{...i,sound:null};return Rr.add(p),process.stderr.write(`Reason worker: your screen ${i.display} could not be served; using the virtual desktop
248
+ `),null}function Zs(e,t){let n=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,o=[["terminal","xterm"],["files","pcmanfm"]].filter(([,i])=>!kr(`/usr/bin/${i}`)).map(([i])=>i),s=Rt({root:e,display:t,screen:pt,browserExec:n,absent:o});for(let i of["","openbox","tint2","picom"])V(X(e,i));for(let[i,p]of Object.entries(s.files))at(X(e,i),p,{mode:384});for(let[i,p]of Object.entries(Tt))at(X(e,`ara-${i}`),Qs(p),{mode:384});return{root:e,openboxConfig:X(e,"openbox","rc.xml"),start:s.start}}async function Ys(e,t){let n=[`ROOT=${JSON.stringify(e.root)}`,...e.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
249
+ `);await new Promise((o)=>{let s=Ar("/bin/sh",["-c",n],{stdio:"ignore",env:{...t,PATH:"/usr/bin:/bin"}}),i=setTimeout(()=>{s.kill(),o()},we);s.once("error",()=>{clearTimeout(i),o()}),s.once("exit",()=>{clearTimeout(i),o()})})}async function Pt(e,t={}){let n=t.now??Date.now,o=$s(e.payload,n());if(e.signal.throwIfAborted(),!o.video)throw new r("display_video_required","Reason desktops stream as video now; this request came without it.");let s=t.platform??process.platform;if(s!=="linux"&&s!=="darwin"&&s!=="win32")throw new r("display_video_unsupported","This machine does not serve desktop video.");let i=o.video,p=(t.video?.desktop??(s==="darwin"?async()=>hr:s==="win32"?async()=>gr:Be))();return await zs(e.signal,o,t,n,(l)=>Er(l,{request:i,desktop:p,...o.viewer?{viewer:o.viewer}:{},viewerSameNetwork:o.viewer_same_network===!0},t.video),(l)=>Fr({type:"error",code:l}))}function zs(e,t,n,o,s,i){let p=o();return new Promise((l,h)=>{let f=null,x=!1,u=!1,S,y,A,q=!1,c=null,_=(w)=>{if(u)return;if(c)w=c;u=!0,clearTimeout(S),clearTimeout(y),e.removeEventListener("abort",D),A?.close();try{f?.close(1000,"display_session_over")}catch{}if("error"in w){h(w.error);return}l({reason:w.reason,...A?.summary(),duration_ms:Math.max(0,o()-p)})},E=()=>_({error:new r("display_relay_unavailable","Reason could not reach the desktop relay.")}),D=()=>{let w=e.reason;_({error:w instanceof r?w:new r("cancelled","Reason closed the desktop session.")})},N=()=>{if(!c||!f)return;let w=c.error;try{f.send(i(w instanceof r?w.code:"display_unavailable"))}catch{}_(c)};if(A=s({get done(){return u||c!==null},get open(){return x&&!u&&c===null},get bufferedAmount(){return f?.bufferedAmount??0},send(w){if(u||c||!x||!f)return;try{f.send(w)}catch{_({reason:"relay_closed"})}},end:(w)=>{if(u||c)return;if(!("error"in w)){_(w);return}if(c=w,q&&x)N()}}),u){A.close();return}if(e.aborted){D();return}e.addEventListener("abort",D,{once:!0}),S=setTimeout(()=>_({reason:"session_expired"}),Math.max(1,Date.parse(t.expires_at)-o())),y=setTimeout(()=>_({reason:"viewer_absent"}),n.viewerWaitMs??Js);try{f=(n.connect??vr)(t.relay_url,(n.loadProxy??j)()?.url)}catch{E();return}f.binaryType="arraybuffer",f.onopen=()=>{if(u||!f)return;x=!0,A?.opened()},f.onmessage=(w)=>{if(u)return;let M=w.data,B=M instanceof ArrayBuffer?new Uint8Array(M):ArrayBuffer.isView(M)?new Uint8Array(M.buffer,M.byteOffset,M.byteLength):null;if(!B||B.byteLength===0)return;if(clearTimeout(y),q=!0,c){N();return}A?.received(B)},f.onclose=()=>{if(u)return;if(!x){E();return}_({reason:"relay_closed"})},f.onerror=()=>{if(u||x)return;E()}})}
250
+ export{$e,Fi,F,Qe,ji,Ct,yr,P,Ui,At,us,V,Be,Pt};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{I}from"./vm-hands-entry-lite-zg3b0c08.js";import{randomUUID as m}from"crypto";import{closeSync as k,constants as c,fstatSync as u,lstatSync as s,mkdirSync as l,openSync as E,readFileSync as S,realpathSync as a,renameSync as g,unlinkSync as p,writeFileSync as v}from"fs";import{dirname as w,resolve as _}from"path";var d=65536;function f(r){try{return s(r),!0}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return!1;throw o}}function b(r,o=!1){if(!f(r)){if(!o)throw Error("worker_state_missing");y(r),l(r,{mode:448})}let e=s(r);if(!e.isDirectory()||e.isSymbolicLink()||!I(e)||a(r)!==_(r))throw Error("worker_state_directory_not_private_or_canonical")}function y(r){let o=w(r);if(!f(o))y(o),l(o,{mode:448});if(a(o)!==_(o))throw Error("worker_parent_not_canonical")}function h(r,o=d){let e=E(r,c.O_RDONLY|c.O_NOFOLLOW);try{let n=u(e);if(!n.isFile()||n.nlink!==1||!I(n)||n.size>o)throw Error("worker_file_not_private");return S(e,"utf8")}finally{k(e)}}function Mi(r,o,e=d){let n=JSON.stringify(o);if(n===void 0)throw Error("worker_file_invalid");let t=n+`
2
+ import{I}from"./vm-hands-entry-lite-9ay6f56v.js";import{randomUUID as m}from"crypto";import{closeSync as k,constants as c,fstatSync as u,lstatSync as s,mkdirSync as l,openSync as E,readFileSync as S,realpathSync as a,renameSync as g,unlinkSync as p,writeFileSync as v}from"fs";import{dirname as w,resolve as _}from"path";var d=65536;function f(r){try{return s(r),!0}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return!1;throw o}}function b(r,o=!1){if(!f(r)){if(!o)throw Error("worker_state_missing");y(r),l(r,{mode:448})}let e=s(r);if(!e.isDirectory()||e.isSymbolicLink()||!I(e)||a(r)!==_(r))throw Error("worker_state_directory_not_private_or_canonical")}function y(r){let o=w(r);if(!f(o))y(o),l(o,{mode:448});if(a(o)!==_(o))throw Error("worker_parent_not_canonical")}function h(r,o=d){let e=E(r,c.O_RDONLY|c.O_NOFOLLOW);try{let n=u(e);if(!n.isFile()||n.nlink!==1||!I(n)||n.size>o)throw Error("worker_file_not_private");return S(e,"utf8")}finally{k(e)}}function Bi(r,o,e=d){let n=JSON.stringify(o);if(n===void 0)throw Error("worker_file_invalid");let t=n+`
3
3
  `;if(Buffer.byteLength(t,"utf8")>e)throw Error("worker_file_too_large");if(b(w(r)),f(r))h(r,e);let i=`${r}.${m()}`;try{v(i,t,{mode:384,flag:"wx"}),g(i,r)}finally{if(f(i))p(i)}}
4
- export{f,b,h,Mi};
4
+ export{f,b,h,Bi};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ht}from"./vm-hands-entry-lite-66ctbcym.js";var ct=Ht.version;export{ct};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var l=Object.create;var{getPrototypeOf:m,defineProperty:h,getOwnPropertyNames:n}=Object;var k=Object.prototype.hasOwnProperty;function o(a){return this[a]}var p,q,hi=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var i=b?p??=new WeakMap:q??=new WeakMap,j=i.get(a);if(j)return j}c=a!=null?l(m(a)):{};let f=b||!a||!a.__esModule||!k.call(a,"default")?h(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let g of n(a))if(!k.call(f,g))h(f,g,{get:o.bind(a,g),enumerable:!0})}if(d)i.set(a,f);return f};var he=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var r=(a)=>a;function s(a,b){this[a]=r.bind(null,b)}var Mo=(a,b)=>{for(var c in b)h(a,c,{get:b[c],enumerable:!0,configurable:!0,set:s.bind(b,c)})};var $o=(a,b,c)=>()=>{if(a)try{b=a(a=0)}catch(d){c=[d]}if(c)throw c[0];return b};var e=import.meta.require;
3
- export{hi,he,Mo,$o,e};
2
+ var l=Object.create;var{getPrototypeOf:m,defineProperty:h,getOwnPropertyNames:n}=Object;var k=Object.prototype.hasOwnProperty;function o(a){return this[a]}var p,q,mi=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var i=b?p??=new WeakMap:q??=new WeakMap,j=i.get(a);if(j)return j}c=a!=null?l(m(a)):{};let f=b||!a||!a.__esModule||!k.call(a,"default")?h(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let g of n(a))if(!k.call(f,g))h(f,g,{get:o.bind(a,g),enumerable:!0})}if(d)i.set(a,f);return f};var he=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var r=(a)=>a;function s(a,b){this[a]=r.bind(null,b)}var Bo=(a,b)=>{for(var c in b)h(a,c,{get:b[c],enumerable:!0,configurable:!0,set:s.bind(b,c)})};var Fo=(a,b,c)=>()=>{if(a)try{b=a(a=0)}catch(d){c=[d]}if(c)throw c[0];return b};var e=import.meta.require;
3
+ export{mi,he,Bo,Fo,e};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{at}from"./vm-hands-entry-lite-8bzqc4xa.js";import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Dn="so.ara.cli",k=[Dn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Br(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${F}"`}var G="ReasonBackgroundIdentity",io="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Br([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Br(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Fr(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Fr(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
2
+ import{ct}from"./vm-hands-entry-lite-0g9xvgdy.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Ln="so.ara.cli",k=[Ln,"com.reasonmachines.cli"],F="5LJFSBRY2F";function jr(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${F}"`}var G="ReasonBackgroundIdentity",so="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=jr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=jr(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Ur(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Ur(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
3
3
  `)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!V.test(i)&&J.has(o)){let c=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
4
  `).find((l)=>l.startsWith("n/"));if(c)i=c.slice(1)}t.push(i)}return t}function _e(e){if(H(e.home),!d(e.sourceApp))throw new h("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??K,n=le(e.home),r=I(n);Y(r,{recursive:!0,mode:448}),ee(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${L()}`,c=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),y=!1;try{if(te(i,c,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(c))throw new h("identity_invalid","The copied Reason background identity is invalid.");let _=e.releaseSigned?["--test-requirement",`=${de}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",..._,c])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let S=!1;for(let p=0;p<4;p+=1){let m=!1;try{E(n,l),m=!0,y=!0}catch(s){if(s.code!=="ENOENT")throw s}if(p===0)e.beforePublish?.();try{E(c,n),S=!0}catch(s){let Z=s.code;if(!["EEXIST","ENOTEMPTY"].includes(Z??""))throw s;if(m)g(l,{recursive:!0,force:!0}),y=!1;if(p===3)throw s;continue}if(m)g(l,{recursive:!0,force:!0}),y=!1;break}if(!S)throw Error("Could not publish Reason's background identity.")}catch(_){if(y&&!x(n)&&x(l))E(l,n);throw _}finally{g(c,{recursive:!0,force:!0}),g(l,{recursive:!0,force:!0})}}return z(n,e,{verified:i!==o}),n}function X(e){return u(I(e),".Reason.app.registered")}function q(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function C(e){let t=q(e);try{return t!==null&&w(X(e),"utf8")===t}catch{return!1}}function Q(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",v)).isSymbolicLink()?"retired":null}catch{return null}}function z(e,t,n={}){let r=t.command??K;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(R,["-f",e])!==0)throw new h("identity_register_failed","Could not register Reason's macOS background identity.");let i=q(e);try{if(i)oe(X(e),i,{mode:384})}catch{}try{Se(e,t.home,r,t.runningExecutables??Ee)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
- `)}}function Se(e,t,n,r){let i=D(e);if(!i)return;let o=O(t),f=I(o),c=(s)=>u(s,"Contents","MacOS",v),l=se(I(c(o)),i),y=`${process.pid}.${L()}`,_=Q(o);if(_===null)return;let S=_==="bundle";if(S)n(R,["-u",o]);let p=u(f,`.Ara.app.${y}.old`);if(!W.has(o)&&!me(r())){if(!S)n(R,["-u",o]);try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}g(p,{recursive:!0,force:!0}),Ie(f);return}if(!S){if(re(c(o))===l)return;let s=`${c(o)}.${y}`;M(l,s);try{E(s,c(o))}finally{g(s,{force:!0})}return}let m=u(f,`.Ara.app.${y}.shim`);Y(I(c(m)),{recursive:!0}),M(l,c(m));try{try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}try{E(m,o)}catch(s){if(x(o))return;throw E(p,o),s}}finally{g(m,{recursive:!0,force:!0}),g(p,{recursive:!0,force:!0})}}function Ie(e){try{if(ne(e).some((n)=>n!==".DS_Store"))return;g(u(e,".DS_Store"),{force:!0}),ie(e)}catch{}}var B=new Map;function Nn(e=a()){let t=B.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=U(e);if(n===null&&x(I(le(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=U(e);if(n===null)return[];return B.set(e,n),n}function U(e){let t=le(e),n=O(e);if(!d(t)||!C(t))try{he({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(C(t)||!d(n))?t:d(n)?n:null,i=r?D(r):null;if(!i)return null;if(r===n)W.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
- `?[i,"--spawn"]:[]}var P=new Map;function st(e=a()){let t=Nn(e),n=t[0];if(!n)return[];let r=P.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
7
- `,P.set(n,r)}return r?t:[]}function oo(e=st(),t=a()){if(e.length>0)return null;if(Fr(t)===null)return"computer_use_identity_missing";return pe(at,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function he(e={}){H(e.home);let t=le(e.home);if(e.skipWhenSettled&&d(t)&&C(t)&&Q(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return _e({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return z(t,e),!0}var Ft="REASON_WORKER_IDENTITY_APP";function so(e,t=process.env,n=a()){let r=t[Ft];return r&&r===le(n)?r:e}function ao(e,t){if(process.platform!=="darwin")return null;let n=le(e),r=u(n,"Contents","MacOS",G),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
5
+ `)}}function Se(e,t,n,r){let i=D(e);if(!i)return;let o=O(t),f=I(o),c=(s)=>u(s,"Contents","MacOS",v),l=se(I(c(o)),i),y=`${process.pid}.${L()}`,_=Q(o);if(_===null)return;let S=_==="bundle";if(S)n(R,["-u",o]);let p=u(f,`.Ara.app.${y}.old`);if(!W.has(o)&&!me(r())){if(!S)n(R,["-u",o]);try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}g(p,{recursive:!0,force:!0}),Ie(f);return}if(!S){if(re(c(o))===l)return;let s=`${c(o)}.${y}`;M(l,s);try{E(s,c(o))}finally{g(s,{force:!0})}return}let m=u(f,`.Ara.app.${y}.shim`);Y(I(c(m)),{recursive:!0}),M(l,c(m));try{try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}try{E(m,o)}catch(s){if(x(o))return;throw E(p,o),s}}finally{g(m,{recursive:!0,force:!0}),g(p,{recursive:!0,force:!0})}}function Ie(e){try{if(ne(e).some((n)=>n!==".DS_Store"))return;g(u(e,".DS_Store"),{force:!0}),ie(e)}catch{}}var B=new Map;function Mn(e=a()){let t=B.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=U(e);if(n===null&&x(I(le(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=U(e);if(n===null)return[];return B.set(e,n),n}function U(e){let t=le(e),n=O(e);if(!d(t)||!C(t))try{he({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(C(t)||!d(n))?t:d(n)?n:null,i=r?D(r):null;if(!i)return null;if(r===n)W.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
+ `?[i,"--spawn"]:[]}var P=new Map;function at(e=a()){let t=Mn(e),n=t[0];if(!n)return[];let r=P.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
7
+ `,P.set(n,r)}return r?t:[]}function ao(e=at(),t=a()){if(e.length>0)return null;if(Ur(t)===null)return"computer_use_identity_missing";return pe(ct,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function he(e={}){H(e.home);let t=le(e.home);if(e.skipWhenSettled&&d(t)&&C(t)&&Q(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return _e({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return z(t,e),!0}var Ut="REASON_WORKER_IDENTITY_APP";function co(e,t=process.env,n=a()){let r=t[Ut];return r&&r===le(n)?r:e}function lo(e,t){if(process.platform!=="darwin")return null;let n=le(e),r=u(n,"Contents","MacOS",G),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
8
8
  `?{app:n,executable:r}:null}
9
- export{Dn,Br,io,le,Fr,Nn,st,oo,Ft,so,ao};
9
+ export{Ln,jr,so,le,Ur,Mn,at,ao,Ut,co,lo};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{mt,R}from"./vm-hands-entry-lite-w9ckj5k4.js";import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{g,Lt}from"./vm-hands-entry-lite-5p5h1eng.js";import{_e}from"./vm-hands-entry-lite-pmcz7j7t.js";function gi(e,i){let r=C(e,"REASON_API_URL")?.trim();if(!r)return Lt(i);let t=new URL(r);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(t.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return t.origin}function l(e){return C(e,"REASON_API_URL")?.trim()?gi(e,"production"):void 0}function wo(e){return C(e,"REASON_API_KEY")?.trim()||void 0}async function bo(e,i){let r=e.env??process.env,t=wo(r);if(!t)return(e.getCredentials??mt)({apiOrigin:l(r),signal:i});let a=gi(r,e.channel??g({env:r})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+t,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),n=_e(p)?p:{};if(!o.ok){let s=typeof n.detail==="string"?n.detail:typeof n.message==="string"?n.message:"API key authentication failed ("+o.status+")";throw new R(o.status,typeof n.error==="string"?n.error:"api_key_auth_failed",s)}if(typeof n.org_id!=="string"||!n.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let c=Array.isArray(n.scopes)?n.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:t,orgId:n.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:c}}async function qo(e){let i=await bo(e),r=l(e.env??process.env);if(!i)throw Error(r?`Not signed in to ${r}. Set REASON_API_KEY, or run \`reason login --api-url ${r}\`.`:"Not signed in. Run `reason login`, or set REASON_API_KEY.");return i}
3
- export{gi,wo,bo,qo};
2
+ import{_t,R}from"./vm-hands-entry-lite-zg36myyf.js";import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{g,$t}from"./vm-hands-entry-lite-ckv17tn8.js";import{_e}from"./vm-hands-entry-lite-pmcz7j7t.js";function yi(e,i){let r=C(e,"REASON_API_URL")?.trim();if(!r)return $t(i);let t=new URL(r);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(t.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return t.origin}function l(e){return C(e,"REASON_API_URL")?.trim()?yi(e,"production"):void 0}function vo(e){return C(e,"REASON_API_KEY")?.trim()||void 0}async function So(e,i){let r=e.env??process.env,t=vo(r);if(!t)return(e.getCredentials??_t)({apiOrigin:l(r),signal:i});let a=yi(r,e.channel??g({env:r})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+t,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),n=_e(p)?p:{};if(!o.ok){let s=typeof n.detail==="string"?n.detail:typeof n.message==="string"?n.message:"API key authentication failed ("+o.status+")";throw new R(o.status,typeof n.error==="string"?n.error:"api_key_auth_failed",s)}if(typeof n.org_id!=="string"||!n.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let c=Array.isArray(n.scopes)?n.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:t,orgId:n.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:c}}async function Wo(e){let i=await So(e),r=l(e.env??process.env);if(!i)throw Error(r?`Not signed in to ${r}. Set REASON_API_KEY, or run \`reason login --api-url ${r}\`.`:"Not signed in. Run `reason login`, or set REASON_API_KEY.");return i}
3
+ export{yi,vo,So,Wo};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class tt extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function zi(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
- export{tt,zi};
2
+ var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class rt extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function Vi(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
+ export{rt,Vi};