sandforge 1.81.0 → 1.83.0

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 (240) hide show
  1. package/README.md +48 -0
  2. package/bin/sandforge-users.mjs +12 -0
  3. package/lib/{chunk-J6G23RUI.mjs → chunk-262TP6UU.mjs} +1 -1
  4. package/lib/{chunk-NWVVCZUK.mjs → chunk-27BBEGUD.mjs} +1 -1
  5. package/lib/{chunk-Y5ZCPY36.mjs → chunk-2ADSD5WK.mjs} +1 -1
  6. package/lib/{chunk-55LQD3Y3.mjs → chunk-2GSMHGIV.mjs} +1 -1
  7. package/lib/chunk-2K5BYZQM.mjs +8 -0
  8. package/lib/{chunk-GK7VEYFM.mjs → chunk-2KTGDYUH.mjs} +1 -1
  9. package/lib/{chunk-T3PLRQ2T.mjs → chunk-2N73W63D.mjs} +1 -1
  10. package/lib/{chunk-7PK5QDQI.mjs → chunk-2R6GFNKF.mjs} +1 -1
  11. package/lib/{chunk-2OIRJEYE.mjs → chunk-2WMKJVD2.mjs} +1 -1
  12. package/lib/{chunk-D62KWDDT.mjs → chunk-36Y225OM.mjs} +1 -1
  13. package/lib/{chunk-HYOOJVR6.mjs → chunk-3CM7LAPE.mjs} +1 -1
  14. package/lib/{chunk-OIIL4NVI.mjs → chunk-3OVTKRS4.mjs} +1 -1
  15. package/lib/{chunk-UT27HXE7.mjs → chunk-3V4YH5KO.mjs} +1 -1
  16. package/lib/{chunk-OZNLOV4U.mjs → chunk-446GBKAC.mjs} +1 -1
  17. package/lib/{chunk-SQGP46QS.mjs → chunk-4GCYGQXD.mjs} +1 -1
  18. package/lib/{chunk-2NAIUKVL.mjs → chunk-4V3QO7HF.mjs} +1 -1
  19. package/lib/{chunk-GWRKS3AL.mjs → chunk-4X5D3MSV.mjs} +1 -1
  20. package/lib/{chunk-KGYXLSQ5.mjs → chunk-5OGNK3JP.mjs} +1 -1
  21. package/lib/{chunk-D7P7DTWL.mjs → chunk-6KOUYHEY.mjs} +1 -1
  22. package/lib/chunk-6QSHWIZI.mjs +48 -0
  23. package/lib/chunk-6VOQFISN.mjs +7 -0
  24. package/lib/{chunk-742SSN7I.mjs → chunk-6YC2ELCU.mjs} +1 -1
  25. package/lib/chunk-77IVKH7R.mjs +7 -0
  26. package/lib/{chunk-KNIRA333.mjs → chunk-77MZRBWX.mjs} +1 -1
  27. package/lib/{chunk-ZUA5BNAO.mjs → chunk-7BQMBXKX.mjs} +1 -1
  28. package/lib/{chunk-OQQHNYR7.mjs → chunk-7DPHZWA4.mjs} +2 -2
  29. package/lib/chunk-7V2UYZ6S.mjs +7 -0
  30. package/lib/chunk-7WSQ65WG.mjs +9 -0
  31. package/lib/{chunk-HVC5CYIB.mjs → chunk-7ZBDACVG.mjs} +1 -1
  32. package/lib/chunk-A32ISQ6M.mjs +28 -0
  33. package/lib/{chunk-XC2QKQT5.mjs → chunk-AG24QMSY.mjs} +1 -1
  34. package/lib/{chunk-K77NR3UK.mjs → chunk-AHUGG3WU.mjs} +1 -1
  35. package/lib/{chunk-K55LH4ZQ.mjs → chunk-ALBY5SOH.mjs} +1 -1
  36. package/lib/chunk-AXFD2OH6.mjs +7 -0
  37. package/lib/{chunk-YCSFP6ER.mjs → chunk-BH76USTQ.mjs} +1 -1
  38. package/lib/chunk-BNKT3R3F.mjs +7 -0
  39. package/lib/{chunk-YIGFYZQY.mjs → chunk-BPHTA6KP.mjs} +1 -1
  40. package/lib/{chunk-MNITSYI2.mjs → chunk-BT43WSOS.mjs} +1 -1
  41. package/lib/{chunk-ZWZXQTAK.mjs → chunk-BVZ5H3N4.mjs} +14 -14
  42. package/lib/{chunk-43K2C6H2.mjs → chunk-C6RKM4BB.mjs} +1 -1
  43. package/lib/{chunk-C4YGSK6W.mjs → chunk-CDWZGQAJ.mjs} +1 -1
  44. package/lib/chunk-CGZGL6VT.mjs +7 -0
  45. package/lib/{chunk-KE2PGD6C.mjs → chunk-CN5HGFG4.mjs} +1 -1
  46. package/lib/chunk-CQAFVEKP.mjs +13 -0
  47. package/lib/{chunk-XIZ5LMQM.mjs → chunk-CTPLYUXA.mjs} +1 -1
  48. package/lib/chunk-CXKZ6TYV.mjs +9 -0
  49. package/lib/{chunk-DHIW4IO5.mjs → chunk-D6JT4PAB.mjs} +1 -1
  50. package/lib/{chunk-AELFEK3G.mjs → chunk-D7XUNWWU.mjs} +1 -1
  51. package/lib/{chunk-GR3NGDVM.mjs → chunk-DB5RVDC5.mjs} +1 -1
  52. package/lib/{chunk-MO3N5XVV.mjs → chunk-DIGUC7S4.mjs} +2 -2
  53. package/lib/{chunk-2OZG6GRW.mjs → chunk-DKDKCGXV.mjs} +1 -1
  54. package/lib/chunk-DMT5SCO3.mjs +7 -0
  55. package/lib/chunk-DNQKVCUV.mjs +475 -0
  56. package/lib/{chunk-MAHZMPMZ.mjs → chunk-DSR2MSBH.mjs} +1 -1
  57. package/lib/{chunk-O6ADMP36.mjs → chunk-E3RQ575Y.mjs} +1 -1
  58. package/lib/{chunk-ETT5GP4P.mjs → chunk-EOQON3E5.mjs} +1 -1
  59. package/lib/{chunk-TKQQVB2D.mjs → chunk-ETNQHIDI.mjs} +1 -1
  60. package/lib/chunk-F5SBGJWW.mjs +7 -0
  61. package/lib/chunk-FBXH4VRQ.mjs +7 -0
  62. package/lib/chunk-FKCIGJOI.mjs +15 -0
  63. package/lib/{chunk-OVOLG3AL.mjs → chunk-FVLFO2S6.mjs} +1 -1
  64. package/lib/{chunk-YOGMP72T.mjs → chunk-FYWNSMOZ.mjs} +1 -1
  65. package/lib/{chunk-DHGPDSXS.mjs → chunk-GEEWPTV5.mjs} +1 -1
  66. package/lib/{chunk-FSDO4DJA.mjs → chunk-GLN4PI5P.mjs} +1 -1
  67. package/lib/{chunk-PYUEHBA6.mjs → chunk-GT5ZKU6V.mjs} +1 -1
  68. package/lib/chunk-GTRU5AV5.mjs +7 -0
  69. package/lib/chunk-H33DVU3D.mjs +7 -0
  70. package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
  71. package/lib/{chunk-4L7FBOJS.mjs → chunk-HQZUQXDC.mjs} +1 -1
  72. package/lib/{chunk-VSU74RQ3.mjs → chunk-HVX2AFYW.mjs} +1 -1
  73. package/lib/chunk-I3ZO76LL.mjs +21 -0
  74. package/lib/{chunk-V4RKM4QZ.mjs → chunk-I5C4O3VA.mjs} +1 -1
  75. package/lib/{chunk-FSZTXLNW.mjs → chunk-IHGYJZZ2.mjs} +1 -1
  76. package/lib/chunk-ISA2NYJV.mjs +7 -0
  77. package/lib/{chunk-2IB7I3IQ.mjs → chunk-ISAUCWYK.mjs} +1 -1
  78. package/lib/{chunk-3B5H24ZG.mjs → chunk-ISOSTAJR.mjs} +1 -1
  79. package/lib/chunk-IXIY6Q4M.mjs +7 -0
  80. package/lib/{chunk-TPHXRHOA.mjs → chunk-J3TIHLWG.mjs} +1 -1
  81. package/lib/{chunk-TQM2XJ27.mjs → chunk-JAV6F6OA.mjs} +1 -1
  82. package/lib/chunk-JBWJ6UEZ.mjs +7 -0
  83. package/lib/{chunk-WM5JI4JI.mjs → chunk-JH4ZTVQN.mjs} +1 -1
  84. package/lib/{chunk-BZFIOZS3.mjs → chunk-JIPT5FUD.mjs} +1 -1
  85. package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
  86. package/lib/{chunk-67CC7RAE.mjs → chunk-JREKJO3D.mjs} +1 -1
  87. package/lib/{chunk-3AOKLIVE.mjs → chunk-JUOQUG7U.mjs} +1 -1
  88. package/lib/chunk-JYUMD357.mjs +7 -0
  89. package/lib/{chunk-56MPPWLA.mjs → chunk-K7G3W7XH.mjs} +1 -1
  90. package/lib/{chunk-OU5W7SCB.mjs → chunk-KKS2KFBT.mjs} +1 -1
  91. package/lib/{chunk-RKALOKAU.mjs → chunk-KWAVSZ2B.mjs} +1 -1
  92. package/lib/{chunk-WI4HYWV6.mjs → chunk-KXUOHACP.mjs} +1 -1
  93. package/lib/{chunk-GTIXJCGS.mjs → chunk-L3I6DAHX.mjs} +1 -1
  94. package/lib/{chunk-FLNLG43R.mjs → chunk-L47JCNP3.mjs} +1 -1
  95. package/lib/{chunk-5344TZBT.mjs → chunk-L4MSL4U7.mjs} +1 -1
  96. package/lib/chunk-L4RJX7DG.mjs +7 -0
  97. package/lib/chunk-L6CLN664.mjs +7 -0
  98. package/lib/chunk-LI2XNV7F.mjs +7 -0
  99. package/lib/chunk-LP2D3JJP.mjs +7 -0
  100. package/lib/{chunk-EH5YUA5W.mjs → chunk-LWES2KZE.mjs} +1 -1
  101. package/lib/{chunk-YJEXE6HZ.mjs → chunk-LYOGCIYD.mjs} +2 -2
  102. package/lib/{chunk-BNO5GIJ6.mjs → chunk-MJD6CPZZ.mjs} +1 -1
  103. package/lib/{chunk-33ZX3A56.mjs → chunk-MTM4KG3T.mjs} +1 -1
  104. package/lib/{chunk-E2YJVSX6.mjs → chunk-N2HYG3BL.mjs} +1 -1
  105. package/lib/chunk-N5UIE4IR.mjs +7 -0
  106. package/lib/{chunk-R6TF26V4.mjs → chunk-NDFFIJL5.mjs} +1 -1
  107. package/lib/{chunk-FDGFUEK3.mjs → chunk-NFEBX75O.mjs} +1 -1
  108. package/lib/{chunk-QXLZINZB.mjs → chunk-NNV7IGM7.mjs} +1 -1
  109. package/lib/{chunk-OXKZ4Y3B.mjs → chunk-NS6ONPWL.mjs} +1 -1
  110. package/lib/{chunk-OEHVAJAB.mjs → chunk-O7GCCRPW.mjs} +1 -1
  111. package/lib/chunk-OO24ZYYJ.mjs +7 -0
  112. package/lib/chunk-OOIDCHBQ.mjs +9 -0
  113. package/lib/{chunk-MWLFFVQV.mjs → chunk-OS5GE52G.mjs} +1 -1
  114. package/lib/chunk-OS6HFJ7L.mjs +7 -0
  115. package/lib/{chunk-HYBH5PFM.mjs → chunk-OTJH6AEA.mjs} +1 -1
  116. package/lib/chunk-OUU47Y7A.mjs +7 -0
  117. package/lib/{chunk-FTA5LOVX.mjs → chunk-P6WRYJN3.mjs} +1 -1
  118. package/lib/{chunk-DXOXLUZA.mjs → chunk-PDRXM5WN.mjs} +1 -1
  119. package/lib/chunk-PGRY365W.mjs +7 -0
  120. package/lib/chunk-Q4PPI3KG.mjs +7 -0
  121. package/lib/chunk-QFTF2PGS.mjs +21 -0
  122. package/lib/chunk-QKJXIY6L.mjs +7 -0
  123. package/lib/{chunk-DMBR24CK.mjs → chunk-QLRWU3MB.mjs} +1 -1
  124. package/lib/chunk-QO4MPHZD.mjs +7 -0
  125. package/lib/chunk-QP3JLFIO.mjs +7 -0
  126. package/lib/{chunk-UCHAZ4ZU.mjs → chunk-QQDZQCO2.mjs} +1 -1
  127. package/lib/chunk-QROPNEGY.mjs +14 -0
  128. package/lib/{chunk-6NADW3OI.mjs → chunk-QXB6U3ZP.mjs} +1 -1
  129. package/lib/chunk-R3OM3X4L.mjs +8 -0
  130. package/lib/chunk-R7GKMAT4.mjs +7 -0
  131. package/lib/{chunk-JU2XEKEO.mjs → chunk-RVCPQVKM.mjs} +1 -1
  132. package/lib/{chunk-WEZLXE34.mjs → chunk-RZKJQOOC.mjs} +1 -1
  133. package/lib/chunk-S4PRKKGC.mjs +8 -0
  134. package/lib/{chunk-NJ3EOEHS.mjs → chunk-SX6QWYCQ.mjs} +1 -1
  135. package/lib/{chunk-ONMBSACW.mjs → chunk-T36DZJPH.mjs} +1 -1
  136. package/lib/{chunk-AJPSGVMD.mjs → chunk-T7DDS4UQ.mjs} +1 -1
  137. package/lib/chunk-TCEXCHXR.mjs +7 -0
  138. package/lib/chunk-TMIESDE5.mjs +7 -0
  139. package/lib/chunk-TQJ5NPRC.mjs +7 -0
  140. package/lib/chunk-TUPZY2QJ.mjs +7 -0
  141. package/lib/{chunk-2Z54GB6X.mjs → chunk-U2CTKIPE.mjs} +1 -1
  142. package/lib/{chunk-DQR5NDMI.mjs → chunk-U4YFYSF3.mjs} +1 -1
  143. package/lib/{chunk-EOSEMFPU.mjs → chunk-UIR77ZJD.mjs} +1 -1
  144. package/lib/{chunk-UUSLTW5V.mjs → chunk-UOHZW2L4.mjs} +1 -1
  145. package/lib/chunk-UV74P4H2.mjs +7 -0
  146. package/lib/{chunk-CULAOP3U.mjs → chunk-VXZ5PTOM.mjs} +1 -1
  147. package/lib/{chunk-IBURU7T7.mjs → chunk-VZLJZEV2.mjs} +1 -1
  148. package/lib/chunk-W3BQGMTR.mjs +7 -0
  149. package/lib/{chunk-WWTXRWNZ.mjs → chunk-WABXKL4N.mjs} +1 -1
  150. package/lib/{chunk-E2OBAWSH.mjs → chunk-WAYQLQAD.mjs} +1 -1
  151. package/lib/{chunk-6CDIIFNX.mjs → chunk-WBELLGNE.mjs} +1 -1
  152. package/lib/{chunk-LO527YLT.mjs → chunk-WJAZ5LHL.mjs} +1 -1
  153. package/lib/{chunk-6IGEASOF.mjs → chunk-WXU6ZJIV.mjs} +1 -1
  154. package/lib/{chunk-YHIOS2PU.mjs → chunk-WZN36ACK.mjs} +1 -1
  155. package/lib/{chunk-AITNZWLB.mjs → chunk-X2XZQ434.mjs} +1 -1
  156. package/lib/chunk-X4HZD5U2.mjs +7 -0
  157. package/lib/chunk-X6XNTOGO.mjs +7 -0
  158. package/lib/{chunk-5VQNKDFU.mjs → chunk-XAMMIPZ4.mjs} +1 -1
  159. package/lib/{chunk-MHW6DV6T.mjs → chunk-XAUQXYPW.mjs} +1 -1
  160. package/lib/{chunk-5UT2ZBGF.mjs → chunk-XCJUNX63.mjs} +1 -1
  161. package/lib/chunk-XJICAOAQ.mjs +7 -0
  162. package/lib/{chunk-GYKNCYES.mjs → chunk-XKFHTBAB.mjs} +1 -1
  163. package/lib/{chunk-6SEDOIO3.mjs → chunk-XMQ5R6TC.mjs} +1 -1
  164. package/lib/chunk-XPXEQKLR.mjs +7 -0
  165. package/lib/{chunk-SW2NUKQL.mjs → chunk-Y7YUNRKK.mjs} +1 -1
  166. package/lib/{chunk-UIUPPEFB.mjs → chunk-YBZIDW6W.mjs} +1 -1
  167. package/lib/{chunk-X2ZVSQ54.mjs → chunk-YEVB7LVK.mjs} +1 -1
  168. package/lib/{chunk-EAFLDSQ2.mjs → chunk-Z3MGN42K.mjs} +1 -1
  169. package/lib/{chunk-MKNAZPOT.mjs → chunk-ZB5E7NHU.mjs} +1 -1
  170. package/lib/chunk-ZCOSME6P.mjs +7 -0
  171. package/lib/{chunk-KRNFVAGC.mjs → chunk-ZOSESZ22.mjs} +1 -1
  172. package/lib/chunk-ZTHC42X6.mjs +7 -0
  173. package/lib/{chunk-XEB6HZ34.mjs → chunk-ZXOUWHYE.mjs} +1 -1
  174. package/lib/sandforge-autopilot.mjs +1 -1
  175. package/lib/sandforge-backup.mjs +1 -1
  176. package/lib/sandforge-checkpoint.mjs +1 -1
  177. package/lib/sandforge-cleanup.mjs +1 -1
  178. package/lib/sandforge-clone.mjs +1 -1
  179. package/lib/sandforge-compare.mjs +1 -1
  180. package/lib/sandforge-dataops.mjs +1 -1
  181. package/lib/sandforge-empty.mjs +4 -4
  182. package/lib/sandforge-env.mjs +184 -139
  183. package/lib/sandforge-frozen.mjs +1 -1
  184. package/lib/sandforge-mcp.mjs +14 -14
  185. package/lib/sandforge-monitor.mjs +1 -1
  186. package/lib/sandforge-pipeline.mjs +1 -1
  187. package/lib/sandforge-seed.mjs +1 -1
  188. package/lib/sandforge-sync.mjs +1 -1
  189. package/lib/sandforge-users.mjs +155 -0
  190. package/lib/sandforge.mjs +1 -22
  191. package/lib/sf/sandforge/autopilot.mjs +20 -0
  192. package/lib/sf/sandforge/backup.mjs +20 -0
  193. package/lib/sf/sandforge/checkpoint.mjs +20 -0
  194. package/lib/sf/sandforge/cleanup.mjs +20 -0
  195. package/lib/sf/sandforge/clone.mjs +20 -0
  196. package/lib/sf/sandforge/compare.mjs +20 -0
  197. package/lib/sf/sandforge/dataops.mjs +20 -0
  198. package/lib/sf/sandforge/empty.mjs +20 -0
  199. package/lib/sf/sandforge/env.mjs +20 -0
  200. package/lib/sf/sandforge/frozen.mjs +20 -0
  201. package/lib/sf/sandforge/hardis-commands.mjs +20 -0
  202. package/lib/sf/sandforge/index.mjs +20 -0
  203. package/lib/sf/sandforge/mcp.mjs +20 -0
  204. package/lib/sf/sandforge/monitor.mjs +20 -0
  205. package/lib/sf/sandforge/pipeline.mjs +20 -0
  206. package/lib/sf/sandforge/seed.mjs +20 -0
  207. package/lib/sf/sandforge/sync.mjs +20 -0
  208. package/lib/sf/sandforge/users.mjs +20 -0
  209. package/lib/sfHelpHook.mjs +7 -0
  210. package/lib/sfPlugin.mjs +11 -0
  211. package/oclif.manifest.json +1 -0
  212. package/package.json +17 -3
  213. package/lib/chunk-2ZMGVBLW.mjs +0 -7
  214. package/lib/chunk-5C5XEVZN.mjs +0 -11
  215. package/lib/chunk-5CKWGZX4.mjs +0 -9
  216. package/lib/chunk-5ZKCLBTN.mjs +0 -474
  217. package/lib/chunk-7DALDJMO.mjs +0 -7
  218. package/lib/chunk-CAFUNR6D.mjs +0 -7
  219. package/lib/chunk-DPYTG6DM.mjs +0 -48
  220. package/lib/chunk-G4VXPS3A.mjs +0 -7
  221. package/lib/chunk-GF247DA7.mjs +0 -7
  222. package/lib/chunk-IKGHRYCN.mjs +0 -7
  223. package/lib/chunk-IM2XA6JI.mjs +0 -7
  224. package/lib/chunk-K5HV4YRO.mjs +0 -7
  225. package/lib/chunk-KOQV4WXC.mjs +0 -8
  226. package/lib/chunk-N6HHNR6J.mjs +0 -7
  227. package/lib/chunk-N7J6NJQ6.mjs +0 -7
  228. package/lib/chunk-NWPQF5XR.mjs +0 -7
  229. package/lib/chunk-O7DAFE6M.mjs +0 -14
  230. package/lib/chunk-OMZJ37JI.mjs +0 -15
  231. package/lib/chunk-R2BJWO5N.mjs +0 -20
  232. package/lib/chunk-T26C576X.mjs +0 -9
  233. package/lib/chunk-T5VAULLQ.mjs +0 -7
  234. package/lib/chunk-V2QO6KOE.mjs +0 -19
  235. package/lib/chunk-V473C7LY.mjs +0 -7
  236. package/lib/chunk-W2AAGIZF.mjs +0 -7
  237. package/lib/chunk-WD47PGUS.mjs +0 -10
  238. package/lib/chunk-XC54KKKC.mjs +0 -7
  239. package/lib/chunk-XGKSSCW7.mjs +0 -7
  240. package/lib/chunk-ZWCRWF7E.mjs +0 -7
