@reason-machines/cli-linux-x64 0.2.491 → 0.2.492

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 (39) hide show
  1. package/bin/reason +1 -1
  2. package/bin/vm-hands/{api-credentials-7kw7d00x.js → api-credentials-19f05m7q.js} +1 -1
  3. package/bin/vm-hands/{api-m49dz9dt.js → api-tz4q7459.js} +1 -1
  4. package/bin/vm-hands/{connect-cli-m2xzzy3s.js → connect-cli-wkmzmnh6.js} +1 -1
  5. package/bin/vm-hands/{local-automation-a5qykmcn.js → local-automation-95hgk32n.js} +1 -1
  6. package/bin/vm-hands/{local-capabilities-w6wec7d9.js → local-capabilities-nrh1by3j.js} +1 -1
  7. package/bin/vm-hands/{local-display-session-fvmwgtff.js → local-display-session-91kgeshv.js} +1 -1
  8. package/bin/vm-hands/local-display-video-gxa2vym0.js +2 -0
  9. package/bin/vm-hands/{local-managed-process-rmksw0hz.js → local-managed-process-5msmf31x.js} +1 -1
  10. package/bin/vm-hands/{managed-runtime-f8v602wy.js → managed-runtime-m06zk018.js} +1 -1
  11. package/bin/vm-hands/{permissions-6jc090mp.js → permissions-1w70qf9j.js} +1 -1
  12. package/bin/vm-hands/{serve-service-wqan0k5g.js → serve-service-2z52ks7d.js} +1 -1
  13. package/bin/vm-hands/{status-6b179rc9.js → status-xrj1cd3h.js} +1 -1
  14. package/bin/vm-hands/version-4cj7rg87.js +2 -0
  15. package/bin/vm-hands/{vm-hands-entry-lite-vjaj1h8k.js → vm-hands-entry-lite-0kr3nwdc.js} +1 -1
  16. package/bin/vm-hands/{vm-hands-entry-lite-padfe0b1.js → vm-hands-entry-lite-0negx0z7.js} +1 -1
  17. package/bin/vm-hands/{vm-hands-entry-lite-v6fjjk98.js → vm-hands-entry-lite-1v7k8aq1.js} +1 -1
  18. package/bin/vm-hands/{vm-hands-entry-lite-rrcy35yb.js → vm-hands-entry-lite-31kattrs.js} +1 -1
  19. package/bin/vm-hands/{vm-hands-entry-lite-gf57dm9q.js → vm-hands-entry-lite-d32t46kh.js} +1 -1
  20. package/bin/vm-hands/{vm-hands-entry-lite-4x2hwv7d.js → vm-hands-entry-lite-f6xg55h7.js} +1 -1
  21. package/bin/vm-hands/{vm-hands-entry-lite-bnc027w2.js → vm-hands-entry-lite-gc654c9j.js} +1 -1
  22. package/bin/vm-hands/{vm-hands-entry-lite-8xdat7p8.js → vm-hands-entry-lite-jpwvk269.js} +1 -1
  23. package/bin/vm-hands/vm-hands-entry-lite-kk3r0v3d.js +3 -0
  24. package/bin/vm-hands/{vm-hands-entry-lite-7sbm0cxh.js → vm-hands-entry-lite-ngv8x7gh.js} +1 -1
  25. package/bin/vm-hands/{vm-hands-entry-lite-kmgps6x0.js → vm-hands-entry-lite-p0kq6zb0.js} +1 -1
  26. package/bin/vm-hands/{vm-hands-entry-lite-qcpsmwk6.js → vm-hands-entry-lite-q1ajqngt.js} +1 -1
  27. package/bin/vm-hands/vm-hands-entry-lite-rpszw34z.js +2 -0
  28. package/bin/vm-hands/{vm-hands-entry-lite-9pvs1aqv.js → vm-hands-entry-lite-snsm9036.js} +1 -1
  29. package/bin/vm-hands/{vm-hands-entry-lite-fffjcnng.js → vm-hands-entry-lite-w8gn8kf9.js} +1 -1
  30. package/bin/vm-hands/{vm-hands-entry-lite-z3fwf40p.js → vm-hands-entry-lite-yjb6kaxw.js} +1 -1
  31. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  32. package/bin/vm-hands/{vm-hands-executor-4fh5zpy2.js → vm-hands-executor-8k112mgx.js} +1 -1
  33. package/bin/vm-hands/{vm-hands-op-runner-qjs7eghs.js → vm-hands-op-runner-jsa9hf1c.js} +1 -1
  34. package/bin/vm-hands/{vm-hands-runtime-sz14ydax.js → vm-hands-runtime-9d62crtc.js} +3 -3
  35. package/package.json +1 -1
  36. package/bin/vm-hands/local-display-video-e3z5qc66.js +0 -2
  37. package/bin/vm-hands/version-y6c94qdh.js +0 -2
  38. package/bin/vm-hands/vm-hands-entry-lite-r35zcvtk.js +0 -3
  39. package/bin/vm-hands/vm-hands-entry-lite-t5wg0e59.js +0 -2
package/bin/reason CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/reason
3
3
  size: 90707424 bytes