@@ -1,9 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a as De}from"./chunk-4TLYUZD5.mjs";import{a as be,b as Le,f as Ue}from"./chunk-SQGP46QS.mjs";import{a as $e}from"./chunk-PPGDAUEQ.mjs";import{a as je,b as He}from"./chunk-PC247GKX.mjs";import{a as de,b as Ne,c as Fe}from"./chunk-TUACWKIH.mjs";import{b as R}from"./chunk-CA5NAXSU.mjs";import{Ec as ae,Ed as Ce,Fd as ce,Gd as Ie,Jd as ue,Kd as Me,Ld as _e,Md as xe,Yb as ve,k as Pe}from"./chunk-DPYTG6DM.mjs";import{b as q,e as Oe,k as B,l as J,v as Re,z as Y}from"./chunk-WZQEK4WT.mjs";var Z=class e{static DEFAULT_MAX_PER_ORG=5;static DEFAULT_RECYCLE_INTERVAL=900*1e3;connections=new Map;config;cleanupTimer;recycleTimer;maxPerOrg;recycleIntervalMs;latencySamples=new Map;constructor(t,n){this.config={maxConnections:t?.maxConnections??10,keepAliveInterval:t?.keepAliveInterval??6e4,connectionTimeout:t?.connectionTimeout??3e4,idleTimeout:t?.idleTimeout??3e5},this.maxPerOrg=n?.maxPerOrg??e.DEFAULT_MAX_PER_ORG,this.recycleIntervalMs=n?.recycleIntervalMs??e.DEFAULT_RECYCLE_INTERVAL}acquire(t,n,s){let r=this.connections.get(t);if(r&&r.active)return r.lastUsedAt=Date.now(),r.accessToken=s,r;this.connections.size>=this.config.maxConnections&&this.evictOldest();let o={orgId:t,instanceUrl:n,accessToken:s,createdAt:Date.now(),lastUsedAt:Date.now(),active:!0};return this.connections.set(t,o),o}release(t){let n=this.connections.get(t);n&&(n.lastUsedAt=Date.now())}remove(t){return this.latencySamples.delete(t),this.connections.delete(t)}get(t){return this.connections.get(t)}get size(){return this.connections.size}getConfig(){return{...this.config}}getMaxPerOrg(){return this.maxPerOrg}recordLatency(t,n){if(!Number.isFinite(n)||n<0)return;let s=this.latencySamples.get(t);s||(s=[],this.latencySamples.set(t,s)),s.push(n),s.length>1e3&&s.splice(0,s.length-1e3)}getLatencyMetrics(t){let n=this.latencySamples.get(t);if(!n||n.length===0)return;let s=[...n].sort((u,f)=>u-f),r=s.reduce((u,f)=>u+f,0),o=Math.floor(s.length*.95),a=Math.floor(s.length*.99);return{min:s[0],max:s[s.length-1],avg:Math.round(r/s.length),p95:s[Math.min(o,s.length-1)],p99:s[Math.min(a,s.length-1)],sampleCount:s.length}}getAllLatencyMetrics(){let t=new Map;for(let n of this.latencySamples.keys()){let s=this.getLatencyMetrics(n);s&&t.set(n,s)}return t}cleanupIdle(){let t=Date.now(),n=0;for(let[s,r]of this.connections)t-r.lastUsedAt>this.config.idleTimeout&&(this.connections.delete(s),n++);return n}recycleStale(){let t=Date.now(),n=0;for(let[s,r]of this.connections)t-r.createdAt>this.recycleIntervalMs&&(r.active=!1,this.connections.delete(s),n++);return n}startCleanup(){this.stopCleanup(),this.cleanupTimer=setInterval(()=>this.cleanupIdle(),this.config.keepAliveInterval)}stopCleanup(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0)}startRecycling(){this.stopRecycling(),this.recycleTimer=setInterval(()=>this.recycleStale(),this.recycleIntervalMs)}stopRecycling(){this.recycleTimer&&(clearInterval(this.recycleTimer),this.recycleTimer=void 0)}evictOldest(){let t,n=1/0;for(let[s,r]of this.connections)r.lastUsedAt<n&&(n=r.lastUsedAt,t=s);t&&this.connections.delete(t)}dispose(){this.stopCleanup(),this.stopRecycling(),this.connections.clear(),this.latencySamples.clear()}};var K=class{state="closed";failureCount=0;lastFailureTime=0;halfOpenSuccesses=0;halfOpenInFlight=0;config;constructor(t){this.config={failureThreshold:t?.failureThreshold??5,resetTimeout:t?.resetTimeout??6e4,halfOpenRequests:t?.halfOpenRequests??1}}getState(){return this.state==="open"&&this.shouldTransitionToHalfOpen()&&(this.state="half_open",this.halfOpenSuccesses=0),this.state}canExecute(){let t=this.getState();return t==="closed"?!0:t==="half_open"?this.halfOpenInFlight<this.config.halfOpenRequests:!1}recordSuccess(){this.state==="half_open"?(this.halfOpenSuccesses++,this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1),this.halfOpenSuccesses>=this.config.halfOpenRequests&&this.reset()):this.failureCount=0}recordFailure(){this.failureCount++,this.lastFailureTime=Date.now(),this.state==="half_open"?this.trip():this.failureCount>=this.config.failureThreshold&&this.trip()}trip(){this.state="open",this.lastFailureTime=Date.now()}reset(){this.state="closed",this.failureCount=0,this.halfOpenSuccesses=0,this.halfOpenInFlight=0}getFailureCount(){return this.failureCount}acquirePermit(){return this.canExecute()?(this.getState()==="half_open"&&this.halfOpenInFlight++,!0):!1}releasePermit(){this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1)}getConfig(){return{...this.config}}shouldTransitionToHalfOpen(){return Date.now()-this.lastFailureTime>=this.config.resetTimeout}};var ze=0;function An(){return ze}async function le(e,t){let n=Ue(e);try{return await t()}finally{ze+=n()}}var L=class extends Error{constructor(n,s,r){super(`${n}: ${r}`);this.code=n;this.orgId=s;this.name="OrgConnectionError"}code;orgId};import{homedir as kt,userInfo as St}from"node:os";var Tt=[/^ELECTRON_.+$/,/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,/^SNAP(|_.*)$/,/^GDK_PIXBUF_.+$/],qe=["HTTP_PROXY","HTTPS_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED"];function We(e){return Tt.some(t=>t.test(e))}function fe(e=process.env){let t={};for(let[n,s]of Object.entries(e))We(n)||(t[n]=s);return t.NO_COLOR="1",t}function vn(e=process.env){let t=Object.keys(e).filter(f=>(e[f]??"")!==""),n=qe.filter(f=>t.some(d=>d.toUpperCase()===f)),s=t.filter(f=>/^(SF|SFDX)_/i.test(f)).sort(),r=t.filter(f=>We(f)),o=r.filter(f=>f.startsWith("ELECTRON_")).sort(),a=r.length-o.length,u=r.length===0?"none":[...o,...a>0?[`${a} VSCODE_ or other VS Code variables`]:[]].join(", ");return`set: ${n.length>0?n.join(", "):"none of "+qe.join(", ")}; SF_/SFDX_: ${s.length>0?s.join(", "):"none"}; not passed to sf, as a terminal does not get them: ${u}`}function At(){try{return St().username}catch{return process.env.USERNAME??process.env.USER??""}}function Be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(e,t=kt(),n=At()){let s=e;return t.length>3&&(s=s.replace(new RegExp(Be(t),"gi"),"~")),n.length>=2&&(s=s.replace(new RegExp(`(?<=[\\\\/])${Be(n)}(?=[\\\\/]|$)`,"gim"),"<user>")),s.replace(/00D\w{12,15}![\w.]+/g,"<token>").replace(/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,"<username>")}function Cn(e){return e.split(/\r?\n/).map(t=>t.trim()).find(t=>t.length>0)}function Ot(e,t){if(process.platform!=="win32")return e[0];let s=(Object.entries(t).find(([r])=>r.toUpperCase()==="PATHEXT")?.[1]??".COM;.EXE;.BAT;.CMD").split(";").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return e.find(r=>{let o=r.lastIndexOf(".");return o>Math.max(r.lastIndexOf("\\"),r.lastIndexOf("/"))&&s.includes(r.slice(o).toLowerCase())})}async function In(e=1e4){let{exec:t}=await import("child_process"),{promisify:n}=await import("util"),s=process.platform==="win32"?"where sf node":"which -a sf node",r=fe(),o,a;try{let h=await n(t)(s,{timeout:e,windowsHide:!0,env:r});o=String(h.stdout)}catch(h){let i=h;o=String(i.stdout??""),o.trim()===""&&(a=Je(i.message??String(h)))}let u=o.split(/\r?\n/).map(h=>h.trim()).filter(h=>h.length>0).map(h=>Je(h)),f=h=>u.filter(i=>new RegExp(`(^|[\\\\/])${h}(\\.[A-Za-z0-9]+)?$`,"i").test(i)),d=f("sf"),c=Ot(d,r);return{sf:d,node:f("node"),...c!==void 0?{runs:c}:{},...a?{failure:a}:{}}}function Q(e,t){let n=(e[t.toLowerCase()]??e[t.toUpperCase()]??"").trim();return n===""?void 0:n}function Rt(e,t){if(t===void 0)return!1;let n=e.hostname.toLowerCase(),s=e.port||(e.protocol==="https:"?"443":"80");return t.split(/[\s,]+/).filter(r=>r!=="").some(r=>{if(r==="*")return!0;let[,o="",a]=/^(.*?)(?::(\d+))?$/.exec(r.toLowerCase())??[];if(a!==void 0&&a!==s)return!1;let u=o.replace(/^\*?\.?/,"");return u!==""&&(n===u||n.endsWith(`.${u}`))})}function Ve(e,t=process.env){let n;try{n=new URL(e)}catch{return}let s=n.protocol==="https:"?Q(t,"https_proxy")??Q(t,"http_proxy"):Q(t,"http_proxy");if(s!==void 0)return Rt(n,Q(t,"no_proxy"))?void 0:s}var Pt="https://login.salesforce.com";async function F(e,t=process.env){let{jsforce:n,HttpProxyTransport:s}=await import("./chunk-L5FGY6YA.mjs"),r=Ve(e.instanceUrl??e.loginUrl??Pt,t),o=new n.Connection({...e,...r!==void 0?{httpProxy:r}:{}});return r===void 0&&(o._transport=new s("")),o}var vt=10*1024*1024,pe=3e4,Ge=pe+2e3,he=`sf did not answer within ${pe/1e3} s \u2014 check the Salesforce CLI`;function Xe(e){return e instanceof Error&&e.message===he}var ge=2e4;function te(e,t,n){let s,r=new Promise((o,a)=>{s=setTimeout(()=>a(new Error(n)),t)});return Promise.race([e,r]).finally(()=>clearTimeout(s))}var U=new Z,Ct=300*1e3,ee=new Map,It={failureThreshold:3,resetTimeout:3e4},Ye=new Map;function Jn(){return U}function Mt(e){let t=Ye.get(e);return t||(t=new K({...It}),Ye.set(e,t)),t}var Ze;var me="panel";function Wn(e){me=e}function _t(e,t=me){return t==="panel"?"Reconnect it on the Organizations page (Try Reconnect on its card).":`Sign in to it again with "sf org login web --alias ${e}" (in a CI job, "sf org login jwt" or "sf org login sfdx-url"), then run the command again, with its --resume if it stopped a run part way.`}function Ke(e=me){return e==="panel"?"Create a new one and import it.":'Create a new one ("sf org create scratch") and give its alias.'}function Qe(e,t){let n=t?.organization_id;if(!(!Ze||typeof n!="string"))try{Ze(e,{organizationId:n})}catch(s){De.warn("Identity observer threw",{orgId:e,error:R(s)})}}var xt="[REDACTED]";function et(e){return typeof e=="string"&&e.length>0&&!e.startsWith(xt)&&!/\s/.test(e)}async function $t(e){if(!/^[\w.@+-]+$/.test(e))throw new Error(`Invalid username format: "${e}"`);let{execFile:t,exec:n}=await import("child_process"),{promisify:s}=await import("util"),r={maxBuffer:vt,timeout:pe,windowsHide:!0,env:fe()},o=i=>te(s(t)("sf",i,r),Ge,he),a=i=>{let g=!1,m,k=new Promise((T,S)=>{m=n(i,r,(E,C)=>{g=!0,E?S(E):T({stdout:C})})});return te(k,Ge,he).catch(T=>{throw!g&&m?.pid!==void 0&&t("taskkill",["/pid",String(m.pid),"/T","/F"],{windowsHide:!0},()=>{}),T})},u=(i,g)=>process.platform==="win32"?a(i):o(g),f=(i,g)=>{let m=i.replace(/\[[0-9;]*m/g,""),k=m.search(/[{[]/);if(k===-1)throw new Error(`Failed to parse "${g}" output: no JSON found. Ensure Salesforce CLI (sf) is installed and the org is authenticated.`);return JSON.parse(m.slice(k)).result??{}},d;try{let{stdout:i}=await u(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),g=f(i,"sf org display");d=typeof g.instanceUrl=="string"?g.instanceUrl:void 0}catch(i){if(Xe(i))throw i;d=void 0}try{let{stdout:i}=await u(`sf org auth show-access-token -o "${e}" --json`,["org","auth","show-access-token","-o",e,"--json"]),g=f(i,"sf org auth show-access-token");if(et(g.accessToken))return{accessToken:g.accessToken,instanceUrl:d}}catch(i){if(Xe(i))throw i}let{stdout:c}=await u(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),h=f(c,"sf org display");if(!et(h.accessToken))throw new Error('Neither "sf org auth show-access-token" nor "sf org display" returned an access token. The org session may have expired \u2014 try re-authenticating with "sf org login".');return!d&&typeof h.instanceUrl=="string"&&(d=h.instanceUrl),{accessToken:h.accessToken,instanceUrl:d}}async function Vn(e,t){return F({instanceUrl:e.instanceUrl,accessToken:e.accessToken??void 0,version:e.version,callOptions:{client:t}})}async function Gn(e){return F({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:e.version})}async function Xn(e,t,n){let s=e,r=n.getOrg(e);if(!r)throw new Error(`Org not found: ${e}`);let o=await t.getCredentials(e);if(!o?.accessToken||!o.instanceUrl)throw new Error(`No credentials for org "${r.alias}" (${e}). Reconnect the org.`);let a=r.metadata.apiVersion||Pe.DEFAULT_API_VERSION,u=U.get(s),f=Date.now()-(ee.get(e)??0)<Ct;if(u&&u.active&&u.accessToken===o.accessToken&&f)return u.lastUsedAt=Date.now(),F({instanceUrl:u.instanceUrl,accessToken:u.accessToken,version:a});let d=await F({instanceUrl:o.instanceUrl,accessToken:o.accessToken,version:a}),c=Mt(e);if(!c.acquirePermit())throw new L("ORG_TEMPORARILY_UNREACHABLE",e,`"${r.alias}" failed several times in a row, so SandForge waits a moment before calling it again. Try again in a minute.`);let h=Date.now(),i=`identity check did not answer within ${ge/1e3} s`;try{let g=await le(d,()=>te(d.identity(),ge,i)),m=Date.now()-h;return c.recordSuccess(),U.acquire(s,o.instanceUrl,o.accessToken),U.recordLatency(s,m),ee.set(e,Date.now()),Qe(e,g),d}catch(g){let m=Date.now()-h;if(U.remove(s),ee.delete(e),$e(g))try{let S=await $t(r.username),E=S.instanceUrl??o.instanceUrl;if(S.accessToken===o.accessToken&&E===o.instanceUrl)throw new Error("sf CLI token store is stale too (same expired token) \u2014 re-authenticate the org");let C=await F({instanceUrl:E,accessToken:S.accessToken,version:a}),W=await le(C,()=>te(C.identity(),ge,i));return await t.saveOrg(r,{...o,accessToken:S.accessToken,instanceUrl:E}),c.recordSuccess(),U.acquire(s,E,S.accessToken),U.recordLatency(s,m),ee.set(e,Date.now()),Qe(e,W),C}catch(S){c.recordFailure();let E=R(S);n.updateStatus(e,"expired");let C=ae(r,new Date().toISOString().slice(0,10));throw C!==void 0?new L("SCRATCH_ORG_EXPIRED",e,`The scratch org "${r.alias}" expired on ${C}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${Ke()} (cause: ${E})`):new L("ORG_AUTH_EXPIRED",e,`The session with "${r.alias}" has expired and could not be renewed. ${_t(r.alias)} (cause: ${E})`)}c.recordFailure();let k=R(g),T=ae(r,new Date().toISOString().slice(0,10));throw T!==void 0?(n.updateStatus(e,"expired"),new L("SCRATCH_ORG_EXPIRED",e,`The scratch org "${r.alias}" expired on ${T}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${Ke()} (cause: ${k})`)):new Error(`Connection failed for "${r.alias}": ${k}`)}finally{c.releasePermit()}}import{randomUUID as bt}from"node:crypto";import{hostname as Lt,homedir as Ut,uptime as Dt}from"node:os";import{mkdir as Nt,readFile as ct,readdir as Ft,rename as ut,writeFile as jt}from"node:fs/promises";import{dirname as we,join as Ee}from"node:path";function tt(e){let t=e,n=typeof t?.errorCode=="string"?t.errorCode:typeof t?.name=="string"?t.name:void 0;return{success:!1,errors:[{...n?{statusCode:n}:{},message:R(e)}]}}function nt(e){return(Array.isArray(e)?e[0]:e)??{success:!1,errors:[{message:"the org answered nothing"}]}}function as(e){return{typeOrg:()=>be(e),query:async t=>({records:(await e.query(t)).records}),identity:async()=>{let t=await e.identity();return{user_id:t.user_id,organization_id:t.organization_id}},createAssignment:async t=>e.sobject("PermissionSetAssignment").create(t,{headers:ve()}).then(nt,tt),deleteAssignment:async t=>e.sobject("PermissionSetAssignment").destroy(t).then(nt,tt)}}var j=class extends Error{constructor(n){super(n.message);this.refusal=n;this.name="MuteRefusedError"}refusal;get code(){return this.refusal.code}};function Ht(e){return e instanceof j||e instanceof Error&&e.name==="MuteRefusedError"&&"refusal"in e}var zt=60,qt=5*6e4,Bt=3e4,Jt=6e4,Wt=200,Vt=448,Gt=384,oe=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,H=q().regex(oe),Xt=J({id:H,permissionSetId:H,permissionSet:q().min(1).max(255)}),Yt=J({runId:q().min(1).max(255),host:q().min(1).max(255),pid:Oe().int().nonnegative(),hostStartedAt:Y.datetime({offset:!0}),acquiredAt:Y.datetime({offset:!0}),endsAt:Y.datetime({offset:!0}),needs:B(H),assigning:B(H),created:B(Xt)}),dt=J({version:Re(1),organizationId:H,userId:H,leases:B(Yt)}),Zt=J(je),Kt=He(e=>{let t=Zt.safeParse(e);return t.success?t.data:void 0});function lt(e=process.env,t=Ut()){let n=e.SANDFORGE_MUTE_LEASES_DIR;return n!==void 0&&n.trim()!==""?n:Ee(t,".sandforge","mute-leases")}function Qt(e,t,n){if(!oe.test(t)||!oe.test(n))throw new Error("A mute lease is journaled under an org id and a user id.");return Ee(e,`${t.slice(0,15)}-${n.slice(0,15)}.json`)}var ft={host:Lt(),pid:de.pid,startedAt:de.startedAt},en=6e4,D=new Set;function gt(e,t,n){return`${e}
8
- ${t}
9
- ${n}`}function tn(e,t,n,s={}){let r=s.now?.()??Date.now();if(!(Date.parse(e.endsAt)>r)||e.assigning.length>0)return!1;if(e.host!==n.host)return!0;if(e.pid===n.pid&&e.hostStartedAt===n.startedAt)return D.has(gt(t,e.runId,e.acquiredAt));let o=s.bootedAt?.()??Date.now()-Dt()*1e3,a=Date.parse(e.hostStartedAt);return Number.isFinite(a)&&a<o-en?!1:(s.isAlive??Fe)(e.pid)}var nn=e=>new Promise(t=>setTimeout(t,e));function ne(e,t,n){let s=n?.code;return new Error(`The journal of the mute leases in ${we(e)} could not be ${t}${typeof s=="string"?` (${s})`:""}: the user SandForge runs as must read and write that folder, or SANDFORGE_MUTE_LEASES_DIR name another, the same for every run that mutes the org.`)}function sn(e,t){let n=Date.parse(e.acquiredAt);return{pid:e.pid,host:e.host,here:e.host===t.host,until:new Date((Number.isFinite(n)?n:Date.now())+Ne).toISOString()}}function ht(e){return"A run locks it only while it takes, renews or ends a lease of the same org and user, but "+(e.here?`a lock its process could not remove holds until that process has ended, ${e.until} at the latest.`:`a lock a process of another machine could not remove holds until ${e.until}.`)}function rn(e){return`nothing was assigned. ${ht(e)} Run again in a moment, or end process ${e.pid} and run again should none of its runs be muting this org.`}async function se(e,t,n,s,r=rn,o=Jt){let a=n.self??ft,u={self:a,...n.checks?{checks:n.checks}:{}},f=Date.now()+o;for(await Nt(we(e),{recursive:!0,mode:Vt}).catch(d=>{throw ne(e,"made",d)});;){let d;try{d=Kt.acquire(`${e}.lock`,c=>c,u)}catch(c){throw ne(e,"locked",c)}if("lock"in d)try{let c=await on(e,t).catch(i=>{throw ne(e,"read",i)});return await s(c,async i=>{let g=`${e}.${process.pid}-${bt()}.tmp`;try{await jt(g,JSON.stringify(i,null,2),{encoding:"utf8",mode:Gt}),await ut(g,e)}catch(m){throw ne(e,"written",m)}})}finally{d.lock.release()}if(Date.now()>f){let c=sn(d.busy,a);throw new j({code:"MUTE_FAILED",message:`The journal of the mute leases in ${we(e)} stayed locked for a minute by process ${c.pid} on ${c.host}: ${r(c)}`})}await nn(Wt)}}async function on(e,t){let n={version:1,...t,leases:[]},s;try{s=await ct(e,"utf8")}catch(r){if(r.code==="ENOENT")return n;throw r}try{let r=dt.safeParse(JSON.parse(s));if(r.success)return r.data}catch{}return await ut(e,`${e}.${Date.now()}.unreadable`).catch(()=>{}),n}var an=new Set(["ENTITY_IS_DELETED","INVALID_CROSS_REFERENCE_KEY","NOT_FOUND"]);async function re(e,t,n,s){let r=t.leases.filter(c=>c!==n&&s(c)),o=[...n.created],a=new Set,u=n.assigning[0];if(u!==void 0){let c=new Set(t.leases.flatMap(i=>i===n?[]:i.created.map(g=>g.id))),h=await e.query(`SELECT Id, PermissionSetId, PermissionSet.Name FROM PermissionSetAssignment WHERE AssigneeId = '${t.userId}' AND PermissionSetId IN ('${u}')`).then(i=>i.records).catch(()=>[]);for(let i of h){let g=typeof i.Id=="string"?i.Id:void 0,m=typeof i.PermissionSetId=="string"?i.PermissionSetId:void 0;if(!g||!m||c.has(g)||o.some(T=>T.id===g))continue;let k=i.PermissionSet;o.push({id:g,permissionSetId:m,permissionSet:typeof k?.Name=="string"?k.Name:m}),a.add(g)}}let f={removed:[],passed:[],left:[],found:[]};for(let c of o){let h=r.find(m=>m.needs.includes(c.permissionSetId));if(h){h.created.some(m=>m.id===c.id)||h.created.push(c),f.passed.push(c);continue}let i=await e.deleteAssignment(c.id),g=i.errors?.[0]?.statusCode??i.errors?.[0]?.errorCode;i.success||g!==void 0&&an.has(g)?(f.removed.push(c),a.has(c.id)&&f.found.push(c)):f.left.push({...c,why:i.errors?.[0]?.message??g??"the org refused the delete"})}let d=t.leases.indexOf(n);return f.left.length===0?t.leases.splice(d,1):t.leases[d]={...n,endsAt:new Date(0).toISOString(),needs:[],assigning:[],created:f.left.map(({id:c,permissionSetId:h,permissionSet:i})=>({id:c,permissionSetId:h,permissionSet:i}))},f}function N(e){return e.map(t=>t.permissionSet)}function st(e,t){let n=r=>N(r).join(", "),s=[];return e.removed.length>0&&s.push(`What this run had assigned was taken back: ${n(e.removed)}.`),e.passed.length>0&&s.push(`${n(e.passed)} stays assigned for another run that mutes this org as the same user${t?", which takes it back as it ends":""}.`),e.left.length>0&&s.push(`${e.left.map(r=>`${r.permissionSet} (${r.why})`).join(", ")} could not be taken back${t?": the next run that mutes this org takes it back":""}.`),s}function rt(e,t){return`The journal still names this run's lease: this process tries again while it runs, and releases the lease once the journal can be written; the next run that mutes this org from another process releases it at the latest once process ${e} has ended.`+(t?` Until it is released, and before ${t.until}, a run of another process that ends may leave what it holds of ${t.sets.join(", ")} assigned for that lease, which the release takes back.`:"")}function pt(e){let t=e.length===1?"it":"them";return`found assigned to the user the run writes as for a run whose process ended as it assigned ${t}; found by user and set, not by id: had an admin assigned ${t} to that user since, theirs went with ${t}`}async function cn(e,t,n){let s=[];for(let r of[...t.leases])n(r)||s.push(...(await re(e,t,r,n)).found);return s}async function un(e){let t;try{t=(await e.query("SELECT PermissionsAssignPermissionSets, PermissionsManageUsers FROM UserPermissionAccess")).records[0]}catch(n){return`the org would not say whether the user the run writes as may assign permission sets (${R(n)})`}if(!(t?.PermissionsAssignPermissionSets===!0||t?.PermissionsManageUsers===!0))return"the user the run writes as cannot assign permission sets (neither Assign Permission Sets nor Manage Users)"}function ot(e){let t=e.indexOf("__");return t>0&&!e.slice(t+2).includes("__")?{namespace:e.slice(0,t),developerName:e.slice(t+2)}:{namespace:"",developerName:e}}var it=/^[A-Za-z][A-Za-z0-9_]*$/;async function dn(e,t){let s=t.map(ot).filter(a=>it.test(a.developerName)&&(!a.namespace||it.test(a.namespace)));if(s.length===0)return new Map;let r=await e.query("SELECT Id, Name, NamespacePrefix FROM PermissionSet WHERE Name IN ("+[...new Set(s.map(a=>`'${a.developerName}'`))].join(", ")+")"),o=new Map;for(let a of t){let{namespace:u,developerName:f}=ot(a),d=r.records.find(c=>String(c.Name??"").toLowerCase()===f.toLowerCase()&&String(c.NamespacePrefix??"").toLowerCase()===u.toLowerCase());typeof d?.Id=="string"&&o.set(a,d.Id)}return o}async function at(e,t,n){if(n.length===0)return new Map;let s=await e.query(`SELECT Id, PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = '${t}' AND PermissionSetId IN (${n.map(o=>`'${o}'`).join(", ")})`),r=new Map;for(let o of s.records){let a=o.PermissionSetId,u=o.Id;typeof a=="string"&&typeof u=="string"&&r.set(a,u)}return r}function ye(e,t,n){return{state:t,assigned:[],held:[],permissions:ce(e),silenced:e.silenced.map(s=>({...s})),stillRan:e.stillRuns.map(s=>({...s})),...e.assign.length>0?{alsoLifted:(e.alsoLifts??[]).map(s=>({...s}))}:{},...e.liftsUnread?{liftsUnread:e.liftsUnread.map(s=>({...s}))}:{},...n?{reason:n}:{}}}var mt="nothing found can be muted: no flow, process or workflow rule the run fires has a bypass a permission set of the target holds; the run goes on as without the option";async function ln(e,t,n={}){let s,r;try{let d=await e.typeOrg();s=Le(d),r=d.id}catch(d){return{refused:{code:"MUTE_PRODUCTION",message:`The target did not say what org it is (${R(d)}), and its automation is muted on no org that cannot be told from a production one. Nothing was assigned.`}}}if(s)return{refused:{code:"MUTE_PRODUCTION",message:"The target is a production org: its automation is never muted there, whatever the setting says. Nothing was assigned; run without the option."}};let{plan:o,automation:a,planned:u}=hn(t,n.writes);if(o.assign.length===0)return{plan:o,automation:t,planned:u,acquire:async()=>({outcome:u,release:async()=>u})};let f=await un(e);return f!==void 0?{refused:{code:"MUTE_NO_RIGHT",message:`The target's automation cannot be muted: ${f}. Nothing was assigned: run it without muting the target's automation, or have that user given Assign Permission Sets.`}}:(wt.set(o,await gn(n.dir??lt(),r)),{plan:o,automation:a,planned:u,acquire:d=>pn(e,o,d,n)})}var wt=new WeakMap,fn=/^[A-Za-z0-9]{15}-[A-Za-z0-9]{15}\.json$/;async function gn(e,t){if(!oe.test(t))return 0;let n=`${t.slice(0,15)}-`,s;try{s=await Ft(e)}catch{return 0}let r=0;for(let o of s)if(!(!o.startsWith(n)||!fn.test(o)))try{let a=dt.safeParse(JSON.parse(await ct(Ee(e,o),"utf8")));if(!a.success)continue;for(let u of a.data.leases)r+=(u.assigning.length>0?1:0)+u.created.length}catch{}return r}function hn(e,t){let n=Ce(e,t);return n.assign.length===0?{plan:n,automation:e,planned:ye(n,"nothing",mt)}:{plan:n,automation:Ie(e,ce(n)),planned:ye(n,"planned")}}async function pn(e,t,n,s={}){let r=s.self??ft,o=()=>s.checks?.now?.()??Date.now(),a=s.minutes??zt,u=l=>{throw new j({code:"MUTE_FAILED",message:l})},f=await e.identity().catch(l=>u(`The target would not say who the run writes as (${R(l)}).`)),d={organizationId:f.organization_id,userId:f.user_id},c=Qt(s.dir??lt(),d.organizationId,d.userId),h=t.assign.map(l=>l.permissionSet),i=await dn(e,h).catch(l=>u(`The permission sets to assign could not be read (${R(l)}).`)),g=h.filter(l=>!i.has(l));g.length>0&&u(`The target holds no permission set ${g.join(", ")}: nothing was assigned.`);let m=h.map(l=>i.get(l)),k=new Map(h.map(l=>[i.get(l),l])),T=l=>tn(l,c,r,s.checks),S=new Date(o()).toISOString(),E=gt(c,n,S),C=!1,W=m.map(l=>k.get(l)),yt=s.retryEveryMs??Bt,V,ke=(l,A)=>{if(V!==void 0)return;let p=new Set(l.map(y=>y.id)),O=!1,P=()=>clearInterval(V);V=setInterval(()=>{O||(O=!0,se(c,d,s,async(y,G)=>{let M=y.leases.find(x=>x.runId===n&&x.acquiredAt===S);if(M){M.assigning=[],M.created=[...M.created,...A.filter(b=>!M.created.some(X=>X.id===b.id))].filter(b=>!p.has(b.id));let x=await re(e,y,M,T);for(let b of x.removed)p.add(b.id);await G(y)}P()},void 0,0).catch(()=>{}).finally(()=>{O=!1}))},yt),V.unref?.()},z=await se(c,d,s,async(l,A)=>{let p=N(await cn(e,l,T)),O=await at(e,d.userId,m),P=m.filter(w=>!O.has(w)),y={runId:n,host:r.host,pid:r.pid,hostStartedAt:r.startedAt,acquiredAt:S,endsAt:new Date(o()+a*6e4).toISOString(),needs:m,assigning:[...P],created:[]};l.leases.push(y),D.add(E),await A(l),C=!0;let G=[...y.assigning],M=()=>A(l).then(()=>{G=[...y.assigning]},w=>R(w)),x=async w=>{y.assigning=[];let I=await re(e,l,y,T);D.delete(E);let v=await M();v!==void 0&&ke(I.removed,[...I.passed,...I.left]);let _=v!==void 0&&G.length===0?{sets:W,until:y.endsAt}:void 0,Ae=st(I,v===void 0);return u([w,...v!==void 0&&v!==w?[v]:[],...Ae.length>0?Ae:["Nothing was assigned."],...v!==void 0&&(I.passed.length>0||I.left.length>0||_)?[rt(r.pid,_)]:[],...p.length>0?[`Taking its lease, the run took back ${p.join(", ")}, ${pt(p)}.`]:[]].join(" "))};for(let w of P){let I=await e.createAssignment({AssigneeId:d.userId,PermissionSetId:w});if(y.assigning=y.assigning.filter(_=>_!==w),I.success&&I.id){y.created.push({id:I.id,permissionSetId:w,permissionSet:k.get(w)});let _=await M();if(_!==void 0)return x(_);continue}let v=I.errors?.[0];if((v?.statusCode??v?.errorCode)==="DUPLICATE_VALUE"){let _=await M();if(_!==void 0)return x(_);continue}return x(`${k.get(w)} could not be assigned to the user the run writes as: ${v?.message??v?.statusCode??"the org refused it"}.`)}let b=await at(e,d.userId,m).catch(()=>new Map),X=m.filter(w=>!b.has(w));if(X.length>0)return x(`Read back, the user the run writes as does not hold ${X.map(w=>k.get(w)).join(", ")}.`);let Et=new Set(y.created.map(w=>w.permissionSetId));return{endsAt:y.endsAt,assigned:y.created.map(w=>w.permissionSet),held:m.filter(w=>!Et.has(w)).map(w=>k.get(w)),found:p}}).catch(l=>{if(D.delete(E),Ht(l))throw l;return u(`${R(l)}${C?"":" Nothing was assigned."}`)}),$={...ye(t,"muted"),assigned:z.assigned,held:z.held,leaseEndsAt:z.endsAt,...z.found.length>0?{tookBackOfEnded:z.found}:{}},Se=s.renewEveryMs??qt,ie=Se>0?setInterval(()=>{se(c,d,s,async(l,A)=>{let p=l.leases.find(P=>P.runId===n&&P.acquiredAt===S);if(!p||!D.has(E))return;let O=new Date(o()+a*6e4).toISOString();p.endsAt=O,await A(l),$.leaseEndsAt=O}).catch(()=>{})},Se):void 0;ie?.unref?.();let Te;return{outcome:$,release:()=>(Te??=(async()=>{ie&&clearInterval(ie);let l={};try{await se(c,d,s,async(p,O)=>{let P=p.leases.find(y=>y.runId===n&&y.acquiredAt===S);D.delete(E),P&&(l.done=await re(e,p,P,T),await O(p))},p=>`nothing was taken back. ${ht(p)} Should none of its runs be muting this org, end process ${p.pid}`);let A=l.done?.left??[];return{...$,released:A.length===0,takenBack:N(l.done?.removed??[]),...l.done&&l.done.passed.length>0?{passed:N(l.done.passed)}:{},...A.length>0?{notTakenBack:N(A),reason:`${A.map(p=>`${p.permissionSet} (${p.why})`).join(", ")} could not be taken back: the lease ends at ${$.leaseEndsAt}, and the next run that mutes this org releases it`}:{}}}catch(A){D.delete(E);let p=l.done;if(ke(p?.removed??[],p?[...p.passed,...p.left]:[]),p!==void 0){let O=$.leaseEndsAt,P=O!==void 0&&Date.parse(O)>o()?{sets:W,until:O}:void 0;return{...$,released:!1,takenBack:N(p.removed),notTakenBack:N([...p.passed,...p.left]),reason:[R(A),...st({...p,removed:[]},!1),rt(r.pid,P)].join(" ")}}return{...$,released:!1,takenBack:[],reason:`the assignments could not be taken back (${R(A)}): this process tries again while it runs, and takes them back once it can use the journal; past ${$.leaseEndsAt}, or once process ${r.pid} has ended, the next run that mutes this org releases the lease`}}})(),Te)}}var mn=2,wn=3;function yn(e){return!e||e.assign.length===0?0:mn+wn+2*e.assign.length+(wt.get(e)??0)}function cs(e){let t=yn(e);return t>0?{mute:t}:{}}function En(e){return{state:"nothing",assigned:[],held:[],permissions:[],silenced:[],stillRan:[],reason:`nothing can be muted: ${e}; the run goes on as without the option`}}function us(e){return e?{mutedAutomation:e.muted,...e.plan?{mutePlan:e.plan}:{}}:{}}async function ds(e,t,n={}){if(typeof t.unread=="string")return{automation:void 0,muted:En(`the target's automation could not be read (${t.unread})`)};let s=await ln(await e(),t,n);if("refused"in s)throw new j(s.refused);return{automation:s.automation,...s.plan.assign.length>0?{prepared:s}:{},muted:s.planned,plan:s.plan}}function ls(e){let t=e?.mutedAutomation;return t!==null&&typeof t=="object"?t:void 0}function fs(e,t){let n=[];e.state==="nothing"?n.push(`mute: ${e.reason??mt}`):e.state==="planned"?n.push(`mute: planned, ${e.permissions.length>0?`the permission set(s) holding ${e.permissions.join(", ")}`:"nothing"} for the user it writes as in ${t}, for the run alone; nothing is assigned yet`):n.push(`mute: ${e.assigned.length>0?`assigned ${e.assigned.join(", ")}`:"assigned nothing"}${e.held.length>0?`; ${e.held.join(", ")} held already`:""} to the user the run writes as in ${t}, for the run alone`),e.tookBackOfEnded&&e.tookBackOfEnded.length>0&&n.push(` taken back before the run: ${e.tookBackOfEnded.join(", ")}, `+pt(e.tookBackOfEnded));for(let r of e.silenced)n.push(` silenced: ${ue(r)} (bypass ${r.permission})`);for(let r of e.stillRan)n.push(` still runs: ${ue(r)} (${Me(r.why)})`);for(let r of e.alsoLifted??[])n.push(` also lifts: ${_e(r)}`);for(let r of e.liftsUnread??[])n.push(` ${xe(r)}`);let s=e.takenBack??(e.released===!0?e.assigned:[]);if(s.length>0&&n.push(` taken back: ${s.join(", ")}, as the run ended`),e.passed&&e.passed.length>0&&n.push(` stays assigned: ${e.passed.join(", ")}, for another run that mutes ${t} as the same user, which takes ${e.passed.length===1?"it":"them"} back as it ends`),e.released===!1){let r=e.notTakenBack!==void 0&&e.notTakenBack.length===0;n.push(` ${r?"lease not released":"not taken back"}: ${e.reason??"the assignments stay until the lease ends"}`)}return n}export{An as a,le as b,L as c,fe as d,vn as e,Je as f,Cn as g,In as h,Ve as i,F as j,te as k,Jn as l,Wn as m,et as n,$t as o,Vn as p,Gn as q,Xn as r,as as s,Ht as t,ln as u,hn as v,yn as w,cs as x,us as y,ds as z,ls as A,fs as B};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{$ as g,Aa as H,Ba as I,Ca as J,Da as K,Ea as L,Fa as M,Ga as N,Ha as O,Ia as P,Ja as Q,Ka as R,V as a,W as b,X as c,Y as d,Z as e,_ as f,aa as h,ba as i,ca as j,da as k,ea as l,fa as m,ga as n,ha as o,ia as p,ja as q,ka as r,la as s,ma as t,na as u,oa as v,pa as w,qa as x,ra as y,sa as z,ta as A,ua as B,va as C,wa as D,xa as E,ya as F,za as G}from"./chunk-KOQV4WXC.mjs";import"./chunk-CULAOP3U.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-2OIRJEYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{m as ASSIGNMENT_RULES_SOQL,h as AUTOMATION_READ_MOST,b as CONDITIONS_BOUND,f as CONDITION_REQUESTS_BOUND,c as DEFINITIONS_BOUND,g as DEFINITION_REQUESTS_BOUND,n as DUPLICATE_RULES_SOQL,i as FLOWS_SOQL,k as PROCESSES_SOQL,d as TOOLING_QUERIES_PER_REQUEST,e as TOOLING_RETRIEVES_PER_REQUEST,j as TRIGGERS_SOQL,N as TargetAutomationReader,o as USER_PERMISSIONS_SOQL,l as WORKFLOW_RULES_SOQL,a as answerOf,R as automationLines,p as conditionSoql,z as customObjectIdsSoql,Q as customPermissionsByIdSoql,A as customPermissionsSoql,G as decisionChecks,F as fieldsRequiredFilled,L as inFlight,H as messagesOf,M as objectsTheRunWrites,I as pathsOf,J as permissionKey,C as permissionSetSizesSoql,B as permissionSetsHoldingSoql,D as permissionsNamed,y as processObjectsSoql,O as readBypassGrants,w as readInComposites,x as ruleDefinitionSoql,P as setCustomPermissionsSoql,E as switchesNamed,v as targetAutomationQueries,s as toolingAnswersOf,q as toolingCompositeBody,t as toolingRecordsOf,r as toolingRetrieveBody,u as toolingRetrievesOver,K as unreadPartOf};