4
- sha256: 12c0a6d0214562b01a89e6658ebe8b05ae1687ea9a188fadec50d1ed1c802ecb
4
+ sha256: d0041421fe2db17979dd6501e4b483f4ddc157af317800e11c9889aecc4930a0
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$i,Wo,ms}from"./vm-hands-entry-lite-4x2hwv7d.js";import"./vm-hands-entry-lite-r35zcvtk.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{$i as apiOriginFromEnvironment,Wo as environmentApiKey,ms as resolveApiCredentials};
2
+ import{$i,Wo,ms}from"./vm-hands-entry-lite-f6xg55h7.js";import"./vm-hands-entry-lite-kk3r0v3d.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{$i as apiOriginFromEnvironment,Wo as environmentApiKey,ms as resolveApiCredentials};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{I,gs,Vo}from"./vm-hands-entry-lite-r35zcvtk.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{I as ApiError,Vo as ReasonApi,gs as createMachineEnrollmentTicketWithToken};
2
+ import{I,gs,Vo}from"./vm-hands-entry-lite-kk3r0v3d.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{I as ApiError,Vo as ReasonApi,gs as createMachineEnrollmentTicketWithToken};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{nt,us,ds,ps}from"./vm-hands-entry-lite-kmgps6x0.js";import"./vm-hands-entry-lite-ytazq3rk.js";import"./vm-hands-entry-lite-sk9jyg5p.js";import"./vm-hands-entry-lite-4x2hwv7d.js";import"./vm-hands-entry-lite-r35zcvtk.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-fffjcnng.js";import"./vm-hands-entry-lite-qcpsmwk6.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-padfe0b1.js";import"./vm-hands-entry-lite-bnc027w2.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-gf57dm9q.js";import"./vm-hands-entry-lite-9pvs1aqv.js";import"./vm-hands-entry-lite-vjaj1h8k.js";import"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-rrcy35yb.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{us as computerDisconnected,nt as connectionDirectory,ds as connectionReport,ps as restartConnection};
2
+ import{nt,us,ds,ps}from"./vm-hands-entry-lite-p0kq6zb0.js";import"./vm-hands-entry-lite-ytazq3rk.js";import"./vm-hands-entry-lite-sk9jyg5p.js";import"./vm-hands-entry-lite-f6xg55h7.js";import"./vm-hands-entry-lite-kk3r0v3d.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-w8gn8kf9.js";import"./vm-hands-entry-lite-q1ajqngt.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-0negx0z7.js";import"./vm-hands-entry-lite-gc654c9j.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-d32t46kh.js";import"./vm-hands-entry-lite-snsm9036.js";import"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-31kattrs.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{us as computerDisconnected,nt as connectionDirectory,ds as connectionReport,ps as restartConnection};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Pn,Os,Is,Ds,Ns,Tn}from"./vm-hands-entry-lite-gf57dm9q.js";import"./vm-hands-entry-lite-9pvs1aqv.js";import"./vm-hands-entry-lite-vjaj1h8k.js";import"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-rrcy35yb.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{Is as ensureLocalBrowser,Pn as localAutomationAvailable,Ds as localBrowserProfile,Os as localUserChromeHost,Ns as runAutomationCallLocally,Tn as runLocalAutomation};
2
+ import{Pn,Os,Is,Ds,Ns,Tn}from"./vm-hands-entry-lite-d32t46kh.js";import"./vm-hands-entry-lite-snsm9036.js";import"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-31kattrs.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{Is as ensureLocalBrowser,Pn as localAutomationAvailable,Ds as localBrowserProfile,Os as localUserChromeHost,Ns as runAutomationCallLocally,Tn as runLocalAutomation};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Go,ji,pn,Ko,Jo,Zo,Xo,ks,Cs,As,Ps}from"./vm-hands-entry-lite-qcpsmwk6.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-padfe0b1.js";import"./vm-hands-entry-lite-bnc027w2.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-gf57dm9q.js";import"./vm-hands-entry-lite-9pvs1aqv.js";import"./vm-hands-entry-lite-vjaj1h8k.js";import"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-rrcy35yb.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{r as LocalCapabilityError,Go as SHORT_REQUEST_CAPABILITIES,ks as capabilityInventoryForRoots,ji as confinedExecutionShell,Ko as defaultLocalCommandRunner,Cs as deliverLocalHandsEnvironment,Xo as enrolledRootPaths,Ps as executeLocalOperation,As as rebindLocalHandsControl,Jo as runFileCapability,Zo as runTransferCapability,pn as spawnCaptured};
2
+ import{Go,ji,pn,Ko,Jo,Zo,Xo,ks,Cs,As,Ps}from"./vm-hands-entry-lite-q1ajqngt.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-0negx0z7.js";import"./vm-hands-entry-lite-gc654c9j.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-d32t46kh.js";import"./vm-hands-entry-lite-snsm9036.js";import"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-31kattrs.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{r as LocalCapabilityError,Go as SHORT_REQUEST_CAPABILITIES,ks as capabilityInventoryForRoots,ji as confinedExecutionShell,Ko as defaultLocalCommandRunner,Cs as deliverLocalHandsEnvironment,Xo as enrolledRootPaths,Ps as executeLocalOperation,As as rebindLocalHandsControl,Jo as runFileCapability,Zo as runTransferCapability,pn as spawnCaptured};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$t,Ls,G,qe,Bt}from"./vm-hands-entry-lite-9pvs1aqv.js";import"./vm-hands-entry-lite-vjaj1h8k.js";import"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{qe as ensureLinuxDesktop,$t as localDisplayAvailable,Ls as localDisplayReady,G as privateDirectory,Bt as runLocalDisplayStream};
2
+ import{$t,Ls,G,qe,Bt}from"./vm-hands-entry-lite-snsm9036.js";import"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{qe as ensureLinuxDesktop,$t as localDisplayAvailable,Ls as localDisplayReady,G as privateDirectory,Bt as runLocalDisplayStream};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{On,In,Dn,Nn,Pr}from"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";export{On as MAC_SCREEN,In as WINDOWS_SCREEN,Dn as createDisplayVideoLane,Pr as localDisplayVideoAvailable,Nn as simulatorVideoFfmpeg};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{it,dr,Ts,Rs}from"./vm-hands-entry-lite-padfe0b1.js";import"./vm-hands-entry-lite-bnc027w2.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{it as ManagedProcessStoppedError,Ts as controlManagedDeviceProcess,Rs as retireManagedDeviceProcess,dr as runManagedDeviceProcess};
2
+ import{it,dr,Ts,Rs}from"./vm-hands-entry-lite-0negx0z7.js";import"./vm-hands-entry-lite-gc654c9j.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-9r4d4mx1.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{it as ManagedProcessStoppedError,Ts as controlManagedDeviceProcess,Rs as retireManagedDeviceProcess,dr as runManagedDeviceProcess};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{_s,ys,bs,vs,Ss,Es,xs}from"./vm-hands-entry-lite-fffjcnng.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{Ss as acquireManagedRuntimeDirectoryLock,bs as currentManagedRuntimeVersion,xs as flushManagedRuntimeLifecycleEvents,vs as isManagedRuntimeVersionExecutable,ys as legacyManagedRuntimePaths,_s as managedRuntimePaths,Es as recordManagedRuntimeLifecycle};
2
+ import{_s,ys,bs,vs,Ss,Es,xs}from"./vm-hands-entry-lite-w8gn8kf9.js";import"./vm-hands-entry-lite-0tzzctxx.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{Ss as acquireManagedRuntimeDirectoryLock,bs as currentManagedRuntimeVersion,xs as flushManagedRuntimeLifecycleEvents,vs as isManagedRuntimeVersionExecutable,ys as legacyManagedRuntimePaths,_s as managedRuntimePaths,Es as recordManagedRuntimeLifecycle};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Qo,es,Ms,$s}from"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";export{$s as allowMacPermissions,Ms as permissionsSummary,es as readMacPermissions,Qo as reasonIdentity};
2
+ import{Qo,es,Ms,$s}from"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";export{$s as allowMacPermissions,Ms as permissionsSummary,es as readMacPermissions,Qo as reasonIdentity};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{qr,xe,J,Kn,Fs,Co,js,Ye,rs,Jn,Us,Hs,Wr,zs,qs}from"./vm-hands-entry-lite-rrcy35yb.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{qr as WORKER_SERVICE_ENV,J as WorkerServiceError,Co as connectServiceLabel,xe as defaultWorkerServiceHost,Hs as installWorkerService,Ye as installedWorkerService,js as isConnectServiceLabel,qs as removeWorkerService,Wr as restartWorkerService,zs as retargetWorkerServiceLogs,rs as retireLegacyWorkerService,Us as workerServiceDefinitionCurrent,Kn as workerServiceLauncher,Jn as workerServiceProcessRunning,Fs as workerServiceRetargetPending};
2
+ import{qr,xe,J,Kn,Fs,Co,js,Ye,rs,Jn,Us,Hs,Wr,zs,qs}from"./vm-hands-entry-lite-31kattrs.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-y7z8pfgt.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-tbawqj1n.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{qr as WORKER_SERVICE_ENV,J as WorkerServiceError,Co as connectServiceLabel,xe as defaultWorkerServiceHost,Hs as installWorkerService,Ye as installedWorkerService,js as isConnectServiceLabel,qs as removeWorkerService,Wr as restartWorkerService,zs as retargetWorkerServiceLogs,rs as retireLegacyWorkerService,Us as workerServiceDefinitionCurrent,Kn as workerServiceLauncher,Jn as workerServiceProcessRunning,Fs as workerServiceRetargetPending};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./vm-hands-entry-lite-r35zcvtk.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{_}from"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-rfz60hb3.js";import"./vm-hands-entry-lite-t5wg0e59.js";import"./vm-hands-entry-lite-4x2hwv7d.js";import{Vt,pt}from"./vm-hands-entry-lite-9r4d4mx1.js";import{w,M,lr,Be,nt}from"./vm-hands-entry-lite-kmgps6x0.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-qcpsmwk6.js";import"./vm-hands-entry-lite-bnc027w2.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-ytazq3rk.js";import"./vm-hands-entry-lite-vjaj1h8k.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-v6fjjk98.js";import"./vm-hands-entry-lite-z3fwf40p.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-fffjcnng.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-rrcy35yb.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-padfe0b1.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-9pvs1aqv.js";import"./vm-hands-entry-lite-gf57dm9q.js";import"./vm-hands-entry-lite-sk9jyg5p.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-g27kmejx.js";import"./vm-hands-entry-lite-tbawqj1n.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 f(e){return`claude mcp add --transport http reason ${e}`}function h(e){return`codex mcp add reason --url ${e}
2
+ import"./vm-hands-entry-lite-kk3r0v3d.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{_}from"./vm-hands-entry-lite-hxhd7btg.js";import"./vm-hands-entry-lite-38g65s5x.js";import"./vm-hands-entry-lite-633mzx27.js";import"./vm-hands-entry-lite-rfz60hb3.js";import"./vm-hands-entry-lite-rpszw34z.js";import"./vm-hands-entry-lite-f6xg55h7.js";import{Vt,pt}from"./vm-hands-entry-lite-9r4d4mx1.js";import{w,M,lr,Be,nt}from"./vm-hands-entry-lite-p0kq6zb0.js";import"./vm-hands-entry-lite-vezfnqf1.js";import"./vm-hands-entry-lite-q1ajqngt.js";import"./vm-hands-entry-lite-gc654c9j.js";import"./vm-hands-entry-lite-p7m36kw7.js";import"./vm-hands-entry-lite-gn2rg810.js";import"./vm-hands-entry-lite-ytazq3rk.js";import"./vm-hands-entry-lite-0kr3nwdc.js";import"./vm-hands-entry-lite-whdnstpa.js";import"./vm-hands-entry-lite-1v7k8aq1.js";import"./vm-hands-entry-lite-yjb6kaxw.js";import"./vm-hands-entry-lite-vtbw3evj.js";import"./vm-hands-entry-lite-w8gn8kf9.js";import"./vm-hands-entry-lite-pk8fxewf.js";import"./vm-hands-entry-lite-31kattrs.js";import"./vm-hands-entry-lite-hy242z2t.js";import"./vm-hands-entry-lite-ya9p67x3.js";import"./vm-hands-entry-lite-nnzqx15h.js";import"./vm-hands-entry-lite-wrvz9jxy.js";import"./vm-hands-entry-lite-0negx0z7.js";import"./vm-hands-entry-lite-ytxa5cq0.js";import"./vm-hands-entry-lite-gfrp4eht.js";import"./vm-hands-entry-lite-snsm9036.js";import"./vm-hands-entry-lite-d32t46kh.js";import"./vm-hands-entry-lite-sk9jyg5p.js";import"./vm-hands-entry-lite-1qjw1rt2.js";import"./vm-hands-entry-lite-0tzzctxx.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-g27kmejx.js";import"./vm-hands-entry-lite-tbawqj1n.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 f(e){return`claude mcp add --transport http reason ${e}`}function h(e){return`codex mcp add reason --url ${e}
3
3
  codex mcp login reason`}var F=f("https://mcp.reasonmachines.com/mcp"),z=h("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
4
 
5
5
  Usage:
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qe,Yn}from"./vm-hands-entry-lite-rpszw34z.js";export{Yn as CLI_USER_AGENT,Qe as CLI_VERSION};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{S,zt,Mn,Ge,$n,Bn}from"./vm-hands-entry-lite-whdnstpa.js";import{Xn}from"./vm-hands-entry-lite-v6fjjk98.js";import{Gn}from"./vm-hands-entry-lite-vtbw3evj.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as qe}from"child_process";import{existsSync as ws}from"fs";import{connect as xs}from"net";function pn(){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 ut=pn();import{createHash as St}from"crypto";import{once as Sn}from"events";import{createWriteStream as vn,existsSync as mr,mkdirSync as gr,mkdtempSync as hr,readFileSync as le,readdirSync as br,renameSync as yr,realpathSync as En,rmSync as Pn,statSync as Ne,writeFileSync as wr}from"fs";import{delimiter as _r,dirname as vt,join as b}from"path";import{finished as Cn}from"stream/promises";var We="omljlfpmafedpplnpkkahegadhkimdje",lo="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var O={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"}},H={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${O.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${O.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${O.obu.version}/open-browser-use-chrome-extension-${O.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as fn}from"module";import{join as mn}from"path";var gn=30000,hn=1048576;function Te(){return process.env.SystemRoot??"C:\\Windows"}function bn(){return mn(Te(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var yn=String.raw`
2
+ import{S,zt,Mn,Ge,$n,Bn}from"./vm-hands-entry-lite-whdnstpa.js";import{Xn}from"./vm-hands-entry-lite-1v7k8aq1.js";import{Gn}from"./vm-hands-entry-lite-vtbw3evj.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as qe}from"child_process";import{existsSync as ws}from"fs";import{connect as xs}from"net";function pn(){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 ut=pn();import{createHash as St}from"crypto";import{once as Sn}from"events";import{createWriteStream as vn,existsSync as mr,mkdirSync as gr,mkdtempSync as hr,readFileSync as le,readdirSync as br,renameSync as yr,realpathSync as En,rmSync as Pn,statSync as Ne,writeFileSync as wr}from"fs";import{delimiter as _r,dirname as vt,join as b}from"path";import{finished as Cn}from"stream/promises";var We="omljlfpmafedpplnpkkahegadhkimdje",lo="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var O={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"}},H={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${O.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${O.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${O.obu.version}/open-browser-use-chrome-extension-${O.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as fn}from"module";import{join as mn}from"path";var gn=30000,hn=1048576;function Te(){return process.env.SystemRoot??"C:\\Windows"}function bn(){return mn(Te(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var yn=String.raw`
3
3
  $ErrorActionPreference = "Stop"
4
4
  Add-Type -TypeDefinition @"
5
5
  using System;
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{H}from"./vm-hands-entry-lite-38g65s5x.js";import{D,R,b}from"./vm-hands-entry-lite-nnzqx15h.js";import{je,hr,fr,wn,bn,st}from"./vm-hands-entry-lite-bnc027w2.js";import{Lr}from"./vm-hands-entry-lite-9r4d4mx1.js";import{p,ct,En,_e,we}from"./vm-hands-entry-lite-1qjw1rt2.js";import{v,h}from"./vm-hands-entry-lite-0tzzctxx.js";import{a,tr,Lo}from"./vm-hands-entry-lite-y7z8pfgt.js";import{nn,y,t,k,o,d,is,Oe,Di,u,i,W,g,ee,s,n,on}from"./vm-hands-entry-lite-g27kmejx.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{se,A}from"./vm-hands-entry-lite-tbawqj1n.js";import{randomUUID as Q}from"crypto";import{spawn as Le}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as We,readFileSync as Ne,realpathSync as G,rmSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,join as j,relative as qe,sep as Je}from"path";var Se=["process.run.v1","process.full.v1"],xe=600000,Pe=1800000,Ee=20000,ne="process.cancel.v1",ie=i({action:n("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:s(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(Pe).default(xe).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),K={device_id:t().uuid(),root_id:t().uuid()},Re=g("action",[ie.extend(K),i({...K,action:n("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(Ee).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),i({...K,action:n("cancel"),process_id:t().uuid()}).strict()]),Fe=nn(Re,{io:"input"}),Ke=ie.extend({process_brain_fence:t().uuid(),process_expires_at:y.datetime()}).strict(),J=i({version:n(1),process_id:t().uuid(),state:s(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:d(),observed_at:y.datetime(),output:u(i({cursor:o().int().min(1),stream:s(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let _=e.first_cursor-1;for(let l of e.output){if(l.cursor<=_||l.cursor>e.next_cursor)return!1;_=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),Oe())}),Ye=i({ready:n(!0),version:n(1),execution_mode:s(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var Ie=i({version:n(1),process_id:t().uuid(),state:s(["queued","cancelled_before_start","not_started"]),exit_code:is(),output:u(Di()).length(0),first_cursor:n(0),next_cursor:n(0),truncated:n(!1),cancellation_requested:n(!1),reason_code:s(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),De=i({...J.shape,state:s(["queued","starting","running","exited","cancelled","expired","uncertain","cancelled_before_start","not_started"]),observed_at:y.datetime().optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it."),cancellation_requested:d(),reason_code:t().nullable().optional(),execution_authority:n("lost").optional().describe("Historical receipt only; the current Brain cannot control this older-generation process."),recovery:i({cause:n("brain_generation_changed"),terminal_confirmed:d(),next_step:s(["inspect_until_terminal","reconcile_effects_before_new_intent"])}).strict().optional().describe("Historical process recovery only. An unconfirmed outcome forbids replay. A confirmed terminal observation proves the old process stopped, not that its command had no effects. Reconcile the result; only restart still-needed, safely repeatable work with a new request_id and current authority. Respect user cancellation."),last_observed_state:J.shape.state.or(n("cancelled_before_start")).nullable().optional().describe("Last saved observation before authority was lost; a running observation does not establish current child liveness.")}).strict(),$e=nn(De),Qe=W([J,Ie.refine((e)=>e.state==="cancelled_before_start")]),X=i({version:n(1),process_id:t().uuid(),state:s(["exited","cancelled","expired"]),exit_code:o().int().min(0).max(255),observed_at:y.datetime()}).strict().refine((e)=>(e.state!=="cancelled"||e.exit_code===130)&&(e.state!=="expired"||e.exit_code===124)),Ze=i({process_terminal_observation:X}).strict();var qi="preview.serve.v1",Wi=43200000;var ce="preview.open.v1",de=1,fn="gid_proxy_v1",Vi="egress",mn=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ce=i({version:n(fn),allowed_domains:u(t().max(260).regex(mn)).max(1024)}).strict(),Ae=on((e)=>H(e)!==null,"invalid workspace"),ke=i({version:n(1),request_id:k(),session_id:k(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),port:o().int().min(1024).max(65535),workspace:Ae,egress:Ce.optional()}).strict(),Gi=ke.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,_){let l=null;try{l=ct(e)}catch{}En({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?_:"binding_invalid"})}function le(e){let c=new Map;return{open(_){let l=(x)=>Y(_,e.claim.operation_id,x),C;try{C=ct(_)}catch{return l("binding_invalid")}let{binding:w,deviceRelayUrl:z}=C,E=e.claim.owner;if(!E||w.organizationId!==E.organization_id||w.userId!==E.user_id||w.deviceId!==E.device_id||w.rootId!==e.claim.root_id||w.jobId!==e.claim.operation_id||w.fenceId!==e.claim.operation_id||w.generation!==de||w.expiresAtMs>Math.min(Date.now()+p.lifetimeMs+Te,e.expiresAtMs))return l("binding_mismatch");if(w.expiresAtMs<=Date.now())return l("binding_expired");if(c.get(w.port)?.abort(),c.delete(w.port),c.size>=Me)return l("preview_capacity");let L=new AbortController;c.set(w.port,L);let P=we({binding:w,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(L.signal.aborted)return null;let x=await e.inspect();return x?{binding:w,executorLaunchId:e.executorLaunchId,job:x}:null}});_e({binding:w,deviceRelayUrl:z,port:P,signal:L.signal}).then((x)=>x.closed,(x)=>{let I=x instanceof Error?x.message:"preview_failed";if(I!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:w.jobId,port:w.port,reason_code:I})}
2
+ import{H}from"./vm-hands-entry-lite-38g65s5x.js";import{D,R,b}from"./vm-hands-entry-lite-nnzqx15h.js";import{je,hr,fr,wn,bn,st}from"./vm-hands-entry-lite-gc654c9j.js";import{Lr}from"./vm-hands-entry-lite-9r4d4mx1.js";import{p,ct,En,_e,we}from"./vm-hands-entry-lite-1qjw1rt2.js";import{v,h}from"./vm-hands-entry-lite-0tzzctxx.js";import{a,tr,Lo}from"./vm-hands-entry-lite-y7z8pfgt.js";import{nn,y,t,k,o,d,is,Oe,Di,u,i,W,g,ee,s,n,on}from"./vm-hands-entry-lite-g27kmejx.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{se,A}from"./vm-hands-entry-lite-tbawqj1n.js";import{randomUUID as Q}from"crypto";import{spawn as Le}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as We,readFileSync as Ne,realpathSync as G,rmSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,join as j,relative as qe,sep as Je}from"path";var Se=["process.run.v1","process.full.v1"],xe=600000,Pe=1800000,Ee=20000,ne="process.cancel.v1",ie=i({action:n("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:s(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(Pe).default(xe).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),K={device_id:t().uuid(),root_id:t().uuid()},Re=g("action",[ie.extend(K),i({...K,action:n("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(Ee).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),i({...K,action:n("cancel"),process_id:t().uuid()}).strict()]),Fe=nn(Re,{io:"input"}),Ke=ie.extend({process_brain_fence:t().uuid(),process_expires_at:y.datetime()}).strict(),J=i({version:n(1),process_id:t().uuid(),state:s(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:d(),observed_at:y.datetime(),output:u(i({cursor:o().int().min(1),stream:s(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let _=e.first_cursor-1;for(let l of e.output){if(l.cursor<=_||l.cursor>e.next_cursor)return!1;_=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),Oe())}),Ye=i({ready:n(!0),version:n(1),execution_mode:s(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var Ie=i({version:n(1),process_id:t().uuid(),state:s(["queued","cancelled_before_start","not_started"]),exit_code:is(),output:u(Di()).length(0),first_cursor:n(0),next_cursor:n(0),truncated:n(!1),cancellation_requested:n(!1),reason_code:s(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),De=i({...J.shape,state:s(["queued","starting","running","exited","cancelled","expired","uncertain","cancelled_before_start","not_started"]),observed_at:y.datetime().optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it."),cancellation_requested:d(),reason_code:t().nullable().optional(),execution_authority:n("lost").optional().describe("Historical receipt only; the current Brain cannot control this older-generation process."),recovery:i({cause:n("brain_generation_changed"),terminal_confirmed:d(),next_step:s(["inspect_until_terminal","reconcile_effects_before_new_intent"])}).strict().optional().describe("Historical process recovery only. An unconfirmed outcome forbids replay. A confirmed terminal observation proves the old process stopped, not that its command had no effects. Reconcile the result; only restart still-needed, safely repeatable work with a new request_id and current authority. Respect user cancellation."),last_observed_state:J.shape.state.or(n("cancelled_before_start")).nullable().optional().describe("Last saved observation before authority was lost; a running observation does not establish current child liveness.")}).strict(),$e=nn(De),Qe=W([J,Ie.refine((e)=>e.state==="cancelled_before_start")]),X=i({version:n(1),process_id:t().uuid(),state:s(["exited","cancelled","expired"]),exit_code:o().int().min(0).max(255),observed_at:y.datetime()}).strict().refine((e)=>(e.state!=="cancelled"||e.exit_code===130)&&(e.state!=="expired"||e.exit_code===124)),Ze=i({process_terminal_observation:X}).strict();var qi="preview.serve.v1",Wi=43200000;var ce="preview.open.v1",de=1,fn="gid_proxy_v1",Vi="egress",mn=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ce=i({version:n(fn),allowed_domains:u(t().max(260).regex(mn)).max(1024)}).strict(),Ae=on((e)=>H(e)!==null,"invalid workspace"),ke=i({version:n(1),request_id:k(),session_id:k(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),port:o().int().min(1024).max(65535),workspace:Ae,egress:Ce.optional()}).strict(),Gi=ke.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,_){let l=null;try{l=ct(e)}catch{}En({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?_:"binding_invalid"})}function le(e){let c=new Map;return{open(_){let l=(x)=>Y(_,e.claim.operation_id,x),C;try{C=ct(_)}catch{return l("binding_invalid")}let{binding:w,deviceRelayUrl:z}=C,E=e.claim.owner;if(!E||w.organizationId!==E.organization_id||w.userId!==E.user_id||w.deviceId!==E.device_id||w.rootId!==e.claim.root_id||w.jobId!==e.claim.operation_id||w.fenceId!==e.claim.operation_id||w.generation!==de||w.expiresAtMs>Math.min(Date.now()+p.lifetimeMs+Te,e.expiresAtMs))return l("binding_mismatch");if(w.expiresAtMs<=Date.now())return l("binding_expired");if(c.get(w.port)?.abort(),c.delete(w.port),c.size>=Me)return l("preview_capacity");let L=new AbortController;c.set(w.port,L);let P=we({binding:w,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(L.signal.aborted)return null;let x=await e.inspect();return x?{binding:w,executorLaunchId:e.executorLaunchId,job:x}:null}});_e({binding:w,deviceRelayUrl:z,port:P,signal:L.signal}).then((x)=>x.closed,(x)=>{let I=x instanceof Error?x.message:"preview_failed";if(I!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:w.jobId,port:w.port,reason_code:I})}
3
3
  `)}).finally(()=>{if(c.get(w.port)===L)c.delete(w.port)})},dispose(){for(let _ of c.values())_.abort();c.clear()}}}class it extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var fe=256,B=new Map,he="preview.serve.v1",V=new Map;function be(e){let c=V.get(e.operation_id);if(c){if(c.claim!==e)throw M("process_authority_lost");return c}if(V.size>=fe)throw M("process_journal_capacity");let _={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return V.set(e.operation_id,_),_}function pe(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ue=(e)=>new Promise((c)=>setTimeout(c,e)),M=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function ze(e=a(),c=Ge()){let _=Ue(Lr({},e)),l=qe(tr(e),_),[C,...w]=l.split(Je);return{directory:j(c,l,"processes"),previous:[j(_,"processes"),...C==="reason"?[j(c,"ara",...w,"processes")]:[]]}}function Ge(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Lo();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function dr(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw M("process_authority_lost");let c=be(e.claim);if(c.executing)throw M("process_busy");if(c.executing=!0,c.cancelRequested)return c.phase="settling",pe(e.claim.operation_id);c.phase="starting";let _=e.journals??ze();We(_.directory,{recursive:!0,mode:448});let l=hr({runtimeDirectory:G(_.directory),previousRuntimeDirectories:(_.previous??[]).filter((m)=>Z(m)).map((m)=>G(m)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:fe});try{for(let m of[e.root,e.cwd])if(!je(G(m),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(m){throw l.disposeSocket(),m}let C=me(l.journalDirectory),w=e.claim.capability===he,z=()=>B.set(e.claim.operation_id,{path:l.journalDirectory,ino:C.ino,dev:C.dev,anyCompletion:w}),E=l.launchDirectory,L=j(E,"config.json"),P={url:"",transport:"local_job_ipc",directShell:{mode:e.mode,executable:e.shell,jobId:e.claim.operation_id},workerVersion:D,protocolVersion:2,workerArtifactSha256:b,workerEntrypoint:R,targetGeneration:1,fenceId:Q(),...process.platform==="win32"?{bashExecutable:se()}:{},workRoot:e.root,workspaceAliasPath:e.root,repoPath:e.cwd,jobEnvPath:j(E,"unused.env"),replSocketPath:j(E,"unused.sock"),readyPath:j(E,"ready.json"),directTerminalReceiptPath:j(E,"terminal.json"),launchId:Q(),expiresAtMs:e.expiresAtMs+5000,bashTimeoutMs:60000,replTimeoutMs:1000,allowedTools:["bash"],managedJobs:{journalDirectory:l.journalDirectory,scopeId:l.scopeId},jobControlSocketPath:l.socketPath,...e.prefix?{bashCommandPrefix:e.prefix}:{},...e.jobsUser?{jobsUser:e.jobsUser}:{}},x;try{He(L,JSON.stringify(P),{mode:384});let m=wn({configPath:L,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:E});x=e.spawnWorker?.(L,P)??Le(m.command,m.args,{...m.options,env:e.environment,stdio:[bn,"ignore","ignore"]})}catch(m){throw l.disposeSocket(),m}let I=!1,F=new Promise((m,S)=>{x.once("exit",(f)=>{I=!0,m(f)}),x.once("error",(f)=>{I=!0,S(f)})});F.catch(()=>{});let ge={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:P.fenceId,executorLaunchId:P.launchId,expiresAtMs:P.expiresAtMs},N=async(m)=>{let S=await fr(ge,{type:"job",version:2,generation:1,id:Q(),jobId:e.claim.operation_id,...m==="start"?{action:m,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:m==="inspect"?{action:m,input:{after:0}}:m==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:m,input:{}}},new AbortController().signal);if(!S.ok)throw M(S.error);return S.job},U=!1,q=!1,te,re=()=>{U=!0,st(x,"SIGTERM")};e.signal.addEventListener("abort",re,{once:!0});let T,oe=0,ve=async(m)=>{let S=[...m.output],f={version:1,process_id:e.claim.operation_id,state:m.state,exit_code:m.exitCode,first_cursor:m.firstCursor,next_cursor:m.nextCursor,truncated:m.truncated,output:S,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&S.length)S.shift(),f.truncated=!0,f.first_cursor=S[0]?.cursor??f.next_cursor+1;T=J.parse(f),await e.emit(T),oe=Date.now()};try{let m=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Z(P.readyPath)){if(I)throw new r("process_start_failed","The managed process supervisor exited before accepting a command; no command was dispatched.");if(e.signal.aborted||Date.now()>=m)throw M("process_start_unconfirmed");await ue(25)}let S=JSON.parse(Ne(P.readyPath,"utf8"));if(S.launchId!==P.launchId||S.fenceId!==P.fenceId||S.workerArtifactSha256!==b)throw M();if(e.signal.throwIfAborted(),c.cancelRequested)return pe(e.claim.operation_id);let f;try{q=!0,f=await N("start")}catch(O){if(!(O instanceof r)||O.code!=="hands_job_result_unknown")throw O;f=await N("inspect")}if(c.phase="running",c.cancel=async()=>{await N("cancel")},w&&e.preview)c.tunnels=le({claim:e.claim,executorLaunchId:P.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>c.phase==="running"&&!I?await N("probe"):null});if(c.cancelRequested)await c.cancel(),f=await N("inspect");for(;;){if(!["starting","running"].includes(f.state))c.phase="settling",c.cancel=void 0;if(!T||T.state!==f.state||T.next_cursor!==f.nextCursor&&Date.now()-oe>=5000)await ve(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||I)throw M();await ue(1000);try{f=await N("inspect"),te=void 0}catch(O){if(!(O instanceof r)||O.code!=="hands_job_result_unknown"||e.signal.aborted||I||Date.now()-(te??=Date.now())>120000)throw O}}if(!T||T.state==="uncertain")throw M();return T}finally{if(c.phase="settling",c.cancel=void 0,c.tunnels?.dispose(),c.tunnels=void 0,await c.cancelInFlight?.catch(()=>{}),e.signal.removeEventListener("abort",re),!I&&!U)st(x,"SIGTERM");let m,S=await Promise.race([F.then((f)=>({code:f})),new Promise((f)=>{m=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(m)});if(!S){try{st(x,"SIGKILL")}catch{}try{await F}finally{if(I)l.disposeSocket()}throw M("process_cleanup_unconfirmed")}try{if((U||e.signal.aborted)&&S.code===0&&q){v(E);let f=JSON.parse(h(P.directTerminalReceiptPath)),O=X.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===P.launchId&&f.fence_id===P.fenceId&&f.scope_id===l.scopeId&&O.success&&O.data.process_id===e.claim.operation_id){if(w)z();throw new it(O.data)}}}catch(f){if(f instanceof it)throw f}finally{if(I)l.disposeSocket()}if(S.code!==0&&!U&&q)throw M("process_cleanup_unconfirmed");if(!U&&S.code===0&&(T&&["exited","cancelled","expired"].includes(T.state)||!q&&c.cancelRequested)||w&&S.code===0&&!q)z()}}async function Ts(e,c){if(c.kind===ce&&e.capability===he){let C=V.get(e.operation_id);if(C?.claim===e&&C.tunnels)C.tunnels.open(c.payload);else Y(c.payload,e.operation_id,"server_not_running");return!0}if(c.kind!==ne||!ae(e.capability)||!e.owner||c.payload.process_id!==e.operation_id)return!1;let _=V.get(e.operation_id);if(_&&_.claim!==e)return!1;let l=be(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Rs(e,c){V.delete(e);let _=B.get(e);if(!_||c!=="succeeded"&&!_.anyCompletion)return B.delete(e),!1;try{let l=me(_.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==_.ino||l.dev!==_.dev||!A(l)||G(_.path)!==_.path||Z(j(_.path,"owner.lock")))return!1;return Ve(_.path,{recursive:!0}),B.delete(e),!0}catch{return!1}}
4
4
  export{qi,Wi,fn,Vi,mn,Gi,it,dr,Ts,Rs};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Qe}from"./vm-hands-entry-lite-t5wg0e59.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.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 Zn="so.ara.cli",k=[Zn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Vr(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",Po="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Vr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Vr(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 Gr(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=Gr(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{Qe}from"./vm-hands-entry-lite-rpszw34z.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.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 Zn="so.ara.cli",k=[Zn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Vr(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",Po="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Vr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Vr(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 Gr(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=Gr(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
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 Xn(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
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{_}from"./vm-hands-entry-lite-hxhd7btg.js";import{Kr,Qn,Jr,ei}from"./vm-hands-entry-lite-pk8fxewf.js";import{Zn,Yt,Oo}from"./vm-hands-entry-lite-v6fjjk98.js";import{C}from"./vm-hands-entry-lite-tbawqj1n.js";import{spawnSync as y}from"child_process";import{createHash as ke,randomUUID as Se}from"crypto";import{chmodSync as we,existsSync as P,mkdirSync as $e,readdirSync as Ve,readFileSync as p,renameSync as ye,rmSync as u,statSync as ve,writeFileSync as be}from"fs";import{dirname as We,isAbsolute as q,join as g}from"path";import{spawnSync as de}from"child_process";import{readFileSync as me}from"fs";import{userInfo as D}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function H(r){return fe(r,"AppData","Local","Reason","Tasks")}function S(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function M(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${S(r)};`}function K(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${S(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(S).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${S(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[M(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function A(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${D().username}`:D().username}function U(r){let e=A(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
2
+ import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{_}from"./vm-hands-entry-lite-hxhd7btg.js";import{Kr,Qn,Jr,ei}from"./vm-hands-entry-lite-pk8fxewf.js";import{Zn,Yt,Oo}from"./vm-hands-entry-lite-1v7k8aq1.js";import{C}from"./vm-hands-entry-lite-tbawqj1n.js";import{spawnSync as y}from"child_process";import{createHash as ke,randomUUID as Se}from"crypto";import{chmodSync as we,existsSync as P,mkdirSync as $e,readdirSync as Ve,readFileSync as p,renameSync as ye,rmSync as u,statSync as ve,writeFileSync as be}from"fs";import{dirname as We,isAbsolute as q,join as g}from"path";import{spawnSync as de}from"child_process";import{readFileSync as me}from"fs";import{userInfo as D}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function H(r){return fe(r,"AppData","Local","Reason","Tasks")}function S(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function M(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${S(r)};`}function K(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${S(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(S).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${S(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[M(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function A(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${D().username}`:D().username}function U(r){let e=A(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
3
3
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
4
4
  <RegistrationInfo>
5
5
  <Description>${A(r.description)}</Description>
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{We,lo,F,Ve,Ft,Tr,x}from"./vm-hands-entry-lite-vjaj1h8k.js";import{K}from"./vm-hands-entry-lite-vtbw3evj.js";import{dt}from"./vm-hands-entry-lite-whdnstpa.js";import{mt}from"./vm-hands-entry-lite-v6fjjk98.js";import{Rr}from"./vm-hands-entry-lite-z3fwf40p.js";import{xt,Mi}from"./vm-hands-entry-lite-ytxa5cq0.js";import{G,qe}from"./vm-hands-entry-lite-9pvs1aqv.js";import{xe,Kn}from"./vm-hands-entry-lite-rrcy35yb.js";import{vt}from"./vm-hands-entry-lite-vezfnqf1.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{C}from"./vm-hands-entry-lite-tbawqj1n.js";import{spawn as R,spawnSync as st}from"child_process";import{createHash as it,randomUUID as ge}from"crypto";import{closeSync as at,copyFileSync as ae,existsSync as M,fstatSync as ct,mkdirSync as ce,openSync as lt,readdirSync as U,readFileSync as X,readlinkSync as ut,renameSync as he,rmSync as pt,statSync as ft,writeFileSync as gt}from"fs";import{connect as ht}from"net";import{tmpdir as L,userInfo as we}from"os";import{basename as le,delimiter as wt,dirname as B,join as f}from"path";var z=`import { spawn, execFileSync } from "node:child_process";
2
+ import{We,lo,F,Ve,Ft,Tr,x}from"./vm-hands-entry-lite-0kr3nwdc.js";import{K}from"./vm-hands-entry-lite-vtbw3evj.js";import{dt}from"./vm-hands-entry-lite-whdnstpa.js";import{mt}from"./vm-hands-entry-lite-1v7k8aq1.js";import{Rr}from"./vm-hands-entry-lite-yjb6kaxw.js";import{xt,Mi}from"./vm-hands-entry-lite-ytxa5cq0.js";import{G,qe}from"./vm-hands-entry-lite-snsm9036.js";import{xe,Kn}from"./vm-hands-entry-lite-31kattrs.js";import{vt}from"./vm-hands-entry-lite-vezfnqf1.js";import{a}from"./vm-hands-entry-lite-y7z8pfgt.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{C}from"./vm-hands-entry-lite-tbawqj1n.js";import{spawn as R,spawnSync as st}from"child_process";import{createHash as it,randomUUID as ge}from"crypto";import{closeSync as at,copyFileSync as ae,existsSync as M,fstatSync as ct,mkdirSync as ce,openSync as lt,readdirSync as U,readFileSync as X,readlinkSync as ut,renameSync as he,rmSync as pt,statSync as ft,writeFileSync as gt}from"fs";import{connect as ht}from"net";import{tmpdir as L,userInfo as we}from"os";import{basename as le,delimiter as wt,dirname as B,join as f}from"path";var z=`import { spawn, execFileSync } from "node:child_process";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Pt,I}from"./vm-hands-entry-lite-r35zcvtk.js";import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{_,er}from"./vm-hands-entry-lite-hxhd7btg.js";import{be}from"./vm-hands-entry-lite-yretc2th.js";function $i(e,i){let t=T(e,"REASON_API_URL")?.trim();if(!t)return er(i);let n=new URL(t);if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(n.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return n.origin}function c(e){return T(e,"REASON_API_URL")?.trim()?$i(e,"production"):void 0}function Wo(e){return T(e,"REASON_API_KEY")?.trim()||void 0}async function ms(e,i){let t=e.env??process.env,n=Wo(t);if(!n)return(e.getCredentials??Pt)({apiOrigin:c(t),signal:i});let a=$i(t,e.channel??_({env:t})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+n,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),r=be(p)?p:{};if(!o.ok){let s=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:"API key authentication failed ("+o.status+")";throw new I(o.status,typeof r.error==="string"?r.error:"api_key_auth_failed",s)}if(typeof r.org_id!=="string"||!r.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let l=Array.isArray(r.scopes)?r.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:n,orgId:r.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:l}}export{$i,Wo,ms};
2
+ import{Pt,I}from"./vm-hands-entry-lite-kk3r0v3d.js";import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{_,er}from"./vm-hands-entry-lite-hxhd7btg.js";import{be}from"./vm-hands-entry-lite-yretc2th.js";function $i(e,i){let t=T(e,"REASON_API_URL")?.trim();if(!t)return er(i);let n=new URL(t);if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["127.0.0.1","localhost","::1"].includes(n.hostname)))throw Error("REASON_API_URL must use HTTPS (HTTP is allowed only for loopback development).");return n.origin}function c(e){return T(e,"REASON_API_URL")?.trim()?$i(e,"production"):void 0}function Wo(e){return T(e,"REASON_API_KEY")?.trim()||void 0}async function ms(e,i){let t=e.env??process.env,n=Wo(t);if(!n)return(e.getCredentials??Pt)({apiOrigin:c(t),signal:i});let a=$i(t,e.channel??_({env:t})),o=await(e.fetchImpl??fetch)(a+"/v3/self",{redirect:"error",headers:{authorization:"Bearer "+n,accept:"application/json"},signal:i}),p=await o.json().catch(()=>({})),r=be(p)?p:{};if(!o.ok){let s=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:"API key authentication failed ("+o.status+")";throw new I(o.status,typeof r.error==="string"?r.error:"api_key_auth_failed",s)}if(typeof r.org_id!=="string"||!r.org_id)throw Error("The API key in the environment did not resolve to a Workspace.");let l=Array.isArray(r.scopes)?r.scopes.filter((s)=>typeof s==="string"):[];return{credentialKind:"api_key",apiOrigin:a,accessToken:n,orgId:r.org_id,clientId:"api-key",refreshToken:"",expiresAt:"",scopes:l}}export{$i,Wo,ms};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Gt,j}from"./vm-hands-entry-lite-9r4d4mx1.js";import{ue,Ce,Z,Ae,de,rr,et,X,O,H,tn}from"./vm-hands-entry-lite-38g65s5x.js";import{No,ti}from"./vm-hands-entry-lite-hxhd7btg.js";import{Eo,P,Je,Se,Ze,ne,Xe,qn,Ee,Xt,ae,U,N,ce,Hr,zr,Vn}from"./vm-hands-entry-lite-ya9p67x3.js";import{Pe,oe,pe,Y,Re,q,Q}from"./vm-hands-entry-lite-vezfnqf1.js";import{It,kr,at,V,D,R,b}from"./vm-hands-entry-lite-nnzqx15h.js";import{Er,xr,vn,io,He,Sn}from"./vm-hands-entry-lite-p7m36kw7.js";import{K}from"./vm-hands-entry-lite-vtbw3evj.js";import{Li}from"./vm-hands-entry-lite-ytxa5cq0.js";import{p,ze,Dt,ct,oo,_e,we}from"./vm-hands-entry-lite-1qjw1rt2.js";import{v,h,co}from"./vm-hands-entry-lite-0tzzctxx.js";import{E}from"./vm-hands-entry-lite-txd50spx.js";import{Qt}from"./vm-hands-entry-lite-7sbm0cxh.js";import{a,ie,Mo}from"./vm-hands-entry-lite-y7z8pfgt.js";import{L,Oi,Ii,Uo,y,t,k,Et,o,d,u,i,c,g,ee,s,n}from"./vm-hands-entry-lite-g27kmejx.js";import{Ni}from"./vm-hands-entry-lite-bveg8vsa.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{zo,se,qo,C,De,Me,A}from"./vm-hands-entry-lite-tbawqj1n.js";var mi=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function l(w){return e[w]??null}let f={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},_={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=_[w.expected]??w.expected,I=Uo(w.input),W=_[I]??I;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Ii(w.values[0])}`;return`Invalid option: expected one of ${Oi(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",I=l(w.origin);if(I)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${I.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",I=l(w.origin);if(I)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${I.unit}`;return`Too small: expected ${w.origin} to be ${S}${w.minimum.toString()}`}case"invalid_format":{let S=w;if(S.format==="starts_with")return`Invalid string: must start with "${S.prefix}"`;if(S.format==="ends_with")return`Invalid string: must end with "${S.suffix}"`;if(S.format==="includes")return`Invalid string: must include "${S.includes}"`;if(S.format==="regex")return`Invalid string: must match pattern ${S.pattern}`;return`Invalid ${f[S.format]??w.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${w.divisor}`;case"unrecognized_keys":return`Unrecognized key${w.keys.length>1?"s":""}: ${Oi(w.keys,", ")}`;case"invalid_key":return`Invalid key in ${w.origin}`;case"invalid_union":if(w.options&&Array.isArray(w.options)&&w.options.length>0)return`Invalid discriminator value. Expected ${w.options.map((I)=>`'${I}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function En(){return{localeError:mi()}}L(En());class pt extends Error{}function Po(e){let l;try{l=new URL(e)}catch{throw new pt("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new pt("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new pt("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new pt("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new pt("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as hi}from"crypto";import{isAbsolute as Io,join as Ao,relative as To,resolve as Vt,sep as Do}from"path";var Jt=t().min(1).refine(Io,"absolute path required"),On=c({version:n(1),apiOrigin:Et(),channel:s(["staging","production"]),stateDirectory:Jt,workspaceRoot:Jt,lifetime:s(["persistent","ephemeral"]),executionMode:s(["confined","host"]).default("confined"),name:t().min(1).max(160).default("Reason headless worker"),slots:o().int().min(1).max(4).default(1),shutdownGraceMs:o().int().min(0).max(300000).default(30000),proxy:c({version:n(Gt),url:t().refine((e)=>{try{return Po(e)===e}catch{return!1}},"invalid proxy URL"),caFile:Jt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(Jt).min(1).max(31).optional()}),gi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=g("channel",[On,On.extend({channel:n("pr"),apiOrigin:t(),prEnvironment:t()}),On.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!gi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else if(e.channel==="pr"){let _=e.prEnvironment,w=/^https:\/\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\.up\.railway\.app$/.exec(e.apiOrigin),S=w?.[1]?.match(/(?:^|-)pr-[0-9]+(?=-|$)/g)?.map((I)=>I.replace(/^-/,""));if(!_||/^pr-[1-9][0-9]*$/.exec(_)?.[0]!==_||w?.[0]!==e.apiOrigin||S?.length!==1||S[0]!==_)l.addIssue({code:"custom",message:"PR worker requires explicit prEnvironment and an exact same-PR HTTPS Railway origin"})}else{let _=new URL(e.apiOrigin);if(_.origin!==e.apiOrigin||_.username||_.password||_.protocol!=="https:"&&!(_.protocol==="http:"&&ti(_.origin))||!ti(_.origin)&&!No(e.channel,_.origin))l.addIssue({code:"custom",message:"API origin must match channel (or loopback)"})}if(!je(e.workspaceRoot,e.stateDirectory))l.addIssue({code:"custom",message:"state and workspace must be disjoint"});let f=e.folders??[];if(new Set([e.workspaceRoot,...f]).size!==f.length+1||f.some((_)=>!je(_,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return Ao(e.stateDirectory,`headless-${e.channel==="pr"?e.prEnvironment:e.channel}`)}function je(e,l){if(Fr(l,e))return!1;return!Fr(e,l)||E(Ao(Do,To(Vt(e),Vt(l))))}function Fr(e,l){let f=To(Vt(e),Vt(l));return f===""||f!==".."&&!f.startsWith(`..${Do}`)&&!Io(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:_,localLogins:w,folders:S,...I}=e;return hi("sha256").update(JSON.stringify(I)).digest("hex")}var bi=4,wi=[2375,2376,9222,9229];function pr(e){let l=new Set(wi);for(let f of e){let _=new URL(f);l.add(Number(_.port||(["https:","wss:"].includes(_.protocol)?443:80)))}return l}function Gr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var yi=60000;function Co(e){let l=new AbortController,f=new Map,_=(x)=>JSON.stringify([x.jobId,x.port]);function w(x){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||x.organization_id!==M.organization_id||x.user_id!==M.user_id||x.device_id!==M.device_id)Gr()}function S(x){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===x.generation&&M.binding.target_fence_id===x.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function I(x,M,G){let F=await W(x,M,G);if(F!=="moved")return F;let T=await W(x,M,G);return T==="moved"?null:T}async function W(x,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||x.expiresAtMs<=Date.now()||x.expiresAtMs>e.expiresAtMs)return null;let T=M.opened,re=T!==void 0&&F.generation>T.generation,J=S(F);if(re){if(J){if(J.revision<=T.revision||x.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==T.attachmentRevision||J.binding.root_grant_revision!==T.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>yi)return null}else if(!J||x.expiresAtMs>Date.parse(J.expires_at)||T&&(F.generation!==T.generation||F.fenceId!==T.fenceId))return null;let z=await e.inspect(x.jobId,G),fe=e.identity(),ve=fe&&S(fe);w(e.authority.owner);let be=J&&{generation:F.generation,fenceId:F.fenceId,snapshotId:J.snapshot_id,revision:J.revision,attachmentRevision:J.binding.target_revision,grantRevision:J.binding.root_grant_revision},Oe=re?T:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ve?.snapshot_id!==J?.snapshot_id||ve?.revision!==J?.revision)return"moved";let $e=z.ok&&z.job.environmentSnapshotId!==void 0&&z.job.environmentRevision!==void 0?{snapshotId:z.job.environmentSnapshotId,revision:z.job.environmentRevision}:null;if(!z.ok||z.generation!==F.generation||!Oe||!$e)return null;if(($e.snapshotId!==Oe.snapshotId||$e.revision!==Oe.revision)&&(re||!e.environment.carried($e.snapshotId,$e.revision)))return null;if(!T&&F.generation===x.generation&&F.fenceId===x.fenceId)M.opened={...Oe,...$e};return{executorLaunchId:e.executorLaunchId,job:z.job,binding:{organizationId:e.authority.owner.organization_id,userId:e.authority.owner.user_id,deviceId:e.authority.owner.device_id,rootId:e.authority.rootId,runId:e.runId,attachmentRevision:Oe.attachmentRevision,grantRevision:Oe.grantRevision,generation:Oe.generation,fenceId:Oe.fenceId,jobId:z.job.jobId,port:x.port,expiresAtMs:x.expiresAtMs}}}catch{return null}}return{async open(x,M,G){w(M);let{binding:F,deviceRelayUrl:T}=ct(x);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(T).origin!==e.authority.relayOrigin)Gr();let re=_(F),J=f.get(re);if(J){if(!ze(J.binding,F)||J.relay!==T)Gr();if(await J.opened,!await Dt(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Gr();return{opened:!0,binding:F}}if(f.size>=bi)Gr();let z=new AbortController,fe={},ve=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>I(F,fe,z.signal)}),be=()=>z.abort();if(G.addEventListener("abort",be,{once:!0}),l.signal.addEventListener("abort",be,{once:!0}),G.aborted||l.signal.aborted)be();let Oe=_e({binding:F,deviceRelayUrl:T,port:ve,signal:z.signal}),$e={binding:F,relay:T,abort:z,port:ve,opened:Oe};f.set(re,$e);let qe=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===$e)f.delete(re)};try{if((await Oe).closed.then(qe),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await Dt(()=>ve.check()))Gr();return{opened:!0,binding:F}}catch{z.abort(),qe(),Gr()}},async close(x,M){w(M);let{binding:G}=oo(x),F=f.get(_(G));if(!F||!ze(F.binding,G))Gr();return F.abort.abort(),await F.opened.then((T)=>T.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let x of f.values())x.abort.abort();f.clear()}}}import{WebSocket as xn}from"ws";var Ho=(e)=>("data"in e)?e.data.length:e.bytes,Lo=2*Xe;function ir(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var _t=(e)=>!["starting","running"].includes(e.state);function Ki(e,l,f=Date.now()){let _=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==_.length||Object.keys(e).some((M)=>!_.includes(M))||!ae(l)||!ae(e.session_id)||typeof e.expires_at!=="string"||typeof e.relay_url!=="string"||e.relay_url.length>4096||![e.cols,e.rows].every((M)=>Number.isSafeInteger(M)&&Number(M)>=1&&Number(M)<=Ee))ir("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))ir("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))ir("invalid_pty_request");let I;try{I=new URL(e.relay_url)}catch{return ir("invalid_pty_request")}if(!["ws:","wss:"].includes(I.protocol)||I.username||I.password||I.hash||I.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(I.hostname))ir("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)ir("invalid_pty_request");return{workspace:H(e.workspace)??ir("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:I.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Bo(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)ir("cancelled");let _=new xn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},I=()=>{w.abort(),S()};e.signal.addEventListener("abort",I,{once:!0});let W=setTimeout(I,Math.max(1,l.leaseExpiresAtMs-Date.now())),x=[],M=0,G=0,F=0,T=!1,re=!1,J=!1,z,fe,ve,be=(le)=>{ve=new r(le,"Bound terminal input was refused."),I()};_.on("error",()=>be("pty_relay_unavailable")),_.on("close",I),_.on("message",(le,he)=>{if(w.signal.aborted)return;if(!re){be("pty_not_ready");return}let xe=Array.isArray(le)?Buffer.concat(le):le instanceof ArrayBuffer?Buffer.from(le):le;if(xe.length===0)return;let Ke=x.at(-1),Le=he&&Ke!==void 0&&"data"in Ke&&Ke.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>qn){be("pty_input_backpressure");return}if(Le)Ke.data=Buffer.concat([Ke.data,xe]);else if(he)x.push({data:Buffer.from(xe)});else try{let Be=JSON.parse(xe.toString("utf8"));if(Be&&Be.t==="close"&&Object.keys(Be).length===1){J=!0,I();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((ke)=>Number.isSafeInteger(ke)&&ke>=1&&ke<=Ee))throw Error("invalid_control");x.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Oe(le){return Vn(JSON.stringify({...f.scope,version:1,sessionId:l.sessionId,operationId:l.operationId,job:{...le,output:[],pty:le.pty?{...le.pty,output:[]}:void 0}}))}function $e(le){if(!le.ok)ir(le.error);let he=le.job;if(le.generation!==f.scope.generation||he.jobId!==l.jobId||!he.pty||he.leaseExpiresAtMs>l.leaseExpiresAtMs||he.process&&he.process.executorLaunchId!==f.scope.executorLaunchId||he.process&&fe&&(he.process.pid!==fe.pid||he.process.processGroupId!==fe.processGroupId)||he.state!=="starting"&&(he.environmentRevision!==f.environment.revision||he.environmentSnapshotId!==f.environment.snapshotId))ir("pty_binding_changed");if(Oe(he),he.process)fe??={...he.process};return he}async function qe(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)ir("cancelled");let xe=$e(he);if(xe.inputSequence!==G)ir("job_input_sequence");if(!_t(xe)&&xe.leaseExpiresAtMs<=Date.now())ir("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||_.readyState!==xn.OPEN||_.bufferedAmount+Buffer.byteLength(le)>Lo)ir("pty_output_backpressure");_.send(le)}function Fe(le){if(le.firstCursor>F+1)F=le.firstCursor-1;for(let he of le.pty.output){if(he.cursor<=F)continue;if(he.cursor!==F+1)ir("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(_.bufferedAmount+xe.length>Lo)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)ir("pty_output_gap");return!0}async function Ve(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ke,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function Te(){let le=AbortSignal.timeout(Xt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ke=new Promise((Le,Be)=>{if(xe=()=>Be(new r("pty_cleanup_unconfirmed","Terminal cleanup acknowledgement was not observed within authority.")),le.addEventListener("abort",xe,{once:!0}),le.aborted)xe()});try{let Le=await Promise.race([he,Ke]);if(le.aborted)ir("pty_cleanup_unconfirmed");return $e(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let ke=setTimeout(()=>{I(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),We=()=>{clearTimeout(ke),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",We,{once:!0}),_.once("open",()=>{clearTimeout(ke),w.signal.removeEventListener("abort",We),Le()}),w.signal.aborted)We()}),f.assertCurrent(),T=!0,z=await qe({jobId:l.jobId,action:"start",input:{mode:"pty",cols:l.cols,rows:l.rows,leaseExpiresAtMs:l.leaseExpiresAtMs}});let le=Date.now()+5000;while(z.state==="starting"){if(Date.now()>=le)ir("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())ir("pty_not_ready");await Ve("pty.ready",Oe(z)),re=!0,ye(JSON.stringify({t:"open",cols:z.pty.cols,rows:z.pty.rows,receipt:Oe(z)}));let he=!1,xe=0,Ke=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=Fe(z);if(_t(z)){if(Be)break}else if(Le)he=!0;else if(he&&Be&&Date.now()>=xe){he=!1,xe=Date.now()+1000;let{cols:We,rows:tr}=z.pty;for(let nr of[{cols:We,rows:tr>1?tr-1:2},{cols:We,rows:tr}]){if(_t(z))break;let Or=++G;if(z=await qe({jobId:l.jobId,action:"resize",input:{sequence:Or,...nr}}),z.inputSequence!==Or)ir("job_input_sequence")}continue}let ke=_t(z)||Ke?void 0:x.shift();if(ke){M-=Ho(ke);let We=++G;try{z=await qe("data"in ke?{jobId:l.jobId,action:"input",input:{sequence:We,dataBase64:ke.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:We,cols:ke.cols,rows:ke.rows}})}catch(tr){if(!(tr instanceof r)||tr.code!=="job_input_backpressure")throw tr;G-=1,x.unshift(ke),M+=Ho(ke),Ke=!0;continue}if(z.inputSequence!==We)ir("job_input_sequence")}else if(await new Promise((We)=>{let tr=setTimeout(We,Ke||!Be?10:50);if(S=()=>{clearTimeout(tr),We()},w.signal.aborted||!Ke&&x.length)S()}),Ke=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(We){if(!J||!(We instanceof r)||We.code!=="cancelled")throw We}}}catch(le){ve??=le}finally{if(re=!1,x.length=0,clearTimeout(W),e.signal.removeEventListener("abort",I),I(),T&&(!z||!_t(z)))try{z=await Te()}catch{z=void 0}try{if(!z||!_t(z)||z.pty?.cleanup!=="confirmed")ir("pty_cleanup_unconfirmed");let le=Oe(z);if(_.readyState===xn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);_.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await Ve("pty.stopped",le)}catch(le){ve??=le}_.terminate()}if(ve)throw ve;if(e.signal.aborted)ir("cancelled");if(!z)ir("pty_cleanup_unconfirmed");return{receipt:Oe(z)}}import{createHash as vi,randomUUID as An}from"crypto";import{spawnSync as $o}from"child_process";import{closeSync as jo,constants as Pn,fstatSync as ki,fsyncSync as Si,lstatSync as Lt,mkdirSync as Ei,mkdtempSync as Ko,openSync as Wo,readFileSync as Ri,readdirSync as Go,realpathSync as Nt,rmSync as In,unlinkSync as xi}from"fs";import{createConnection as Pi}from"net";import{dirname as Ai,join as tt,sep as Ti}from"path";import{tmpdir as Di}from"os";var Rr=new Map,Jr=new Map;function Ur(e,l){return vi("sha256").update(JSON.stringify([e,l])).digest("hex")}function mt(e){try{Ei(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Lt(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Nt(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function Ci(e){let l;try{l=Lt(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||Go(e).length>0}function hr(e){let l=Ur(e.root,e.runId),f=e.previousRuntimeDirectories?.find((I)=>Ci(tt(I,"jobs",l.slice(0,16))))??e.runtimeDirectory;mt(f);let _=tt(f,"jobs");mt(_);let w=tt(_,l.slice(0,16));if(e.maxScopes!==void 0){let I=Go(_);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||I.length>e.maxScopes||!I.includes(l.slice(0,16))&&I.length>=e.maxScopes)throw new r("process_journal_capacity","Managed process receipt capacity is full; preserve uncertain jobs and reconcile their existing receipts before starting more work.")}mt(w);let S=Ko(tt(qo(),"reason-j-"));try{return mt(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:tt(S,"control.sock"),disposeSocket:()=>In(S,{recursive:!0,force:!0})}}catch(I){throw In(S,{recursive:!0,force:!0}),I}}var Hi=60000,Bi=5000;function ji(e){if(process.platform==="win32")return Mi(e);let l=$o("ps",["-o","lstart=","-p",String(e)],{encoding:"utf8",timeout:2000,env:{...process.env,LC_ALL:"C",LANG:"C"}}),f=l.status===0?/^\w{3} (\w{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/.exec(l.stdout.trim()):null,_=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||_<0||_%3!==0)return null;let w=new Date(Number(f[6]),_/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function Mi(e){let l=$o(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:De()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function Jo(e,l={}){let f=tt(e.journalDirectory,"owner.lock"),_;try{_=Wo(f,Pn.O_RDONLY|Pn.O_NOFOLLOW)}catch{return null}try{let w=ki(_);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(Ri(_,"utf8"))}catch{}let I;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Hi)return null;I={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:T,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof T!=="number"||!Number.isSafeInteger(T))return null;if(!(l.exists??((z)=>{try{return process.kill(z,0),!0}catch(fe){return!(fe instanceof Error&&("code"in fe)&&fe.code==="ESRCH")}}))(F))I={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??ji)(F);if(z===null||z<=T+Bi)return null;I={reason:"pid_reused",executorLaunchId:re}}}let W=Lt(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;xi(f);let x=Wo(e.journalDirectory,Pn.O_RDONLY);try{Si(x)}finally{jo(x)}return I}catch{return null}finally{jo(_)}}function Vo(e){let l={...e,workspace:e.workspace&&Object.freeze({...e.workspace}),previewAuthority:e.previewAuthority&&Object.freeze({...e.previewAuthority,owner:Object.freeze({...e.previewAuthority.owner}),deniedPorts:new Set(e.previewAuthority.deniedPorts)})},f=Ur(l.root,l.runId);if(Rr.has(f)||l.operationId!==void 0&&Jr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let _={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)_.previews=Co({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>Rr.get(_.key)===_,identity:()=>{try{return ht(l)}catch{return null}},inspect:(w,S)=>{if(Rr.get(_.key)!==_)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return Yo(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(Rr.set(f,_),l.operationId!==void 0)Jr.set(l.operationId,_);return()=>{if(Rr.get(_.key)===_)Rr.delete(_.key);if(l.operationId!==void 0&&Jr.get(l.operationId)===_)Jr.delete(l.operationId);_.previews?.dispose();for(let w of _.terminals.values())w.abort()}}var Wi=5000,Fi=20;async function Ji(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!U(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=Jr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Wi;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(Jr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=ht(f.binding)}catch{}if(S&&S.generation===e.targetGeneration&&S.fenceId===e.fenceId)break;if(S&&S.generation>e.targetGeneration||Date.now()>=w)l("The executor did not adopt this take.");await new Promise((I)=>setTimeout(I,Fi))}if(Jr.get(e.operationId)!==f||Rr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let _=Ur(e.root,e.runId);if(f.key===_)return;if(Rr.has(_))l("The taking run already has a live Hands job supervisor.");Rr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=_,Rr.set(_,f)}function ot(e){let l="operationId"in e?Jr.get(e.operationId):Rr.get(Ur(e.root,e.runId)),f=l&&l.binding.root===e.root?l.binding:void 0;if(!f?.environment||f.expiresAtMs<=Date.now())throw new r("environment_unavailable","No live Hands supervisor owns this environment.");return f.environment.install(e.payload)}async function Zi(e){let l=Rr.get(Ur(e.root,e.runId));if(!l?.previews||!e.owner)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.open(e.payload,e.owner,e.signal)}async function Xi(e){let l=Rr.get(Ur(e.root,e.runId));if(!l?.previews||!e.owner||e.signal.aborted)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.close(e.payload,e.owner)}async function Yi(e){let l=Ur(e.root,e.runId),f=Rr.get(l),_=f?.binding,w=_?.runId,S=_?.previewAuthority,I=_?.environment,W=e.owner&&{...e.owner},x=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!_||!S||!I||!W||!x||!_.workspace)return M();let G=Object.freeze({..._.workspace}),F=ht(_),T=I.current(),re=()=>{if(Rr.get(l)!==f||W.organization_id!==S.owner.organization_id||W.user_id!==S.owner.user_id||W.device_id!==S.owner.device_id||e.deviceId!==S.owner.device_id||e.rootId!==S.rootId||O(e.workspace)!==O(G))M();let z=ht(_),fe=I.current();if(z.generation!==F.generation||z.fenceId!==F.fenceId||fe.run_id!==w||fe.device_id!==e.deviceId||fe.root_id!==e.rootId||fe.snapshot_id!==T.snapshot_id||fe.revision!==T.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||x.device_id!==e.deviceId||x.binding!==fe.binding.kind||x.target_revision!==fe.binding.target_revision||x.root_grant_revision!==fe.binding.root_grant_revision||x.target_generation!==F.generation||x.target_fence_id!==F.fenceId)M()};if(re(),new URL(e.session.relayUrl).origin!==S.relayOrigin||f.terminals.has(e.session.jobId)||f.terminals.size>=4)return M();let J=new AbortController;f.terminals.set(e.session.jobId,J);try{return await Bo({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(T.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:T.revision,snapshotId:T.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:T.binding.kind,targetRevision:T.binding.target_revision,rootGrantRevision:T.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>fr(F,Hr(JSON.stringify({...z,type:"job",version:2,generation:F.generation,id:An()})),fe)}})}finally{if(f.terminals.get(e.session.jobId)===J)f.terminals.delete(e.session.jobId)}}async function Qi(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=Rr.get(Ur(e.root,e.runId))?.binding;if(!l||l.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","No live Hands supervisor owns this Session and root.");return Yo(l,e.payload,e.signal)}var Ui=1e4,zi=20,$i=Se/2,Gi=Je/2,Vi=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function Yo(e,l,f){if(Object.keys(l).some((M)=>!["jobId","action","input","waitForExitMs"].includes(M)))throw new r("invalid_payload","Unexpected job control field.");let{waitForExitMs:_,...w}=l;if(_!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof _!=="number"||!Number.isSafeInteger(_)||_<1||_>Ui))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=ht(e);return fr(G,Hr(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},I=await S(w);if(_===void 0)return I;let W=Date.now()+_,x=I;while(x.ok&&["starting","running"].includes(x.job.state)&&x.job.output.length<$i&&Vi(x.job)<Gi&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(zi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;x=M}catch{break}}return x}function ht(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!U(l.generation)||!N(l.fenceId)||l.generation<e.generation||l.generation===e.generation&&l.fenceId!==e.fenceId)throw new r("hands_jobs_unavailable","The live Hands fencing identity could not be verified.");return e.generation=l.generation,e.fenceId=l.fenceId,{...e}}function fr(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((_,w)=>{let S=Pi(e.socketPath),I="",W=!1,x,M=(F,T)=>{if(W)return;if(W=!0,clearTimeout(x),f.removeEventListener("abort",G),S.destroy(),F)w(F);else _(T)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),x=setTimeout(()=>M(new r("hands_job_result_unknown","Job control timed out; inspect before retrying mutations.")),Math.min(1e4,Math.max(1,e.expiresAtMs-Date.now()))),S.on("error",()=>M(new r("hands_job_result_unknown","Hands job control connection failed."))),S.once("connect",()=>S.write(JSON.stringify({version:1,scopeId:e.scopeId,fenceId:e.fenceId,executorLaunchId:e.executorLaunchId,request:l})+`
2
+ import{Gt,j}from"./vm-hands-entry-lite-9r4d4mx1.js";import{ue,Ce,Z,Ae,de,rr,et,X,O,H,tn}from"./vm-hands-entry-lite-38g65s5x.js";import{No,ti}from"./vm-hands-entry-lite-hxhd7btg.js";import{Eo,P,Je,Se,Ze,ne,Xe,qn,Ee,Xt,ae,U,N,ce,Hr,zr,Vn}from"./vm-hands-entry-lite-ya9p67x3.js";import{Pe,oe,pe,Y,Re,q,Q}from"./vm-hands-entry-lite-vezfnqf1.js";import{It,kr,at,V,D,R,b}from"./vm-hands-entry-lite-nnzqx15h.js";import{Er,xr,vn,io,He,Sn}from"./vm-hands-entry-lite-p7m36kw7.js";import{K}from"./vm-hands-entry-lite-vtbw3evj.js";import{Li}from"./vm-hands-entry-lite-ytxa5cq0.js";import{p,ze,Dt,ct,oo,_e,we}from"./vm-hands-entry-lite-1qjw1rt2.js";import{v,h,co}from"./vm-hands-entry-lite-0tzzctxx.js";import{E}from"./vm-hands-entry-lite-txd50spx.js";import{Qt}from"./vm-hands-entry-lite-ngv8x7gh.js";import{a,ie,Mo}from"./vm-hands-entry-lite-y7z8pfgt.js";import{L,Oi,Ii,Uo,y,t,k,Et,o,d,u,i,c,g,ee,s,n}from"./vm-hands-entry-lite-g27kmejx.js";import{Ni}from"./vm-hands-entry-lite-bveg8vsa.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{zo,se,qo,C,De,Me,A}from"./vm-hands-entry-lite-tbawqj1n.js";var mi=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function l(w){return e[w]??null}let f={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},_={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=_[w.expected]??w.expected,I=Uo(w.input),W=_[I]??I;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Ii(w.values[0])}`;return`Invalid option: expected one of ${Oi(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",I=l(w.origin);if(I)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${I.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",I=l(w.origin);if(I)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${I.unit}`;return`Too small: expected ${w.origin} to be ${S}${w.minimum.toString()}`}case"invalid_format":{let S=w;if(S.format==="starts_with")return`Invalid string: must start with "${S.prefix}"`;if(S.format==="ends_with")return`Invalid string: must end with "${S.suffix}"`;if(S.format==="includes")return`Invalid string: must include "${S.includes}"`;if(S.format==="regex")return`Invalid string: must match pattern ${S.pattern}`;return`Invalid ${f[S.format]??w.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${w.divisor}`;case"unrecognized_keys":return`Unrecognized key${w.keys.length>1?"s":""}: ${Oi(w.keys,", ")}`;case"invalid_key":return`Invalid key in ${w.origin}`;case"invalid_union":if(w.options&&Array.isArray(w.options)&&w.options.length>0)return`Invalid discriminator value. Expected ${w.options.map((I)=>`'${I}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function En(){return{localeError:mi()}}L(En());class pt extends Error{}function Po(e){let l;try{l=new URL(e)}catch{throw new pt("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new pt("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new pt("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new pt("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new pt("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as hi}from"crypto";import{isAbsolute as Io,join as Ao,relative as To,resolve as Vt,sep as Do}from"path";var Jt=t().min(1).refine(Io,"absolute path required"),On=c({version:n(1),apiOrigin:Et(),channel:s(["staging","production"]),stateDirectory:Jt,workspaceRoot:Jt,lifetime:s(["persistent","ephemeral"]),executionMode:s(["confined","host"]).default("confined"),name:t().min(1).max(160).default("Reason headless worker"),slots:o().int().min(1).max(4).default(1),shutdownGraceMs:o().int().min(0).max(300000).default(30000),proxy:c({version:n(Gt),url:t().refine((e)=>{try{return Po(e)===e}catch{return!1}},"invalid proxy URL"),caFile:Jt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(Jt).min(1).max(31).optional()}),gi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=g("channel",[On,On.extend({channel:n("pr"),apiOrigin:t(),prEnvironment:t()}),On.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!gi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else if(e.channel==="pr"){let _=e.prEnvironment,w=/^https:\/\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\.up\.railway\.app$/.exec(e.apiOrigin),S=w?.[1]?.match(/(?:^|-)pr-[0-9]+(?=-|$)/g)?.map((I)=>I.replace(/^-/,""));if(!_||/^pr-[1-9][0-9]*$/.exec(_)?.[0]!==_||w?.[0]!==e.apiOrigin||S?.length!==1||S[0]!==_)l.addIssue({code:"custom",message:"PR worker requires explicit prEnvironment and an exact same-PR HTTPS Railway origin"})}else{let _=new URL(e.apiOrigin);if(_.origin!==e.apiOrigin||_.username||_.password||_.protocol!=="https:"&&!(_.protocol==="http:"&&ti(_.origin))||!ti(_.origin)&&!No(e.channel,_.origin))l.addIssue({code:"custom",message:"API origin must match channel (or loopback)"})}if(!je(e.workspaceRoot,e.stateDirectory))l.addIssue({code:"custom",message:"state and workspace must be disjoint"});let f=e.folders??[];if(new Set([e.workspaceRoot,...f]).size!==f.length+1||f.some((_)=>!je(_,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return Ao(e.stateDirectory,`headless-${e.channel==="pr"?e.prEnvironment:e.channel}`)}function je(e,l){if(Fr(l,e))return!1;return!Fr(e,l)||E(Ao(Do,To(Vt(e),Vt(l))))}function Fr(e,l){let f=To(Vt(e),Vt(l));return f===""||f!==".."&&!f.startsWith(`..${Do}`)&&!Io(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:_,localLogins:w,folders:S,...I}=e;return hi("sha256").update(JSON.stringify(I)).digest("hex")}var bi=4,wi=[2375,2376,9222,9229];function pr(e){let l=new Set(wi);for(let f of e){let _=new URL(f);l.add(Number(_.port||(["https:","wss:"].includes(_.protocol)?443:80)))}return l}function Gr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var yi=60000;function Co(e){let l=new AbortController,f=new Map,_=(x)=>JSON.stringify([x.jobId,x.port]);function w(x){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||x.organization_id!==M.organization_id||x.user_id!==M.user_id||x.device_id!==M.device_id)Gr()}function S(x){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===x.generation&&M.binding.target_fence_id===x.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function I(x,M,G){let F=await W(x,M,G);if(F!=="moved")return F;let T=await W(x,M,G);return T==="moved"?null:T}async function W(x,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||x.expiresAtMs<=Date.now()||x.expiresAtMs>e.expiresAtMs)return null;let T=M.opened,re=T!==void 0&&F.generation>T.generation,J=S(F);if(re){if(J){if(J.revision<=T.revision||x.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==T.attachmentRevision||J.binding.root_grant_revision!==T.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>yi)return null}else if(!J||x.expiresAtMs>Date.parse(J.expires_at)||T&&(F.generation!==T.generation||F.fenceId!==T.fenceId))return null;let z=await e.inspect(x.jobId,G),fe=e.identity(),ve=fe&&S(fe);w(e.authority.owner);let be=J&&{generation:F.generation,fenceId:F.fenceId,snapshotId:J.snapshot_id,revision:J.revision,attachmentRevision:J.binding.target_revision,grantRevision:J.binding.root_grant_revision},Oe=re?T:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ve?.snapshot_id!==J?.snapshot_id||ve?.revision!==J?.revision)return"moved";let $e=z.ok&&z.job.environmentSnapshotId!==void 0&&z.job.environmentRevision!==void 0?{snapshotId:z.job.environmentSnapshotId,revision:z.job.environmentRevision}:null;if(!z.ok||z.generation!==F.generation||!Oe||!$e)return null;if(($e.snapshotId!==Oe.snapshotId||$e.revision!==Oe.revision)&&(re||!e.environment.carried($e.snapshotId,$e.revision)))return null;if(!T&&F.generation===x.generation&&F.fenceId===x.fenceId)M.opened={...Oe,...$e};return{executorLaunchId:e.executorLaunchId,job:z.job,binding:{organizationId:e.authority.owner.organization_id,userId:e.authority.owner.user_id,deviceId:e.authority.owner.device_id,rootId:e.authority.rootId,runId:e.runId,attachmentRevision:Oe.attachmentRevision,grantRevision:Oe.grantRevision,generation:Oe.generation,fenceId:Oe.fenceId,jobId:z.job.jobId,port:x.port,expiresAtMs:x.expiresAtMs}}}catch{return null}}return{async open(x,M,G){w(M);let{binding:F,deviceRelayUrl:T}=ct(x);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(T).origin!==e.authority.relayOrigin)Gr();let re=_(F),J=f.get(re);if(J){if(!ze(J.binding,F)||J.relay!==T)Gr();if(await J.opened,!await Dt(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Gr();return{opened:!0,binding:F}}if(f.size>=bi)Gr();let z=new AbortController,fe={},ve=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>I(F,fe,z.signal)}),be=()=>z.abort();if(G.addEventListener("abort",be,{once:!0}),l.signal.addEventListener("abort",be,{once:!0}),G.aborted||l.signal.aborted)be();let Oe=_e({binding:F,deviceRelayUrl:T,port:ve,signal:z.signal}),$e={binding:F,relay:T,abort:z,port:ve,opened:Oe};f.set(re,$e);let qe=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===$e)f.delete(re)};try{if((await Oe).closed.then(qe),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await Dt(()=>ve.check()))Gr();return{opened:!0,binding:F}}catch{z.abort(),qe(),Gr()}},async close(x,M){w(M);let{binding:G}=oo(x),F=f.get(_(G));if(!F||!ze(F.binding,G))Gr();return F.abort.abort(),await F.opened.then((T)=>T.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let x of f.values())x.abort.abort();f.clear()}}}import{WebSocket as xn}from"ws";var Ho=(e)=>("data"in e)?e.data.length:e.bytes,Lo=2*Xe;function ir(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var _t=(e)=>!["starting","running"].includes(e.state);function Ki(e,l,f=Date.now()){let _=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==_.length||Object.keys(e).some((M)=>!_.includes(M))||!ae(l)||!ae(e.session_id)||typeof e.expires_at!=="string"||typeof e.relay_url!=="string"||e.relay_url.length>4096||![e.cols,e.rows].every((M)=>Number.isSafeInteger(M)&&Number(M)>=1&&Number(M)<=Ee))ir("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))ir("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))ir("invalid_pty_request");let I;try{I=new URL(e.relay_url)}catch{return ir("invalid_pty_request")}if(!["ws:","wss:"].includes(I.protocol)||I.username||I.password||I.hash||I.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(I.hostname))ir("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)ir("invalid_pty_request");return{workspace:H(e.workspace)??ir("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:I.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Bo(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)ir("cancelled");let _=new xn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},I=()=>{w.abort(),S()};e.signal.addEventListener("abort",I,{once:!0});let W=setTimeout(I,Math.max(1,l.leaseExpiresAtMs-Date.now())),x=[],M=0,G=0,F=0,T=!1,re=!1,J=!1,z,fe,ve,be=(le)=>{ve=new r(le,"Bound terminal input was refused."),I()};_.on("error",()=>be("pty_relay_unavailable")),_.on("close",I),_.on("message",(le,he)=>{if(w.signal.aborted)return;if(!re){be("pty_not_ready");return}let xe=Array.isArray(le)?Buffer.concat(le):le instanceof ArrayBuffer?Buffer.from(le):le;if(xe.length===0)return;let Ke=x.at(-1),Le=he&&Ke!==void 0&&"data"in Ke&&Ke.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>qn){be("pty_input_backpressure");return}if(Le)Ke.data=Buffer.concat([Ke.data,xe]);else if(he)x.push({data:Buffer.from(xe)});else try{let Be=JSON.parse(xe.toString("utf8"));if(Be&&Be.t==="close"&&Object.keys(Be).length===1){J=!0,I();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((ke)=>Number.isSafeInteger(ke)&&ke>=1&&ke<=Ee))throw Error("invalid_control");x.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Oe(le){return Vn(JSON.stringify({...f.scope,version:1,sessionId:l.sessionId,operationId:l.operationId,job:{...le,output:[],pty:le.pty?{...le.pty,output:[]}:void 0}}))}function $e(le){if(!le.ok)ir(le.error);let he=le.job;if(le.generation!==f.scope.generation||he.jobId!==l.jobId||!he.pty||he.leaseExpiresAtMs>l.leaseExpiresAtMs||he.process&&he.process.executorLaunchId!==f.scope.executorLaunchId||he.process&&fe&&(he.process.pid!==fe.pid||he.process.processGroupId!==fe.processGroupId)||he.state!=="starting"&&(he.environmentRevision!==f.environment.revision||he.environmentSnapshotId!==f.environment.snapshotId))ir("pty_binding_changed");if(Oe(he),he.process)fe??={...he.process};return he}async function qe(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)ir("cancelled");let xe=$e(he);if(xe.inputSequence!==G)ir("job_input_sequence");if(!_t(xe)&&xe.leaseExpiresAtMs<=Date.now())ir("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||_.readyState!==xn.OPEN||_.bufferedAmount+Buffer.byteLength(le)>Lo)ir("pty_output_backpressure");_.send(le)}function Fe(le){if(le.firstCursor>F+1)F=le.firstCursor-1;for(let he of le.pty.output){if(he.cursor<=F)continue;if(he.cursor!==F+1)ir("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(_.bufferedAmount+xe.length>Lo)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)ir("pty_output_gap");return!0}async function Ve(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ke,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function Te(){let le=AbortSignal.timeout(Xt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ke=new Promise((Le,Be)=>{if(xe=()=>Be(new r("pty_cleanup_unconfirmed","Terminal cleanup acknowledgement was not observed within authority.")),le.addEventListener("abort",xe,{once:!0}),le.aborted)xe()});try{let Le=await Promise.race([he,Ke]);if(le.aborted)ir("pty_cleanup_unconfirmed");return $e(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let ke=setTimeout(()=>{I(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),We=()=>{clearTimeout(ke),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",We,{once:!0}),_.once("open",()=>{clearTimeout(ke),w.signal.removeEventListener("abort",We),Le()}),w.signal.aborted)We()}),f.assertCurrent(),T=!0,z=await qe({jobId:l.jobId,action:"start",input:{mode:"pty",cols:l.cols,rows:l.rows,leaseExpiresAtMs:l.leaseExpiresAtMs}});let le=Date.now()+5000;while(z.state==="starting"){if(Date.now()>=le)ir("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())ir("pty_not_ready");await Ve("pty.ready",Oe(z)),re=!0,ye(JSON.stringify({t:"open",cols:z.pty.cols,rows:z.pty.rows,receipt:Oe(z)}));let he=!1,xe=0,Ke=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=Fe(z);if(_t(z)){if(Be)break}else if(Le)he=!0;else if(he&&Be&&Date.now()>=xe){he=!1,xe=Date.now()+1000;let{cols:We,rows:tr}=z.pty;for(let nr of[{cols:We,rows:tr>1?tr-1:2},{cols:We,rows:tr}]){if(_t(z))break;let Or=++G;if(z=await qe({jobId:l.jobId,action:"resize",input:{sequence:Or,...nr}}),z.inputSequence!==Or)ir("job_input_sequence")}continue}let ke=_t(z)||Ke?void 0:x.shift();if(ke){M-=Ho(ke);let We=++G;try{z=await qe("data"in ke?{jobId:l.jobId,action:"input",input:{sequence:We,dataBase64:ke.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:We,cols:ke.cols,rows:ke.rows}})}catch(tr){if(!(tr instanceof r)||tr.code!=="job_input_backpressure")throw tr;G-=1,x.unshift(ke),M+=Ho(ke),Ke=!0;continue}if(z.inputSequence!==We)ir("job_input_sequence")}else if(await new Promise((We)=>{let tr=setTimeout(We,Ke||!Be?10:50);if(S=()=>{clearTimeout(tr),We()},w.signal.aborted||!Ke&&x.length)S()}),Ke=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(We){if(!J||!(We instanceof r)||We.code!=="cancelled")throw We}}}catch(le){ve??=le}finally{if(re=!1,x.length=0,clearTimeout(W),e.signal.removeEventListener("abort",I),I(),T&&(!z||!_t(z)))try{z=await Te()}catch{z=void 0}try{if(!z||!_t(z)||z.pty?.cleanup!=="confirmed")ir("pty_cleanup_unconfirmed");let le=Oe(z);if(_.readyState===xn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);_.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await Ve("pty.stopped",le)}catch(le){ve??=le}_.terminate()}if(ve)throw ve;if(e.signal.aborted)ir("cancelled");if(!z)ir("pty_cleanup_unconfirmed");return{receipt:Oe(z)}}import{createHash as vi,randomUUID as An}from"crypto";import{spawnSync as $o}from"child_process";import{closeSync as jo,constants as Pn,fstatSync as ki,fsyncSync as Si,lstatSync as Lt,mkdirSync as Ei,mkdtempSync as Ko,openSync as Wo,readFileSync as Ri,readdirSync as Go,realpathSync as Nt,rmSync as In,unlinkSync as xi}from"fs";import{createConnection as Pi}from"net";import{dirname as Ai,join as tt,sep as Ti}from"path";import{tmpdir as Di}from"os";var Rr=new Map,Jr=new Map;function Ur(e,l){return vi("sha256").update(JSON.stringify([e,l])).digest("hex")}function mt(e){try{Ei(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Lt(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Nt(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function Ci(e){let l;try{l=Lt(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||Go(e).length>0}function hr(e){let l=Ur(e.root,e.runId),f=e.previousRuntimeDirectories?.find((I)=>Ci(tt(I,"jobs",l.slice(0,16))))??e.runtimeDirectory;mt(f);let _=tt(f,"jobs");mt(_);let w=tt(_,l.slice(0,16));if(e.maxScopes!==void 0){let I=Go(_);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||I.length>e.maxScopes||!I.includes(l.slice(0,16))&&I.length>=e.maxScopes)throw new r("process_journal_capacity","Managed process receipt capacity is full; preserve uncertain jobs and reconcile their existing receipts before starting more work.")}mt(w);let S=Ko(tt(qo(),"reason-j-"));try{return mt(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:tt(S,"control.sock"),disposeSocket:()=>In(S,{recursive:!0,force:!0})}}catch(I){throw In(S,{recursive:!0,force:!0}),I}}var Hi=60000,Bi=5000;function ji(e){if(process.platform==="win32")return Mi(e);let l=$o("ps",["-o","lstart=","-p",String(e)],{encoding:"utf8",timeout:2000,env:{...process.env,LC_ALL:"C",LANG:"C"}}),f=l.status===0?/^\w{3} (\w{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/.exec(l.stdout.trim()):null,_=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||_<0||_%3!==0)return null;let w=new Date(Number(f[6]),_/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function Mi(e){let l=$o(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:De()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function Jo(e,l={}){let f=tt(e.journalDirectory,"owner.lock"),_;try{_=Wo(f,Pn.O_RDONLY|Pn.O_NOFOLLOW)}catch{return null}try{let w=ki(_);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(Ri(_,"utf8"))}catch{}let I;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Hi)return null;I={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:T,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof T!=="number"||!Number.isSafeInteger(T))return null;if(!(l.exists??((z)=>{try{return process.kill(z,0),!0}catch(fe){return!(fe instanceof Error&&("code"in fe)&&fe.code==="ESRCH")}}))(F))I={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??ji)(F);if(z===null||z<=T+Bi)return null;I={reason:"pid_reused",executorLaunchId:re}}}let W=Lt(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;xi(f);let x=Wo(e.journalDirectory,Pn.O_RDONLY);try{Si(x)}finally{jo(x)}return I}catch{return null}finally{jo(_)}}function Vo(e){let l={...e,workspace:e.workspace&&Object.freeze({...e.workspace}),previewAuthority:e.previewAuthority&&Object.freeze({...e.previewAuthority,owner:Object.freeze({...e.previewAuthority.owner}),deniedPorts:new Set(e.previewAuthority.deniedPorts)})},f=Ur(l.root,l.runId);if(Rr.has(f)||l.operationId!==void 0&&Jr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let _={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)_.previews=Co({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>Rr.get(_.key)===_,identity:()=>{try{return ht(l)}catch{return null}},inspect:(w,S)=>{if(Rr.get(_.key)!==_)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return Yo(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(Rr.set(f,_),l.operationId!==void 0)Jr.set(l.operationId,_);return()=>{if(Rr.get(_.key)===_)Rr.delete(_.key);if(l.operationId!==void 0&&Jr.get(l.operationId)===_)Jr.delete(l.operationId);_.previews?.dispose();for(let w of _.terminals.values())w.abort()}}var Wi=5000,Fi=20;async function Ji(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!U(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=Jr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Wi;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(Jr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=ht(f.binding)}catch{}if(S&&S.generation===e.targetGeneration&&S.fenceId===e.fenceId)break;if(S&&S.generation>e.targetGeneration||Date.now()>=w)l("The executor did not adopt this take.");await new Promise((I)=>setTimeout(I,Fi))}if(Jr.get(e.operationId)!==f||Rr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let _=Ur(e.root,e.runId);if(f.key===_)return;if(Rr.has(_))l("The taking run already has a live Hands job supervisor.");Rr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=_,Rr.set(_,f)}function ot(e){let l="operationId"in e?Jr.get(e.operationId):Rr.get(Ur(e.root,e.runId)),f=l&&l.binding.root===e.root?l.binding:void 0;if(!f?.environment||f.expiresAtMs<=Date.now())throw new r("environment_unavailable","No live Hands supervisor owns this environment.");return f.environment.install(e.payload)}async function Zi(e){let l=Rr.get(Ur(e.root,e.runId));if(!l?.previews||!e.owner)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.open(e.payload,e.owner,e.signal)}async function Xi(e){let l=Rr.get(Ur(e.root,e.runId));if(!l?.previews||!e.owner||e.signal.aborted)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.close(e.payload,e.owner)}async function Yi(e){let l=Ur(e.root,e.runId),f=Rr.get(l),_=f?.binding,w=_?.runId,S=_?.previewAuthority,I=_?.environment,W=e.owner&&{...e.owner},x=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!_||!S||!I||!W||!x||!_.workspace)return M();let G=Object.freeze({..._.workspace}),F=ht(_),T=I.current(),re=()=>{if(Rr.get(l)!==f||W.organization_id!==S.owner.organization_id||W.user_id!==S.owner.user_id||W.device_id!==S.owner.device_id||e.deviceId!==S.owner.device_id||e.rootId!==S.rootId||O(e.workspace)!==O(G))M();let z=ht(_),fe=I.current();if(z.generation!==F.generation||z.fenceId!==F.fenceId||fe.run_id!==w||fe.device_id!==e.deviceId||fe.root_id!==e.rootId||fe.snapshot_id!==T.snapshot_id||fe.revision!==T.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||x.device_id!==e.deviceId||x.binding!==fe.binding.kind||x.target_revision!==fe.binding.target_revision||x.root_grant_revision!==fe.binding.root_grant_revision||x.target_generation!==F.generation||x.target_fence_id!==F.fenceId)M()};if(re(),new URL(e.session.relayUrl).origin!==S.relayOrigin||f.terminals.has(e.session.jobId)||f.terminals.size>=4)return M();let J=new AbortController;f.terminals.set(e.session.jobId,J);try{return await Bo({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(T.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:T.revision,snapshotId:T.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:T.binding.kind,targetRevision:T.binding.target_revision,rootGrantRevision:T.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>fr(F,Hr(JSON.stringify({...z,type:"job",version:2,generation:F.generation,id:An()})),fe)}})}finally{if(f.terminals.get(e.session.jobId)===J)f.terminals.delete(e.session.jobId)}}async function Qi(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=Rr.get(Ur(e.root,e.runId))?.binding;if(!l||l.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","No live Hands supervisor owns this Session and root.");return Yo(l,e.payload,e.signal)}var Ui=1e4,zi=20,$i=Se/2,Gi=Je/2,Vi=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function Yo(e,l,f){if(Object.keys(l).some((M)=>!["jobId","action","input","waitForExitMs"].includes(M)))throw new r("invalid_payload","Unexpected job control field.");let{waitForExitMs:_,...w}=l;if(_!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof _!=="number"||!Number.isSafeInteger(_)||_<1||_>Ui))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=ht(e);return fr(G,Hr(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},I=await S(w);if(_===void 0)return I;let W=Date.now()+_,x=I;while(x.ok&&["starting","running"].includes(x.job.state)&&x.job.output.length<$i&&Vi(x.job)<Gi&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(zi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;x=M}catch{break}}return x}function ht(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!U(l.generation)||!N(l.fenceId)||l.generation<e.generation||l.generation===e.generation&&l.fenceId!==e.fenceId)throw new r("hands_jobs_unavailable","The live Hands fencing identity could not be verified.");return e.generation=l.generation,e.fenceId=l.fenceId,{...e}}function fr(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((_,w)=>{let S=Pi(e.socketPath),I="",W=!1,x,M=(F,T)=>{if(W)return;if(W=!0,clearTimeout(x),f.removeEventListener("abort",G),S.destroy(),F)w(F);else _(T)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),x=setTimeout(()=>M(new r("hands_job_result_unknown","Job control timed out; inspect before retrying mutations.")),Math.min(1e4,Math.max(1,e.expiresAtMs-Date.now()))),S.on("error",()=>M(new r("hands_job_result_unknown","Hands job control connection failed."))),S.once("connect",()=>S.write(JSON.stringify({version:1,scopeId:e.scopeId,fenceId:e.fenceId,executorLaunchId:e.executorLaunchId,request:l})+`
3
3
  `)),S.on("data",(F)=>{if(I+=F,Buffer.byteLength(I)>Ze)M(new r("hands_job_result_unknown","Hands job result exceeded its bound."))}),S.once("end",()=>{if(Date.now()>=e.expiresAtMs){M(new r("hands_job_result_unknown","Hands authority expired before the result was acknowledged."));return}try{let F=zr(I.trim());if(F.id!==l.id||F.generation!==e.generation||F.ok&&F.job.jobId!==l.jobId)throw Error("identity");M(void 0,F)}catch{M(new r("hands_job_result_unknown","Hands job response identity or shape was invalid."))}}),S.once("close",()=>{if(!W)M(new r("hands_job_result_unknown","Hands job control closed before an acknowledged result."))})})}function Fo(e){let l=Nt(e.root),f=e.authority,_=Date.parse(e.leaseUntil),w=()=>{if(e.signal.throwIfAborted(),!Number.isFinite(_)||_<=Date.now())throw Error("local_device_gh_lease_expired")};if(w(),f.readOnly&&f.generation===null)return{root:l,readOnly:!0,signal:e.signal,deadlineMs:_,assertCurrent:w};let S=Ur(l,e.runId),I=Rr.get(S),W=I?.binding;if(!W?.environment||!W.workspace||W.localGithubConfinement!==!0)throw Error("local_device_gh_confinement_unavailable");let x=W.environment.current(),M=()=>{w();let F=W.environment.current(),T=ht(W);if(Rr.get(S)!==I||F.github_auth!=="local_gh"||F.run_id!==W.runId||f.runId!==e.runId||F.device_id!==f.deviceId||F.root_id!==f.rootId||String(F.binding.root_grant_revision)!==f.rootRevision||F.binding.target_generation!==f.generation||F.binding.target_fence_id!==f.fenceId||T.generation!==f.generation||T.fenceId!==f.fenceId||F.snapshot_id!==x.snapshot_id||F.revision!==x.revision)throw Error("local_device_gh_authority_changed")};M();let G=ie(l,W.workspace);return{root:G.boundary,signal:e.signal,deadlineMs:_,privateDirectory:Ai(W.environment.path),repoPath:G.path,readOnly:f.readOnly,forbiddenSecretValues:Object.values(x.variables),secretNames:(F)=>Object.entries(x.variables).filter(([,T])=>T.trim()===F.trim()).map(([T])=>`variable ${T}`),assertCurrent:M}}async function eo(e,l){let f=Pe.parse(e.request),_=oe.parse(e.authority);if(_.contributorRefresh&&f.kind==="read"&&_.readOnly)return l(Fo(e));let w=Boolean(_.contributorRefresh);if(w&&(_.merge||f.kind!=="pr_mutation"||f.mutation.action!=="edit"||typeof f.mutation.body!=="string"||f.mutation.title!==void 0||f.mutation.base!==void 0||_.readOnly||_.runId!==e.runId||_.repoFullName!==f.repoFullName))throw Error("local_device_gh_contributor_refresh_authority_invalid");if(f.kind!=="pr_merge"&&!w){if(_.merge)throw Error("local_device_gh_merge_authority_invalid");return l(Fo(e))}if(!w&&(!_.merge||_.readOnly||_.runId!==e.runId||_.repoFullName!==f.repoFullName||_.merge.source==="agent"&&(_.generation===null||_.fenceId===null)))throw Error("local_device_gh_merge_authority_invalid");let S=Nt(e.root),I=Lt(S),W=Date.parse(e.leaseUntil);if(!Number.isFinite(W)||W<=Date.now())throw Error("local_device_gh_lease_expired");let x=Nt(Di());if(x===S||x.startsWith(S+Ti))throw Error("local_device_gh_private_scope_unavailable");let M=Ko(tt(x,"reason-gh-merge-"));try{mt(M);let G=()=>{if(e.signal.throwIfAborted(),Date.now()>=W)throw Error("local_device_gh_lease_expired");let F=Lt(e.root);if(F.isSymbolicLink()||F.dev!==I.dev||F.ino!==I.ino||Nt(e.root)!==S)throw Error("local_device_gh_authority_changed");mt(M)};return G(),await l({root:S,readOnly:!1,privateDirectory:M,forbiddenSecretValues:[],signal:e.signal,deadlineMs:W,assertCurrent:G})}finally{In(M,{recursive:!0,force:!0})}}var Qo=43200000;function gt(e){return Number.isSafeInteger(e)&&Math.abs(e)<=8640000000000000?e:null}function Xo(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Zo(e,l){return Object.keys(e).length===l.length&&l.every((f)=>Object.hasOwn(e,f))}function to(e){if(!Xo(e)||!Zo(e,["version","outcome","clock_source","validation_now_ms","expiry_ms","remaining_ms","maximum_lifetime_ms","cli_artifact"])||e.version!==1||e.maximum_lifetime_ms!==43200000||typeof e.outcome!=="string"||!["accepted","parse","noncanonical","expired","over_cap"].includes(e.outcome)||typeof e.clock_source!=="string"||!["date_now","injected"].includes(e.clock_source))return null;for(let _ of["validation_now_ms","expiry_ms"]){let w=e[_];if(w!==null&&(typeof w!=="number"||gt(w)===null))return null}if(e.remaining_ms!==null&&(typeof e.remaining_ms!=="number"||!Number.isSafeInteger(e.remaining_ms)))return null;let l=typeof e.expiry_ms==="number"&&typeof e.validation_now_ms==="number"?e.expiry_ms-e.validation_now_ms:null;if(e.remaining_ms!==(l!==null&&Number.isSafeInteger(l)?l:null))return null;if(e.outcome==="parse"&&e.expiry_ms!==null)return null;if(e.outcome!=="parse"&&e.expiry_ms===null)return null;if(e.outcome==="expired"&&!(typeof l==="number"&&l<=0))return null;if(e.outcome==="over_cap"&&!(typeof l==="number"&&l>43200000))return null;if(e.outcome==="accepted"&&!(typeof l==="number"&&l>0&&l<=43200000))return null;let f=e.cli_artifact;if(!Xo(f)||!Zo(f,["kind","status","sha256","observed_at_ms"])||f.observed_at_ms!==null&&(typeof f.observed_at_ms!=="number"||gt(f.observed_at_ms)===null))return null;if(f.kind==="entrypoint_file"){if(f.status!=="observed"||typeof f.sha256!=="string"||!/^[a-f0-9]{64}$/.test(f.sha256)||f.observed_at_ms===null)return null}else if(f.kind!=="unavailable"||f.sha256!==null||typeof f.status!=="string"||!["unsupported_entrypoint","read_failed","file_changed","size_limit","time_limit"].includes(f.status))return null;return e}var Tn=c({kind:s(["workspace_source","mcp_control"]),target_revision:o().int().nonnegative(),root_grant_revision:o().int().positive()}),es=new RegExp(at.tokenPattern),qi=c({token_url:Et().max(2048),request_token:t().min(1).max(8192).regex(es),aws_credentials_url:Et().max(2048).nullable()});function rs(e,l){let f=(_,w)=>{try{let S=new URL(_);return S.origin===new URL(l).origin&&S.pathname===w&&!S.username&&!S.password&&!S.search&&!S.hash}catch{return!1}};if(!es.test(e.request_token)||!f(e.token_url,at.tokenPath)||e.aws_credentials_url!==null&&!f(e.aws_credentials_url,at.awsPath))return null;return{REASON_OIDC_TOKEN_URL:e.token_url,REASON_OIDC_REQUEST_TOKEN:e.request_token,...e.aws_credentials_url!==null?{AWS_CONTAINER_CREDENTIALS_FULL_URI:e.aws_credentials_url,AWS_CONTAINER_AUTHORIZATION_TOKEN:e.request_token}:{}}}function ts(e){return new TextEncoder().encode(e).byteLength}function ea(e){return ts(JSON.stringify(e)+`
4
4
  `)}var mr=c({version:n(1),snapshot_id:k(),revision:o().int().positive(),run_id:t().min(1).max(160),device_id:k(),root_id:k(),binding:Tn.extend({target_generation:o().int().positive(),target_fence_id:k()}),expires_at:y.datetime({offset:!0}),variables:ee(t().max(128).regex(It),t().refine((e)=>!e.includes("\x00")&&ts(e)<=V.valueBytes)).refine((e)=>Object.keys(e).length<=V.variables),github_auth:n("local_gh").optional(),git:c({base_url:Et().max(2048),token:t().min(1).max(4096).regex(/^[A-Za-z0-9._~-]+$/),expires_at:y.datetime({offset:!0})}).nullable(),cloud_access:qi.optional()}).refine((e)=>e.github_auth!=="local_gh"||e.git===null,"conflicting git authority").refine((e)=>ea(e)<=V.snapshotBytes,"snapshot too large");import{spawn as ra}from"child_process";import{basename as ta,isAbsolute as Eu}from"path";var na=0,ns=120000,os=15000,oa=65536;function Dn(e=process.execPath,l=process.argv[1]){let f=ta(e),_=(f.startsWith("bun")||f.startsWith("node"))&&typeof l==="string"&&l.length>0;return{command:e,prefix:_?[l]:[]}}function ro(e={}){let{command:l,prefix:f}=Dn(e.executablePath,e.sourceEntrypoint),_=e.spawnProcess??ra,w=e.now??Date.now,S=null,I=0,W=!1,x=(G)=>{try{G.kill("SIGKILL")}catch{}},M=()=>{if(W)return;if(S&&w()-I<ns-os)return;if(S){let F=S;S=null,x(F)}let G;try{G=_(l,[...f,"__device","__hands-worker","--handoff-fd",String(na)],{cwd:"/",env:{PATH:process.env.PATH??"/usr/local/bin:/usr/bin:/bin"},shell:!1,stdio:["pipe","ignore","pipe"]})}catch{return}S=G,I=w(),G.on("error",()=>{if(S===G)S=null}),G.once("exit",(F,T)=>{if(S!==G)return;S=null,e.log?.("hands.worker_prespawn_exited",{exit_code:F,exit_signal:T})}),e.log?.("hands.worker_prespawned",{pid:G.pid??null})};return{arm:M,take(G){let F=S;if(!F||W)return null;let T=G.args.at(-1),re=G.options.env,J=G.options.cwd,z=[...f,"__device","__hands-worker","--config"];if(G.command!==l||G.args.length!==z.length+1||z.some((Oe,$e)=>G.args[$e]!==Oe)||typeof T!=="string"||!re||typeof J!=="string"||G.options.shell||JSON.stringify(G.options.stdio)!==JSON.stringify(["ignore","ignore","pipe"]))return null;S=null;let fe=F.stdin,ve={configPath:T,cwd:J,env:Object.fromEntries(Object.entries(re).filter((Oe)=>typeof Oe[1]==="string"))},be=JSON.stringify(ve);if(F.exitCode!==null||F.signalCode!==null||!fe||fe.destroyed||w()-I>=ns-os||Buffer.byteLength(be,"utf8")>oa)return x(F),null;return fe.on("error",()=>{return}),fe.end(be),F.once("exit",()=>{M()}),e.log?.("hands.worker_prespawn_taken",{pid:F.pid??null}),F},adopt(G){G.once("exit",()=>{M()})},close(){if(W=!0,S)x(S);S=null}}}import{accessSync as la,constants as ua,statSync as fa}from"fs";import{homedir as pa,tmpdir as _a,userInfo as ma}from"os";import{delimiter as ha,win32 as ga}from"path";var sa=new Set(["ALL_PROXY","BUN_BE_BUN","BUN_OPTIONS","CURL_CA_BUNDLE","GIT_SSL_CAINFO","GRPC_DEFAULT_SSL_ROOTS_FILE_PATH","HTTPS_PROXY","HTTP_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED","REQUESTS_CA_BUNDLE","SSLKEYLOGFILE","SSL_CERT_DIR","SSL_CERT_FILE","all_proxy","http_proxy","https_proxy","no_proxy"]);var ia=["BUN_CONFIG_","BUN_INSPECT","DYLD_","NODE_DEBUG"],aa=new Set(["BUN_INSTALL"]);var ca=/^--(?:max-old-space-size|max-semi-space-size|stack-size)=\d{1,9}$/;function da(e){return(e??"").split(/\s+/).filter(Boolean).every((l)=>ca.test(l.replaceAll("_","-")))}function ss(e){return Object.keys(e).filter((l)=>sa.has(l)&&!(l==="NODE_OPTIONS"&&da(e[l]))||ia.some((f)=>l.startsWith(f))||l.startsWith("BUN_")&&!aa.has(l)).sort()}var ba=new Set(["HOME","PATH","PWD","OLDPWD","SHLVL","_","TMPDIR","TMP","TEMP","SHELL","BASH_ENV","ENV","ZDOTDIR","PROMPT_COMMAND","IFS","CDPATH","GLOBIGNORE","SHELLOPTS","BASHOPTS","NODE_PATH"]),wa=/^(?:ARA_|REASON_|PI_|GIT_|GH_|GITHUB_|LD_|DYLD_|BUN_|BASH_FUNC_|SSH_)/,ya=/TOKEN|SECRET|PASSW|PASSPHRASE|CREDENTIAL|API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|AUTH/i,va=/^[A-Za-z_][A-Za-z0-9_]*$/;function gr(e=process.env){let l=(w)=>{if(!(process.platform==="win32"?ga.isAbsolute(w):w.startsWith("/"))||/[\0\r\n]/.test(w)||w.length>32768)throw Error("invalid_host_execution_environment");return w};if(e.PATH!==void 0&&(/[\0\r\n]/.test(e.PATH)||e.PATH.length>32768))throw Error("invalid_host_execution_environment");let f=new Set(ss(e)),_=Object.fromEntries(Object.entries(e).filter((w)=>{let[S,I]=w;return typeof I==="string"&&I.length<=32768&&!I.includes("\x00")&&S.length<=128&&va.test(S)&&!f.has(S)&&!ba.has(S)&&!wa.test(S)&&!ya.test(S)}).sort(([w],[S])=>w.localeCompare(S)).slice(0,512));return{home:l(e.HOME||(process.platform==="win32"?e.USERPROFILE:void 0)||pa()),path:((w)=>process.platform==="win32"?Sn(w):w)(xr(e.PATH??"").join(ha)||Er),temporaryDirectory:l(e.TMPDIR||e.TMP||e.TEMP||_a()),variables:_}}function _r(e=process.env,l=()=>ma().shell){if(process.platform==="win32")return se();let f=(w)=>{if(!w||!/^\/[A-Za-z0-9._/-]*\/(?:bash|zsh)$/.test(w))return!1;try{return la(w,ua.X_OK),fa(w).isFile()}catch{return!1}};if(f(e.SHELL))return e.SHELL;let _;try{_=l()}catch{_=void 0}return f(_)?_:"/bin/zsh"}import{readdir as ka}from"fs/promises";var Sa=15000;function gn(e){let l=e instanceof Error&&"code"in e?e.code:null;return l==="EPERM"||l==="EACCES"}function _n(e){return new r("folder_access_denied",`macOS blocked Reason from opening ${e}. Allow Reason in System Settings \u203A Privacy & Security \u203A Files and Folders `+"(or Full Disk Access), then try again.")}async function is(e,{timeoutMs:l=Sa,open:f=(_)=>ka(_)}={}){let _,w=new Promise((S)=>{_=setTimeout(()=>S("pending"),l)});try{if(await Promise.race([f(e).then(()=>"open"),w])==="pending")throw new r("folder_access_pending",`macOS is asking whether Reason may open ${e}. Answer the prompt on this Mac, then try again.`)}catch(S){if(gn(S))throw _n(e);if(S instanceof r)throw S}finally{clearTimeout(_)}}import{chmodSync as rc,closeSync as tc,constants as Un,fstatSync as nc,lstatSync as Rs,openSync as oc,readSync as sc,realpathSync as zn,unlinkSync as ic}from"fs";import{lookup as ac}from"dns/promises";import{createRequire as cc}from"module";import{request as dc}from"http";import{request as lc}from"https";import it from"net";import{platform as As}from"os";import{basename as uc,extname as fc,isAbsolute as Os,relative as $n,resolve as yt,sep as Kn}from"path";var as=String.raw`
5
5
  async (roots) => {
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var ar="--vm-hands-op-runner-kind=person",cr="--vm-hands-op-runner-kind=surface",kt="--vm-hands-surface-uid=",Ct="--vm-hands-surface-dir=",At=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-a5qykmcn.js"),import("./local-display-session-fvmwgtff.js"),import("./local-display-video-e3z5qc66.js"),import("./worker-preview-readiness-y992mb4a.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function ls(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-w6wec7d9.js"),import("./local-pty-session-h88gf14w.js"),import("./desktop-account-c35292yy.js"),import("./worker-sandbox-y62j1dkh.js")]);y();let i=process.argv.includes(ar),s=process.argv.includes(cr),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(kt))?.slice(kt.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-rmksw0hz.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-rmksw0hz.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(At.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(Ct))?.slice(Ct.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
2
+ import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var ar="--vm-hands-op-runner-kind=person",cr="--vm-hands-op-runner-kind=surface",kt="--vm-hands-surface-uid=",Ct="--vm-hands-surface-dir=",At=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-95hgk32n.js"),import("./local-display-session-91kgeshv.js"),import("./local-display-video-gxa2vym0.js"),import("./worker-preview-readiness-y992mb4a.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function ls(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-nrh1by3j.js"),import("./local-pty-session-h88gf14w.js"),import("./desktop-account-c35292yy.js"),import("./worker-sandbox-y62j1dkh.js")]);y();let i=process.argv.includes(ar),s=process.argv.includes(cr),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(kt))?.slice(kt.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-5msmf31x.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-5msmf31x.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(At.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(Ct))?.slice(Ct.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
3
3
  export{ar,cr,kt,Ct,At,ls};