sandforge 1.83.0 → 1.84.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 (254) hide show
  1. package/README.md +1 -1
  2. package/lib/chunk-23SEDORH.mjs +11 -0
  3. package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
  4. package/lib/chunk-26POJDIT.mjs +7 -0
  5. package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
  6. package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
  7. package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
  8. package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
  9. package/lib/chunk-2WFIVO4F.mjs +13 -0
  10. package/lib/chunk-2YHZBUZE.mjs +7 -0
  11. package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
  12. package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
  13. package/lib/chunk-3PVRGTVK.mjs +7 -0
  14. package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
  15. package/lib/chunk-3TZSBHEY.mjs +7 -0
  16. package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
  17. package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
  18. package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
  19. package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
  20. package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
  21. package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
  22. package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
  23. package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
  24. package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
  25. package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
  26. package/lib/chunk-6I6TWNV5.mjs +7 -0
  27. package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
  28. package/lib/chunk-6O222PW6.mjs +7 -0
  29. package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
  30. package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
  31. package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
  32. package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
  33. package/lib/chunk-6ZLKIT3H.mjs +7 -0
  34. package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
  35. package/lib/chunk-7SQSWVAU.mjs +9 -0
  36. package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
  37. package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
  38. package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
  39. package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
  40. package/lib/chunk-AL4C3GFT.mjs +7 -0
  41. package/lib/chunk-B3FBHVNN.mjs +21 -0
  42. package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
  43. package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
  44. package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
  45. package/lib/chunk-BEA27DLS.mjs +7 -0
  46. package/lib/chunk-BRY3PLIZ.mjs +7 -0
  47. package/lib/chunk-CBH3TOWK.mjs +341 -0
  48. package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
  49. package/lib/chunk-CVHNXJH3.mjs +7 -0
  50. package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
  51. package/lib/chunk-DGDRQRCW.mjs +7 -0
  52. package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
  53. package/lib/chunk-DUN2EPRC.mjs +7 -0
  54. package/lib/chunk-E3A3LOCY.mjs +7 -0
  55. package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
  56. package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
  57. package/lib/chunk-EPFCERGL.mjs +7 -0
  58. package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
  59. package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
  60. package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
  61. package/lib/chunk-FNJ4SGWO.mjs +7 -0
  62. package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
  63. package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
  64. package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
  65. package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
  66. package/lib/chunk-GOOVPVWX.mjs +7 -0
  67. package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
  68. package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
  69. package/lib/chunk-H4CGM6YO.mjs +7 -0
  70. package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
  71. package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
  72. package/lib/chunk-HSBXRQTI.mjs +7 -0
  73. package/lib/chunk-HUZPBE47.mjs +7 -0
  74. package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
  75. package/lib/chunk-I6E6T6YY.mjs +7 -0
  76. package/lib/chunk-IUM4NFKI.mjs +10 -0
  77. package/lib/chunk-IVFVNNGB.mjs +37 -0
  78. package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
  79. package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
  80. package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
  81. package/lib/chunk-JCFBFF4Y.mjs +7 -0
  82. package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
  83. package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
  84. package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
  85. package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
  86. package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
  87. package/lib/chunk-JTJK2D36.mjs +7 -0
  88. package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
  89. package/lib/chunk-KB4ZHM4Q.mjs +10 -0
  90. package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
  91. package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
  92. package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
  93. package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
  94. package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
  95. package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
  96. package/lib/chunk-LC3NDW4N.mjs +7 -0
  97. package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
  98. package/lib/chunk-M2ABR4JM.mjs +7 -0
  99. package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
  100. package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
  101. package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
  102. package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
  103. package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
  104. package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
  105. package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
  106. package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
  107. package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
  108. package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
  109. package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
  110. package/lib/chunk-OFTT7J2M.mjs +7 -0
  111. package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
  112. package/lib/chunk-OM5NORJG.mjs +7 -0
  113. package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
  114. package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
  115. package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
  116. package/lib/chunk-OVNMB6Q2.mjs +7 -0
  117. package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
  118. package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
  119. package/lib/chunk-PEDQPM2P.mjs +926 -0
  120. package/lib/chunk-PH7SP4YK.mjs +21 -0
  121. package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
  122. package/lib/chunk-PMWAFDUB.mjs +48 -0
  123. package/lib/chunk-PPLVFX6N.mjs +7 -0
  124. package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
  125. package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
  126. package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
  127. package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
  128. package/lib/chunk-Q7TLC3I2.mjs +7 -0
  129. package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
  130. package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
  131. package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
  132. package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
  133. package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
  134. package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
  135. package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
  136. package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
  137. package/lib/chunk-RKTFFCNS.mjs +7 -0
  138. package/lib/chunk-RMFU4BAL.mjs +28 -0
  139. package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
  140. package/lib/chunk-RT47RKLY.mjs +7 -0
  141. package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
  142. package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
  143. package/lib/chunk-T3G6VZNS.mjs +7 -0
  144. package/lib/chunk-TNT27RBG.mjs +7 -0
  145. package/lib/chunk-UBIKR5VO.mjs +7 -0
  146. package/lib/chunk-UI3JQVRU.mjs +8 -0
  147. package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
  148. package/lib/chunk-UX3BVH2Y.mjs +7 -0
  149. package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
  150. package/lib/chunk-VINGECAJ.mjs +10 -0
  151. package/lib/chunk-VOXJHJIE.mjs +7 -0
  152. package/lib/chunk-W6PN6TJG.mjs +7 -0
  153. package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
  154. package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
  155. package/lib/chunk-WWTCWWZI.mjs +7 -0
  156. package/lib/chunk-WXDLQT2O.mjs +10 -0
  157. package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
  158. package/lib/chunk-X4BXESMQ.mjs +7 -0
  159. package/lib/chunk-XBQGZGWR.mjs +7 -0
  160. package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
  161. package/lib/chunk-XKWW3GKF.mjs +7 -0
  162. package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
  163. package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
  164. package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
  165. package/lib/chunk-YHR4WQPR.mjs +7 -0
  166. package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
  167. package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
  168. package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
  169. package/lib/chunk-ZBAWJUG2.mjs +7 -0
  170. package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
  171. package/lib/chunk-ZQQXSCVI.mjs +7 -0
  172. package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
  173. package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
  174. package/lib/sandforge-autopilot.mjs +25 -25
  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 +52 -21
  180. package/lib/sandforge-dataops.mjs +1 -1
  181. package/lib/sandforge-empty.mjs +1 -1
  182. package/lib/sandforge-env.mjs +95 -95
  183. package/lib/sandforge-frozen.mjs +1 -1
  184. package/lib/sandforge-mcp.mjs +12 -12
  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 +1 -1
  190. package/lib/sandforge.mjs +1 -1
  191. package/lib/sf/sandforge/compare.mjs +2 -2
  192. package/lib/sfPlugin.mjs +1 -1
  193. package/oclif.manifest.json +1 -1
  194. package/package.json +1 -1
  195. package/lib/chunk-2ADSD5WK.mjs +0 -7
  196. package/lib/chunk-2GSMHGIV.mjs +0 -7
  197. package/lib/chunk-36Y225OM.mjs +0 -7
  198. package/lib/chunk-3OVTKRS4.mjs +0 -7
  199. package/lib/chunk-4GCYGQXD.mjs +0 -7
  200. package/lib/chunk-4JKR4PTZ.mjs +0 -8
  201. package/lib/chunk-5OGNK3JP.mjs +0 -37
  202. package/lib/chunk-6QSHWIZI.mjs +0 -48
  203. package/lib/chunk-77IVKH7R.mjs +0 -7
  204. package/lib/chunk-77MZRBWX.mjs +0 -7
  205. package/lib/chunk-7WSQ65WG.mjs +0 -9
  206. package/lib/chunk-A32ISQ6M.mjs +0 -28
  207. package/lib/chunk-AG24QMSY.mjs +0 -7
  208. package/lib/chunk-BH76USTQ.mjs +0 -11
  209. package/lib/chunk-BZ24IAP5.mjs +0 -7
  210. package/lib/chunk-CN5HGFG4.mjs +0 -7
  211. package/lib/chunk-CTPLYUXA.mjs +0 -7
  212. package/lib/chunk-DIGUC7S4.mjs +0 -341
  213. package/lib/chunk-DSR2MSBH.mjs +0 -7
  214. package/lib/chunk-ETNQHIDI.mjs +0 -9
  215. package/lib/chunk-FBXH4VRQ.mjs +0 -7
  216. package/lib/chunk-FYWNSMOZ.mjs +0 -10
  217. package/lib/chunk-GEEWPTV5.mjs +0 -7
  218. package/lib/chunk-GTRU5AV5.mjs +0 -7
  219. package/lib/chunk-I3ZO76LL.mjs +0 -21
  220. package/lib/chunk-ISA2NYJV.mjs +0 -7
  221. package/lib/chunk-IXIY6Q4M.mjs +0 -7
  222. package/lib/chunk-JAV6F6OA.mjs +0 -7
  223. package/lib/chunk-JYUMD357.mjs +0 -7
  224. package/lib/chunk-L47JCNP3.mjs +0 -7
  225. package/lib/chunk-LI2XNV7F.mjs +0 -7
  226. package/lib/chunk-LP2D3JJP.mjs +0 -7
  227. package/lib/chunk-LYOGCIYD.mjs +0 -925
  228. package/lib/chunk-N5UIE4IR.mjs +0 -7
  229. package/lib/chunk-O7GCCRPW.mjs +0 -7
  230. package/lib/chunk-OO24ZYYJ.mjs +0 -7
  231. package/lib/chunk-OS6HFJ7L.mjs +0 -7
  232. package/lib/chunk-P6WRYJN3.mjs +0 -7
  233. package/lib/chunk-PGRY365W.mjs +0 -7
  234. package/lib/chunk-PPGDAUEQ.mjs +0 -7
  235. package/lib/chunk-Q4PPI3KG.mjs +0 -7
  236. package/lib/chunk-QFTF2PGS.mjs +0 -21
  237. package/lib/chunk-QO4MPHZD.mjs +0 -7
  238. package/lib/chunk-QXB6U3ZP.mjs +0 -7
  239. package/lib/chunk-R3OM3X4L.mjs +0 -8
  240. package/lib/chunk-R7GKMAT4.mjs +0 -7
  241. package/lib/chunk-SCKUIE3R.mjs +0 -7
  242. package/lib/chunk-SU65Z2BA.mjs +0 -7
  243. package/lib/chunk-T7DDS4UQ.mjs +0 -7
  244. package/lib/chunk-TQJ5NPRC.mjs +0 -7
  245. package/lib/chunk-VZLJZEV2.mjs +0 -7
  246. package/lib/chunk-W3BQGMTR.mjs +0 -7
  247. package/lib/chunk-WXU6ZJIV.mjs +0 -7
  248. package/lib/chunk-X4HZD5U2.mjs +0 -7
  249. package/lib/chunk-X6XNTOGO.mjs +0 -7
  250. package/lib/chunk-XMQ5R6TC.mjs +0 -10
  251. package/lib/chunk-XPXEQKLR.mjs +0 -7
  252. package/lib/chunk-YBZIDW6W.mjs +0 -7
  253. package/lib/chunk-ZCOSME6P.mjs +0 -7
  254. package/lib/chunk-ZTHC42X6.mjs +0 -7
@@ -4,13 +4,13 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{e as zt}from"./chunk-L4MSL4U7.mjs";import"./chunk-I5C4O3VA.mjs";import"./chunk-RVCPQVKM.mjs";import{a as Be,c as Ft,g as Mt,h as He}from"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import{a as Ue,b as je,e as Nt}from"./chunk-BZ24IAP5.mjs";import{a as $,b as Re}from"./chunk-SCKUIE3R.mjs";import"./chunk-66NMFCWX.mjs";import{a as Ge,k as Lt}from"./chunk-SX6QWYCQ.mjs";import"./chunk-EOQON3E5.mjs";import"./chunk-Y7YUNRKK.mjs";import"./chunk-4JKR4PTZ.mjs";import{d as Dt,z as X}from"./chunk-N2HYG3BL.mjs";import"./chunk-ZXOUWHYE.mjs";import{b as It,c as Ct,h as Wt}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-7BQMBXKX.mjs";import"./chunk-KWAVSZ2B.mjs";import"./chunk-TUACWKIH.mjs";import{B as kt,Ra as $t,_ as U,bc as Et,da as vt,ea as Rt,ga as At,ha as jt,ia as St,na as _t,oa as xt,pa as Ot,qa as Pt,ra as Ae,sa as Tt,z as qe}from"./chunk-6QSHWIZI.mjs";import{A as i,b,e as z,f as ze,i as yt,k as Y,l as P,u as bt,v as Z,z as q}from"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{readFileSync as po}from"node:fs";import{join as fo,resolve as on}from"node:path";import{createInterface as mo}from"node:readline";import{randomBytes as Gt}from"node:crypto";import{open as Gn,readFile as Vt,readdir as Vn,rename as Jn,rm as Je,stat as qt}from"node:fs/promises";import{join as Xe,resolve as Ut}from"node:path";var Ke="SANDFORGE_MCP_HOLD_SECONDS",Yn=45,Zn=55,ae=50,Xn=20,Kn="mcp-runs",Qn=1440*6e4,Q=/^mr-\d{8}-\d{6}-[a-z0-9]{4}$/,Bt="abcdefghijklmnopqrstuvwxyz0123456789";function Qe(e,t=new Date){let n=t.toISOString(),o=`${n.slice(0,4)}${n.slice(5,7)}${n.slice(8,10)}`,r=`${n.slice(11,13)}${n.slice(14,16)}${n.slice(17,19)}`,s=Array.from(Gt(4),a=>Bt[a%Bt.length]).join("");return`${e}-${o}-${r}-${s}`}function _e(e=process.env){let t=e[Ke]?.trim(),n=t!==void 0&&/^\d+(\.\d+)?$/.test(t)?Number(t):Number.NaN;return Number.isFinite(n)&&n<=Zn?Math.round(n*1e3):Yn*1e3}function xe(e){return Xe(e,Kn)}function ie(e){return Q.test(e)}function Ht(e,t){if(!ie(t))throw new Error(`Not the handle of a run: ${t}`);return Xe(e,`${t}.json`)}function Ve(e,t){return Xe(e,`${t}.meta.json`)}var Ye=class{constructor(t=Xn){this.most=t}most;kept=[];open="";push(t){let n=`${this.open}${t}`.split(/\r?\n/);this.open=n.pop()??"";for(let o of n)this.kept.push(o),this.kept.length>this.most&&this.kept.shift()}lines(){return(this.open===""?[...this.kept]:[...this.kept,this.open]).slice(-this.most)}},Se=z().int().nonnegative().catch(0),eo=P({running:Z(!0).optional().catch(void 0),interrupted:Z(!0).optional().catch(void 0),error:b().optional().catch(void 0),journal:b().min(1).optional().catch(void 0),finishedAt:b().optional().catch(void 0),result:P({successCount:Se,updatedCount:Se,linkedCount:Se,failedCount:Se,createdByObject:Y(yt()).catch([])}).partial().catch({})});async function H(e){let t;try{t=JSON.parse(await Vt(e,"utf8"))}catch{return}let n=eo.safeParse(t);if(!n.success)return;let o=n.data,r=o.result;return{state:o.running===!0?"running":o.interrupted===!0?"interrupted":o.error!==void 0?"failed":"ended",...o.journal!==void 0?{journal:o.journal}:{},written:(r.successCount??0)+(r.updatedCount??0)+(r.linkedCount??0),failed:r.failedCount??0,objectsWritten:(r.createdByObject??[]).length,...o.finishedAt!==void 0?{finishedAt:o.finishedAt}:{}}}var to=P({handle:b().regex(Q),tool:b().min(1),target:b().min(1).optional(),plan:b().min(1).optional(),startedAt:q.datetime(),summary:b().min(1).optional(),expectedSeconds:z().nonnegative().optional()}),Ze=class{constructor(t,n,o){this.meta=t;this.ended=Promise.resolve().then(()=>n({signal:this.controller.signal,onStderr:r=>this.said.push(r)})).catch(r=>({code:1,stdout:"",stderr:`The script could not be started: ${r instanceof Error?r.message:String(r)}`})).then(r=>(this.ran=r,o(this),r))}meta;controller=new AbortController;said=new Ye;ran;final;ended;handedBack=!1;get handle(){return this.meta.handle}get result(){return this.ran}get running(){return this.ran===void 0}tail(){return this.said.lines()}stop(){this.controller.abort()}settled(t){return this.final??=this.ended.then(t),this.final}},se=class{constructor(t){this.options=t;this.now=t.now??(()=>new Date)}options;runs=new Map;now;get holdMs(){return this.options.holdMs}newHandle(){return Qe("mr",this.now())}summaryPathOf(t){return Ht(this.options.dir,t)}start(t,n){if(!ie(t.handle))throw new Error(`Not the handle of a run: ${t.handle}`);let o=new Ze({...t,startedAt:this.now().toISOString()},n,r=>{r.handedBack||this.runs.delete(r.handle)});return o.running&&this.runs.set(o.handle,o),o}async hold(t,n=this.options.holdMs){if(!t.running)return t.result;let o,r=new Promise(s=>{o=setTimeout(()=>s(void 0),Math.max(0,n))});try{return await Promise.race([t.ended,r])}finally{clearTimeout(o)}}waitFor(t,n){let o=Number.isFinite(n)?Math.min(Math.max(0,n),ae):0;return this.hold(t,o*1e3)}async handBack(t){t.handedBack=!0,this.runs.set(t.handle,t),await X(this.options.dir),await et(Ve(this.options.dir,t.handle),`${JSON.stringify(t.meta)}
8
- `)}get(t){return ie(t)?this.runs.get(t):void 0}all(){return[...this.runs.values()]}busyWith(t){return this.all().find(n=>n.running&&n.meta.target===t)}async underWayWith(t){let n=Ut(t);for(let o of this.all()){if(!o.running||o.meta.summary===void 0)continue;let r=(await H(o.meta.summary))?.journal;if(r!==void 0&&Ut(r)===n)return o}}async progress(t){let n=t.meta.summary!==void 0?await H(t.meta.summary):void 0;return{elapsedSeconds:Math.max(0,Math.round((this.now().getTime()-Date.parse(t.meta.startedAt))/1e3)),...t.meta.expectedSeconds!==void 0?{expectedSeconds:t.meta.expectedSeconds}:{},...n?{summary:n}:{},tail:t.tail()}}async readOnDisk(t){if(!ie(t))return;let n;try{n=to.parse(JSON.parse(await Vt(Ve(this.options.dir,t),"utf8")))}catch{return}if(n.handle!==t)return;let o=n.summary!==void 0?await H(n.summary):void 0;return{meta:n,...o?{summary:o}:{}}}async stopAll(){let t=this.all().filter(n=>n.running);for(let n of t)n.stop();await Promise.allSettled(t.map(n=>n.ended))}async sweep(){let t;try{t=await Vn(this.options.dir)}catch{return 0}let n=this.now().getTime(),o=0;for(let r of t){let s=r.replace(/\.meta\.json$/,"");if(s===r||!ie(s)||this.runs.has(s))continue;let a=Ve(this.options.dir,s),d=await qt(a).catch(()=>{});if(!d||n-d.mtimeMs<Qn)continue;let h=(await this.readOnDisk(s))?.summary?.journal;h!==void 0&&await qt(h).catch(()=>{})||(await Je(Ht(this.options.dir,s),{force:!0}),await Je(a,{force:!0}),o++)}return o}};async function et(e,t){let n=`${e}.${process.pid}-${Gt(4).toString("hex")}.tmp`,o=await Gn(n,"wx",Dt);try{await o.writeFile(t,"utf8"),await o.sync()}finally{await o.close()}try{await Jn(n,e)}catch(r){throw await Je(n,{force:!0}),r}}import{existsSync as Pe}from"node:fs";import{readFile as no,readdir as oo,rm as de,stat as ro}from"node:fs/promises";import{join as D}from"node:path";var io="mcp-plans",Te=/^co-\d{8}-\d{6}-[a-z0-9]{4}$/,so=P({run:b().regex(Q),startedAt:q.datetime(),summary:b().min(1),resume:ze(),ended:P({code:z().int(),wrote:ze(),journal:b().min(1).optional()}).optional()}),nt=P({version:Z(1),id:b().regex(Te),createdAt:q.datetime(),expiresAt:q.datetime(),source:b().min(1),target:b().min(1),args:Y(b()),mode:bt(["sample","whole"]),totalRows:z().int().positive(),sample:P({dir:b().min(1),sha256:b().regex(/^[0-9a-f]{64}$/),drawnAt:q.datetime()}).optional(),question:b().optional(),durationSeconds:z().nonnegative().optional(),accepted:Y(b()),runs:Y(so),dead:P({code:b().min(1),at:q.datetime()}).optional()});function $e(e){return D(e,io)}function ne(e){return Te.test(e)}function Jt(e,t){if(!ne(t))throw new Error(`Not the id of a plan: ${t}`);return D($e(e),`${t}.json`)}function Oe(e,t){if(!ne(t))throw new Error(`Not the id of a plan: ${t}`);return D($e(e),t)}var ao=P({tool:Z("sandforge-clone"),dryRun:Z(!0),writePlan:P({totalRows:z().int().positive()}),wholeOrg:P({question:b().min(1).optional(),durationSeconds:z().nonnegative().optional().catch(void 0),sample:P({plan:P({path:b().min(1),sha256:b().regex(/^[0-9a-f]{64}$/),drawnAt:q.datetime()})}).optional()}),wouldBeRefused:Y(b()).max(0).optional()});function Yt(e){let t=ao.safeParse(e);if(!t.success)return;let{writePlan:n,wholeOrg:o}=t.data;return{mode:o.sample?"sample":"whole",totalRows:n.totalRows,...o.sample?{sample:{...o.sample.plan}}:{},...o.question!==void 0?{question:o.question}:{},...o.durationSeconds!==void 0?{durationSeconds:o.durationSeconds}:{}}}function co(e){return e.filter(t=>t!=="--dry-run"&&t!=="--json")}async function Zt(e,t,n=new Date){let o=Qe("co",n);await X($e(e));let r,s=t.planned.sample;if(s){await X(Oe(e,o));try{let l=await Lt(s.path,D(Oe(e,o),"sample"),s.sha256);r={dir:l.dir,sha256:l.sha256,drawnAt:l.manifest.drawnAt}}catch(l){throw await de(Oe(e,o),{recursive:!0,force:!0}),l}}let a=Math.min(n.getTime(),r?Date.parse(r.drawnAt):n.getTime()),d={version:1,id:o,createdAt:n.toISOString(),expiresAt:new Date(a+Ge).toISOString(),source:t.source,target:t.target,args:co(t.dryRunArgs),mode:t.planned.mode,totalRows:t.planned.totalRows,...r?{sample:r}:{},...t.planned.question!==void 0?{question:t.planned.question}:{},...t.planned.durationSeconds!==void 0?{durationSeconds:t.planned.durationSeconds}:{},accepted:[...t.accepted],runs:[]};return await Xt(e,nt.parse(d)),d}async function Xt(e,t){await et(Jt(e,t.id),`${JSON.stringify(t,null,2)}
9
- `)}async function ce(e,t){if(ne(t))try{let n=nt.parse(JSON.parse(await no(Jt(e,t),"utf8")));return n.id===t?n:void 0}catch{return}}async function lo(e){return e.ended?.journal??(await H(e.summary))?.journal}async function uo(e){if(e.ended)return e.ended.wrote;let t=await H(e.summary);return t?t.written>0||t.journal!==void 0&&Pe(t.journal):!0}async function ot(e,t,n=new Date){let o=await ce(e,t);if(!o)return{state:"gone",why:"unknown"};let r=[];for(let s of o.runs)await uo(s)&&r.push(s);if(r.length>0){let s;for(let d of[...o.runs].reverse())if(s=await lo(d),s!==void 0)break;if(s!==void 0&&!Pe(s))return{state:"gone",why:"journalGone",receipt:o};let a=o.runs[o.runs.length-1]??r[r.length-1];return{state:"written",receipt:o,run:a,...s!==void 0?{journal:s}:{}}}return o.dead?{state:"gone",why:"dead",receipt:o}:n.getTime()>=Date.parse(o.expiresAt)?{state:"gone",why:"expired",receipt:o}:{state:"ready",receipt:o}}function ho(e,t,n){let o=[];for(let r=0;r<e.length;r++){if(e[r]===t){r++;continue}o.push(e[r])}return[...o,t,n]}function Kt(e,t){let n=e.mode==="whole"?ho(e.args,"--max-total",String(e.totalRows)):[...e.args];return t.resume!==void 0?n=[...n,"--resume",t.resume]:e.sample&&(n=[...n,"--fit-plan",e.sample.dir]),[...n,"--yes","--summary",t.summary,"--json"]}async function rt(e,t,n){let o=await ce(e,t);if(!o)return;let r=nt.parse(n(o));return await Xt(e,r),r}function Qt(e,t,n){return rt(e,t,o=>({...o,runs:[...o.runs,{...n}]}))}function en(e,t,n,o){let r=o.journal!==void 0&&Pe(o.journal);return rt(e,t,s=>({...s,runs:s.runs.map(a=>a.run===n?{...a,ended:{code:o.code,wrote:r,...o.journal!==void 0?{journal:o.journal}:{}}}:a)}))}function tn(e,t,n,o=new Date){return rt(e,t,r=>({...r,dead:{code:n,at:o.toISOString()}}))}async function nn(e,t=new Date,n=()=>!1){let o=$e(e),r;try{r=await oo(o)}catch{return 0}let s=0;for(let a of r){let d=a.replace(/\.json$/,"");if(ne(d)&&a===`${d}.json`){if(n(d))continue;let l=await ot(e,d,t);if(l.state!=="gone"||l.why==="unknown"&&!await tt(D(o,a),t)||l.why==="dead"&&t.getTime()<Date.parse(l.receipt?.expiresAt??""))continue;await de(D(o,a),{force:!0}),await de(Oe(e,d),{recursive:!0,force:!0}),s++}else if(!ne(a)&&await tt(D(o,a),t))await de(D(o,a),{recursive:!0,force:!0}),s++;else if(ne(a)&&!Pe(D(o,`${a}.json`))){if(!await tt(D(o,a),t))continue;await de(D(o,a),{recursive:!0,force:!0}),s++}}return s}async function tt(e,t){let n=await ro(e).catch(()=>{});return n!==void 0&&t.getTime()-n.mtimeMs>=Ge}var ee="2026-07-28",ge=["2025-11-25","2025-06-18","2025-03-26"],le={version:"io.modelcontextprotocol/protocolVersion",capabilities:"io.modelcontextprotocol/clientCapabilities",serverInfo:"io.modelcontextprotocol/serverInfo"},E={parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603,unsupportedVersion:-32022},rn=60*6e4,sn={name:"sandforge",title:"SandForge",version:String(JSON.parse(po(fo(__dirname,"..","package.json"),"utf8")).version??"0.0.0")},an=`SandForge's Seed, Forge's clone of a record, of the records a query chooses or of the whole org, the removal of a run, the emptying of objects or of a whole org, Checkpoints and their replay into another org, the environments of a sandforge.yaml and the plan of an Automation pipeline, run from the sandforge npm package. Every org is named by its sf CLI alias, as \`sf alias list\` shows them. A tool that writes to an org takes confirm, the alias of that org exactly: give it only once the person using you has agreed to that write, after a dry run, a preview or a plan has said what it would do. The acceptances (acceptAutomation and the others) are theirs to give too. A production org is refused by every tool that writes to an org. Each answer carries the script's own JSON, its exit code and its lines. A clone of the whole org, or of a sample of it that fits the target: clone_org_plan, show the person the question its plan comes back with, then clone_org with that plan and confirm; its personal fields are always anonymized. A call still running after ${Math.round(_e()/1e3)} seconds hands back a run: run_status follows it, run_stop stops it. pipeline_plan says what a run of a pipeline exported from the Automation page would do and refuse, writing nothing; no tool runs one: its run is the person's, on a terminal (${$("pipeline")} run --file <file>). No tool clones whole tables (${$("clone")} --object <ApiName> --where <condition>), nor compares two orgs (${$("compare")}) or takes a DataOps snapshot (${$("backup")}): give the person the command to run in a terminal, or a sandforge.yaml resource that env_plan and env_apply run.`,go=1e6;function wo(e={}){return Ft({...e,relayedBy:"sandforge mcp"})}var yo=wo();function bo(e){let t=i.toJSONSchema(e);return delete t.$schema,t}function k(e){return{definition:{name:e.name,title:e.title,description:e.description,inputSchema:bo(e.args),annotations:{title:e.title,readOnlyHint:e.readOnly,...e.readOnly?{}:{destructiveHint:e.destructive===!0}}},...e.writes!==void 0?{writes:e.writes}:{},...e.readFirst!==void 0?{readFirst:e.readFirst}:{},flags:e.flags??{},named:e.named??{},exits:e.exits??{},read:async(t,n,o)=>{let r=e.refuseFirst?.(t);if(r!==void 0)return{refusal:{code:"ARGUMENTS",message:r}};let s=e.args.safeParse(t);if(!s.success)return{refusal:{code:"ARGUMENTS",message:`${e.name}: `+s.error.issues.map(y=>`${y.path.join(".")||"arguments"}: ${y.message}`).join("; ")+". Nothing was run."}};let a=s.data,d;if(e.prepare){let y=await e.prepare(a,n);if("refusal"in y)return y;d=y.prepared}else d=void 0;let l=e.writesTo?.(a,d),h=a.confirm,{beforeStart:c,settle:A}=e;return{call:{...l!==void 0?{writesTo:l}:{},...typeof h=="string"?{confirm:h}:{},run:e.run(a,d,o),after:y=>e.after?.(a,y)??[],beforeStart:()=>c?.(a,d,o,n)??Promise.resolve(),...A?{settle:y=>A(a,d,y)}:{}}}}}}var C=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,dn=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,ko=/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,F=/^[^-\r\n][^\r\n]*$/,vo=/^[a-z][a-z0-9-]{0,62}$/,v=e=>i.string().regex(Ct,'an sf CLI alias, or the username it stands for, not starting with "-"').describe(e),I=e=>i.string().max(255).describe(`The alias of ${e} again, exactly as given: the person using you agrees to this write. Without it, the call is refused before anything is read.`),pe=e=>i.string().min(1).max(200).regex(F,'one line, not starting with "-"').describe(e),u=e=>i.boolean().optional().describe(e),ue=e=>i.strictObject({keepDays:i.number().int().min(qe.min).max(qe.max).optional().describe("The days it is kept on this machine; 0 until it is deleted (default 7)."),excluded:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects to leave out of it, by API name, named in the answer: a rewind leaves their records as they are.")}).optional().describe(`Before ${e}'s first write, take a checkpoint of each object it writes, and of each the target's flows that still run create as it writes them, held whole: {} takes it with the defaults. Its cost is that of the tables, not of the records written, and its values stay unencrypted on this machine: give it only once the person using you has seen, in a dry run with it, what it would hold and cost. Refused, ${e} writes nothing; deleted again when it writes nothing.`);function ye(e){return e===void 0?[]:["--checkpoint-first",...e.keepDays!==void 0?["--checkpoint-keep-days",String(e.keepDays)]:[],...(e.excluded??[]).flatMap(t=>["--checkpoint-exclude-object",t])]}var he=e=>u(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for the run alone, under a lease, and taken back as it ends; what no bypass keeps quiet still runs. A dry run with it says what it would assign, and assigns nothing. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`),fe=e=>u(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for ${e} alone, under a lease, and taken back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`);function cn(e){return`is no parameter of ${e}: an environment's acceptance of automation is its file's. Write accept: { automation: true } on the resource whose run it names, in the file, once the person using you has accepted what fires, then call ${e} again.`}var _n={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation","--accept-no-undo":"acceptNoUndo","--accept-recreate":"acceptRecreate","--accept-outside":"acceptOutside","--accept-unseen":"acceptUnseen"},Ro=Object.fromEntries(Object.entries(_n).map(([e,t])=>[e,`is checkpoint_rewind's ${t}: true, on the rewind this preview is of. Give it only once the person using you has accepted what it lets through.`])),ln=()=>i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Limit the rewind to these objects of the checkpoint, by API name (default: every object). What they depend on is never added: the answer names it."),un=/^em-\d{8}-\d{6}-[a-z0-9]{4}$/,hn={objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Empty these objects, by API name: every record of each. Not with wholeOrg."),wholeOrg:i.literal(!0).optional().describe("Empty every object people work in, less users, setup, Chatter, history, sharing, the org's flows, settings and definitions, and the standard price book. Not with objects."),excluded:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("With wholeOrg: objects to leave out, by API name."),customSettings:u("With wholeOrg: empty the custom settings too."),files:u("With wholeOrg: empty the files and attachments too."),managedPackages:u("With wholeOrg: empty the objects of managed packages too."),unrestorable:u("With wholeOrg: empty too, by passes of their own, the objects whose records Salesforce does not bring back from the recycle bin on their own. Only once the person using you has accepted that Undo cannot bring those back."),hardDelete:u("Delete for good, with what goes along: nothing goes to the recycle bin and no undo brings anything back. Needs the Bulk API Hard Delete permission of the user. Only once the person using you has accepted that nothing can be brought back."),checkpointFirst:u("Take a checkpoint of the objects emptied before the first delete, to rewind to."),acceptAutomation:u("Empty although the org runs flows, Apex triggers, processes or workflow rules as the records are deleted, or would not say what it runs."),acceptEmails:u("Empty although the org delivers every email what still runs as the records go sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:fe("the emptying"),acceptNoUndo:u("Empty although some records go before a record they name, as Salesforce requires, so that Undo cannot bring them back once both have gone."),acceptPeopleActive:u("Empty although people other than the user changed records of these objects in the hour before the read, their work going with it: empty_preview says how many and each one's last change. It covers those the preview named, and taking up a run, whoever. Only once the person using you has accepted that their work goes.")};function pn(e){return[e.objects,e.wholeOrg,e.resume].filter(n=>n!==void 0).length===1}function fn(e){return[...e.objects!==void 0?["--objects",e.objects.join(",")]:[],...e.wholeOrg===!0?["--org"]:[],...(e.excluded??[]).flatMap(t=>["--exclude-object",t]),...e.customSettings===!0?["--custom-settings"]:[],...e.files===!0?["--files"]:[],...e.managedPackages===!0?["--managed-packages"]:[],...e.unrestorable===!0?["--unrestorable"]:[],...e.hardDelete===!0?["--hard-delete"]:[],...e.checkpointFirst===!0?["--checkpoint-first"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[]]}function it(e){return[...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[]]}var xn={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},mn={...xn,"--accept-no-undo":"acceptNoUndo","--accept-people-active":"acceptPeopleActive"},gn={"--undo":"is empty_undo, with the run the line names: it brings back what that run deleted.","--resume":"is empty_run's resume, with the run the line names: it takes that run up."};function Ao(e){if(typeof e!="object"||e===null)return[];let{result:t}=e;return typeof t?.runId=="string"&&t.runId!==""&&t.undo?.offered===!0?[`empty_undo with run "${t.runId}" brings back what it deleted while the recycle bin holds it, as long as no other emptying of the org follows.`]:[]}var Ee=()=>i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The sandforge.yaml, by its path; a relative path is read from where the server was started."),wn=e=>u(`${e} Only once the person using you has accepted that Salesforce emails these people.`),yn=e=>i.array(i.string().regex(vo,"a resource of the file, by its name")).min(1).max(50).optional().describe(e);function bn(e){return e==="plan"?{"--replace":"is this tool's replace: the resources, by their names in the file, it plans replaced as env_apply's replace replaces them.","--replace-drifted":"is this tool's replaceDrifted: true plans every drifted resource replaced, as env_apply's replaceDrifted replaces them."}:{"--replace":"is this tool's replace: the resources to replace, by their names in the file. Give it only once the person using you has agreed to it.","--replace-drifted":"is this tool's replaceDrifted: true replaces every drifted resource. Give it only once the person using you has agreed to it."}}var kn="it keeps the scheduled jobs read on this machine, to compare with after the next refresh.",vn=/^[^=\r\n-][^=\r\n]{0,199}$/,jo=/^[^\s=-][^\s=]{0,199}$/,So=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function _o(e){return["plan","--file",e.file,...(e.acceptOrgs??[]).flatMap(t=>["--accept-org",`${t.key}=${t.organizationId}`]),...(e.vars??[]).flatMap(t=>["--var",`${t.name}=${t.value}`]),...(e.varEnvs??[]).flatMap(t=>["--var-env",`${t.name}=${t.env}`]),...(e.approve??[]).flatMap(t=>["--approve",t]),...e.store!==void 0?["--store",e.store]:[],"--json"]}function xo(e){return`No tool runs a pipeline: its run is the person's, on a terminal, ${$("pipeline")} run --file ${Me(e)} --dry-run first, then without --dry-run. This plan had no terminal: an Approval step it says has no one to ask (APPROVAL_NO_TERMINAL) is asked there, or answered ahead by approve.`}function Oo(e,t,n){let o=n===void 0?"gives no confirm":`gives confirm "${n}", which is not "${t}", the alias of the org it writes to`;return`${e.definition.name} writes to ${t}: it ${e.writes??"writes to the org"}. This call ${o}. `+(e.readFirst!==void 0?`Before it, ${e.readFirst}. `:"")+`Give confirm: "${t}" once the person using you has agreed to this write. Refused: nothing was read or written.`}function st(e,t){if(typeof t!="object"||t===null)return[];let{runFile:n,journal:o}=t,r=e==="seed"?n:o;return typeof r=="string"?[`run_remove with module "${e}" and run "${r}" takes this run back.`]:[]}function we(e){if(typeof e!="object"||e===null)return[];let{checkpoint:t}=e;return t?.state==="taken"&&typeof t.checkpointId=="string"?[`checkpoint_rewind with checkpoint "${t.checkpointId}" returns the org to how it was before this run, and takes back what anyone did since on the objects it holds: checkpoint_preview says what it would do first.`]:[]}var Rn=()=>i.string().min(1).max(512).regex(F,'one line, not starting with "-"').refine(e=>vt.safeParse(e).success,{message:"a SOQL condition without WHERE: no comment marker (--, /*, */) and no ; at its end"}).describe("A SOQL WHERE condition, without WHERE."),An=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,at={checkpoint:pe("The checkpoint: its id, as checkpoint_list names it; or its name, or latest, with from."),from:v("With a checkpoint named by its name or latest: the org it was taken of, by its alias, its username or its Organization Id, as checkpoint_list names it. Refreshed or expired since, it is not reached.").optional()};function On(e,t){e.from!==void 0&&e.checkpoint===void 0&&t.addIssue({code:"custom",path:["from"],message:"from goes with checkpoint, named by its name or latest"}),e.checkpoint!==void 0&&e.from===void 0&&!$t.safeParse(e.checkpoint).success&&t.addIssue({code:"custom",path:["from"],message:`"${e.checkpoint}" is not a checkpoint's id: a name, or latest, names one of an org's checkpoints, so give from, the org it was taken of, or its id`})}function dt(e){return e.preview===!0||e.sweepList===!0}function Po(e,t){let n=(o,r)=>t.addIssue({code:"custom",path:[o],message:r});if(e.sweep===!0&&e.sweepList===!0&&n("sweepList","sweep deletes and sweepList only lists: give one of them"),e.preview===!0&&e.sweepList===!0&&n("sweepList","preview deletes nothing, and sweepList lists what a sweep would take: give preview without it, or with sweep"),e.sweep!==!0&&e.sweepList!==!0)for(let o of["sweepLate","sweepUntied"])e[o]===!0&&n(o,`${o} goes with sweep, or with sweepList to see what it would take`)}var To=["maxRecords","objects","excludedObjects","owners","customSettings","mask","again","acceptAutomation","acceptEmails","muteAutomation","checkpointFirst"];function $o(e,t){let n=(o,r)=>t.addIssue({code:"custom",path:[o],message:r});if(e.checkpoint===void 0==(e.file===void 0)&&n("checkpoint","give checkpoint, one kept on this machine, or file, a .sfcheckpoint a teammate sent: one of them"),e.file!==void 0&&e.keyEnv===void 0&&n("keyEnv","a file goes with keyEnv, the name of the variable of the server's environment that holds its key: no terminal is there to type it"),e.keyEnv!==void 0&&e.file===void 0&&n("keyEnv","keyEnv goes with file: a checkpoint kept on this machine needs no key"),On(e,t),e.dryRun===void 0==(e.verify===void 0)&&n("dryRun","give dryRun \u2014 true first, then false to replay \u2014 or verify: true, one of them"),e.verify===!0)for(let o of To)e[o]!==void 0&&n(o,`${o} goes with a replay or its dry run: verify reads the choices its last replay was made with, and writes nothing`);e.dryRun===!1&&e.maxRecords===void 0&&n("maxRecords","a replay that writes takes maxRecords, the count its dry run said, once the person using you has agreed to that many"),e.dryRun===!0&&e.maxRecords!==void 0&&n("maxRecords","maxRecords goes with dryRun: false: the dry run says the count")}function Pn(e){return e.file!==void 0?["--file",e.file,"--key-env",e.keyEnv??""]:["--checkpoint",e.checkpoint??"",...e.from!==void 0?["--from",e.from]:[]]}function Tn(e){return["replay",...Pn(e),"--target",e.target,...e.verify===!0?["--verify"]:e.dryRun===!0?["--dry-run"]:[],...e.objects!==void 0?["--objects",e.objects.join(",")]:[],...(e.excludedObjects??[]).flatMap(t=>["--exclude-object",t]),...e.owners!==void 0?["--owners",e.owners]:[],...e.customSettings===!0?["--custom-settings"]:[],...e.mask===!0?["--mask"]:[],...e.again===!0?["--again"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...ye(e.checkpointFirst),...e.dryRun===!1?["--max-records",String(e.maxRecords),"--yes"]:[],"--json"]}function Eo(e){let t=w(w(e).plan).perObject;if(Array.isArray(t))return t.reduce((n,o)=>n+(R(w(o).toInsert)??0),0)}function Io(e,t){let n=Eo(t);return n===void 0||n===0?[]:[`checkpoint_replay with the same parameters, dryRun: false, maxRecords: ${n} and confirm "${e.target}" creates them, once the person using you has agreed to it; checkpoint_replay_remove takes it back.`]}var Co=/\b(requiredFieldDefaults|requiredLookupPlaceholders)\["([^"\]\n]+)"\]/g;function No(e,t){if(!ht(t,"LOAD_CONFIG"))return;let n={};for(let[,r="",s=""]of t.matchAll(Co)){let a=n[r]??={};a[s]=r==="requiredFieldDefaults"?"\u2026":{name:"\u2026"}}let o=Tn({...e,dryRun:!0,verify:void 0,maxRecords:void 0}).filter(r=>r!=="--json");return"LOAD_CONFIG, named above, is no parameter of this tool: the values of the required fields it names are the person\u2019s to declare"+(Object.keys(n).length>0?`, in a file such as ${JSON.stringify(n)}`:"")+`, and the replay goes from a terminal, its dry run first: ${$("checkpoint")} ${o.map(Me).join(" ")} --replay-config <file.json>`}function Do(e){return Array.isArray(e)?e.flatMap(t=>{let{id:n,replayWith:o}=w(t),r=S(o);if(typeof n!="string"||r===void 0)return[];let s=/--target (\S+)/.exec(r)?.[1];return[`checkpoint "${n}" no longer rewinds its org, and replays into another: checkpoint_replay with checkpoint "${n}", `+(s!==void 0&&s!=="<alias>"?`target "${s}"`:"target the org it goes into")+" and dryRun: true says what it would create there."]}):[]}async function Fo(e,t){let{parts:n,context:o}=t,r=["replays","--target",e,"--json"],s;try{s=await o.runCommand("sandforge-checkpoint",r,o.stopping)}catch(h){s={code:1,stdout:"",stderr:`${Re("sandforge-checkpoint")} could not be started: ${h instanceof Error?h.message:String(h)}`}}let a=`read by: ${be("sandforge-checkpoint",r)}`,d=pt(s.stdout);if(s.code!==0||!Array.isArray(d))return{...n,added:[...n.added,`The replays into ${e} could not be read (exit ${s.code}): ${s.stderr.trimEnd()}`,a]};let l=d.map(w).filter(h=>(R(h.inPlace)??0)>0);return{...n,added:[...n.added,d.length===0?`No replay into ${e} is kept on this machine.`:`${d.length} replay(s) into ${e} kept on this machine, ${l.length} of them with records still there (replays):`,...l.map(h=>` checkpoint "${String(h.checkpointId)}": ${String(h.inPlace)} record(s) in ${e}; checkpoint_replay_remove with checkpoint "${String(h.checkpointId)}" and target "${e}" takes them back, preview: true first.`),a],structured:{...n.structured,replays:d}}}function $n(e){return`SELECT Id FROM ${e.object}`+(e.where!==void 0?` WHERE ${e.where}`:"")+(e.orderBy!==void 0?` ORDER BY ${e.orderBy}`:"")+` LIMIT ${e.limit}`}function En(e){return[...e.recordIds!==void 0?[...e.recordIds.flatMap(n=>["--record",n]),"--max-roots",String(e.recordIds.length)]:["--query",$n({object:e.object??"",where:e.where,orderBy:e.orderBy,limit:e.limit??U}),"--max-roots",String(e.limit??U)],"--source",e.source,"--target",e.target,...e.depth===void 0?[]:typeof e.depth=="number"?["--depth","custom","--custom-depth",String(e.depth)]:["--depth",e.depth],...e.maxNodes!==void 0?["--max-nodes",String(e.maxNodes)]:[],...e.maxReadTotal!==void 0?["--max-read-total",String(e.maxReadTotal)]:[],...e.dryRun?["--dry-run"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...ye(e.checkpointFirst),"--json"]}function Mo(e,t){let n=w(w(t).targetGaps).gaps;if(!Array.isArray(n))return[];let o=Lo(t),r=n.map(w).flatMap(d=>{let l=S(d.objectApiName),h=S(d.field);return d.kind==="required_field_missing"&&d.answeredBy===void 0&&l!==void 0&&h!==void 0&&o.has(l)?[{object:l,field:h}]:[]});if(r.length===0)return[];let s=En({...e,dryRun:!0}).filter(d=>d!=="--json"),a=r.map(({object:d,field:l})=>({object:d,field:l,value:"\u2026"}));return[...r.map(({object:d,field:l})=>`${d}.${l} is a field ${e.target} requires that the clone does not write: a real run sees every record of ${d} refused, and no parameter of this tool gives it a value.`),`The person using you gives ${r.length===1?"it":"them"} in a Forge configuration file, ${JSON.stringify({defaultValues:a})}, and clones from a terminal, its dry run first: ${$("clone")} ${s.map(Me).join(" ")} --config <file.json>`]}function Lo(e){let t=w(e),n=w(t.writePlan).objects,o=Array.isArray(n)?n.map(w).filter(r=>(R(r.rows)??0)>0):(()=>{let r=w(t.result).readByObject;return Array.isArray(r)?r.map(w).filter(s=>(R(s.read)??0)>0):[]})();return new Set(o.flatMap(r=>S(r.objectApiName)??[]))}var Wo="is this tool's object, where, orderBy and limit: the query they make, SELECT Id FROM <object> WHERE <where> ORDER BY <orderBy> LIMIT <limit>.",zo=/--query "SELECT Id FROM [^"]* ORDER BY ([^"]+?) LIMIT (\d+)"/;function qo(e){let t=zo.exec(e);return t?`is this call with limit: ${t[2]??""} and orderBy: "${t[1]??""}", its object and where as they were: dryRun: true first.`:Wo}function Uo(e,t){let n=(r,s)=>t.addIssue({code:"custom",path:[r],message:s});if(e.object===void 0==(e.recordIds===void 0)){n("object","give object, with limit, for the records a query chooses, or recordIds, the records named one by one: one of them");return}if(e.recordIds!==void 0){for(let s of["where","orderBy","limit"])e[s]!==void 0&&n(s,`${s} goes with object: recordIds names its records one by one`);let r=[...new Set(e.recordIds.map(s=>s.slice(0,3)))];r.length>1&&n("recordIds",`the records of one object: these are of ${r.length} (${r.map(s=>`${s}\u2026`).join(", ")}); clone each object\u2019s apart`);return}if(e.limit===void 0){n("limit",`limit goes with object: the most records the query chooses, 1 to ${U}, which the run clones and no more`);return}let o=jt($n({object:e.object??"",where:e.where,orderBy:e.orderBy,limit:e.limit}));o!==void 0&&n(o.kind==="orderBy"?"orderBy":o.kind==="object"?"object":"where",`${St(o)} (ROOTS_QUERY_REFUSED)`)}var Bo={seed:"sandforge-seed",forge:"sandforge-clone",sync:"sandforge-sync"},ct=`An agent's clone of the whole org always anonymizes its personal fields: no tool copies them as the source holds them. A person who means to does it on a terminal, ${$("clone")} --depth all --source <alias> --target <alias> --no-anonymize after its --dry-run, or in a sandforge.yaml whose depth: all resource says accept: { realData: true }, reviewed where the repository is, that env_plan and env_apply run.`,Ho=/^[A-Za-z][A-Za-z0-9_]{0,79}\.[A-Za-z][A-Za-z0-9_]{0,79}$/,jn=e=>i.string().refine(t=>Ae(t,e)!==void 0,{message:"a date, as 2025-06-30, or an instant in UTC, as 2025-06-30T12:00:00Z"}),Go=()=>i.strictObject({field:i.enum(["created","modified"]).describe("created: the roots made in the window; modified: those last changed in it."),from:jn(!1).optional().describe("Its start: a date, from 00:00 UTC, or an instant in UTC."),to:jn(!0).optional().describe("Its end, left out of it: a date alone takes its whole day."),lastDays:i.number().int().min(1).max(_t).optional().describe("The last days, counted back from when the sample is drawn; not with from or to.")}).superRefine((e,t)=>{(e.from!==void 0||e.to!==void 0)===(e.lastDays!==void 0)&&t.addIssue({code:"custom",path:["lastDays"],message:"a window gives from, to or both, or lastDays: one or the other"});let o=e.from!==void 0?Ae(e.from,!1):void 0,r=e.to!==void 0?Ae(e.to,!0):void 0;o!==void 0&&r!==void 0&&o>=r&&t.addIssue({code:"custom",path:["to"],message:"a window starts before it ends: no root is made in this one"})}).optional().describe("With fit: draw only the roots made, or last changed, in a window of dates, in UTC. The records under or above a root come whatever their date."),Vo=()=>i.array(i.string().regex(Pt,"a field, as RecordTypeId, or an object and its field, as Account.RecordTypeId")).min(1).max(xt).superRefine((e,t)=>{let n=Tt.safeParse(e);if(!n.success)for(let o of n.error.issues)t.addIssue({code:"custom",path:[...o.path],message:o.message})}).optional().describe("With fit: keep the same share of the roots of each value of a picklist, a checkbox or a lookup (RecordTypeId, OwnerId), at least fitFloor of each value: Field, of every object drawn that has it, or Object.Field, one field of each object."),Jo=1e6,Yo=["plan","confirm","resume"],Zo=new Set(["SAMPLE_PLAN_MISMATCH","SAMPLE_PLAN_GONE","MAX_TOTAL_EXCEEDED","STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED"]);function Xo(e){return e.lastDays!==void 0?`${e.field}:${e.lastDays}d`:`${e.field}:${e.from??""}..${e.to??""}`}function Ko(e){return["--depth","all","--source",e.source,"--target",e.target,...e.fit!==void 0?["--fit",e.fit]:[],...e.fitWithinMB!==void 0?["--fit-within",String(e.fitWithinMB)]:[],...e.fitSeed!==void 0?["--fit-seed",String(e.fitSeed)]:[],...e.fitDraw!==void 0?["--fit-draw",e.fitDraw]:[],...e.fitWindow!==void 0?["--fit-window",Xo(e.fitWindow)]:[],...(e.fitWhere??[]).flatMap(t=>["--fit-where",`${t.objectApiName}=${t.where}`]),...(e.fitStrata??[]).flatMap(t=>["--fit-strata",t]),...e.fitParents!==void 0?["--fit-parents",e.fitParents]:[],...e.fitChildren!==void 0?["--fit-children",String(e.fitChildren)]:[],...(e.fitWhole??[]).flatMap(t=>["--fit-whole",t]),...e.fitFloor!==void 0?["--fit-floor",String(e.fitFloor)]:[],...e.maxTotal!==void 0?["--max-total",String(e.maxTotal)]:[],...(e.excludedObjects??[]).flatMap(t=>["--exclude-object",t]),...(e.excludedFields??[]).flatMap(t=>["--exclude",t]),...(e.filters??[]).flatMap(t=>["--filter",`${t.objectApiName}=${t.where}`]),"--anonymize",...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...ye(e.checkpointFirst),"--skip-preflight","--dry-run","--json"]}function Qo(e){return[...e.acceptAutomation===!0?["acceptAutomation"]:[],...e.acceptEmails===!0?["acceptEmails"]:[],...e.muteAutomation===!0?["muteAutomation"]:[],...e.checkpointFirst!==void 0?["checkpointFirst"]:[]]}function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function R(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function S(e){return typeof e=="string"&&e!==""?e:void 0}function er(e,t){let n=w(t),o=w(n.wholeOrg),r=w(o.storage),s=w(o.requests),a=w(o.sample),d=y=>R(w(y).estimate),l={...R(r.estimateMB)!==void 0?{estimate:R(r.estimateMB)}:{},...R(r.remainingMB)!==void 0?{remaining:R(r.remainingMB)}:{}},h={...d(s.target)!==void 0?{target:d(s.target)}:{},...d(s.source)!==void 0?{source:d(s.source)}:{}},c=S(w(a.budget).limitedBy),A=w(a.roots);return{id:e.id,expiresAt:e.expiresAt,mode:e.mode,source:e.source,target:e.target,records:e.totalRows,objects:Array.isArray(o.wouldInsert)?o.wouldInsert.length:0,...Object.keys(l).length>0?{storageMB:l}:{},...Object.keys(h).length>0?{requests:h}:{},...d(o.bulkBatches)!==void 0?{bulkBatches:d(o.bulkBatches)}:{},...e.durationSeconds!==void 0?{durationSeconds:e.durationSeconds}:{},...e.question!==void 0?{question:e.question}:{},anonymize:n.anonymize!==!1,accepted:[...e.accepted],...e.mode==="sample"?{sample:{...R(a.share)!==void 0?{share:R(a.share)}:{},...R(a.seed)!==void 0?{seed:R(a.seed)}:{},...S(a.draw)!==void 0?{draw:S(a.draw)}:{},...c!==void 0?{limitedBy:c}:{},...Object.keys(A).length>0?{roots:A}:{}}}:{}}}function tr(e){let t=e.draw==="recent"?"newest first":e.draw==="oldest"?"oldest first":void 0,n=e.roots??{},o=[...n.window!==void 0?["within a window of their dates"]:[],...n.where!==void 0?["among the records a condition keeps"]:[],...n.strata!==void 0?["by strata"]:[]];return t===void 0&&o.length===0?"":`, its roots drawn ${[...t!==void 0?[t]:[],...o].join(", ")}`+(o.length>0?" (plan.sample.roots says how)":"")}function nr(e){let t=e.sample?.share,n=e.mode==="sample"?`a sample of ${e.source}`+(t!==void 0?`, ${Math.round(t*1e3)/10} % of each object's roots`:"")+(e.sample!==void 0?tr(e.sample):"")+(e.sample?.limitedBy!==void 0?`, held by ${e.sample.limitedBy}`:""):`every record of ${e.source} it can take`;return[`The plan "${e.id}": ${e.records} records of ${e.objects} objects into ${e.target}, ${n}, every personal field anonymized`+(e.durationSeconds!==void 0?`; its writes take about ${e.durationSeconds} seconds`:"")+`. It holds until ${e.expiresAt}`+(e.accepted.length>0?`, with ${e.accepted.join(", ")} given`:"")+".",...e.question!==void 0?[`Its question, which a terminal would ask before the first write: ${e.question}`]:[],`Show the person this plan and its question. clone_org with plan "${e.id}" and confirm "${e.target}" writes it and nothing else, once they have said yes: nothing is written before.`]}async function or(e,t){let{ran:n,run:o,parts:r,context:s}=t;if(n.code!==0)return r;let a=Yt(r.answer);if(!a)return{...r,added:[...r.added,"No plan was kept: the dry run counted no record to write, or answered otherwise than a dry run of the whole org that would go. Nothing was written."]};let d;try{d=await Zt(s.journalDir,{source:e.source,target:e.target,dryRunArgs:o.args,planned:a,accepted:Qo(e)},s.now())}catch(h){let c=`No plan was kept: the plan of ids its dry run drew is no longer the one it gave \u2014 ${h instanceof Error?h.message:String(h)}. clone_org_plan again draws one, kept as it is shown. Nothing was written.`;return{...r,added:[...r.added,c],structured:{...r.structured,refusal:{code:"PLAN_NOT_KEPT",message:c}},isError:!0}}let l=er(d,r.answer);return{...r,added:[...r.added,...nr(l)],structured:{...r.structured,plan:l}}}function rr(e,t,n){switch(t){case"expired":return`plan "${e}" held until ${n?.expiresAt??"a day after it was drawn"}, and no run of it wrote`;case"dead":return`plan "${e}" no longer holds: a run of it was refused`+(n?.dead!==void 0?` (${n.dead.code})`:"")+" for what changed since it was planned, writing nothing";case"journalGone":return`a run of plan "${e}" wrote, and its journal is no longer on this machine: nothing says what it wrote, to take up or back`;default:return`plan "${e}" is not on this machine`}}async function ir(e,t){let n=e.plan,o=await ot(t.journalDir,n,t.now()),r="Refused: nothing was read or written.";if(o.state==="gone")return{refusal:{code:"PLAN_GONE",message:`clone_org: ${rr(n,o.why,o.receipt)}. clone_org_plan again with the same parameters says what a clone would write now: show the person its question, then clone_org with its plan. ${r}`}};let{receipt:s}=o;if(o.state==="written"){let d=o.run.run,l=t.runs.get(d)?.running===!0,h=o.journal,c=h!==void 0?`run_remove with module "forge", org "${s.target}" and run "${h}" (preview: true first) takes it back`:`run_status with run "${d}" says what is known of it`;if(e.resume!==!0||l)return{refusal:{code:"PLAN_USED",message:`clone_org: plan "${n}" ${l?"is being written by":"was written by"} run "${d}"${h!==void 0?`, whose journal is ${h}`:""}: a plan is written once. run_status with run "${d}" `+(l?"follows it, and run_stop stops it":"says how it ended")+`; clone_org with plan "${n}", resume: true and confirm "${s.target}" takes up a run of it that stopped part way; ${c}. ${r}`}};if(h===void 0)return{refusal:{code:"NOTHING_TO_RESUME",message:`clone_org: run "${d}" of plan "${n}" named no journal, so nothing says what it wrote and no resume takes it up. ${c}. ${r}`}}}else if(e.resume===!0)return{refusal:{code:"NOTHING_TO_RESUME",message:`clone_org: no run of plan "${n}" has written, and resume takes up a run that stopped part way. clone_org with plan "${n}" and confirm "${s.target}", without resume, writes it. ${r}`}};let a=t.runs.busyWith(s.target);return a?{refusal:{code:"TARGET_BUSY",message:`clone_org: ${s.target} is being written by run "${a.handle}" of ${a.meta.tool}, which this server runs: two runs writing one org at once could not tell their records apart. run_status with run "${a.handle}" says when it has ended, and run_stop stops it. ${r}`}}:{prepared:{receipt:s,...o.state==="written"&&o.journal!==void 0?{journal:o.journal}:{}}}}function sr(e){return S(w(e).journal)}var ar=50;async function dr(e,t,n){let o=["--verify",n,"--source",t.source,"--target",t.target,"--json"],r;try{r=await e.runCommand("sandforge-clone",o,e.stopping,{relayedBy:He})}catch(c){r={code:1,stdout:"",stderr:`${Re("sandforge-clone")} could not be started: ${c instanceof Error?c.message:String(c)}`}}let s=w(w(pt(r.stdout)).result),a=S(s.verdict),d=Array.isArray(s.objects)?s.objects.map(w):[],l=c=>d.reduce((A,y)=>A+(R(y[c])??0),0),h=l("moreInTheWindow");return{said:{exitCode:r.code,...a!==void 0?{status:a.toUpperCase(),expected:l("expected"),present:l("present"),deleted:l("deleted"),notVisible:l("notVisible"),linksBroken:l("linksBroken"),unchecked:d.filter(c=>S(c.error)!==void 0||S(c.linksUnchecked)!==void 0).length,...h>0?{moreInTheWindow:h}:{}}:{},...a!==void 0&&a!=="verified"?{objects:d.filter(c=>(R(c.present)??0)<(R(c.expected)??0)||(R(c.linksBroken)??0)>0||(R(c.moreInTheWindow)??0)>0||S(c.error)!==void 0||S(c.linksUnchecked)!==void 0).slice(0,ar).map(c=>({objectApiName:c.objectApiName,expected:c.expected,present:c.present,deleted:c.deleted,notVisible:c.notVisible,linksBroken:c.linksBroken,...R(c.withTheirRecord)!==void 0?{withTheirRecord:c.withTheirRecord}:{},...(R(c.moreInTheWindow)??0)>0?{moreInTheWindow:c.moreInTheWindow}:{},...S(c.error)!==void 0?{error:c.error}:{},...S(c.linksUnchecked)!==void 0?{linksUnchecked:c.linksUnchecked}:{}}))}:{}},line:`verified by: ${be("sandforge-clone",o)}`,stderr:r.stderr.trimEnd()}}function cr(e,t){let n=e.expected!==void 0?`${e.present??0} of the ${e.expected} records the run created read back from ${t}`+(e.deleted?`, ${e.deleted} in its recycle bin`:"")+(e.notVisible?`, ${e.notVisible} out of sight`:"")+(e.linksBroken?`; ${e.linksBroken} lookups not where the run set them`:"")+(e.unchecked?`; ${e.unchecked} objects not read or checked whole`:""):"",o=(e.objects??[]).filter(s=>(R(s.moreInTheWindow)??0)>0),r=(e.present??0)<(e.expected??0)||(e.linksBroken??0)>0?`${t} does not hold all of it as it was written`:o.length>0?`${t} holds ${e.moreInTheWindow??0} records more of ${o.map(s=>S(s.objectApiName)??"").join(", ")}, created during the run by the user it wrote as, than the run wrote and the platform wrote with its records`:"what it wrote could not all be checked";switch(e.status){case"VERIFIED":return`Verification: VERIFIED \u2014 ${n}, every lookup checked where the run set it.`;case"PARTIAL":return`Verification: PARTIAL \u2014 the clone ended, and ${r}: ${n}. verification.objects names the objects, each with what it found.`;case"UNSTABLE":return`Verification: UNSTABLE \u2014 no two readings of ${t} agreed: something still writes to the run's records (${n}). run_status says it again, verified again, once nothing does.`;default:return`Verification: not done \u2014 the verification of the run ended on ${e.exitCode} (its lines follow): what the clone wrote is not known to be there.`}}async function lr(e,t){let{ran:n,launch:o,parts:r,context:s}=t,{receipt:a}=e,d=w(r.answer),l=sr(d)??(await H(o.summary))?.journal;await en(s.journalDir,a.id,o.handle,{code:n.code,...l!==void 0?{journal:l}:{}});let h=[],c=[...r.added],A=r.structured,y=l!==void 0?`run_remove with module "forge", org "${a.target}" and run "${l}" takes it back: preview: true first says what it would delete.`:void 0,L=w(d.refused),B=S(L.code);if(ut.has(n.code)){let T=w(d.result),N=R(T.successCount);if(N!==void 0&&c.push(`It created ${N} records of the ${a.totalRows} its plan counted`+(R(T.failedCount)?`, ${R(T.failedCount)} refused`:"")+"."),l!==void 0){let W=await dr(s,a,l),ke=cr(W.said,a.target);W.said.status==="VERIFIED"?c.push(ke,W.line):(h.push(ke),c.push(W.line,...W.stderr!==""?[W.stderr]:[])),A={...A,verification:W.said}}y!==void 0&&c.push(`This run: ${y}`),c.push(...we(d))}else if(In.has(n.code))c.push(l!==void 0?`It stopped part way, between two calls to the org: its journal ${l} holds what it wrote. clone_org with plan "${a.id}", resume: true and confirm "${a.target}" takes it up, writing nothing twice; ${y??""}`:`It stopped before it wrote anything: plan "${a.id}" still holds until ${a.expiresAt}, and clone_org with it writes it.`),c.push(...we(d));else if(B!==void 0&&Zo.has(B))await tn(s.journalDir,a.id,B,s.now()),c.push(`The plan no longer holds (${B}): what it was drawn or counted from changed since. clone_org_plan again with the same parameters says what a clone would write now; show the person its question, then clone_org with its plan. Nothing was written.`);else if(B==="API_BUDGET_EXCEEDED")c.push(`Plan "${a.id}" still holds until ${a.expiresAt}: clone_org with it again once the org has the requests it takes, within its day, or clone_org_plan again. Nothing was written.`);else if(B==="RESUME_UNCERTAIN"){let T=S(L.retryAt);c.push(T!==void 0?`clone_org with plan "${a.id}", resume: true and confirm "${a.target}" again from ${T}, once the calls the run left under way have ended. Nothing was written.`:`${y??"run_remove takes back what it wrote"} Nothing was written.`)}return{...r,head:h,added:c,structured:A}}var Fe=[k({name:"seed_templates",title:"Seed templates",description:"The built-in Seed templates, as the Seed page's gallery lists them: id, name, what it is for, and the records each object gets at most. The first is the one a new Developer Edition holds whole. seed_run takes the id. Reads no org.",readOnly:!0,args:i.strictObject({}),run:()=>({local:hr})}),k({name:"seed_run",title:"Seed an org",description:`Fill an org with records, from a Seed template (template, an id seed_templates gives) or with generated rows (objects), as sandforge seed --json does. Run it with dryRun: true first: it reads the org and writes nothing, and says what a real run would meet \u2014 the data storage it takes, the emails the org's automation would send, what runs as the records are created. Past the storage the org has left, it says the counts that fit; fit: "share" seeds them, the largest share of every count that fits, and fitWithinMB holds the run to fewer MB still. checkpointFirst takes a checkpoint of what the run writes before its first write, and a dry run says what it would hold and cost. dryRun: false writes, a production org refused, and needs confirm. acceptEmails lets it write although the org delivers every email what still runs sends, or would not say whether it does; muteAutomation keeps the org's automation quiet for the run through its own bypass, and a dry run with it says what it would assign. The answer names the run file, which run_remove with module "seed" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:i.strictObject({org:v("The org to fill: its sf CLI alias."),template:i.string().regex(ko,"a template id, as seed_templates gives them").optional().describe("A built-in template, by the id seed_templates gives; or give objects."),objects:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),count:i.number().int().min(1).max(1e5)})).min(1).max(50).optional().describe("Objects and how many records each gets, in insert order, their fields drawn by the faker; or give template."),dryRun:i.boolean().describe("true: read the org and say what a run would do, writing nothing."),fit:i.enum(["share"]).optional().describe('"share": seed the largest share of every count that fits the data storage the org has left, each object about that share of its records, a child no more than its parents kept hold, room kept for what its flows still running create. The answer says the counts, object by object; give it to a write only once the person using you has seen them in a dry run.'),fitWithinMB:i.number().min(.01).max(1e6).optional().describe("With fit: take no more than this many MB, whatever the org has left."),checkpointFirst:ue("the seed"),acceptEmails:u("Write although the org delivers every email of what still runs as the records go in, or would not say whether it does: only once the person using you has accepted that these emails go out."),muteAutomation:he("the seed"),confirm:I("org").optional()}).refine(e=>e.fitWithinMB===void 0||e.fit!==void 0,{message:'fitWithinMB goes with fit: "share"',path:["fitWithinMB"]}),writesTo:e=>e.dryRun?void 0:e.org,writes:"creates the records of the seed in it",readFirst:"a dry run of the same seed says what it would write and meet",flags:{"--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...st("seed",t),...we(t)],run:e=>({script:"sandforge-seed",args:["--target",e.org,...e.template!==void 0?["--template",e.template]:[],...(e.objects??[]).flatMap(t=>["--object",`${t.objectApiName}:${t.count}`]),...e.dryRun?["--dry-run"]:[],...e.fit!==void 0?["--fit",e.fit]:[],...e.fitWithinMB!==void 0?["--fit-within",String(e.fitWithinMB)]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...ye(e.checkpointFirst),"--json"]})}),k({name:"clone_record",title:"Clone a record (Forge)",description:`Clone one record from source into target with the records it needs and the ones that hang from it, as Forge's record clone and sandforge clone --record --json do. Run it with dryRun: true first: it reads both orgs, counts what it would write and says what would stop a real run \u2014 the target's automation, its data storage, the emails its flows send \u2014 and writes nothing. dryRun: false writes into target, a sandbox or a Developer Edition only, and needs confirm, the alias of target. acceptAutomation lets it write although the target runs automation as the records go in; acceptEmails, although the target delivers every email what still runs sends, or would not say whether it does, which acceptAutomation never stands for. muteAutomation keeps what the target runs quiet for the clone through the target's own bypass; what no bypass keeps quiet still needs acceptAutomation. checkpointFirst takes a checkpoint of what the clone writes before its first write, and a dry run says what it would hold and cost. The answer names the run journal, which run_remove with module "forge" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org to write into: its sf CLI alias."),recordId:i.string().regex(dn,"a 15- or 18-character Salesforce record id").describe("The record to clone, in source."),depth:i.union([i.enum(["direct","full"]),i.number().int().min(1).max(10)]).optional().describe('How far from the record discovery goes: "direct", "full", or a number of hops (default 5).'),maxNodes:i.number().int().min(10).max(500).optional().describe("How many objects discovery may reach (default 50)."),dryRun:i.boolean().describe("true: read both orgs and say what a clone would do, writing nothing."),confirm:I("target").optional(),acceptAutomation:u("Write although the target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although the target delivers every email of what still runs as the records go in, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:he("the clone"),checkpointFirst:ue("the clone")}),writesTo:e=>e.dryRun?void 0:e.target,writes:"creates the records of the clone in it",readFirst:"a dry run of the same clone says what it would write and meet",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...st("forge",t),...we(t)],run:e=>({script:"sandforge-clone",args:["--record",e.recordId,"--source",e.source,"--target",e.target,...e.depth===void 0?[]:typeof e.depth=="number"?["--depth","custom","--custom-depth",String(e.depth)]:["--depth",e.depth],...e.maxNodes!==void 0?["--max-nodes",String(e.maxNodes)]:[],...e.dryRun?["--dry-run"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...ye(e.checkpointFirst),"--json"]})}),k({name:"clone_records",title:"Clone records a query chooses (Forge)",description:`Clone from source into target the records a query chooses \u2014 object, with where, orderBy and limit, 1 to ${U} \u2014, or several records named by their ids (recordIds, of one object), each with the records it needs and the ones that hang from it, as sandforge clone --query --json does: a record they share is read and written once. Run it with dryRun: true first: it reads both orgs, says the records the query chose and per object what it would write, and what would stop a real run, and writes nothing. dryRun: false writes into target, a sandbox or a Developer Edition only, and needs confirm, the alias of target; the run reads the query again. acceptAutomation, acceptEmails, muteAutomation and checkpointFirst as for clone_record. maxReadTotal bounds the records it reads in all before it writes. The answer names the run journal, which run_remove with module "forge" takes the run back from.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org to write into: its sf CLI alias."),object:i.string().regex(C,"an object API name").optional().describe("The object whose records the query chooses, by API name; or give recordIds."),where:Rn().optional().describe("With object: the condition its records are chosen by, without WHERE. It chooses the records cloned, and filters nothing they reach."),orderBy:i.string().min(1).max(Rt).refine(e=>At.safeParse(e).success,{message:"field paths, each with ASC or DESC and NULLS FIRST or LAST, separated by commas"}).optional().describe("With object: the order the records are chosen in, without ORDER BY (default Id): CreatedDate DESC, Id DESC takes the newest, the ids ordering those made in the same second."),limit:i.number().int().min(1).max(U).optional().describe(`With object: the most records the query chooses and the run clones, 1 to ${U}.`),recordIds:i.array(i.string().regex(dn,"a 15- or 18-character Salesforce record id")).min(2).max(U).optional().describe("In place of object: the records to clone, by their ids in source, two or more, all of one object; clone_record clones one."),depth:i.union([i.enum(["direct","full"]),i.number().int().min(1).max(10)]).optional().describe('How far from each record discovery goes: "direct", "full", or a number of hops (default 5).'),maxNodes:i.number().int().min(10).max(500).optional().describe("How many objects discovery may reach (default 50)."),maxReadTotal:i.number().int().min(1).max(1e7).optional().describe("The most records the run reads in all before it writes (default 50,000): past it, it is refused, nothing written."),dryRun:i.boolean().describe("true: read both orgs and say what a clone would do, writing nothing."),confirm:I("target").optional(),acceptAutomation:u("Write although the target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although the target delivers every email of what still runs as the records go in, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:he("the clone"),checkpointFirst:ue("the clone")}).superRefine(Uo),writesTo:e=>e.dryRun?void 0:e.target,writes:"creates the records of the clone in it",readFirst:"a dry run of the same clone says the records it chose and what it would write",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--query":qo,"--max-roots":`is this tool's limit, or the count of its recordIds: the records a run clones, 1 to ${U}.`,"--max-read-total":"is this tool's maxReadTotal.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--fit":`is clone_org_plan's fit: "share", a sample of the whole org, whose fitWhere draws an object's roots among the records a condition keeps.`},exits:{2:"the clone refused what it was asked before any org was reached \u2014 a query its object, where, orderBy and limit make that cannot choose the records it clones (ROOTS_QUERY_REFUSED), records of two objects \u2014: change the parameter it names, then dryRun: true again; nothing was read or written"},after:(e,t)=>[...Mo(e,t),...e.dryRun?[]:[...st("forge",t),...we(t)]],run:e=>({script:"sandforge-clone",args:En(e)})}),k({name:"clone_org_plan",title:"Plan a clone of the whole org (Forge)",description:`The dry run of a clone of the whole org from source into target, or of a sample of it that fits the target (fit: "share"), as sandforge clone --depth all --dry-run --json says it: per object the records it would write, the API requests, Bulk API batches, data storage and time it takes against what each org has left today, what it leaves out and why, and every refusal a run would meet, each with the parameter that lifts it. It reads both orgs and writes nothing to either. A plan that would go is kept on this machine for a day, its owner's alone \u2014 of a sample, the ids of the records it drew \u2014 and comes back with its id and the question a terminal would ask before the first write: show the person both; clone_org with that plan and confirm writes it and nothing else. Every personal field is anonymized, always. acceptAutomation, acceptEmails, muteAutomation and checkpointFirst are given here, to the plan, which says what was accepted; maxTotal bounds the records, excludedObjects, excludedFields and filters narrow the clone. A production target is refused.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org the plan writes into: its sf CLI alias."),fit:i.enum(["share"]).optional().describe('"share": a sample of the org rather than every record \u2014 roots drawn of each object, each with its children and the records it names, none without a record it cannot be written without \u2014, the largest share that fits what the target has left and maxTotal.'),fitWithinMB:i.number().min(.01).max(Jo).optional().describe("With fit: take no more than this many MB of the target."),fitSeed:i.number().int().min(0).max(999999999999999).optional().describe("With fit: the seed the roots are drawn by (default 1)."),fitDraw:i.enum(["uniform","recent","oldest"]).optional().describe('With fit: "uniform" spreads the roots over each object (default), "recent" takes the newest by their creation date, "oldest" the oldest.'),fitWindow:Go(),fitWhere:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),where:Rn()})).min(1).max(Ot).optional().describe("With fit: draw an object's roots only among its records that match, one condition an object. Unlike filters, the records under or above the roots come whatever it says, and no lookup is written empty for it. Not of an object of fitWhole or excludedObjects."),fitStrata:Vo(),fitParents:i.enum(["all","required"]).optional().describe('With fit: "all" copies a record outside the sample an optional lookup names (default), "required" writes such a lookup empty.'),fitChildren:i.union([i.number().int().min(1).max(1e6),i.literal("all")]).optional().describe("With fit: the most children a record brings through each relation (100)."),fitWhole:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("With fit: objects copied whole, by API name."),fitFloor:i.number().int().min(0).max(1e4).optional().describe("With fit: the roots kept of each object whatever the share (default 1)."),maxTotal:i.number().int().min(1).max(1e8).optional().describe("The most records the clone may write in all (default 10,000): past it, its run is refused, and a sample is drawn within it."),excludedObjects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects left out, by API name; what that costs is said."),excludedFields:i.array(i.string().regex(Ho,"Object.Field, by API names")).min(1).max(500).optional().describe("Fields left out, as Object.Field."),filters:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),where:i.string().min(1).max(512).regex(F,'one line, not starting with "-"').describe("A SOQL WHERE condition, without WHERE.")})).min(1).max(50).optional().describe("Conditions that narrow an object, each added to what the clone reads of it."),anonymize:i.literal(!0).optional().describe("Always on, whether given or not: every personal field is anonymized by its category's default method. false is refused: no tool copies them as they are."),acceptAutomation:u("Plan the run with --accept-automation: it writes although the target runs flows, Apex triggers, processes or workflow rules as the records go in. Only once the person using you has accepted what a plan without it named."),acceptEmails:u("Plan the run with --accept-emails: it writes although the target delivers every email what still runs sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that they go out."),muteAutomation:he("the clone"),checkpointFirst:ue("the clone")}).refine(e=>e.fit!==void 0||[e.fitWithinMB,e.fitSeed,e.fitDraw,e.fitWindow,e.fitWhere,e.fitStrata,e.fitParents,e.fitChildren,e.fitWhole,e.fitFloor].every(t=>t===void 0),{message:'the fit* parameters go with fit: "share"',path:["fit"]}),refuseFirst:e=>e.anonymize===!1||["acceptRealData","noAnonymize","realData"].some(t=>t in e)?`clone_org_plan: the personal fields cannot be left as they are. ${ct} Nothing was run.`:void 0,prepare:async(e,t)=>(await Wn(t.journalDir,t.runs,t.now(),t.log),{prepared:void 0}),flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--max-total":"is this tool's maxTotal: the most records the clone may write. Give it the count the dry run said only once the person using you has agreed to that many.","--fit":`is this tool's fit: "share", a sample of the org that fits the target rather than every record.`,"--fit-within":"is this tool's fitWithinMB.","--fit-seed":"is this tool's fitSeed.","--fit-draw":"is this tool's fitDraw.","--fit-window":`is this tool's fitWindow: {field: "created" or "modified", from, to}, each a date or an instant in UTC, either left out, or {field, lastDays}.`,"--fit-where":"is this tool's fitWhere, an objectApiName and the where its roots match.","--fit-strata":"is this tool's fitStrata, a Field or an Object.Field.","--fit-parents":"is this tool's fitParents.","--fit-children":"is this tool's fitChildren.","--fit-whole":"is this tool's fitWhole, an object by API name.","--fit-floor":"is this tool's fitFloor.","--exclude-object":"is this tool's excludedObjects, an object by API name.","--exclude":"is this tool's excludedFields, as Object.Field.","--filter":"is this tool's filters, an objectApiName and its where.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--no-anonymize":`is no parameter of any tool. ${ct}`,"--yes":"is clone_org's to give: once the person has said yes to the plan's question, clone_org with the plan and confirm writes it without asking again."},exits:{1:"refused, or a run of this plan would be: each refusal is said above, with the parameter that lifts it; no plan was kept",2:"refused for what it was asked, before any record was drawn: a window, a condition of the roots or a stratum the source cannot take, or two parameters that do not go together, each said above with the parameter of its flag; no plan was kept"},run:e=>({script:"sandforge-clone",args:Ko(e),relayedBy:Mt}),settle:(e,t,n)=>or(e,n)}),k({name:"clone_org",title:"Clone the whole org (Forge)",description:`Write the plan clone_org_plan kept, and nothing else: its records into its target, as sandforge clone --depth all writes them, as Bulk API jobs from 2000 records of an object and by REST under that. plan is the id clone_org_plan gave, good for a day; confirm is the alias of the plan's target, given once the person has said yes to the question the plan came back with, which the run then does not ask again. A sample writes the records its dry run drew, a plan of every record no more than its dry run counted: a source or a target that changed since is refused, nothing written, and needs a new plan. It takes no scope of its own. resume: true takes up the run of the plan that stopped part way, from its journal. Once a run has ended, the server verifies what it wrote, and says the verification first unless VERIFIED. The answer names the journal, which run_remove with module "forge" takes the run back from. A plan already written, gone or past its day is refused before anything is read.`,readOnly:!1,destructive:!1,args:i.strictObject({plan:i.string().regex(Te,"the id of a plan clone_org_plan kept, co-...").describe("The plan clone_org_plan kept, by the id its answer gave."),confirm:I("the plan's target").optional(),resume:i.literal(!0).optional().describe("Take up the run of this plan that stopped part way, from its journal, writing nothing it wrote.")}),refuseFirst:e=>{let t=Object.keys(e).filter(n=>!Yo.includes(n));if(t.length!==0)return`clone_org takes a plan, not its scope: ${t.join(", ")} ${t.length===1?"is":"are"} clone_org_plan's to give. clone_org_plan with ${t.length===1?"it":"them"} plans again: show the person its question, then clone_org with its plan and confirm. Nothing was run.`},prepare:(e,t)=>ir(e,t),writesTo:(e,t)=>t.receipt.target,writes:"writes into it the records of the plan, and nothing else",readFirst:"clone_org_plan says what it would write, with the question to answer",named:{"--resume":"is this tool's resume: true, with the plan and confirm: it takes the run up from its journal.","--remove":'is run_remove, with module "forge", the org the run wrote to and its journal: preview: true first says what it would delete.',"--max-total":"is no parameter of clone_org, which holds a run to the count its plan's dry run gave: clone_org_plan again plans with the source as it is now.","--no-anonymize":`is no parameter of any tool. ${ct}`},beforeStart:async(e,t,n,o)=>{await X(xe(o.journalDir)),await Qt(o.journalDir,t.receipt.id,{run:n.handle,startedAt:o.now().toISOString(),summary:n.summary,resume:e.resume===!0})},run:(e,t,n)=>({script:"sandforge-clone",args:Kt(t.receipt,{summary:n.summary,...e.resume===!0&&t.journal!==void 0?{resume:t.journal}:{}}),relayedBy:He,follow:{plan:t.receipt.id,summary:n.summary,...t.receipt.durationSeconds!==void 0?{expectedSeconds:t.receipt.durationSeconds}:{}}}),settle:(e,t,n)=>lr(t,n)}),k({name:"run_remove",title:"Remove a run's records",description:`Delete from org, into its recycle bin, what one run of Seed (module "seed"), Forge (module "forge") or Sync (module "sync") created, as that script's --remove --json does; a Sync run also gives the records it wrote over their values back. run is the summary file the run's --json was saved to, its run file or journal, or, for Seed and Sync, its run id. Records changed since the run are kept, unless includeChanged. A production org is refused. preview: true, for a Seed or Forge run, says per object what it would delete, what is gone already, what changed since and who changed it, and what a removal would be refused for, deleting nothing and needing no confirm; otherwise it needs confirm, the alias of org. A run of this server still running is refused: run_stop stops it first. acceptAutomation lets it delete although the org runs automation as the records go; muteAutomation keeps that automation quiet for the removal through the org's own bypass. Where its user may not delete the records of some objects of the run, it stops before its first delete, unless leaveUndeletable. store, for a Sync run of a saved configuration, is that configuration's store, which the removal tells what it took.`,readOnly:!1,destructive:!0,args:i.strictObject({module:i.enum(["seed","forge","sync"]).describe("Which module made the run."),org:v("The org the run wrote to: its sf CLI alias."),run:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The run's summary file, its run file or journal, or (Seed, Sync) its run id; a relative path is read from where the server was started."),confirm:I("org").optional(),includeChanged:u("Take also the records changed since the run, and what was added to them since: on a shared sandbox, others' work. Only once the person using you has accepted it."),acceptAutomation:u("Delete although the org runs flows, Apex triggers, processes or workflow rules as the records go, or would not say what it runs: only once the person using you has accepted it."),muteAutomation:u("Keep quiet what the org runs as the records go, through its own bypass: the removal assigns the permission sets holding it to the user it deletes as, for the removal alone, under a lease, and takes them back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it."),leaveUndeletable:u("Where the user the alias connects as may not delete the records of some objects of the run, remove the rest and leave those, with the records they hang from; without it the removal stops before its first delete and names them. Only once the person using you has accepted it."),store:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe(`module "sync" only: the directory the saved configuration the run was of is kept in, the run's --store, which the removal tells what it took, so that its next delta run reads those objects whole; a relative path is read from where the server was started. The person using you names it.`),preview:u('module "seed" or "forge": say what the removal would do, and do nothing \u2014 per object the records it would delete, those gone already, those changed since the run and who changed them, and what a removal now would be refused for. It reads the org, deletes nothing, and takes no confirm.')}).refine(e=>e.store===void 0||e.module==="sync",{message:'store goes with module "sync": a Seed or Forge run keeps no configuration',path:["store"]}).refine(e=>e.preview!==!0||e.module!=="sync",{message:'preview goes with module "seed" or "forge": the removal of a Sync run has none, and says what it gives back as it does it',path:["preview"]}),prepare:async(e,t)=>{let n=await kr(t.runs,e.run);return n?{refusal:vr(n,e.run)}:{prepared:void 0}},writesTo:e=>e.preview===!0?void 0:e.org,writes:"deletes the records the run created, into the recycle bin",readFirst:"run_remove with preview: true (a Seed or Forge run) says what it would delete, deleting nothing",flags:{"--include-changed":"includeChanged","--accept-automation":"acceptAutomation","--mute-automation":"muteAutomation","--leave-undeletable":"leaveUndeletable"},named:{"--store":"is this tool's store: the directory of the run's saved configuration, as the person using you names it.","--preview":"is this tool's preview: true, for a Seed or Forge run: it says what the removal would delete, and deletes nothing."},run:e=>({script:Bo[e.module],args:["--remove",e.run,"--target",e.org,...e.preview===!0?["--preview"]:[],...e.includeChanged===!0?["--include-changed"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.leaveUndeletable===!0?["--leave-undeletable"]:[],...e.store!==void 0?["--store",e.store]:[],"--json"]})}),k({name:"run_status",title:"Follow a run",description:`How far a run is that a call handed back, by its handle (mr-...): a call whose script still runs after ${Math.round(_e()/1e3)} seconds answers with one. While it runs, its time against its plan's, what it wrote so far, its journal and its script's last lines; once it has ended, the answer its call would have given, the verification of a clone included. waitSeconds waits that long for its end first (default 30, 50 at most). A run of a server that has ended since is read off this machine: what it wrote, and the calls that take it up or back. Reads this machine alone.`,readOnly:!0,args:i.strictObject({run:i.string().regex(Q,"the handle of a run, mr-...").describe("The run, by the handle the call that started it answered with."),waitSeconds:i.number().min(0).max(ae).optional().describe("How long to wait for its end first, in seconds (default 30).")}),run:e=>({local:t=>yr(t,e.run,e.waitSeconds??gr)})}),k({name:"run_stop",title:"Stop a run",description:"Stop a run a call handed back, by its handle, as Ctrl-C stops its script on a terminal: before its next call to the org, what it wrote kept in its journal, a Bulk API job still open aborted and one the org is writing left to end. Only when the person using you asks. It waits a while for the run to end, then answers as run_status does, with the calls that take the run up or back.",readOnly:!1,destructive:!1,args:i.strictObject({run:i.string().regex(Q,"the handle of a run, mr-...").describe("The run, by the handle the call that started it answered with.")}),run:e=>({local:t=>br(t,e.run)})}),k({name:"checkpoint_list",title:"List checkpoints",description:"The checkpoints of org kept on this machine, newest first, with what a rewind and an undo can still reach, and of one that no longer rewinds it, the dry run of its replay into another org; then the replays into org kept on this machine (replays), each with the records it left there, which checkpoint_replay_remove takes back. Reads this machine alone, and never contacts an org. Named org only: the other orgs' names and aliases never reach the agent.",readOnly:!0,args:i.strictObject({org:v("The org, by its sf CLI alias: its checkpoints alone.")}),after:(e,t)=>Do(t),run:e=>({script:"sandforge-checkpoint",args:["list","--org",e.org,"--json"]}),settle:(e,t,n)=>Fo(e.org,n)}),k({name:"checkpoint_preview",title:"Preview a rewind",description:"What a rewind of org to a checkpoint would do: the records it would delete, give back and bring back, who last changed them, what the org runs as the rewind writes, the emails and API requests it takes, what neither a rewind nor its undo can take back, and the refusal a rewind would meet now. Given objects, those of a rewind limited to them, with what it would leave of them and the objects it needs added. Reads the org, writes nothing.",readOnly:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:pe("A checkpoint of it: its id, its name, or latest (the default).").optional(),objects:ln()}),named:Ro,run:e=>({script:"sandforge-checkpoint",args:["preview","--org",e.org,"--checkpoint",e.checkpoint??"latest",...(e.objects??[]).flatMap(t=>["--object",t]),"--json"]})}),k({name:"checkpoint_take",title:"Take a checkpoint",description:"Read org's records and keep them on this machine as a checkpoint, to rewind the org to later: every object people work in, or the objects named. estimate: true says the records, API requests, time and disk it would take, and keeps nothing. It writes nothing to the org; the checkpoint holds the records' values unencrypted, readable by this machine's user alone. A production org is refused.",readOnly:!1,destructive:!1,args:i.strictObject({org:v("The org: its sf CLI alias."),name:i.string().min(1).max(200).regex(F,'one line, not starting with "-"').optional().describe("What it is called (default: the date and time)."),objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("The objects to keep, by API name (default: every object people work in)."),maxTotal:i.number().int().min(1).max(go).optional().describe("The most records it holds, all objects together (default 500,000, a million at most): past it, it is refused before reading any, the refusal naming --max-total, which this sets."),estimate:i.boolean().optional().describe("true: say what it would take, then stop, keeping nothing.")}),run:e=>({script:"sandforge-checkpoint",args:["take","--org",e.org,...e.name!==void 0?["--name",e.name]:[],...(e.objects??[]).flatMap(t=>["--object",t]),...e.maxTotal!==void 0?["--max-total",String(e.maxTotal)]:[],...e.estimate===!0?["--estimate"]:[],"--json"]})}),k({name:"checkpoint_rewind",title:"Rewind an org",description:"Return org to a checkpoint: delete the records created since, give the records changed since their values back and bring back from the recycle bin the records deleted since \u2014 whoever made those changes \u2014 then read the org again. It rewinds from its own preview, said first in its answer with who last changed what; the answer says what Undo could not bring back, and checkpoint_undo takes the rewind back. Needs confirm, the alias of org: checkpoint_preview first. Refused without acceptAutomation when the org runs automation as the rewind writes, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back records it deletes, without acceptRecreate when records no longer in the recycle bin would be made again with new Ids, without acceptUnseen when, for a user without View All Data and Modify All Data, what it deletes takes along records the user is not proven to see. Given objects, it rewinds those alone, never adding what they depend on: its answer names what it left of them, the objects to add, and what still differs in the others. A production org is refused.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:pe("The checkpoint: its id or its name. latest is refused: one taken since would be the one the rewind returns to."),confirm:I("org").optional(),acceptAutomation:u("Rewind although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:u("Rewind although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the rewind writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:fe("the rewind"),acceptNoUndo:u("Rewind although Undo could not bring back some records it deletes (objects Salesforce undeletes only with their parent)."),acceptRecreate:u("Make again, with new Ids, the records deleted since that the recycle bin no longer gives back: what outside Salesforce names their old Ids no longer finds them."),acceptOutside:u("For a checkpoint of picked objects: also delete the records outside it created under records it deletes."),acceptUnseen:u("For a user without View All Data and Modify All Data: delete records whose delete takes along records of objects the user is not proven to see, tasks and events among them, which no count holds."),objects:ln()}),writesTo:e=>e.org,writes:"deletes the records created since the checkpoint, gives the records changed since their values back and brings back the records deleted since, whoever made those changes",readFirst:"checkpoint_preview says what it would do, writing nothing",flags:_n,run:e=>({script:"sandforge-checkpoint",args:["rewind","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...(e.objects??[]).flatMap(t=>["--object",t]),...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[],...e.acceptRecreate===!0?["--accept-recreate"]:[],...e.acceptOutside===!0?["--accept-outside"]:[],...e.acceptUnseen===!0?["--accept-unseen"]:[],"--json"]})}),k({name:"checkpoint_undo",title:"Undo a rewind",description:"Take back org's last rewind to a checkpoint: bring back what it deleted, give back what it wrote over, send back to the recycle bin what it brought back; what anyone changed since the rewind stays, and is said. Needs confirm, the alias of org. acceptAutomation and acceptEmails as for checkpoint_rewind.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:pe("The checkpoint the rewind went back to: its id or its name."),confirm:I("org").optional(),acceptAutomation:u("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:u("Undo although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the undo writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:fe("the undo")}),writesTo:e=>e.org,writes:"brings back what its last rewind deleted, gives back what it wrote over and sends back to the recycle bin what it brought back",readFirst:"checkpoint_list says which rewind it would take back, and until when",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},run:e=>({script:"sandforge-checkpoint",args:["undo","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],"--json"]})}),k({name:"checkpoint_delete",title:"Delete a checkpoint",description:"Delete a checkpoint of org from this machine: the org is not touched, and can no longer be rewound to it, nor its last rewind to it undone. Needs confirm, the alias of org.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:pe("The checkpoint: its id or its name."),confirm:I("org").optional()}),writesTo:e=>e.org,writes:"deletes the checkpoint from this machine, and the org can no longer be rewound to it",run:e=>({script:"sandforge-checkpoint",args:["delete","--org",e.org,"--checkpoint",e.checkpoint,"--yes","--json"]})}),k({name:"checkpoint_replay",title:"Replay a checkpoint into another org",description:"Set a checkpoint's records up again in another org (target), parents first, with new Ids, as sandforge checkpoint replay --json does: the sandbox its org became once refreshed, another sandbox, a scratch org. The checkpoint's own org is never reached, and nothing target holds is changed or deleted. Run it with dryRun: true first: it reads target and says what it would create, link, leave and refuse \u2014 owners, record types, currencies, the files a checkpoint keeps no content of \u2014, writing nothing. dryRun: false replays, with confirm, the alias of target, and maxRecords, the count its dry run said. A checkpoint of a Partial Copy, a Full or a Staging sandbox replays masked only (mask: true). file replays a .sfcheckpoint a teammate sent, its key read from the server's environment by the variable keyEnv names, never given in an argument. verify: true counts what its last replay created there. again replays over what the replays before created there, which goes first. checkpoint_replay_remove takes a replay back. A production org and the checkpoint's own org are refused; the Staging mark the editor gives a sandbox is not seen here.",readOnly:!1,destructive:!0,args:i.strictObject({checkpoint:at.checkpoint.optional(),from:at.from,file:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe("In place of checkpoint: a .sfcheckpoint file a teammate sent, replayed without its org, the key standing for the teammate's consent; a relative path is read from where the server was started. With keyEnv."),keyEnv:i.string().regex(An,"the name of an environment variable").refine(e=>zt(e)===void 0,{message:"the name of the variable that holds the key, never the key: a key in the arguments stays in the agent's context and in its client's logs"}).optional().describe("With file: the name of the variable of the server's environment that holds its key, which the person using you set where the server is started. Never the key."),target:v("The org the records go into: its sf CLI alias. A sandbox, a scratch org or a Developer Edition org."),dryRun:i.boolean().optional().describe("true: read target and say what the replay would do, writing nothing; false: replay, with maxRecords and confirm. Not with verify."),verify:i.literal(!0).optional().describe("Read target and count what the last replay of the checkpoint created there against what it said it created; writes nothing. Not with dryRun."),maxRecords:i.number().int().min(1).max(kt).optional().describe("With dryRun: false: the most records it may create, the count its dry run said; more is refused before it writes."),confirm:I("target").optional(),objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Replay these objects of the checkpoint alone, by API name (default: all)."),excludedObjects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects of the checkpoint to leave out, by API name."),owners:i.enum(["same","me"]).optional().describe('"same" (default): a record keeps its owner where target has that user active, and goes to the user who replays otherwise; "me": every record to that user.'),customSettings:u("Set up the custom settings the checkpoint holds too; a row target has already is kept, never written over."),mask:u("Mask personal data, as Forge's anonymization masks it: required of a checkpoint of a Partial Copy, a Full or a Staging sandbox, which may hold real data."),again:u("Replay over what the replays of this checkpoint before created in target, which goes first, deleted. Only once the person using you has agreed to it."),acceptAutomation:u("Write although target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although target delivers the emails what still runs sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:he("the replay"),checkpointFirst:ue("the replay")}).superRefine($o),refuseFirst:e=>{let t=Object.keys(e).filter(n=>/key/i.test(n)&&n!=="keyEnv");return t.length>0?`checkpoint_replay takes no key (${t.join(", ")}): a key in the arguments stays in the agent's context and in its client's logs. keyEnv names the variable of the server's environment that holds it, which the person using you sets where the server is started. Nothing was run.`:void 0},writesTo:e=>e.dryRun===!1?e.target:void 0,writes:"creates there the records of the checkpoint, with new Ids",readFirst:"checkpoint_replay with dryRun: true says what it would create, link and leave",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--dry-run":"is this tool's dryRun: true.","--verify":"is this tool's verify: true.","--remove":"is checkpoint_replay_remove, with the checkpoint and the target: preview: true first says what it would delete.","--again":"is this tool's again: true, once the person using you has agreed to it.","--mask":"is this tool's mask: true.","--max-records":"is this tool's maxRecords: the count the dry run said, once the person using you has agreed to that many.","--objects":"is this tool's objects, by API name.","--exclude-object":"is this tool's excludedObjects, by API name.","--owners":`is this tool's owners: "same" or "me".`,"--custom-settings":"is this tool's customSettings: true.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--key-env":"is this tool's keyEnv: the name of a variable of the server's environment that holds the key, never the key.","--no-real-data":`is no parameter of any tool: the declaration that a sandbox's checkpoint holds no real data is the person's, on a terminal, kept in the audit trail (${$("checkpoint")} replay \u2026 --no-real-data). mask: true replays it masked.`},after:(e,t)=>e.dryRun===!0?Io(e,t):[],settle:async(e,t,{ran:n,parts:o})=>{let r=No(e,`${n.stderr}
10
- ${n.stdout}`);return r===void 0?o:{...o,added:[...o.added,r]}},run:e=>({script:"sandforge-checkpoint",args:Tn(e)})}),k({name:"checkpoint_replay_remove",title:"Take a replay back",description:"Delete from target, into its recycle bin, what the replays of a checkpoint created there, children first, the checkpoint kept or not, as sandforge checkpoint replay --remove --json does; records changed since are kept, unless includeChanged. preview: true says what it would delete, deleting nothing and needing no confirm; otherwise it needs confirm, the alias of target. sweep takes too what the automation of target made for those records, and sweepList lists it, deleting nothing and needing no confirm; sweepLate and sweepUntied take too what the list says came late, or is tied to nothing of the replay. acceptAutomation lets it delete although target runs automation as the records go; muteAutomation keeps that automation quiet through target's own bypass. checkpoint_list names the replays into an org, by their checkpoint. A replay this server still runs into target is refused: run_stop stops it first. A production org is refused.",readOnly:!1,destructive:!0,args:i.strictObject({...at,target:v("The org the replay went into: its sf CLI alias."),preview:u("Say what the removal would delete, and delete nothing: it reads target, and takes no confirm."),confirm:I("target").optional(),sweep:u("Take too what target's automation made for the records of the replay. Only once the person using you has seen, in a preview with it, what it takes."),sweepList:u("List what sweep would take, per object, and delete nothing: it reads target, and takes no confirm. Not with sweep, nor with preview, which lists it with sweep."),sweepLate:u("With sweep, take too what the list says came late, after the replay ended; with sweepList, say what it would take. Only once the person using you has seen it."),sweepUntied:u("With sweep, take too what the list says is tied to nothing of the replay, refused when another run of this machine wrote to target meanwhile; with sweepList, say what it would take. Only once the person using you has seen it."),includeChanged:u("Take also the records changed since the replay, and what was added under them since: on a shared sandbox, others' work. Only once the person using you has accepted it."),acceptAutomation:u("Delete although target runs flows, Apex triggers, processes or workflow rules as the records go, or would not say what it runs: only once the person using you has accepted it."),muteAutomation:fe("the removal")}).superRefine(On).superRefine(Po),prepare:(e,t)=>{let n=t.runs.busyWith(e.target);return Promise.resolve(!dt(e)&&n?.meta.tool==="checkpoint_replay"?{refusal:Rr(n,e.target)}:{prepared:void 0})},writesTo:e=>dt(e)?void 0:e.target,writes:"deletes from it, into its recycle bin, what the replays of the checkpoint created",readFirst:"checkpoint_replay_remove with preview: true says what it would delete, deleting nothing",flags:{"--include-changed":"includeChanged","--sweep":"sweep","--sweep-late":"sweepLate","--sweep-untied":"sweepUntied","--accept-automation":"acceptAutomation","--mute-automation":"muteAutomation"},named:{"--preview":"is this tool's preview: true: it says what it would delete, and deletes nothing.","--sweep-list":"is this tool's sweepList: true: it lists what the sweep would take, and deletes nothing."},run:e=>({script:"sandforge-checkpoint",args:["replay",...Pn(e),"--target",e.target,"--remove",...e.preview===!0?["--preview"]:[],...e.sweep===!0?["--sweep"]:[],...e.sweepList===!0?["--sweep-list"]:[],...e.sweepLate===!0?["--sweep-late"]:[],...e.sweepUntied===!0?["--sweep-untied"]:[],...e.includeChanged===!0?["--include-changed"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...dt(e)?[]:["--yes"],"--json"]})}),k({name:"empty_preview",title:"Preview an emptying",description:"What emptying objects of org, or every object people work in there, would do: per object the records it deletes and what the org deletes along with them, in the order it takes them; what will likely refuse, what blocks, what no undo would bring back, what it leaves out and why; the API requests, Bulk API batches and time against what the org has left today, and the recycle bin; what the user is not proven to see; what the org runs as the records go, and its emails; and every refusal a run with the same parameters would meet now. Reads the org, deletes nothing.",readOnly:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),...hn}).refine(pn,{message:"give objects or wholeOrg, one of them"}),flags:mn,named:gn,run:e=>({script:"sandforge-empty",args:["--target",e.org,...fn(e),...it(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--dry-run","--json"]})}),k({name:"empty_run",title:"Empty objects or an org",description:"Delete every record of the objects named of org, or of every object people work in there, with what the org deletes along with them: to the recycle bin, which empty_undo brings them back from, or for good with hardDelete. It reads the org as empty_preview does, says it all first in its answer, and deletes only when nothing refuses it. Given resume, the run id of the org's last emptying stopped part way, it takes that run up instead. Needs confirm, the alias of org: empty_preview first. Refused without acceptAutomation when the org runs automation as the records go, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back some records, without acceptPeopleActive while someone else changed records of these objects in the last hour, past the day's API requests or Bulk API batches, and on a production org, always.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),confirm:I("org").optional(),...hn,resume:i.string().regex(un,"the run id of an emptying, em-...").optional().describe("Take up the org's last emptying stopped part way, by its run id, in place of objects or wholeOrg: on what its journal confirmed.")}).refine(pn,{message:"give objects, wholeOrg or resume, one of them"}),writesTo:e=>e.org,writes:"deletes every record of the objects named, or of every object people work in, with what the org deletes along with them",readFirst:"empty_preview says what it would delete and meet, deleting nothing",flags:mn,named:gn,after:(e,t)=>Ao(t),run:e=>({script:"sandforge-empty",args:["--target",e.org,...e.resume!==void 0?["--resume",e.resume]:fn(e),...it(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--yes","--json"]})}),k({name:"empty_undo",title:"Undo an emptying",description:"Bring back from the recycle bin what org's last emptying deleted, parents first, while the bin holds them; the answer names what could not come back and why. Refused for a run that deleted for good. Needs confirm, the alias of org. acceptAutomation, acceptEmails and muteAutomation as for empty_run.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),run:i.string().regex(un,"the run id of an emptying, em-...").describe("The org's last emptying, by the run id its answer gave."),confirm:I("org").optional(),acceptAutomation:u("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are brought back, or would not say what it runs."),acceptEmails:u("Undo although the org delivers every email what still runs as records come back sends, or would not say whether it does. Only once the person using you has accepted that these emails go out."),muteAutomation:fe("the undo")}),writesTo:e=>e.org,writes:"brings back from the recycle bin what the org's last emptying deleted",readFirst:"empty_run's answer names the run and whether its undo is offered",flags:xn,run:e=>({script:"sandforge-empty",args:["--target",e.org,"--undo",e.run,...it(e),"--yes","--json"]})}),k({name:"env_plan",title:"Plan an environment",description:"What env_apply would do to org from a sandforge.yaml (file), as sandforge env plan --json says it: per resource, create, keep, replace, delete, or why it is blocked; what an earlier apply left there and what changed since; per object the records it would write; the API requests, storage and emails it takes. Each resource is dry-run by its own script. Reads the org and the sources its resources clone from, writes nothing to an org. failOnDrift: true ends it exit 3 when the org no longer holds the environment as applied \u2014 records deleted or changed since. replace, replaceDrifted and acceptNoState plan what env_apply would do with them.",readOnly:!0,args:i.strictObject({file:Ee(),org:v("The org to fill: its sf CLI alias."),failOnDrift:i.boolean().optional().describe("true: exit 3 when records the environment holds were deleted or changed since."),replace:yn("Plan what env_apply would do with replace: these resources replaced although kept or drifted, by their names in the file."),replaceDrifted:u("Plan what env_apply would do with replaceDrifted: every drifted resource replaced."),acceptNoState:u("Plan what env_apply would do with acceptNoState: an apply to a Developer Edition or a sandbox this machine has no state of is otherwise refused."),acceptEmails:u("Plan what env_apply would do with acceptEmails: a seed or a clone is otherwise blocked where the org delivers the emails what still runs sends, or would not say whether it does."),acceptUserEmails:wn("Plan what env_apply would do with acceptUserEmails: a users resource that asks addresses back otherwise blocks the apply (USERS_EMAILS_NOT_ACCEPTED), Salesforce emailing each of those people the link that confirms their address.")}),flags:{"--accept-no-state":"acceptNoState","--accept-emails":"acceptEmails","--accept-user-emails":"acceptUserEmails"},named:bn("plan"),exits:{3:"drift: the org no longer holds the environment as applied, records deleted or changed since, each said above"},run:e=>({script:"sandforge-env",args:["plan","--file",e.file,"--org",e.org,...e.failOnDrift===!0?["--fail-on-drift"]:[],...(e.replace??[]).flatMap(t=>["--replace",t]),...e.replaceDrifted===!0?["--replace-drifted"]:[],...e.acceptNoState===!0?["--accept-no-state"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.acceptUserEmails===!0?["--accept-user-emails"]:[],"--json"]})}),k({name:"env_apply",title:"Apply an environment",description:"Do to org what env_plan says, as sandforge env apply --yes --json does: plans again, then creates what the file declares, replaces what it is told to (replace: the resources, by name; replaceDrifted: every drifted resource) and deletes the resources the file no longer holds, each by its own script, into the state kept on this machine; applied again, it writes nothing. A production org is refused, and a sandbox the file does not list. Needs confirm, the alias of org: env_plan first. acceptNoState lets it apply to an org this machine has no state of, where records an earlier apply left would be created twice. A resource's accept: { automation: true } in the file is what lets its runs be taken back although the org runs automation. acceptEmails lets its resources write although the org delivers the emails what still runs sends, or would not say whether it does; acceptUserEmails lets Salesforce email the people whose address a users resource asks back, which no file accepts. The answer ends with the env_destroy call that takes the environment back.",readOnly:!1,destructive:!0,args:i.strictObject({file:Ee(),org:v("The org to fill: its sf CLI alias."),confirm:I("org").optional(),replace:yn("Resources to replace although kept or drifted, by their names in the file: their earlier runs are taken back, then run again."),replaceDrifted:u("Replace every drifted resource: its earlier runs are taken back, then run again. Only once the person using you has agreed to it."),acceptNoState:u("Apply to a Developer Edition or a sandbox this machine has no state of: records an earlier apply left there would be created twice. Only once the person using you has accepted it."),acceptEmails:u("Apply although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as its resources write sends some. Only once the person using you has accepted that these emails go out."),acceptUserEmails:wn("Let Salesforce email the people whose address a users resource asks back: the link that confirms each address, a system email, which leaves under System email only too. Without it the plan refuses the apply (USERS_EMAILS_NOT_ACCEPTED), and no file accepts it.")}),writesTo:e=>e.org,writes:"creates, replaces and deletes the resources of the file there as its plan says, taking back the earlier runs a replace or a delete takes back",readFirst:"env_plan of the same file says what it would do, writing nothing",flags:{"--accept-no-state":"acceptNoState","--accept-emails":"acceptEmails","--accept-user-emails":"acceptUserEmails"},named:{...bn("apply"),"--accept-automation":cn("env_apply"),"--save":`is env_audit's save, with the same file and org: ${kn}`},after:e=>[`env_destroy with file "${e.file}" and org "${e.org}" takes this environment back.`],run:e=>({script:"sandforge-env",args:["apply","--file",e.file,"--org",e.org,...(e.replace??[]).flatMap(t=>["--replace",t]),...e.replaceDrifted===!0?["--replace-drifted"]:[],...e.acceptNoState===!0?["--accept-no-state"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.acceptUserEmails===!0?["--accept-user-emails"]:[],"--yes","--json"]})}),k({name:"env_destroy",title:"Destroy an environment",description:"Take back from org what env_apply created there from file, the last resource first, into its recycle bin, as sandforge env destroy --yes --json does; what it cannot take back is named, with why. Records changed since the apply are kept unless includeChanged: on a shared sandbox, a colleague\u2019s work. A production org is refused. Needs confirm, the alias of org. It takes back by removal alone: no rewind to a checkpoint.",readOnly:!1,destructive:!0,args:i.strictObject({file:Ee(),org:v("The org the environment was applied to: its sf CLI alias."),confirm:I("org").optional(),includeChanged:u("Take also the records changed since the apply, and what was created under them since: on a shared sandbox, others' work. Only once the person using you has accepted it.")}),writesTo:e=>e.org,writes:"deletes the records its applies created, into the recycle bin, the last resource first",readFirst:"env_plan of the same file says what the org holds of the environment and what changed since",flags:{"--include-changed":"includeChanged"},named:{"--accept-automation":cn("env_destroy")},run:e=>({script:"sandforge-env",args:["destroy","--file",e.file,"--org",e.org,...e.includeChanged===!0?["--include-changed"]:[],"--yes","--json"]})}),k({name:"env_audit",title:"Audit an environment",description:"Read org as sandforge env audit --json reads it, writing nothing to it: whether it delivers email, its scheduled jobs against the inventory this machine kept of it before its refresh, and the endpoints that still name production, each part the file's audits do not turn off. An audit that could not be read is said not read, with why, never taken for one that found nothing; no URL is given with its query or its credentials. save: true keeps the jobs read on this machine, to compare with after the next refresh: the day before it. failOnFindings: true ends it exit 3 on what it found. A production org is refused, and a sandbox the file does not list. SandForge changes none of what it finds: Setup, sf or a deployment puts it right.",readOnly:!1,destructive:!1,args:i.strictObject({file:Ee(),org:v("The org to audit: its sf CLI alias."),save:i.boolean().optional().describe("true: keep the scheduled jobs read, in audits/ of the journal directory by the org's host, its owner's alone, to compare with after its next refresh. Refused, exit 2, when the file's audits read no scheduled jobs."),failOnFindings:i.boolean().optional().describe("true: exit 3 on a job gone or run as a user who can no longer run it, an endpoint that names production, or a deliverability open to all email.")}),named:{"--save":`is this tool's save: ${kn}`},exits:{3:"findings: a job gone or run as a user who can no longer run it, an endpoint that names production, or a deliverability open to all email, each said above"},run:e=>({script:"sandforge-env",args:["audit","--file",e.file,"--org",e.org,...e.save===!0?["--save"]:[],...e.failOnFindings===!0?["--fail-on-findings"]:[],"--json"]})}),k({name:"pipeline_plan",title:"Plan a pipeline",description:"What a run of a pipeline exported from the Automation page would do and refuse, as sandforge pipeline plan --json says it: each org of the file reached by its alias and typed, each step, and every refusal a run would meet before its first step, with what lifts it. It reads the orgs, on a copy of the pipeline's store, and writes nothing. No tool runs a pipeline: its run is the person's, on a terminal, where its Approval steps are asked. approve answers one ahead, as a run with no terminal is answered; vars and varEnvs give its variables, a secret by varEnvs, a variable of the server's environment; acceptOrgs takes an org whose Organization Id changed since the export, a sandbox refreshed, once the person using you checked it is the one.",readOnly:!0,args:i.strictObject({file:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The pipeline file the Automation page exported (<name>.sandforge-pipeline.json), by its path; a relative path is read from where the server was started."),approve:i.array(i.string().min(1).max(200).regex(F,'one line, not starting with "-"')).min(1).max(200).optional().describe("Approval steps, by name, answered ahead, yes, as --approve answers them for a run with no terminal; never one before a write to a sandbox marked Staging."),vars:i.array(i.strictObject({name:i.string().regex(vn,"a variable of the pipeline, by its name"),value:i.string().min(1).max(2e3).regex(/^[^\r\n]*$/,"one line")})).min(1).max(200).optional().describe("Variables of the pipeline and their values. A secret goes by varEnvs."),varEnvs:i.array(i.strictObject({name:i.string().regex(vn,"a variable of the pipeline, by its name"),env:i.string().regex(An,"the name of an environment variable")})).min(1).max(200).optional().describe("Variables of the pipeline, each read from a variable of the server's environment: a secret, which neither the file nor the arguments hold."),acceptOrgs:i.array(i.strictObject({key:i.string().regex(jo,"an org of the file, by its alias or its key in its orgs"),organizationId:i.string().regex(So,"an Organization Id, 00D and 12 or 15 letters and digits")})).min(1).max(50).optional().describe("Orgs of the file whose alias reaches an org of another Organization Id than the file's \u2014 a sandbox refreshed since \u2014, taken for it once the person using you checked it is the one: the org by its alias, or by its key in the file, and the Id the plan said, as its refusal (ORG_MOVED) names them."),store:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe("Where the pipeline's runs keep their state, as its runs are given it: the plan reads a copy of it. The default is the pipeline's folder under the journal folder.")}),refuseFirst:e=>{if("org"in e||"orgs"in e)return`pipeline_plan plans the orgs the file names, each by its alias in the file: a person maps one to another alias on a terminal, ${$("pipeline")} plan --file <file> --org <key>=<alias>. Nothing was run.`;if(["dryRun","run","confirm"].some(t=>t in e))return`pipeline_plan only plans: no tool runs a pipeline. Its run is the person's, on a terminal, ${$("pipeline")} run --file <file> --dry-run first. Nothing was run.`},named:{"--approve":"is this tool's approve: the Approval steps answered ahead, by name; never one before a write to a sandbox marked Staging, which a person answers at a terminal.","--accept-org":"is this tool's acceptOrgs: the org by its alias, or by its key in the file, and the Organization Id taken for it, once the person using you checked it is the one.","--var":"is this tool's vars, a name and its value; a secret goes by varEnvs.","--var-env":"is this tool's varEnvs, a name and the variable of the server's environment that holds its value.","--store":"is this tool's store.","--org":`is no parameter of pipeline_plan, which plans the aliases the file names: a person maps an org of the file to another alias on a terminal, ${$("pipeline")} plan --file <file> --org <key>=<alias>.`,"--confirm-rewind":`is no parameter of any tool: a Rewind step is confirmed by the person, on a terminal, ${$("pipeline")} confirm --file <file>.`},exits:{2:"the plan refuses: a run would be refused before its first step, or the file does not read, each refusal said above with what lifts it; nothing ran"},run:e=>({script:"sandforge-pipeline",args:_o(e)}),settle:(e,t,n)=>Promise.resolve({...n.parts,added:[...n.parts.added,xo(e.file)]})})],ur=new Map(Fe.map(e=>[e.definition.name,e]));async function hr(){let{templateDisplayName:e}=await import("./sandforge-seed.mjs"),t=Et.map(n=>{let o=n.objects.map(r=>({objectApiName:r.objectApiName,records:r.recordCount}));return{id:n.id,name:e(n),description:e({name:n.description}),objects:o,records:o.reduce((r,s)=>r+s.records,0)}});return V(t.map(n=>`${n.id} \u2014 ${n.name}: ${n.records} records at most in ${n.objects.length} objects (${n.objects.map(o=>`${o.objectApiName} ${o.records}`).join(", ")})`),{templates:t},!1)}function V(e,t,n){return{content:[{type:"text",text:e.join(`
11
- `)},{type:"text",text:JSON.stringify(t)}],structuredContent:t,isError:n}}function lt(e,t){return V([t],{refusal:{code:e,message:t}},!0)}function pr(e){switch(e){case 0:return"done";case 1:return"refused before it wrote, could not start, or did nothing but fail";case 2:return"a request the script could not take, or a question for the person using you: nothing was written";case 3:return"partial: records were left, refused or not checked, each said with why";case 4:return"unstable: someone else wrote to the records meanwhile";default:{let t=Ue.find(n=>je(n)===e);return t!==void 0?`stopped by ${t} before it was through`:"ended on an error"}}}var ut=new Set([0,3,4]),In=new Set(Ue.map(e=>je(e))),fr="no terminal to answer",ht=(e,t)=>new RegExp(`(?<![\\w-])${t}(?![\\w-])`).test(e);function Me(e){return/^[\w.@:+/=,-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function be(e,t){let n=t.map(Me);return["npx sandforge",e.replace(/^sandforge-/,""),...n].join(" ")}function mr(e){let t=/^refused \(([A-Z][A-Z0-9_]*)\): (.+)$/m.exec(e);return t?{code:t[1]??"",message:(t[2]??"").trim()}:void 0}function pt(e){let t=e.trim();if(t!=="")try{return JSON.parse(t)}catch{return}}function Ce(e){let t=[...e.head,...e.head.length>0?[""]:[],...e.said];return e.added.length>0&&t.push("",...e.added),V(t,e.structured,e.isError)}function ii(e,t,n,o=()=>[]){return Ce(Cn(e,t,n,o))}function Cn(e,t,n,o=()=>[]){let r=pt(n.stdout),s=[`ran: ${be(t.script,t.args)}`,`exit ${n.code}: ${e.exits?.[n.code]??pr(n.code)}`],a=n.stderr.trimEnd();a!==""&&s.push("",a),r===void 0&&n.stdout.trim()!==""&&s.push("",n.stdout.trimEnd());let d=[];n.code===2&&n.stderr.includes(fr)&&d.push("The script asked the question above and had no terminal to answer it on, so it stopped having written nothing. It is a question for the person using you: no parameter of this tool answers it.");let l=`${n.stderr}
12
- ${n.stdout}`;for(let[c,A]of Object.entries(e.flags))ht(l,c)&&d.push(`${c}, named above, is this tool's ${A}: true. Give it only once the person using you has accepted what it lets through.`);for(let[c,A]of Object.entries(e.named??{}))ht(l,c)&&d.push(`${c}, named above, ${typeof A=="function"?A(l):A}`);if(ut.has(n.code))d.push(...o(r));else if(In.has(n.code)){let c=o(r);c.length>0&&d.push("It stopped part way, between two calls to the org: what it wrote is kept, and said above.",...c)}let h=r===void 0?mr(n.stderr):void 0;return{head:[],said:s,added:d,structured:{exitCode:n.code,...r!==void 0?{answer:r}:{},...h!==void 0?{refused:h}:{}},answer:r,isError:!ut.has(n.code)}}var gr=30;async function ft(e,t){let n,o=new Promise(r=>{n=setTimeout(()=>r(void 0),Math.max(0,t))});try{return await Promise.race([e,o])}finally{clearTimeout(n)}}function wr(e,t){let{handle:n,meta:o}=e;return V([`ran: ${be(t.script,t.args)}`,`still running: run_status with run "${n}" follows it (waitSeconds up to ${ae}), and gives its answer once it has ended; run_stop with run "${n}" stops it as Ctrl-C would, what it wrote kept. It runs as long as this server: closing the agent's session stops it the same way.`],{running:{run:n,tool:o.tool,startedAt:o.startedAt,...o.expectedSeconds!==void 0?{expectedSeconds:o.expectedSeconds}:{},...o.plan!==void 0?{plan:o.plan}:{},...o.summary!==void 0?{summary:o.summary}:{}}},!1)}function Nn(e,t){let n={...e.structuredContent,run:{run:t,state:"ended"}};return V([e.content[0]?.text??""],n,e.isError)}function Dn(e,t){return`${e.written} records written`+(t!==void 0?` of the ${t} its plan counted`:"")+`, of ${e.objectsWritten} objects`+(e.failed>0?`, ${e.failed} refused by the org`:"")+(e.journal!==void 0?`; its journal is ${e.journal}`:"")}async function Fn(e,t,n=!1){let o=await e.runs.progress(t),r=t.meta.plan!==void 0?await ce(e.journalDir,t.meta.plan):void 0,{handle:s}=t,a=[`run "${s}" of ${t.meta.tool} `+(t.running?n?"is stopping: it stops before its next call to the org, and says what it wrote":"is still running":"has ended, and what the server does after it \u2014 the verification of a clone \u2014 is under way")+`: ${o.elapsedSeconds} seconds since it started`+(o.expectedSeconds!==void 0?`, its plan said its writes take about ${o.expectedSeconds}`:"")+".",...o.summary?[`So far: ${Dn(o.summary,r?.totalRows)}.`]:[],...o.tail.length>0?["Its last lines:",...o.tail]:[],`run_status with run "${s}" follows it`+(t.running&&!n?`; run_stop with run "${s}" stops it.`:".")];return V(a,{running:{run:s,tool:t.meta.tool,startedAt:t.meta.startedAt,state:t.running?n?"stopping":"running":"settling",elapsedSeconds:o.elapsedSeconds,...o.expectedSeconds!==void 0?{expectedSeconds:o.expectedSeconds}:{},...r?{plan:{id:r.id,records:r.totalRows}}:{},...o.summary?{summary:o.summary}:{},tail:o.tail}},!1)}async function Mn(e,t,n){let{meta:o,summary:r}=n,s=r?.state==="running"?"its summary was last written while it ran: it was cut without saying it stopped":r?.state==="interrupted"?"it stopped part way, as its summary says":r?.state==="failed"?"it ended on an error, as its summary says":r?.state==="ended"?"it ended, as its summary says":"no summary of it is left",a=o.plan!==void 0?await ce(e.journalDir,o.plan):void 0,d=r?.journal,l=[`run "${t}" of ${o.tool} is not one of this server's: the server that started it at ${o.startedAt} has ended, which stopped it as Ctrl-C stops it. ${s}`+(r?`: ${Dn(r,a?.totalRows)}`:"")+".",...o.tool==="clone_org"&&o.plan!==void 0&&o.target!==void 0?[`clone_org with plan "${o.plan}", resume: true and confirm "${o.target}" takes it up, writing nothing twice.`]:[],...d!==void 0&&o.target!==void 0?[`run_remove with module "forge", org "${o.target}" and run "${d}" takes it back: preview: true first says what it would delete.`]:[]];return V(l,{run:{run:t,state:"gone",tool:o.tool,startedAt:o.startedAt,...o.target!==void 0?{target:o.target}:{},...o.plan!==void 0?{plan:o.plan}:{},...r?{summary:r}:{}}},!1)}function Ln(e){return lt("RUN_UNKNOWN",`No run "${e}" on this machine: this server holds none by that handle, and no server before it left one. A call answers with the handle of its run only when it is still running after its hold; the handle is in that answer.`)}async function yr(e,t,n){let o=e.runs.get(t);if(o){let s=e.finalOf(t),a=Math.min(Math.max(0,n),ae),d=s?await ft(s,a*1e3):void 0;return d?Nn(d,t):Fn(e,o)}let r=await e.runs.readOnDisk(t);return r?Mn(e,t,r):Ln(t)}async function br(e,t){let n=e.runs.get(t);if(n){let r=n.running;r&&(e.log(`sandforge mcp: run_stop stops ${t} as Ctrl-C stops its script`),n.stop());let s=e.finalOf(t),a=s?await ft(s,e.runs.holdMs):void 0;if(!a)return Fn(e,n,r);let d=Nn(a,t);return r?d:V([`run "${t}" had already ended: nothing was stopped.`,"",d.content[0]?.text??""],d.structuredContent,d.isError)}let o=await e.runs.readOnDisk(t);return o?Mn(e,t,o):Ln(t)}async function kr(e,t){let n=on(t);return e.all().find(r=>r.running&&r.meta.summary!==void 0&&on(r.meta.summary)===n)??await e.underWayWith(t)}function vr(e,t){return{code:"RUN_UNDER_WAY",message:`run_remove: ${t} is the run "${e.handle}" of ${e.meta.tool}, which this server still runs: a removal now would delete under it what it goes on writing. run_stop with run "${e.handle}" stops it, and run_status says when it has ended; then run_remove takes back what it wrote. Refused: nothing was read or written.`}}function Rr(e,t){return{code:"RUN_UNDER_WAY",message:`checkpoint_replay_remove: run "${e.handle}" of checkpoint_replay, which this server still runs, writes into ${t}: a removal now would delete under it what it goes on creating. run_stop with run "${e.handle}" stops it, and run_status says when it has ended; then checkpoint_replay_remove takes back what it created. Refused: nothing was read or written.`}}async function Wn(e,t,n,o){try{let r=new Set(t.all().filter(s=>s.running).map(s=>s.meta.plan));await nn(e,n,s=>r.has(s)),await t.sweep()}catch(r){o(`sandforge mcp: the plans and runs past their day could not all be removed: ${r instanceof Error?r.message:String(r)}`)}}var G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ie=e=>typeof e=="string"||typeof e=="number"&&Number.isInteger(e);function Ar(e){let t=e.runCommand??yo,n=e.log??(f=>{process.stderr.write(`${f}
13
- `)}),o=e.journalDir??Be(),r=e.now??(()=>new Date),s=new se({dir:xe(o),holdMs:e.holdMs??_e(),now:r}),a=new Map,d=new AbortController,l={journalDir:o,runs:s,now:r,log:n,runCommand:t,stopping:d.signal,finalOf:f=>a.get(f)},h,c=new Map,A=new Set,y=new Set,L=new Set,B=f=>{let m=f.then(()=>{},()=>{}).finally(()=>{L.delete(m)});return L.add(m),f},T=f=>{e.send(JSON.stringify({jsonrpc:"2.0",...f}))},N=(f,m)=>f==="perRequest"?{resultType:"complete",...m,_meta:{[le.serverInfo]:sn}}:m,W=f=>{let m=G(f)?f.protocolVersion:void 0;if(typeof m!="string")return{error:{code:E.invalidParams,message:"initialize names the protocol version it asks for in protocolVersion."}};let p=ge.includes(m)?m:ge[0];return h=p,n(`sandforge mcp: ${m===p?"agreed on":`asked for ${m}, offered`} ${p}`),{result:{protocolVersion:p,capabilities:{tools:{}},serverInfo:sn,instructions:an}}},ke=async(f,m,p)=>{if(!G(m)||typeof m.name!="string")return{error:{code:E.invalidParams,message:"tools/call names its tool in name."}};let g=ur.get(m.name);if(!g)return{error:{code:E.invalidParams,message:`Unknown tool: ${m.name}`}};if(m.arguments!==void 0&&!G(m.arguments))return{error:{code:E.invalidParams,message:"tools/call takes its arguments as an object."}};let x=s.newHandle(),_={handle:x,summary:s.summaryPathOf(x)};A.add(f);try{let O=await g.read(m.arguments??{},l,_);if(y.has(f))return;if("refusal"in O)return{result:N(p,{...lt(O.refusal.code,O.refusal.message)})};let{call:j}=O;if(j.writesTo!==void 0&&j.confirm!==j.writesTo)return{result:N(p,{...lt("CONFIRM",Oo(g,j.writesTo,j.confirm))})};if("local"in j.run){let ve=await j.run.local(l);return y.has(f)?void 0:{result:N(p,{...ve})}}return await zn(f,p,g,j,j.run,_)}finally{A.delete(f),y.delete(f)}},zn=async(f,m,p,g,x,_)=>{let{handle:O}=_,{script:j,args:ve,relayedBy:wt,follow:te}=x;await g.beforeStart(),n(`sandforge mcp: ${p.definition.name} runs ${be(j,ve)}`);let oe=s.start({handle:O,tool:p.definition.name,...g.writesTo!==void 0?{target:g.writesTo}:{},...te?.plan!==void 0?{plan:te.plan}:{},...te?.summary!==void 0?{summary:te.summary}:{},...te?.expectedSeconds!==void 0?{expectedSeconds:te.expectedSeconds}:{}},({signal:J,onStderr:M})=>{let re={...wt!==void 0?{relayedBy:wt}:{},onStderr:M};return t(j,ve,J,re).catch(We=>({code:1,stdout:"",stderr:`${Re(j)} could not be started: ${We instanceof Error?We.message:String(We)}`}))}),Le=B(oe.settled(async J=>{let M=Cn(p,x,J,g.after);if(!g.settle)return Ce(M);try{return Ce(await g.settle({ran:J,run:x,launch:_,parts:M,context:l}))}catch(re){return Ce({...M,added:[...M.added,`What the server does once ${p.definition.name} has ended failed: ${re instanceof Error?re.message:String(re)}.`],isError:!0})}}));a.set(O,Le),c.set(f,oe),y.has(f)&&oe.stop();try{let J=await ft(Le,s.holdMs);if(y.has(f)){await Le,a.delete(O);return}return J!==void 0?(a.delete(O),{result:N(m,{...J})}):(await s.handBack(oe).catch(M=>{n(`sandforge mcp: what a later server reads of ${O} could not be written: ${M instanceof Error?M.message:String(M)}`)}),n(`sandforge mcp: ${p.definition.name} handed back as ${O}, still running`),{result:N(m,{...wr(oe,x)})})}finally{c.delete(f)}},qn=async(f,m,p)=>{if(m==="initialize")return W(p);let g=G(p)&&G(p._meta)?p._meta:void 0,x=g?.[le.version],_;if(x!==void 0){if(x!==ee)return{error:{code:E.unsupportedVersion,message:"Unsupported protocol version",data:{supported:[ee],requested:String(x)}}};if(!G(g?.[le.capabilities]))return{error:{code:E.invalidParams,message:`A request of ${ee} names its client's capabilities in _meta["${le.capabilities}"].`}};_="perRequest"}else{if(m==="ping")return{result:{}};if(h!==void 0)_="handshake";else return{error:{code:E.invalidParams,message:`Name the protocol version in _meta["${le.version}"] (${ee}), or open with initialize (${ge.join(", ")}).`}}}switch(m){case"server/discover":if(_!=="perRequest")break;return{result:N(_,{supportedVersions:[ee],capabilities:{tools:{}},instructions:an,ttlMs:rn,cacheScope:"public"})};case"ping":return{result:N(_,{})};case"tools/list":return{result:N(_,{tools:Fe.map(O=>O.definition),..._==="perRequest"?{ttlMs:rn,cacheScope:"public"}:{}})};case"tools/call":return ke(f,p,_)}return{error:{code:E.methodNotFound,message:`${m} is not a method of this server: it serves tools/list and tools/call.`}}},Un=(f,m)=>{if(f!=="notifications/cancelled"||!G(m))return;let{requestId:p}=m;if(!Ie(p)||!A.has(p))return;y.add(p);let g=c.get(p);g&&(n(`sandforge mcp: request ${String(p)} cancelled: its script is stopped as Ctrl-C stops it`),g.stop())},Bn=f=>{let m=f.trim();if(m==="")return;let p;try{p=JSON.parse(m)}catch{T({error:{code:E.parse,message:"Parse error: a line that is not JSON."}});return}if(Array.isArray(p)){T({error:{code:E.invalidRequest,message:"A batch is not a message of this protocol: send one message a line."}});return}if(!G(p)){T({error:{code:E.invalidRequest,message:"A message is a JSON-RPC object."}});return}let{id:g,method:x,params:_}=p;if(x===void 0&&("result"in p||"error"in p))return;if(p.jsonrpc!=="2.0"||typeof x!="string"){T({...Ie(g)?{id:g}:{},error:{code:E.invalidRequest,message:'A message has jsonrpc "2.0" and a method.'}});return}if(g===void 0){Un(x,_);return}if(!Ie(g)||A.has(g)){T({error:{code:E.invalidRequest,message:Ie(g)?`A request with the id ${String(g)} is still under way: give each its own.`:"A request id is a string or a whole number."}});return}let O=qn(g,x,_).then(j=>{j!==void 0&&T({id:g,...j})}).catch(j=>{T({id:g,error:{code:E.internal,message:j instanceof Error?j.message:String(j)}})}).finally(()=>{L.delete(O)});L.add(O)},mt=async()=>{for(d.abort(),await s.stopAll();L.size>0;)await Promise.allSettled([...L])},gt=mo({input:e.input,crlfDelay:1/0});return gt.on("line",Bn),{done:new Promise(f=>{gt.once("close",()=>{mt().then(f)})}),stop:mt}}function jr(e,t){let n=e.write.bind(e);return e.write=t.write.bind(t),o=>{n(`${o}
7
+ import{e as zt}from"./chunk-IZGCEOYO.mjs";import"./chunk-24RFOFYT.mjs";import"./chunk-UIOMAX56.mjs";import{a as Be,c as Ft,g as Mt,h as He}from"./chunk-2METQHGG.mjs";import{a as Ue,b as Se,e as Nt}from"./chunk-RKTFFCNS.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-QROPNEGY.mjs";import{a as Ge,k as Lt}from"./chunk-H2BHESDA.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import{d as Dt,z as X}from"./chunk-KGU4SVIT.mjs";import{a as $,b as Ae,c as ie}from"./chunk-AL4C3GFT.mjs";import"./chunk-YA6ATMTB.mjs";import{b as It,c as Ct,h as Wt}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import{B as kt,Ra as $t,_ as U,bc as Et,da as vt,ea as Rt,ga as At,ha as jt,ia as St,na as _t,oa as xt,pa as Ot,qa as Pt,ra as je,sa as Tt,z as qe}from"./chunk-PMWAFDUB.mjs";import{A as i,b,e as z,f as ze,i as yt,k as Y,l as P,u as bt,v as Z,z as q}from"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{readFileSync as po}from"node:fs";import{join as fo,resolve as on}from"node:path";import{createInterface as mo}from"node:readline";import{randomBytes as Gt}from"node:crypto";import{open as Gn,readFile as Vt,readdir as Vn,rename as Jn,rm as Je,stat as qt}from"node:fs/promises";import{join as Xe,resolve as Ut}from"node:path";var Ke="SANDFORGE_MCP_HOLD_SECONDS",Yn=45,Zn=55,de=50,Xn=20,Kn="mcp-runs",Qn=1440*6e4,Q=/^mr-\d{8}-\d{6}-[a-z0-9]{4}$/,Bt="abcdefghijklmnopqrstuvwxyz0123456789";function Qe(e,t=new Date){let n=t.toISOString(),o=`${n.slice(0,4)}${n.slice(5,7)}${n.slice(8,10)}`,r=`${n.slice(11,13)}${n.slice(14,16)}${n.slice(17,19)}`,s=Array.from(Gt(4),a=>Bt[a%Bt.length]).join("");return`${e}-${o}-${r}-${s}`}function xe(e=process.env){let t=e[Ke]?.trim(),n=t!==void 0&&/^\d+(\.\d+)?$/.test(t)?Number(t):Number.NaN;return Number.isFinite(n)&&n<=Zn?Math.round(n*1e3):Yn*1e3}function Oe(e){return Xe(e,Kn)}function se(e){return Q.test(e)}function Ht(e,t){if(!se(t))throw new Error(`Not the handle of a run: ${t}`);return Xe(e,`${t}.json`)}function Ve(e,t){return Xe(e,`${t}.meta.json`)}var Ye=class{constructor(t=Xn){this.most=t}most;kept=[];open="";push(t){let n=`${this.open}${t}`.split(/\r?\n/);this.open=n.pop()??"";for(let o of n)this.kept.push(o),this.kept.length>this.most&&this.kept.shift()}lines(){return(this.open===""?[...this.kept]:[...this.kept,this.open]).slice(-this.most)}},_e=z().int().nonnegative().catch(0),eo=P({running:Z(!0).optional().catch(void 0),interrupted:Z(!0).optional().catch(void 0),error:b().optional().catch(void 0),journal:b().min(1).optional().catch(void 0),finishedAt:b().optional().catch(void 0),result:P({successCount:_e,updatedCount:_e,linkedCount:_e,failedCount:_e,createdByObject:Y(yt()).catch([])}).partial().catch({})});async function H(e){let t;try{t=JSON.parse(await Vt(e,"utf8"))}catch{return}let n=eo.safeParse(t);if(!n.success)return;let o=n.data,r=o.result;return{state:o.running===!0?"running":o.interrupted===!0?"interrupted":o.error!==void 0?"failed":"ended",...o.journal!==void 0?{journal:o.journal}:{},written:(r.successCount??0)+(r.updatedCount??0)+(r.linkedCount??0),failed:r.failedCount??0,objectsWritten:(r.createdByObject??[]).length,...o.finishedAt!==void 0?{finishedAt:o.finishedAt}:{}}}var to=P({handle:b().regex(Q),tool:b().min(1),target:b().min(1).optional(),plan:b().min(1).optional(),startedAt:q.datetime(),summary:b().min(1).optional(),expectedSeconds:z().nonnegative().optional()}),Ze=class{constructor(t,n,o){this.meta=t;this.ended=Promise.resolve().then(()=>n({signal:this.controller.signal,onStderr:r=>this.said.push(r)})).catch(r=>({code:1,stdout:"",stderr:`The script could not be started: ${r instanceof Error?r.message:String(r)}`})).then(r=>(this.ran=r,o(this),r))}meta;controller=new AbortController;said=new Ye;ran;final;ended;handedBack=!1;get handle(){return this.meta.handle}get result(){return this.ran}get running(){return this.ran===void 0}tail(){return this.said.lines()}stop(){this.controller.abort()}settled(t){return this.final??=this.ended.then(t),this.final}},ae=class{constructor(t){this.options=t;this.now=t.now??(()=>new Date)}options;runs=new Map;now;get holdMs(){return this.options.holdMs}newHandle(){return Qe("mr",this.now())}summaryPathOf(t){return Ht(this.options.dir,t)}start(t,n){if(!se(t.handle))throw new Error(`Not the handle of a run: ${t.handle}`);let o=new Ze({...t,startedAt:this.now().toISOString()},n,r=>{r.handedBack||this.runs.delete(r.handle)});return o.running&&this.runs.set(o.handle,o),o}async hold(t,n=this.options.holdMs){if(!t.running)return t.result;let o,r=new Promise(s=>{o=setTimeout(()=>s(void 0),Math.max(0,n))});try{return await Promise.race([t.ended,r])}finally{clearTimeout(o)}}waitFor(t,n){let o=Number.isFinite(n)?Math.min(Math.max(0,n),de):0;return this.hold(t,o*1e3)}async handBack(t){t.handedBack=!0,this.runs.set(t.handle,t),await X(this.options.dir),await et(Ve(this.options.dir,t.handle),`${JSON.stringify(t.meta)}
8
+ `)}get(t){return se(t)?this.runs.get(t):void 0}all(){return[...this.runs.values()]}busyWith(t){return this.all().find(n=>n.running&&n.meta.target===t)}async underWayWith(t){let n=Ut(t);for(let o of this.all()){if(!o.running||o.meta.summary===void 0)continue;let r=(await H(o.meta.summary))?.journal;if(r!==void 0&&Ut(r)===n)return o}}async progress(t){let n=t.meta.summary!==void 0?await H(t.meta.summary):void 0;return{elapsedSeconds:Math.max(0,Math.round((this.now().getTime()-Date.parse(t.meta.startedAt))/1e3)),...t.meta.expectedSeconds!==void 0?{expectedSeconds:t.meta.expectedSeconds}:{},...n?{summary:n}:{},tail:t.tail()}}async readOnDisk(t){if(!se(t))return;let n;try{n=to.parse(JSON.parse(await Vt(Ve(this.options.dir,t),"utf8")))}catch{return}if(n.handle!==t)return;let o=n.summary!==void 0?await H(n.summary):void 0;return{meta:n,...o?{summary:o}:{}}}async stopAll(){let t=this.all().filter(n=>n.running);for(let n of t)n.stop();await Promise.allSettled(t.map(n=>n.ended))}async sweep(){let t;try{t=await Vn(this.options.dir)}catch{return 0}let n=this.now().getTime(),o=0;for(let r of t){let s=r.replace(/\.meta\.json$/,"");if(s===r||!se(s)||this.runs.has(s))continue;let a=Ve(this.options.dir,s),d=await qt(a).catch(()=>{});if(!d||n-d.mtimeMs<Qn)continue;let h=(await this.readOnDisk(s))?.summary?.journal;h!==void 0&&await qt(h).catch(()=>{})||(await Je(Ht(this.options.dir,s),{force:!0}),await Je(a,{force:!0}),o++)}return o}};async function et(e,t){let n=`${e}.${process.pid}-${Gt(4).toString("hex")}.tmp`,o=await Gn(n,"wx",Dt);try{await o.writeFile(t,"utf8"),await o.sync()}finally{await o.close()}try{await Jn(n,e)}catch(r){throw await Je(n,{force:!0}),r}}import{existsSync as Te}from"node:fs";import{readFile as no,readdir as oo,rm as ce,stat as ro}from"node:fs/promises";import{join as D}from"node:path";var io="mcp-plans",$e=/^co-\d{8}-\d{6}-[a-z0-9]{4}$/,so=P({run:b().regex(Q),startedAt:q.datetime(),summary:b().min(1),resume:ze(),ended:P({code:z().int(),wrote:ze(),journal:b().min(1).optional()}).optional()}),nt=P({version:Z(1),id:b().regex($e),createdAt:q.datetime(),expiresAt:q.datetime(),source:b().min(1),target:b().min(1),args:Y(b()),mode:bt(["sample","whole"]),totalRows:z().int().positive(),sample:P({dir:b().min(1),sha256:b().regex(/^[0-9a-f]{64}$/),drawnAt:q.datetime()}).optional(),question:b().optional(),durationSeconds:z().nonnegative().optional(),accepted:Y(b()),runs:Y(so),dead:P({code:b().min(1),at:q.datetime()}).optional()});function Ee(e){return D(e,io)}function ne(e){return $e.test(e)}function Jt(e,t){if(!ne(t))throw new Error(`Not the id of a plan: ${t}`);return D(Ee(e),`${t}.json`)}function Pe(e,t){if(!ne(t))throw new Error(`Not the id of a plan: ${t}`);return D(Ee(e),t)}var ao=P({tool:Z("sandforge-clone"),dryRun:Z(!0),writePlan:P({totalRows:z().int().positive()}),wholeOrg:P({question:b().min(1).optional(),durationSeconds:z().nonnegative().optional().catch(void 0),sample:P({plan:P({path:b().min(1),sha256:b().regex(/^[0-9a-f]{64}$/),drawnAt:q.datetime()})}).optional()}),wouldBeRefused:Y(b()).max(0).optional()});function Yt(e){let t=ao.safeParse(e);if(!t.success)return;let{writePlan:n,wholeOrg:o}=t.data;return{mode:o.sample?"sample":"whole",totalRows:n.totalRows,...o.sample?{sample:{...o.sample.plan}}:{},...o.question!==void 0?{question:o.question}:{},...o.durationSeconds!==void 0?{durationSeconds:o.durationSeconds}:{}}}function co(e){return e.filter(t=>t!=="--dry-run"&&t!=="--json")}async function Zt(e,t,n=new Date){let o=Qe("co",n);await X(Ee(e));let r,s=t.planned.sample;if(s){await X(Pe(e,o));try{let l=await Lt(s.path,D(Pe(e,o),"sample"),s.sha256);r={dir:l.dir,sha256:l.sha256,drawnAt:l.manifest.drawnAt}}catch(l){throw await ce(Pe(e,o),{recursive:!0,force:!0}),l}}let a=Math.min(n.getTime(),r?Date.parse(r.drawnAt):n.getTime()),d={version:1,id:o,createdAt:n.toISOString(),expiresAt:new Date(a+Ge).toISOString(),source:t.source,target:t.target,args:co(t.dryRunArgs),mode:t.planned.mode,totalRows:t.planned.totalRows,...r?{sample:r}:{},...t.planned.question!==void 0?{question:t.planned.question}:{},...t.planned.durationSeconds!==void 0?{durationSeconds:t.planned.durationSeconds}:{},accepted:[...t.accepted],runs:[]};return await Xt(e,nt.parse(d)),d}async function Xt(e,t){await et(Jt(e,t.id),`${JSON.stringify(t,null,2)}
9
+ `)}async function le(e,t){if(ne(t))try{let n=nt.parse(JSON.parse(await no(Jt(e,t),"utf8")));return n.id===t?n:void 0}catch{return}}async function lo(e){return e.ended?.journal??(await H(e.summary))?.journal}async function uo(e){if(e.ended)return e.ended.wrote;let t=await H(e.summary);return t?t.written>0||t.journal!==void 0&&Te(t.journal):!0}async function ot(e,t,n=new Date){let o=await le(e,t);if(!o)return{state:"gone",why:"unknown"};let r=[];for(let s of o.runs)await uo(s)&&r.push(s);if(r.length>0){let s;for(let d of[...o.runs].reverse())if(s=await lo(d),s!==void 0)break;if(s!==void 0&&!Te(s))return{state:"gone",why:"journalGone",receipt:o};let a=o.runs[o.runs.length-1]??r[r.length-1];return{state:"written",receipt:o,run:a,...s!==void 0?{journal:s}:{}}}return o.dead?{state:"gone",why:"dead",receipt:o}:n.getTime()>=Date.parse(o.expiresAt)?{state:"gone",why:"expired",receipt:o}:{state:"ready",receipt:o}}function ho(e,t,n){let o=[];for(let r=0;r<e.length;r++){if(e[r]===t){r++;continue}o.push(e[r])}return[...o,t,n]}function Kt(e,t){let n=e.mode==="whole"?ho(e.args,"--max-total",String(e.totalRows)):[...e.args];return t.resume!==void 0?n=[...n,"--resume",t.resume]:e.sample&&(n=[...n,"--fit-plan",e.sample.dir]),[...n,"--yes","--summary",t.summary,"--json"]}async function rt(e,t,n){let o=await le(e,t);if(!o)return;let r=nt.parse(n(o));return await Xt(e,r),r}function Qt(e,t,n){return rt(e,t,o=>({...o,runs:[...o.runs,{...n}]}))}function en(e,t,n,o){let r=o.journal!==void 0&&Te(o.journal);return rt(e,t,s=>({...s,runs:s.runs.map(a=>a.run===n?{...a,ended:{code:o.code,wrote:r,...o.journal!==void 0?{journal:o.journal}:{}}}:a)}))}function tn(e,t,n,o=new Date){return rt(e,t,r=>({...r,dead:{code:n,at:o.toISOString()}}))}async function nn(e,t=new Date,n=()=>!1){let o=Ee(e),r;try{r=await oo(o)}catch{return 0}let s=0;for(let a of r){let d=a.replace(/\.json$/,"");if(ne(d)&&a===`${d}.json`){if(n(d))continue;let l=await ot(e,d,t);if(l.state!=="gone"||l.why==="unknown"&&!await tt(D(o,a),t)||l.why==="dead"&&t.getTime()<Date.parse(l.receipt?.expiresAt??""))continue;await ce(D(o,a),{force:!0}),await ce(Pe(e,d),{recursive:!0,force:!0}),s++}else if(!ne(a)&&await tt(D(o,a),t))await ce(D(o,a),{recursive:!0,force:!0}),s++;else if(ne(a)&&!Te(D(o,`${a}.json`))){if(!await tt(D(o,a),t))continue;await ce(D(o,a),{recursive:!0,force:!0}),s++}}return s}async function tt(e,t){let n=await ro(e).catch(()=>{});return n!==void 0&&t.getTime()-n.mtimeMs>=Ge}var ee="2026-07-28",we=["2025-11-25","2025-06-18","2025-03-26"],ue={version:"io.modelcontextprotocol/protocolVersion",capabilities:"io.modelcontextprotocol/clientCapabilities",serverInfo:"io.modelcontextprotocol/serverInfo"},E={parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603,unsupportedVersion:-32022},rn=60*6e4,sn={name:"sandforge",title:"SandForge",version:String(JSON.parse(po(fo(__dirname,"..","package.json"),"utf8")).version??"0.0.0")},an=`SandForge's Seed, Forge's clone of a record, of the records a query chooses or of the whole org, the removal of a run, the emptying of objects or of a whole org, Checkpoints and their replay into another org, the environments of a sandforge.yaml and the plan of an Automation pipeline, run from the sandforge npm package. Every org is named by its sf CLI alias, as \`sf alias list\` shows them. A tool that writes to an org takes confirm, the alias of that org exactly: give it only once the person using you has agreed to that write, after a dry run, a preview or a plan has said what it would do. The acceptances (acceptAutomation and the others) are theirs to give too. A production org is refused by every tool that writes to an org. Each answer carries the script's own JSON, its exit code and its lines. A clone of the whole org, or of a sample of it that fits the target: clone_org_plan, show the person the question its plan comes back with, then clone_org with that plan and confirm; its personal fields are always anonymized. A call still running after ${Math.round(xe()/1e3)} seconds hands back a run: run_status follows it, run_stop stops it. pipeline_plan says what a run of a pipeline exported from the Automation page would do and refuse, writing nothing; no tool runs one: its run is the person's, on a terminal (${$("pipeline")} run --file <file>). No tool clones whole tables (${$("clone")} --object <ApiName> --where <condition>), nor compares two orgs (${$("compare")}) or takes a DataOps snapshot (${$("backup")}): give the person the command to run in a terminal, or a sandforge.yaml resource that env_plan and env_apply run.`,go=1e6;function wo(e={}){return Ft({...e,relayedBy:"sandforge mcp"})}var yo=wo();function bo(e){let t=i.toJSONSchema(e);return delete t.$schema,t}function k(e){return{definition:{name:e.name,title:e.title,description:e.description,inputSchema:bo(e.args),annotations:{title:e.title,readOnlyHint:e.readOnly,...e.readOnly?{}:{destructiveHint:e.destructive===!0}}},...e.writes!==void 0?{writes:e.writes}:{},...e.readFirst!==void 0?{readFirst:e.readFirst}:{},flags:e.flags??{},named:e.named??{},exits:e.exits??{},read:async(t,n,o)=>{let r=e.refuseFirst?.(t);if(r!==void 0)return{refusal:{code:"ARGUMENTS",message:r}};let s=e.args.safeParse(t);if(!s.success)return{refusal:{code:"ARGUMENTS",message:`${e.name}: `+s.error.issues.map(y=>`${y.path.join(".")||"arguments"}: ${y.message}`).join("; ")+". Nothing was run."}};let a=s.data,d;if(e.prepare){let y=await e.prepare(a,n);if("refusal"in y)return y;d=y.prepared}else d=void 0;let l=e.writesTo?.(a,d),h=a.confirm,{beforeStart:c,settle:A}=e;return{call:{...l!==void 0?{writesTo:l}:{},...typeof h=="string"?{confirm:h}:{},run:e.run(a,d,o),after:y=>e.after?.(a,y)??[],beforeStart:()=>c?.(a,d,o,n)??Promise.resolve(),...A?{settle:y=>A(a,d,y)}:{}}}}}}var C=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,dn=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,ko=/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,F=/^[^-\r\n][^\r\n]*$/,vo=/^[a-z][a-z0-9-]{0,62}$/,v=e=>i.string().regex(Ct,'an sf CLI alias, or the username it stands for, not starting with "-"').describe(e),I=e=>i.string().max(255).describe(`The alias of ${e} again, exactly as given: the person using you agrees to this write. Without it, the call is refused before anything is read.`),fe=e=>i.string().min(1).max(200).regex(F,'one line, not starting with "-"').describe(e),u=e=>i.boolean().optional().describe(e),he=e=>i.strictObject({keepDays:i.number().int().min(qe.min).max(qe.max).optional().describe("The days it is kept on this machine; 0 until it is deleted (default 7)."),excluded:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects to leave out of it, by API name, named in the answer: a rewind leaves their records as they are.")}).optional().describe(`Before ${e}'s first write, take a checkpoint of each object it writes, and of each the target's flows that still run create as it writes them, held whole: {} takes it with the defaults. Its cost is that of the tables, not of the records written, and its values stay unencrypted on this machine: give it only once the person using you has seen, in a dry run with it, what it would hold and cost. Refused, ${e} writes nothing; deleted again when it writes nothing.`);function be(e){return e===void 0?[]:["--checkpoint-first",...e.keepDays!==void 0?["--checkpoint-keep-days",String(e.keepDays)]:[],...(e.excluded??[]).flatMap(t=>["--checkpoint-exclude-object",t])]}var pe=e=>u(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for the run alone, under a lease, and taken back as it ends; what no bypass keeps quiet still runs. A dry run with it says what it would assign, and assigns nothing. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`),me=e=>u(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for ${e} alone, under a lease, and taken back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`);function cn(e){return`is no parameter of ${e}: an environment's acceptance of automation is its file's. Write accept: { automation: true } on the resource whose run it names, in the file, once the person using you has accepted what fires, then call ${e} again.`}var _n={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation","--accept-no-undo":"acceptNoUndo","--accept-recreate":"acceptRecreate","--accept-outside":"acceptOutside","--accept-unseen":"acceptUnseen"},Ro=Object.fromEntries(Object.entries(_n).map(([e,t])=>[e,`is checkpoint_rewind's ${t}: true, on the rewind this preview is of. Give it only once the person using you has accepted what it lets through.`])),ln=()=>i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Limit the rewind to these objects of the checkpoint, by API name (default: every object). What they depend on is never added: the answer names it."),un=/^em-\d{8}-\d{6}-[a-z0-9]{4}$/,hn={objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Empty these objects, by API name: every record of each. Not with wholeOrg."),wholeOrg:i.literal(!0).optional().describe("Empty every object people work in, less users, setup, Chatter, history, sharing, the org's flows, settings and definitions, and the standard price book. Not with objects."),excluded:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("With wholeOrg: objects to leave out, by API name."),customSettings:u("With wholeOrg: empty the custom settings too."),files:u("With wholeOrg: empty the files and attachments too."),managedPackages:u("With wholeOrg: empty the objects of managed packages too."),unrestorable:u("With wholeOrg: empty too, by passes of their own, the objects whose records Salesforce does not bring back from the recycle bin on their own. Only once the person using you has accepted that Undo cannot bring those back."),hardDelete:u("Delete for good, with what goes along: nothing goes to the recycle bin and no undo brings anything back. Needs the Bulk API Hard Delete permission of the user. Only once the person using you has accepted that nothing can be brought back."),checkpointFirst:u("Take a checkpoint of the objects emptied before the first delete, to rewind to."),acceptAutomation:u("Empty although the org runs flows, Apex triggers, processes or workflow rules as the records are deleted, or would not say what it runs."),acceptEmails:u("Empty although the org delivers every email what still runs as the records go sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:me("the emptying"),acceptNoUndo:u("Empty although some records go before a record they name, as Salesforce requires, so that Undo cannot bring them back once both have gone."),acceptPeopleActive:u("Empty although people other than the user changed records of these objects in the hour before the read, their work going with it: empty_preview says how many and each one's last change. It covers those the preview named, and taking up a run, whoever. Only once the person using you has accepted that their work goes.")};function pn(e){return[e.objects,e.wholeOrg,e.resume].filter(n=>n!==void 0).length===1}function fn(e){return[...e.objects!==void 0?["--objects",e.objects.join(",")]:[],...e.wholeOrg===!0?["--org"]:[],...(e.excluded??[]).flatMap(t=>["--exclude-object",t]),...e.customSettings===!0?["--custom-settings"]:[],...e.files===!0?["--files"]:[],...e.managedPackages===!0?["--managed-packages"]:[],...e.unrestorable===!0?["--unrestorable"]:[],...e.hardDelete===!0?["--hard-delete"]:[],...e.checkpointFirst===!0?["--checkpoint-first"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[]]}function it(e){return[...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[]]}var xn={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},mn={...xn,"--accept-no-undo":"acceptNoUndo","--accept-people-active":"acceptPeopleActive"},gn={"--undo":"is empty_undo, with the run the line names: it brings back what that run deleted.","--resume":"is empty_run's resume, with the run the line names: it takes that run up."};function Ao(e){if(typeof e!="object"||e===null)return[];let{result:t}=e;return typeof t?.runId=="string"&&t.runId!==""&&t.undo?.offered===!0?[`empty_undo with run "${t.runId}" brings back what it deleted while the recycle bin holds it, as long as no other emptying of the org follows.`]:[]}var Ie=()=>i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The sandforge.yaml, by its path; a relative path is read from where the server was started."),wn=e=>u(`${e} Only once the person using you has accepted that Salesforce emails these people.`),yn=e=>i.array(i.string().regex(vo,"a resource of the file, by its name")).min(1).max(50).optional().describe(e);function bn(e){return e==="plan"?{"--replace":"is this tool's replace: the resources, by their names in the file, it plans replaced as env_apply's replace replaces them.","--replace-drifted":"is this tool's replaceDrifted: true plans every drifted resource replaced, as env_apply's replaceDrifted replaces them."}:{"--replace":"is this tool's replace: the resources to replace, by their names in the file. Give it only once the person using you has agreed to it.","--replace-drifted":"is this tool's replaceDrifted: true replaces every drifted resource. Give it only once the person using you has agreed to it."}}var kn="it keeps the scheduled jobs read on this machine, to compare with after the next refresh.",vn=/^[^=\r\n-][^=\r\n]{0,199}$/,jo=/^[^\s=-][^\s=]{0,199}$/,So=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function _o(e){return["plan","--file",e.file,...(e.acceptOrgs??[]).flatMap(t=>["--accept-org",`${t.key}=${t.organizationId}`]),...(e.vars??[]).flatMap(t=>["--var",`${t.name}=${t.value}`]),...(e.varEnvs??[]).flatMap(t=>["--var-env",`${t.name}=${t.env}`]),...(e.approve??[]).flatMap(t=>["--approve",t]),...e.store!==void 0?["--store",e.store]:[],"--json"]}function xo(e){return`No tool runs a pipeline: its run is the person's, on a terminal, ${$("pipeline")} run --file ${ie(e)} --dry-run first, then without --dry-run. This plan had no terminal: an Approval step it says has no one to ask (APPROVAL_NO_TERMINAL) is asked there, or answered ahead by approve.`}function Oo(e,t,n){let o=n===void 0?"gives no confirm":`gives confirm "${n}", which is not "${t}", the alias of the org it writes to`;return`${e.definition.name} writes to ${t}: it ${e.writes??"writes to the org"}. This call ${o}. `+(e.readFirst!==void 0?`Before it, ${e.readFirst}. `:"")+`Give confirm: "${t}" once the person using you has agreed to this write. Refused: nothing was read or written.`}function st(e,t){if(typeof t!="object"||t===null)return[];let{runFile:n,journal:o}=t,r=e==="seed"?n:o;return typeof r=="string"?[`run_remove with module "${e}" and run "${r}" takes this run back.`]:[]}function ye(e){if(typeof e!="object"||e===null)return[];let{checkpoint:t}=e;return t?.state==="taken"&&typeof t.checkpointId=="string"?[`checkpoint_rewind with checkpoint "${t.checkpointId}" returns the org to how it was before this run, and takes back what anyone did since on the objects it holds: checkpoint_preview says what it would do first.`]:[]}var Rn=()=>i.string().min(1).max(512).regex(F,'one line, not starting with "-"').refine(e=>vt.safeParse(e).success,{message:"a SOQL condition without WHERE: no comment marker (--, /*, */) and no ; at its end"}).describe("A SOQL WHERE condition, without WHERE."),An=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,at={checkpoint:fe("The checkpoint: its id, as checkpoint_list names it; or its name, or latest, with from."),from:v("With a checkpoint named by its name or latest: the org it was taken of, by its alias, its username or its Organization Id, as checkpoint_list names it. Refreshed or expired since, it is not reached.").optional()};function On(e,t){e.from!==void 0&&e.checkpoint===void 0&&t.addIssue({code:"custom",path:["from"],message:"from goes with checkpoint, named by its name or latest"}),e.checkpoint!==void 0&&e.from===void 0&&!$t.safeParse(e.checkpoint).success&&t.addIssue({code:"custom",path:["from"],message:`"${e.checkpoint}" is not a checkpoint's id: a name, or latest, names one of an org's checkpoints, so give from, the org it was taken of, or its id`})}function dt(e){return e.preview===!0||e.sweepList===!0}function Po(e,t){let n=(o,r)=>t.addIssue({code:"custom",path:[o],message:r});if(e.sweep===!0&&e.sweepList===!0&&n("sweepList","sweep deletes and sweepList only lists: give one of them"),e.preview===!0&&e.sweepList===!0&&n("sweepList","preview deletes nothing, and sweepList lists what a sweep would take: give preview without it, or with sweep"),e.sweep!==!0&&e.sweepList!==!0)for(let o of["sweepLate","sweepUntied"])e[o]===!0&&n(o,`${o} goes with sweep, or with sweepList to see what it would take`)}var To=["maxRecords","objects","excludedObjects","owners","customSettings","mask","again","acceptAutomation","acceptEmails","muteAutomation","checkpointFirst"];function $o(e,t){let n=(o,r)=>t.addIssue({code:"custom",path:[o],message:r});if(e.checkpoint===void 0==(e.file===void 0)&&n("checkpoint","give checkpoint, one kept on this machine, or file, a .sfcheckpoint a teammate sent: one of them"),e.file!==void 0&&e.keyEnv===void 0&&n("keyEnv","a file goes with keyEnv, the name of the variable of the server's environment that holds its key: no terminal is there to type it"),e.keyEnv!==void 0&&e.file===void 0&&n("keyEnv","keyEnv goes with file: a checkpoint kept on this machine needs no key"),On(e,t),e.dryRun===void 0==(e.verify===void 0)&&n("dryRun","give dryRun \u2014 true first, then false to replay \u2014 or verify: true, one of them"),e.verify===!0)for(let o of To)e[o]!==void 0&&n(o,`${o} goes with a replay or its dry run: verify reads the choices its last replay was made with, and writes nothing`);e.dryRun===!1&&e.maxRecords===void 0&&n("maxRecords","a replay that writes takes maxRecords, the count its dry run said, once the person using you has agreed to that many"),e.dryRun===!0&&e.maxRecords!==void 0&&n("maxRecords","maxRecords goes with dryRun: false: the dry run says the count")}function Pn(e){return e.file!==void 0?["--file",e.file,"--key-env",e.keyEnv??""]:["--checkpoint",e.checkpoint??"",...e.from!==void 0?["--from",e.from]:[]]}function Tn(e){return["replay",...Pn(e),"--target",e.target,...e.verify===!0?["--verify"]:e.dryRun===!0?["--dry-run"]:[],...e.objects!==void 0?["--objects",e.objects.join(",")]:[],...(e.excludedObjects??[]).flatMap(t=>["--exclude-object",t]),...e.owners!==void 0?["--owners",e.owners]:[],...e.customSettings===!0?["--custom-settings"]:[],...e.mask===!0?["--mask"]:[],...e.again===!0?["--again"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...be(e.checkpointFirst),...e.dryRun===!1?["--max-records",String(e.maxRecords),"--yes"]:[],"--json"]}function Eo(e){let t=w(w(e).plan).perObject;if(Array.isArray(t))return t.reduce((n,o)=>n+(R(w(o).toInsert)??0),0)}function Io(e,t){let n=Eo(t);return n===void 0||n===0?[]:[`checkpoint_replay with the same parameters, dryRun: false, maxRecords: ${n} and confirm "${e.target}" creates them, once the person using you has agreed to it; checkpoint_replay_remove takes it back.`]}var Co=/\b(requiredFieldDefaults|requiredLookupPlaceholders)\["([^"\]\n]+)"\]/g;function No(e,t){if(!ht(t,"LOAD_CONFIG"))return;let n={};for(let[,r="",s=""]of t.matchAll(Co)){let a=n[r]??={};a[s]=r==="requiredFieldDefaults"?"\u2026":{name:"\u2026"}}let o=Tn({...e,dryRun:!0,verify:void 0,maxRecords:void 0}).filter(r=>r!=="--json");return"LOAD_CONFIG, named above, is no parameter of this tool: the values of the required fields it names are the person\u2019s to declare"+(Object.keys(n).length>0?`, in a file such as ${JSON.stringify(n)}`:"")+`, and the replay goes from a terminal, its dry run first: ${$("checkpoint")} ${o.map(r=>ie(r)).join(" ")} --replay-config <file.json>`}function Do(e){return Array.isArray(e)?e.flatMap(t=>{let{id:n,replayWith:o}=w(t),r=S(o);if(typeof n!="string"||r===void 0)return[];let s=/--target (\S+)/.exec(r)?.[1];return[`checkpoint "${n}" no longer rewinds its org, and replays into another: checkpoint_replay with checkpoint "${n}", `+(s!==void 0&&s!=="<alias>"?`target "${s}"`:"target the org it goes into")+" and dryRun: true says what it would create there."]}):[]}async function Fo(e,t){let{parts:n,context:o}=t,r=["replays","--target",e,"--json"],s;try{s=await o.runCommand("sandforge-checkpoint",r,o.stopping)}catch(h){s={code:1,stdout:"",stderr:`${Ae("sandforge-checkpoint")} could not be started: ${h instanceof Error?h.message:String(h)}`}}let a=`read by: ${ke("sandforge-checkpoint",r)}`,d=pt(s.stdout);if(s.code!==0||!Array.isArray(d))return{...n,added:[...n.added,`The replays into ${e} could not be read (exit ${s.code}): ${s.stderr.trimEnd()}`,a]};let l=d.map(w).filter(h=>(R(h.inPlace)??0)>0);return{...n,added:[...n.added,d.length===0?`No replay into ${e} is kept on this machine.`:`${d.length} replay(s) into ${e} kept on this machine, ${l.length} of them with records still there (replays):`,...l.map(h=>` checkpoint "${String(h.checkpointId)}": ${String(h.inPlace)} record(s) in ${e}; checkpoint_replay_remove with checkpoint "${String(h.checkpointId)}" and target "${e}" takes them back, preview: true first.`),a],structured:{...n.structured,replays:d}}}function $n(e){return`SELECT Id FROM ${e.object}`+(e.where!==void 0?` WHERE ${e.where}`:"")+(e.orderBy!==void 0?` ORDER BY ${e.orderBy}`:"")+` LIMIT ${e.limit}`}function En(e){return[...e.recordIds!==void 0?[...e.recordIds.flatMap(n=>["--record",n]),"--max-roots",String(e.recordIds.length)]:["--query",$n({object:e.object??"",where:e.where,orderBy:e.orderBy,limit:e.limit??U}),"--max-roots",String(e.limit??U)],"--source",e.source,"--target",e.target,...e.depth===void 0?[]:typeof e.depth=="number"?["--depth","custom","--custom-depth",String(e.depth)]:["--depth",e.depth],...e.maxNodes!==void 0?["--max-nodes",String(e.maxNodes)]:[],...e.maxReadTotal!==void 0?["--max-read-total",String(e.maxReadTotal)]:[],...e.dryRun?["--dry-run"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...be(e.checkpointFirst),"--json"]}function Mo(e,t){let n=w(w(t).targetGaps).gaps;if(!Array.isArray(n))return[];let o=Lo(t),r=n.map(w).flatMap(d=>{let l=S(d.objectApiName),h=S(d.field);return d.kind==="required_field_missing"&&d.answeredBy===void 0&&l!==void 0&&h!==void 0&&o.has(l)?[{object:l,field:h}]:[]});if(r.length===0)return[];let s=En({...e,dryRun:!0}).filter(d=>d!=="--json"),a=r.map(({object:d,field:l})=>({object:d,field:l,value:"\u2026"}));return[...r.map(({object:d,field:l})=>`${d}.${l} is a field ${e.target} requires that the clone does not write: a real run sees every record of ${d} refused, and no parameter of this tool gives it a value.`),`The person using you gives ${r.length===1?"it":"them"} in a Forge configuration file, ${JSON.stringify({defaultValues:a})}, and clones from a terminal, its dry run first: ${$("clone")} ${s.map(d=>ie(d)).join(" ")} --config <file.json>`]}function Lo(e){let t=w(e),n=w(t.writePlan).objects,o=Array.isArray(n)?n.map(w).filter(r=>(R(r.rows)??0)>0):(()=>{let r=w(t.result).readByObject;return Array.isArray(r)?r.map(w).filter(s=>(R(s.read)??0)>0):[]})();return new Set(o.flatMap(r=>S(r.objectApiName)??[]))}var Wo="is this tool's object, where, orderBy and limit: the query they make, SELECT Id FROM <object> WHERE <where> ORDER BY <orderBy> LIMIT <limit>.",zo=/--query "SELECT Id FROM [^"]* ORDER BY ([^"]+?) LIMIT (\d+)"/;function qo(e){let t=zo.exec(e);return t?`is this call with limit: ${t[2]??""} and orderBy: "${t[1]??""}", its object and where as they were: dryRun: true first.`:Wo}function Uo(e,t){let n=(r,s)=>t.addIssue({code:"custom",path:[r],message:s});if(e.object===void 0==(e.recordIds===void 0)){n("object","give object, with limit, for the records a query chooses, or recordIds, the records named one by one: one of them");return}if(e.recordIds!==void 0){for(let s of["where","orderBy","limit"])e[s]!==void 0&&n(s,`${s} goes with object: recordIds names its records one by one`);let r=[...new Set(e.recordIds.map(s=>s.slice(0,3)))];r.length>1&&n("recordIds",`the records of one object: these are of ${r.length} (${r.map(s=>`${s}\u2026`).join(", ")}); clone each object\u2019s apart`);return}if(e.limit===void 0){n("limit",`limit goes with object: the most records the query chooses, 1 to ${U}, which the run clones and no more`);return}let o=jt($n({object:e.object??"",where:e.where,orderBy:e.orderBy,limit:e.limit}));o!==void 0&&n(o.kind==="orderBy"?"orderBy":o.kind==="object"?"object":"where",`${St(o)} (ROOTS_QUERY_REFUSED)`)}var Bo={seed:"sandforge-seed",forge:"sandforge-clone",sync:"sandforge-sync"},ct=`An agent's clone of the whole org always anonymizes its personal fields: no tool copies them as the source holds them. A person who means to does it on a terminal, ${$("clone")} --depth all --source <alias> --target <alias> --no-anonymize after its --dry-run, or in a sandforge.yaml whose depth: all resource says accept: { realData: true }, reviewed where the repository is, that env_plan and env_apply run.`,Ho=/^[A-Za-z][A-Za-z0-9_]{0,79}\.[A-Za-z][A-Za-z0-9_]{0,79}$/,jn=e=>i.string().refine(t=>je(t,e)!==void 0,{message:"a date, as 2025-06-30, or an instant in UTC, as 2025-06-30T12:00:00Z"}),Go=()=>i.strictObject({field:i.enum(["created","modified"]).describe("created: the roots made in the window; modified: those last changed in it."),from:jn(!1).optional().describe("Its start: a date, from 00:00 UTC, or an instant in UTC."),to:jn(!0).optional().describe("Its end, left out of it: a date alone takes its whole day."),lastDays:i.number().int().min(1).max(_t).optional().describe("The last days, counted back from when the sample is drawn; not with from or to.")}).superRefine((e,t)=>{(e.from!==void 0||e.to!==void 0)===(e.lastDays!==void 0)&&t.addIssue({code:"custom",path:["lastDays"],message:"a window gives from, to or both, or lastDays: one or the other"});let o=e.from!==void 0?je(e.from,!1):void 0,r=e.to!==void 0?je(e.to,!0):void 0;o!==void 0&&r!==void 0&&o>=r&&t.addIssue({code:"custom",path:["to"],message:"a window starts before it ends: no root is made in this one"})}).optional().describe("With fit: draw only the roots made, or last changed, in a window of dates, in UTC. The records under or above a root come whatever their date."),Vo=()=>i.array(i.string().regex(Pt,"a field, as RecordTypeId, or an object and its field, as Account.RecordTypeId")).min(1).max(xt).superRefine((e,t)=>{let n=Tt.safeParse(e);if(!n.success)for(let o of n.error.issues)t.addIssue({code:"custom",path:[...o.path],message:o.message})}).optional().describe("With fit: keep the same share of the roots of each value of a picklist, a checkbox or a lookup (RecordTypeId, OwnerId), at least fitFloor of each value: Field, of every object drawn that has it, or Object.Field, one field of each object."),Jo=1e6,Yo=["plan","confirm","resume"],Zo=new Set(["SAMPLE_PLAN_MISMATCH","SAMPLE_PLAN_GONE","MAX_TOTAL_EXCEEDED","STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED"]);function Xo(e){return e.lastDays!==void 0?`${e.field}:${e.lastDays}d`:`${e.field}:${e.from??""}..${e.to??""}`}function Ko(e){return["--depth","all","--source",e.source,"--target",e.target,...e.fit!==void 0?["--fit",e.fit]:[],...e.fitWithinMB!==void 0?["--fit-within",String(e.fitWithinMB)]:[],...e.fitSeed!==void 0?["--fit-seed",String(e.fitSeed)]:[],...e.fitDraw!==void 0?["--fit-draw",e.fitDraw]:[],...e.fitWindow!==void 0?["--fit-window",Xo(e.fitWindow)]:[],...(e.fitWhere??[]).flatMap(t=>["--fit-where",`${t.objectApiName}=${t.where}`]),...(e.fitStrata??[]).flatMap(t=>["--fit-strata",t]),...e.fitParents!==void 0?["--fit-parents",e.fitParents]:[],...e.fitChildren!==void 0?["--fit-children",String(e.fitChildren)]:[],...(e.fitWhole??[]).flatMap(t=>["--fit-whole",t]),...e.fitFloor!==void 0?["--fit-floor",String(e.fitFloor)]:[],...e.maxTotal!==void 0?["--max-total",String(e.maxTotal)]:[],...(e.excludedObjects??[]).flatMap(t=>["--exclude-object",t]),...(e.excludedFields??[]).flatMap(t=>["--exclude",t]),...(e.filters??[]).flatMap(t=>["--filter",`${t.objectApiName}=${t.where}`]),"--anonymize",...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...be(e.checkpointFirst),"--skip-preflight","--dry-run","--json"]}function Qo(e){return[...e.acceptAutomation===!0?["acceptAutomation"]:[],...e.acceptEmails===!0?["acceptEmails"]:[],...e.muteAutomation===!0?["muteAutomation"]:[],...e.checkpointFirst!==void 0?["checkpointFirst"]:[]]}function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function R(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function S(e){return typeof e=="string"&&e!==""?e:void 0}function er(e,t){let n=w(t),o=w(n.wholeOrg),r=w(o.storage),s=w(o.requests),a=w(o.sample),d=y=>R(w(y).estimate),l={...R(r.estimateMB)!==void 0?{estimate:R(r.estimateMB)}:{},...R(r.remainingMB)!==void 0?{remaining:R(r.remainingMB)}:{}},h={...d(s.target)!==void 0?{target:d(s.target)}:{},...d(s.source)!==void 0?{source:d(s.source)}:{}},c=S(w(a.budget).limitedBy),A=w(a.roots);return{id:e.id,expiresAt:e.expiresAt,mode:e.mode,source:e.source,target:e.target,records:e.totalRows,objects:Array.isArray(o.wouldInsert)?o.wouldInsert.length:0,...Object.keys(l).length>0?{storageMB:l}:{},...Object.keys(h).length>0?{requests:h}:{},...d(o.bulkBatches)!==void 0?{bulkBatches:d(o.bulkBatches)}:{},...e.durationSeconds!==void 0?{durationSeconds:e.durationSeconds}:{},...e.question!==void 0?{question:e.question}:{},anonymize:n.anonymize!==!1,accepted:[...e.accepted],...e.mode==="sample"?{sample:{...R(a.share)!==void 0?{share:R(a.share)}:{},...R(a.seed)!==void 0?{seed:R(a.seed)}:{},...S(a.draw)!==void 0?{draw:S(a.draw)}:{},...c!==void 0?{limitedBy:c}:{},...Object.keys(A).length>0?{roots:A}:{}}}:{}}}function tr(e){let t=e.draw==="recent"?"newest first":e.draw==="oldest"?"oldest first":void 0,n=e.roots??{},o=[...n.window!==void 0?["within a window of their dates"]:[],...n.where!==void 0?["among the records a condition keeps"]:[],...n.strata!==void 0?["by strata"]:[]];return t===void 0&&o.length===0?"":`, its roots drawn ${[...t!==void 0?[t]:[],...o].join(", ")}`+(o.length>0?" (plan.sample.roots says how)":"")}function nr(e){let t=e.sample?.share,n=e.mode==="sample"?`a sample of ${e.source}`+(t!==void 0?`, ${Math.round(t*1e3)/10} % of each object's roots`:"")+(e.sample!==void 0?tr(e.sample):"")+(e.sample?.limitedBy!==void 0?`, held by ${e.sample.limitedBy}`:""):`every record of ${e.source} it can take`;return[`The plan "${e.id}": ${e.records} records of ${e.objects} objects into ${e.target}, ${n}, every personal field anonymized`+(e.durationSeconds!==void 0?`; its writes take about ${e.durationSeconds} seconds`:"")+`. It holds until ${e.expiresAt}`+(e.accepted.length>0?`, with ${e.accepted.join(", ")} given`:"")+".",...e.question!==void 0?[`Its question, which a terminal would ask before the first write: ${e.question}`]:[],`Show the person this plan and its question. clone_org with plan "${e.id}" and confirm "${e.target}" writes it and nothing else, once they have said yes: nothing is written before.`]}async function or(e,t){let{ran:n,run:o,parts:r,context:s}=t;if(n.code!==0)return r;let a=Yt(r.answer);if(!a)return{...r,added:[...r.added,"No plan was kept: the dry run counted no record to write, or answered otherwise than a dry run of the whole org that would go. Nothing was written."]};let d;try{d=await Zt(s.journalDir,{source:e.source,target:e.target,dryRunArgs:o.args,planned:a,accepted:Qo(e)},s.now())}catch(h){let c=`No plan was kept: the plan of ids its dry run drew is no longer the one it gave \u2014 ${h instanceof Error?h.message:String(h)}. clone_org_plan again draws one, kept as it is shown. Nothing was written.`;return{...r,added:[...r.added,c],structured:{...r.structured,refusal:{code:"PLAN_NOT_KEPT",message:c}},isError:!0}}let l=er(d,r.answer);return{...r,added:[...r.added,...nr(l)],structured:{...r.structured,plan:l}}}function rr(e,t,n){switch(t){case"expired":return`plan "${e}" held until ${n?.expiresAt??"a day after it was drawn"}, and no run of it wrote`;case"dead":return`plan "${e}" no longer holds: a run of it was refused`+(n?.dead!==void 0?` (${n.dead.code})`:"")+" for what changed since it was planned, writing nothing";case"journalGone":return`a run of plan "${e}" wrote, and its journal is no longer on this machine: nothing says what it wrote, to take up or back`;default:return`plan "${e}" is not on this machine`}}async function ir(e,t){let n=e.plan,o=await ot(t.journalDir,n,t.now()),r="Refused: nothing was read or written.";if(o.state==="gone")return{refusal:{code:"PLAN_GONE",message:`clone_org: ${rr(n,o.why,o.receipt)}. clone_org_plan again with the same parameters says what a clone would write now: show the person its question, then clone_org with its plan. ${r}`}};let{receipt:s}=o;if(o.state==="written"){let d=o.run.run,l=t.runs.get(d)?.running===!0,h=o.journal,c=h!==void 0?`run_remove with module "forge", org "${s.target}" and run "${h}" (preview: true first) takes it back`:`run_status with run "${d}" says what is known of it`;if(e.resume!==!0||l)return{refusal:{code:"PLAN_USED",message:`clone_org: plan "${n}" ${l?"is being written by":"was written by"} run "${d}"${h!==void 0?`, whose journal is ${h}`:""}: a plan is written once. run_status with run "${d}" `+(l?"follows it, and run_stop stops it":"says how it ended")+`; clone_org with plan "${n}", resume: true and confirm "${s.target}" takes up a run of it that stopped part way; ${c}. ${r}`}};if(h===void 0)return{refusal:{code:"NOTHING_TO_RESUME",message:`clone_org: run "${d}" of plan "${n}" named no journal, so nothing says what it wrote and no resume takes it up. ${c}. ${r}`}}}else if(e.resume===!0)return{refusal:{code:"NOTHING_TO_RESUME",message:`clone_org: no run of plan "${n}" has written, and resume takes up a run that stopped part way. clone_org with plan "${n}" and confirm "${s.target}", without resume, writes it. ${r}`}};let a=t.runs.busyWith(s.target);return a?{refusal:{code:"TARGET_BUSY",message:`clone_org: ${s.target} is being written by run "${a.handle}" of ${a.meta.tool}, which this server runs: two runs writing one org at once could not tell their records apart. run_status with run "${a.handle}" says when it has ended, and run_stop stops it. ${r}`}}:{prepared:{receipt:s,...o.state==="written"&&o.journal!==void 0?{journal:o.journal}:{}}}}function sr(e){return S(w(e).journal)}var ar=50;async function dr(e,t,n){let o=["--verify",n,"--source",t.source,"--target",t.target,"--json"],r;try{r=await e.runCommand("sandforge-clone",o,e.stopping,{relayedBy:He})}catch(c){r={code:1,stdout:"",stderr:`${Ae("sandforge-clone")} could not be started: ${c instanceof Error?c.message:String(c)}`}}let s=w(w(pt(r.stdout)).result),a=S(s.verdict),d=Array.isArray(s.objects)?s.objects.map(w):[],l=c=>d.reduce((A,y)=>A+(R(y[c])??0),0),h=l("moreInTheWindow");return{said:{exitCode:r.code,...a!==void 0?{status:a.toUpperCase(),expected:l("expected"),present:l("present"),deleted:l("deleted"),notVisible:l("notVisible"),linksBroken:l("linksBroken"),unchecked:d.filter(c=>S(c.error)!==void 0||S(c.linksUnchecked)!==void 0).length,...h>0?{moreInTheWindow:h}:{}}:{},...a!==void 0&&a!=="verified"?{objects:d.filter(c=>(R(c.present)??0)<(R(c.expected)??0)||(R(c.linksBroken)??0)>0||(R(c.moreInTheWindow)??0)>0||S(c.error)!==void 0||S(c.linksUnchecked)!==void 0).slice(0,ar).map(c=>({objectApiName:c.objectApiName,expected:c.expected,present:c.present,deleted:c.deleted,notVisible:c.notVisible,linksBroken:c.linksBroken,...R(c.withTheirRecord)!==void 0?{withTheirRecord:c.withTheirRecord}:{},...(R(c.moreInTheWindow)??0)>0?{moreInTheWindow:c.moreInTheWindow}:{},...S(c.error)!==void 0?{error:c.error}:{},...S(c.linksUnchecked)!==void 0?{linksUnchecked:c.linksUnchecked}:{}}))}:{}},line:`verified by: ${ke("sandforge-clone",o)}`,stderr:r.stderr.trimEnd()}}function cr(e,t){let n=e.expected!==void 0?`${e.present??0} of the ${e.expected} records the run created read back from ${t}`+(e.deleted?`, ${e.deleted} in its recycle bin`:"")+(e.notVisible?`, ${e.notVisible} out of sight`:"")+(e.linksBroken?`; ${e.linksBroken} lookups not where the run set them`:"")+(e.unchecked?`; ${e.unchecked} objects not read or checked whole`:""):"",o=(e.objects??[]).filter(s=>(R(s.moreInTheWindow)??0)>0),r=(e.present??0)<(e.expected??0)||(e.linksBroken??0)>0?`${t} does not hold all of it as it was written`:o.length>0?`${t} holds ${e.moreInTheWindow??0} records more of ${o.map(s=>S(s.objectApiName)??"").join(", ")}, created during the run by the user it wrote as, than the run wrote and the platform wrote with its records`:"what it wrote could not all be checked";switch(e.status){case"VERIFIED":return`Verification: VERIFIED \u2014 ${n}, every lookup checked where the run set it.`;case"PARTIAL":return`Verification: PARTIAL \u2014 the clone ended, and ${r}: ${n}. verification.objects names the objects, each with what it found.`;case"UNSTABLE":return`Verification: UNSTABLE \u2014 no two readings of ${t} agreed: something still writes to the run's records (${n}). run_status says it again, verified again, once nothing does.`;default:return`Verification: not done \u2014 the verification of the run ended on ${e.exitCode} (its lines follow): what the clone wrote is not known to be there.`}}async function lr(e,t){let{ran:n,launch:o,parts:r,context:s}=t,{receipt:a}=e,d=w(r.answer),l=sr(d)??(await H(o.summary))?.journal;await en(s.journalDir,a.id,o.handle,{code:n.code,...l!==void 0?{journal:l}:{}});let h=[],c=[...r.added],A=r.structured,y=l!==void 0?`run_remove with module "forge", org "${a.target}" and run "${l}" takes it back: preview: true first says what it would delete.`:void 0,L=w(d.refused),B=S(L.code);if(ut.has(n.code)){let T=w(d.result),N=R(T.successCount);if(N!==void 0&&c.push(`It created ${N} records of the ${a.totalRows} its plan counted`+(R(T.failedCount)?`, ${R(T.failedCount)} refused`:"")+"."),l!==void 0){let W=await dr(s,a,l),ve=cr(W.said,a.target);W.said.status==="VERIFIED"?c.push(ve,W.line):(h.push(ve),c.push(W.line,...W.stderr!==""?[W.stderr]:[])),A={...A,verification:W.said}}y!==void 0&&c.push(`This run: ${y}`),c.push(...ye(d))}else if(In.has(n.code))c.push(l!==void 0?`It stopped part way, between two calls to the org: its journal ${l} holds what it wrote. clone_org with plan "${a.id}", resume: true and confirm "${a.target}" takes it up, writing nothing twice; ${y??""}`:`It stopped before it wrote anything: plan "${a.id}" still holds until ${a.expiresAt}, and clone_org with it writes it.`),c.push(...ye(d));else if(B!==void 0&&Zo.has(B))await tn(s.journalDir,a.id,B,s.now()),c.push(`The plan no longer holds (${B}): what it was drawn or counted from changed since. clone_org_plan again with the same parameters says what a clone would write now; show the person its question, then clone_org with its plan. Nothing was written.`);else if(B==="API_BUDGET_EXCEEDED")c.push(`Plan "${a.id}" still holds until ${a.expiresAt}: clone_org with it again once the org has the requests it takes, within its day, or clone_org_plan again. Nothing was written.`);else if(B==="RESUME_UNCERTAIN"){let T=S(L.retryAt);c.push(T!==void 0?`clone_org with plan "${a.id}", resume: true and confirm "${a.target}" again from ${T}, once the calls the run left under way have ended. Nothing was written.`:`${y??"run_remove takes back what it wrote"} Nothing was written.`)}return{...r,head:h,added:c,structured:A}}var Me=[k({name:"seed_templates",title:"Seed templates",description:"The built-in Seed templates, as the Seed page's gallery lists them: id, name, what it is for, and the records each object gets at most. The first is the one a new Developer Edition holds whole. seed_run takes the id. Reads no org.",readOnly:!0,args:i.strictObject({}),run:()=>({local:hr})}),k({name:"seed_run",title:"Seed an org",description:`Fill an org with records, from a Seed template (template, an id seed_templates gives) or with generated rows (objects), as sandforge seed --json does. Run it with dryRun: true first: it reads the org and writes nothing, and says what a real run would meet \u2014 the data storage it takes, the emails the org's automation would send, what runs as the records are created. Past the storage the org has left, it says the counts that fit; fit: "share" seeds them, the largest share of every count that fits, and fitWithinMB holds the run to fewer MB still. checkpointFirst takes a checkpoint of what the run writes before its first write, and a dry run says what it would hold and cost. dryRun: false writes, a production org refused, and needs confirm. acceptEmails lets it write although the org delivers every email what still runs sends, or would not say whether it does; muteAutomation keeps the org's automation quiet for the run through its own bypass, and a dry run with it says what it would assign. The answer names the run file, which run_remove with module "seed" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:i.strictObject({org:v("The org to fill: its sf CLI alias."),template:i.string().regex(ko,"a template id, as seed_templates gives them").optional().describe("A built-in template, by the id seed_templates gives; or give objects."),objects:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),count:i.number().int().min(1).max(1e5)})).min(1).max(50).optional().describe("Objects and how many records each gets, in insert order, their fields drawn by the faker; or give template."),dryRun:i.boolean().describe("true: read the org and say what a run would do, writing nothing."),fit:i.enum(["share"]).optional().describe('"share": seed the largest share of every count that fits the data storage the org has left, each object about that share of its records, a child no more than its parents kept hold, room kept for what its flows still running create. The answer says the counts, object by object; give it to a write only once the person using you has seen them in a dry run.'),fitWithinMB:i.number().min(.01).max(1e6).optional().describe("With fit: take no more than this many MB, whatever the org has left."),checkpointFirst:he("the seed"),acceptEmails:u("Write although the org delivers every email of what still runs as the records go in, or would not say whether it does: only once the person using you has accepted that these emails go out."),muteAutomation:pe("the seed"),confirm:I("org").optional()}).refine(e=>e.fitWithinMB===void 0||e.fit!==void 0,{message:'fitWithinMB goes with fit: "share"',path:["fitWithinMB"]}),writesTo:e=>e.dryRun?void 0:e.org,writes:"creates the records of the seed in it",readFirst:"a dry run of the same seed says what it would write and meet",flags:{"--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...st("seed",t),...ye(t)],run:e=>({script:"sandforge-seed",args:["--target",e.org,...e.template!==void 0?["--template",e.template]:[],...(e.objects??[]).flatMap(t=>["--object",`${t.objectApiName}:${t.count}`]),...e.dryRun?["--dry-run"]:[],...e.fit!==void 0?["--fit",e.fit]:[],...e.fitWithinMB!==void 0?["--fit-within",String(e.fitWithinMB)]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...be(e.checkpointFirst),"--json"]})}),k({name:"clone_record",title:"Clone a record (Forge)",description:`Clone one record from source into target with the records it needs and the ones that hang from it, as Forge's record clone and sandforge clone --record --json do. Run it with dryRun: true first: it reads both orgs, counts what it would write and says what would stop a real run \u2014 the target's automation, its data storage, the emails its flows send \u2014 and writes nothing. dryRun: false writes into target, a sandbox or a Developer Edition only, and needs confirm, the alias of target. acceptAutomation lets it write although the target runs automation as the records go in; acceptEmails, although the target delivers every email what still runs sends, or would not say whether it does, which acceptAutomation never stands for. muteAutomation keeps what the target runs quiet for the clone through the target's own bypass; what no bypass keeps quiet still needs acceptAutomation. checkpointFirst takes a checkpoint of what the clone writes before its first write, and a dry run says what it would hold and cost. The answer names the run journal, which run_remove with module "forge" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org to write into: its sf CLI alias."),recordId:i.string().regex(dn,"a 15- or 18-character Salesforce record id").describe("The record to clone, in source."),depth:i.union([i.enum(["direct","full"]),i.number().int().min(1).max(10)]).optional().describe('How far from the record discovery goes: "direct", "full", or a number of hops (default 5).'),maxNodes:i.number().int().min(10).max(500).optional().describe("How many objects discovery may reach (default 50)."),dryRun:i.boolean().describe("true: read both orgs and say what a clone would do, writing nothing."),confirm:I("target").optional(),acceptAutomation:u("Write although the target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although the target delivers every email of what still runs as the records go in, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:pe("the clone"),checkpointFirst:he("the clone")}),writesTo:e=>e.dryRun?void 0:e.target,writes:"creates the records of the clone in it",readFirst:"a dry run of the same clone says what it would write and meet",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...st("forge",t),...ye(t)],run:e=>({script:"sandforge-clone",args:["--record",e.recordId,"--source",e.source,"--target",e.target,...e.depth===void 0?[]:typeof e.depth=="number"?["--depth","custom","--custom-depth",String(e.depth)]:["--depth",e.depth],...e.maxNodes!==void 0?["--max-nodes",String(e.maxNodes)]:[],...e.dryRun?["--dry-run"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...be(e.checkpointFirst),"--json"]})}),k({name:"clone_records",title:"Clone records a query chooses (Forge)",description:`Clone from source into target the records a query chooses \u2014 object, with where, orderBy and limit, 1 to ${U} \u2014, or several records named by their ids (recordIds, of one object), each with the records it needs and the ones that hang from it, as sandforge clone --query --json does: a record they share is read and written once. Run it with dryRun: true first: it reads both orgs, says the records the query chose and per object what it would write, and what would stop a real run, and writes nothing. dryRun: false writes into target, a sandbox or a Developer Edition only, and needs confirm, the alias of target; the run reads the query again. acceptAutomation, acceptEmails, muteAutomation and checkpointFirst as for clone_record. maxReadTotal bounds the records it reads in all before it writes. The answer names the run journal, which run_remove with module "forge" takes the run back from.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org to write into: its sf CLI alias."),object:i.string().regex(C,"an object API name").optional().describe("The object whose records the query chooses, by API name; or give recordIds."),where:Rn().optional().describe("With object: the condition its records are chosen by, without WHERE. It chooses the records cloned, and filters nothing they reach."),orderBy:i.string().min(1).max(Rt).refine(e=>At.safeParse(e).success,{message:"field paths, each with ASC or DESC and NULLS FIRST or LAST, separated by commas"}).optional().describe("With object: the order the records are chosen in, without ORDER BY (default Id): CreatedDate DESC, Id DESC takes the newest, the ids ordering those made in the same second."),limit:i.number().int().min(1).max(U).optional().describe(`With object: the most records the query chooses and the run clones, 1 to ${U}.`),recordIds:i.array(i.string().regex(dn,"a 15- or 18-character Salesforce record id")).min(2).max(U).optional().describe("In place of object: the records to clone, by their ids in source, two or more, all of one object; clone_record clones one."),depth:i.union([i.enum(["direct","full"]),i.number().int().min(1).max(10)]).optional().describe('How far from each record discovery goes: "direct", "full", or a number of hops (default 5).'),maxNodes:i.number().int().min(10).max(500).optional().describe("How many objects discovery may reach (default 50)."),maxReadTotal:i.number().int().min(1).max(1e7).optional().describe("The most records the run reads in all before it writes (default 50,000): past it, it is refused, nothing written."),dryRun:i.boolean().describe("true: read both orgs and say what a clone would do, writing nothing."),confirm:I("target").optional(),acceptAutomation:u("Write although the target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although the target delivers every email of what still runs as the records go in, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:pe("the clone"),checkpointFirst:he("the clone")}).superRefine(Uo),writesTo:e=>e.dryRun?void 0:e.target,writes:"creates the records of the clone in it",readFirst:"a dry run of the same clone says the records it chose and what it would write",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--query":qo,"--max-roots":`is this tool's limit, or the count of its recordIds: the records a run clones, 1 to ${U}.`,"--max-read-total":"is this tool's maxReadTotal.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--fit":`is clone_org_plan's fit: "share", a sample of the whole org, whose fitWhere draws an object's roots among the records a condition keeps.`},exits:{2:"the clone refused what it was asked before any org was reached \u2014 a query its object, where, orderBy and limit make that cannot choose the records it clones (ROOTS_QUERY_REFUSED), records of two objects \u2014: change the parameter it names, then dryRun: true again; nothing was read or written"},after:(e,t)=>[...Mo(e,t),...e.dryRun?[]:[...st("forge",t),...ye(t)]],run:e=>({script:"sandforge-clone",args:En(e)})}),k({name:"clone_org_plan",title:"Plan a clone of the whole org (Forge)",description:`The dry run of a clone of the whole org from source into target, or of a sample of it that fits the target (fit: "share"), as sandforge clone --depth all --dry-run --json says it: per object the records it would write, the API requests, Bulk API batches, data storage and time it takes against what each org has left today, what it leaves out and why, and every refusal a run would meet, each with the parameter that lifts it. It reads both orgs and writes nothing to either. A plan that would go is kept on this machine for a day, its owner's alone \u2014 of a sample, the ids of the records it drew \u2014 and comes back with its id and the question a terminal would ask before the first write: show the person both; clone_org with that plan and confirm writes it and nothing else. Every personal field is anonymized, always. acceptAutomation, acceptEmails, muteAutomation and checkpointFirst are given here, to the plan, which says what was accepted; maxTotal bounds the records, excludedObjects, excludedFields and filters narrow the clone. A production target is refused.`,readOnly:!1,destructive:!1,args:i.strictObject({source:v("The org to read from: its sf CLI alias."),target:v("The org the plan writes into: its sf CLI alias."),fit:i.enum(["share"]).optional().describe('"share": a sample of the org rather than every record \u2014 roots drawn of each object, each with its children and the records it names, none without a record it cannot be written without \u2014, the largest share that fits what the target has left and maxTotal.'),fitWithinMB:i.number().min(.01).max(Jo).optional().describe("With fit: take no more than this many MB of the target."),fitSeed:i.number().int().min(0).max(999999999999999).optional().describe("With fit: the seed the roots are drawn by (default 1)."),fitDraw:i.enum(["uniform","recent","oldest"]).optional().describe('With fit: "uniform" spreads the roots over each object (default), "recent" takes the newest by their creation date, "oldest" the oldest.'),fitWindow:Go(),fitWhere:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),where:Rn()})).min(1).max(Ot).optional().describe("With fit: draw an object's roots only among its records that match, one condition an object. Unlike filters, the records under or above the roots come whatever it says, and no lookup is written empty for it. Not of an object of fitWhole or excludedObjects."),fitStrata:Vo(),fitParents:i.enum(["all","required"]).optional().describe('With fit: "all" copies a record outside the sample an optional lookup names (default), "required" writes such a lookup empty.'),fitChildren:i.union([i.number().int().min(1).max(1e6),i.literal("all")]).optional().describe("With fit: the most children a record brings through each relation (100)."),fitWhole:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("With fit: objects copied whole, by API name."),fitFloor:i.number().int().min(0).max(1e4).optional().describe("With fit: the roots kept of each object whatever the share (default 1)."),maxTotal:i.number().int().min(1).max(1e8).optional().describe("The most records the clone may write in all (default 10,000): past it, its run is refused, and a sample is drawn within it."),excludedObjects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects left out, by API name; what that costs is said."),excludedFields:i.array(i.string().regex(Ho,"Object.Field, by API names")).min(1).max(500).optional().describe("Fields left out, as Object.Field."),filters:i.array(i.strictObject({objectApiName:i.string().regex(C,"an object API name"),where:i.string().min(1).max(512).regex(F,'one line, not starting with "-"').describe("A SOQL WHERE condition, without WHERE.")})).min(1).max(50).optional().describe("Conditions that narrow an object, each added to what the clone reads of it."),anonymize:i.literal(!0).optional().describe("Always on, whether given or not: every personal field is anonymized by its category's default method. false is refused: no tool copies them as they are."),acceptAutomation:u("Plan the run with --accept-automation: it writes although the target runs flows, Apex triggers, processes or workflow rules as the records go in. Only once the person using you has accepted what a plan without it named."),acceptEmails:u("Plan the run with --accept-emails: it writes although the target delivers every email what still runs sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that they go out."),muteAutomation:pe("the clone"),checkpointFirst:he("the clone")}).refine(e=>e.fit!==void 0||[e.fitWithinMB,e.fitSeed,e.fitDraw,e.fitWindow,e.fitWhere,e.fitStrata,e.fitParents,e.fitChildren,e.fitWhole,e.fitFloor].every(t=>t===void 0),{message:'the fit* parameters go with fit: "share"',path:["fit"]}),refuseFirst:e=>e.anonymize===!1||["acceptRealData","noAnonymize","realData"].some(t=>t in e)?`clone_org_plan: the personal fields cannot be left as they are. ${ct} Nothing was run.`:void 0,prepare:async(e,t)=>(await Wn(t.journalDir,t.runs,t.now(),t.log),{prepared:void 0}),flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--max-total":"is this tool's maxTotal: the most records the clone may write. Give it the count the dry run said only once the person using you has agreed to that many.","--fit":`is this tool's fit: "share", a sample of the org that fits the target rather than every record.`,"--fit-within":"is this tool's fitWithinMB.","--fit-seed":"is this tool's fitSeed.","--fit-draw":"is this tool's fitDraw.","--fit-window":`is this tool's fitWindow: {field: "created" or "modified", from, to}, each a date or an instant in UTC, either left out, or {field, lastDays}.`,"--fit-where":"is this tool's fitWhere, an objectApiName and the where its roots match.","--fit-strata":"is this tool's fitStrata, a Field or an Object.Field.","--fit-parents":"is this tool's fitParents.","--fit-children":"is this tool's fitChildren.","--fit-whole":"is this tool's fitWhole, an object by API name.","--fit-floor":"is this tool's fitFloor.","--exclude-object":"is this tool's excludedObjects, an object by API name.","--exclude":"is this tool's excludedFields, as Object.Field.","--filter":"is this tool's filters, an objectApiName and its where.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--no-anonymize":`is no parameter of any tool. ${ct}`,"--yes":"is clone_org's to give: once the person has said yes to the plan's question, clone_org with the plan and confirm writes it without asking again."},exits:{1:"refused, or a run of this plan would be: each refusal is said above, with the parameter that lifts it; no plan was kept",2:"refused for what it was asked, before any record was drawn: a window, a condition of the roots or a stratum the source cannot take, or two parameters that do not go together, each said above with the parameter of its flag; no plan was kept"},run:e=>({script:"sandforge-clone",args:Ko(e),relayedBy:Mt}),settle:(e,t,n)=>or(e,n)}),k({name:"clone_org",title:"Clone the whole org (Forge)",description:`Write the plan clone_org_plan kept, and nothing else: its records into its target, as sandforge clone --depth all writes them, as Bulk API jobs from 2000 records of an object and by REST under that. plan is the id clone_org_plan gave, good for a day; confirm is the alias of the plan's target, given once the person has said yes to the question the plan came back with, which the run then does not ask again. A sample writes the records its dry run drew, a plan of every record no more than its dry run counted: a source or a target that changed since is refused, nothing written, and needs a new plan. It takes no scope of its own. resume: true takes up the run of the plan that stopped part way, from its journal. Once a run has ended, the server verifies what it wrote, and says the verification first unless VERIFIED. The answer names the journal, which run_remove with module "forge" takes the run back from. A plan already written, gone or past its day is refused before anything is read.`,readOnly:!1,destructive:!1,args:i.strictObject({plan:i.string().regex($e,"the id of a plan clone_org_plan kept, co-...").describe("The plan clone_org_plan kept, by the id its answer gave."),confirm:I("the plan's target").optional(),resume:i.literal(!0).optional().describe("Take up the run of this plan that stopped part way, from its journal, writing nothing it wrote.")}),refuseFirst:e=>{let t=Object.keys(e).filter(n=>!Yo.includes(n));if(t.length!==0)return`clone_org takes a plan, not its scope: ${t.join(", ")} ${t.length===1?"is":"are"} clone_org_plan's to give. clone_org_plan with ${t.length===1?"it":"them"} plans again: show the person its question, then clone_org with its plan and confirm. Nothing was run.`},prepare:(e,t)=>ir(e,t),writesTo:(e,t)=>t.receipt.target,writes:"writes into it the records of the plan, and nothing else",readFirst:"clone_org_plan says what it would write, with the question to answer",named:{"--resume":"is this tool's resume: true, with the plan and confirm: it takes the run up from its journal.","--remove":'is run_remove, with module "forge", the org the run wrote to and its journal: preview: true first says what it would delete.',"--max-total":"is no parameter of clone_org, which holds a run to the count its plan's dry run gave: clone_org_plan again plans with the source as it is now.","--no-anonymize":`is no parameter of any tool. ${ct}`},beforeStart:async(e,t,n,o)=>{await X(Oe(o.journalDir)),await Qt(o.journalDir,t.receipt.id,{run:n.handle,startedAt:o.now().toISOString(),summary:n.summary,resume:e.resume===!0})},run:(e,t,n)=>({script:"sandforge-clone",args:Kt(t.receipt,{summary:n.summary,...e.resume===!0&&t.journal!==void 0?{resume:t.journal}:{}}),relayedBy:He,follow:{plan:t.receipt.id,summary:n.summary,...t.receipt.durationSeconds!==void 0?{expectedSeconds:t.receipt.durationSeconds}:{}}}),settle:(e,t,n)=>lr(t,n)}),k({name:"run_remove",title:"Remove a run's records",description:`Delete from org, into its recycle bin, what one run of Seed (module "seed"), Forge (module "forge") or Sync (module "sync") created, as that script's --remove --json does; a Sync run also gives the records it wrote over their values back. run is the summary file the run's --json was saved to, its run file or journal, or, for Seed and Sync, its run id. Records changed since the run are kept, unless includeChanged. A production org is refused. preview: true, for a Seed or Forge run, says per object what it would delete, what is gone already, what changed since and who changed it, and what a removal would be refused for, deleting nothing and needing no confirm; otherwise it needs confirm, the alias of org. A run of this server still running is refused: run_stop stops it first. acceptAutomation lets it delete although the org runs automation as the records go; muteAutomation keeps that automation quiet for the removal through the org's own bypass. Where its user may not delete the records of some objects of the run, it stops before its first delete, unless leaveUndeletable. store, for a Sync run of a saved configuration, is that configuration's store, which the removal tells what it took.`,readOnly:!1,destructive:!0,args:i.strictObject({module:i.enum(["seed","forge","sync"]).describe("Which module made the run."),org:v("The org the run wrote to: its sf CLI alias."),run:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The run's summary file, its run file or journal, or (Seed, Sync) its run id; a relative path is read from where the server was started."),confirm:I("org").optional(),includeChanged:u("Take also the records changed since the run, and what was added to them since: on a shared sandbox, others' work. Only once the person using you has accepted it."),acceptAutomation:u("Delete although the org runs flows, Apex triggers, processes or workflow rules as the records go, or would not say what it runs: only once the person using you has accepted it."),muteAutomation:u("Keep quiet what the org runs as the records go, through its own bypass: the removal assigns the permission sets holding it to the user it deletes as, for the removal alone, under a lease, and takes them back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it."),leaveUndeletable:u("Where the user the alias connects as may not delete the records of some objects of the run, remove the rest and leave those, with the records they hang from; without it the removal stops before its first delete and names them. Only once the person using you has accepted it."),store:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe(`module "sync" only: the directory the saved configuration the run was of is kept in, the run's --store, which the removal tells what it took, so that its next delta run reads those objects whole; a relative path is read from where the server was started. The person using you names it.`),preview:u('module "seed" or "forge": say what the removal would do, and do nothing \u2014 per object the records it would delete, those gone already, those changed since the run and who changed them, and what a removal now would be refused for. It reads the org, deletes nothing, and takes no confirm.')}).refine(e=>e.store===void 0||e.module==="sync",{message:'store goes with module "sync": a Seed or Forge run keeps no configuration',path:["store"]}).refine(e=>e.preview!==!0||e.module!=="sync",{message:'preview goes with module "seed" or "forge": the removal of a Sync run has none, and says what it gives back as it does it',path:["preview"]}),prepare:async(e,t)=>{let n=await kr(t.runs,e.run);return n?{refusal:vr(n,e.run)}:{prepared:void 0}},writesTo:e=>e.preview===!0?void 0:e.org,writes:"deletes the records the run created, into the recycle bin",readFirst:"run_remove with preview: true (a Seed or Forge run) says what it would delete, deleting nothing",flags:{"--include-changed":"includeChanged","--accept-automation":"acceptAutomation","--mute-automation":"muteAutomation","--leave-undeletable":"leaveUndeletable"},named:{"--store":"is this tool's store: the directory of the run's saved configuration, as the person using you names it.","--preview":"is this tool's preview: true, for a Seed or Forge run: it says what the removal would delete, and deletes nothing."},run:e=>({script:Bo[e.module],args:["--remove",e.run,"--target",e.org,...e.preview===!0?["--preview"]:[],...e.includeChanged===!0?["--include-changed"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.leaveUndeletable===!0?["--leave-undeletable"]:[],...e.store!==void 0?["--store",e.store]:[],"--json"]})}),k({name:"run_status",title:"Follow a run",description:`How far a run is that a call handed back, by its handle (mr-...): a call whose script still runs after ${Math.round(xe()/1e3)} seconds answers with one. While it runs, its time against its plan's, what it wrote so far, its journal and its script's last lines; once it has ended, the answer its call would have given, the verification of a clone included. waitSeconds waits that long for its end first (default 30, 50 at most). A run of a server that has ended since is read off this machine: what it wrote, and the calls that take it up or back. Reads this machine alone.`,readOnly:!0,args:i.strictObject({run:i.string().regex(Q,"the handle of a run, mr-...").describe("The run, by the handle the call that started it answered with."),waitSeconds:i.number().min(0).max(de).optional().describe("How long to wait for its end first, in seconds (default 30).")}),run:e=>({local:t=>yr(t,e.run,e.waitSeconds??gr)})}),k({name:"run_stop",title:"Stop a run",description:"Stop a run a call handed back, by its handle, as Ctrl-C stops its script on a terminal: before its next call to the org, what it wrote kept in its journal, a Bulk API job still open aborted and one the org is writing left to end. Only when the person using you asks. It waits a while for the run to end, then answers as run_status does, with the calls that take the run up or back.",readOnly:!1,destructive:!1,args:i.strictObject({run:i.string().regex(Q,"the handle of a run, mr-...").describe("The run, by the handle the call that started it answered with.")}),run:e=>({local:t=>br(t,e.run)})}),k({name:"checkpoint_list",title:"List checkpoints",description:"The checkpoints of org kept on this machine, newest first, with what a rewind and an undo can still reach, and of one that no longer rewinds it, the dry run of its replay into another org; then the replays into org kept on this machine (replays), each with the records it left there, which checkpoint_replay_remove takes back. Reads this machine alone, and never contacts an org. Named org only: the other orgs' names and aliases never reach the agent.",readOnly:!0,args:i.strictObject({org:v("The org, by its sf CLI alias: its checkpoints alone.")}),after:(e,t)=>Do(t),run:e=>({script:"sandforge-checkpoint",args:["list","--org",e.org,"--json"]}),settle:(e,t,n)=>Fo(e.org,n)}),k({name:"checkpoint_preview",title:"Preview a rewind",description:"What a rewind of org to a checkpoint would do: the records it would delete, give back and bring back, who last changed them, what the org runs as the rewind writes, the emails and API requests it takes, what neither a rewind nor its undo can take back, and the refusal a rewind would meet now. Given objects, those of a rewind limited to them, with what it would leave of them and the objects it needs added. Reads the org, writes nothing.",readOnly:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:fe("A checkpoint of it: its id, its name, or latest (the default).").optional(),objects:ln()}),named:Ro,run:e=>({script:"sandforge-checkpoint",args:["preview","--org",e.org,"--checkpoint",e.checkpoint??"latest",...(e.objects??[]).flatMap(t=>["--object",t]),"--json"]})}),k({name:"checkpoint_take",title:"Take a checkpoint",description:"Read org's records and keep them on this machine as a checkpoint, to rewind the org to later: every object people work in, or the objects named. estimate: true says the records, API requests, time and disk it would take, and keeps nothing. It writes nothing to the org; the checkpoint holds the records' values unencrypted, readable by this machine's user alone. A production org is refused.",readOnly:!1,destructive:!1,args:i.strictObject({org:v("The org: its sf CLI alias."),name:i.string().min(1).max(200).regex(F,'one line, not starting with "-"').optional().describe("What it is called (default: the date and time)."),objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("The objects to keep, by API name (default: every object people work in)."),maxTotal:i.number().int().min(1).max(go).optional().describe("The most records it holds, all objects together (default 500,000, a million at most): past it, it is refused before reading any, the refusal naming --max-total, which this sets."),estimate:i.boolean().optional().describe("true: say what it would take, then stop, keeping nothing.")}),run:e=>({script:"sandforge-checkpoint",args:["take","--org",e.org,...e.name!==void 0?["--name",e.name]:[],...(e.objects??[]).flatMap(t=>["--object",t]),...e.maxTotal!==void 0?["--max-total",String(e.maxTotal)]:[],...e.estimate===!0?["--estimate"]:[],"--json"]})}),k({name:"checkpoint_rewind",title:"Rewind an org",description:"Return org to a checkpoint: delete the records created since, give the records changed since their values back and bring back from the recycle bin the records deleted since \u2014 whoever made those changes \u2014 then read the org again. It rewinds from its own preview, said first in its answer with who last changed what; the answer says what Undo could not bring back, and checkpoint_undo takes the rewind back. Needs confirm, the alias of org: checkpoint_preview first. Refused without acceptAutomation when the org runs automation as the rewind writes, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back records it deletes, without acceptRecreate when records no longer in the recycle bin would be made again with new Ids, without acceptUnseen when, for a user without View All Data and Modify All Data, what it deletes takes along records the user is not proven to see. Given objects, it rewinds those alone, never adding what they depend on: its answer names what it left of them, the objects to add, and what still differs in the others. A production org is refused.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:fe("The checkpoint: its id or its name. latest is refused: one taken since would be the one the rewind returns to."),confirm:I("org").optional(),acceptAutomation:u("Rewind although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:u("Rewind although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the rewind writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:me("the rewind"),acceptNoUndo:u("Rewind although Undo could not bring back some records it deletes (objects Salesforce undeletes only with their parent)."),acceptRecreate:u("Make again, with new Ids, the records deleted since that the recycle bin no longer gives back: what outside Salesforce names their old Ids no longer finds them."),acceptOutside:u("For a checkpoint of picked objects: also delete the records outside it created under records it deletes."),acceptUnseen:u("For a user without View All Data and Modify All Data: delete records whose delete takes along records of objects the user is not proven to see, tasks and events among them, which no count holds."),objects:ln()}),writesTo:e=>e.org,writes:"deletes the records created since the checkpoint, gives the records changed since their values back and brings back the records deleted since, whoever made those changes",readFirst:"checkpoint_preview says what it would do, writing nothing",flags:_n,run:e=>({script:"sandforge-checkpoint",args:["rewind","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...(e.objects??[]).flatMap(t=>["--object",t]),...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[],...e.acceptRecreate===!0?["--accept-recreate"]:[],...e.acceptOutside===!0?["--accept-outside"]:[],...e.acceptUnseen===!0?["--accept-unseen"]:[],"--json"]})}),k({name:"checkpoint_undo",title:"Undo a rewind",description:"Take back org's last rewind to a checkpoint: bring back what it deleted, give back what it wrote over, send back to the recycle bin what it brought back; what anyone changed since the rewind stays, and is said. Needs confirm, the alias of org. acceptAutomation and acceptEmails as for checkpoint_rewind.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:fe("The checkpoint the rewind went back to: its id or its name."),confirm:I("org").optional(),acceptAutomation:u("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:u("Undo although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the undo writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:me("the undo")}),writesTo:e=>e.org,writes:"brings back what its last rewind deleted, gives back what it wrote over and sends back to the recycle bin what it brought back",readFirst:"checkpoint_list says which rewind it would take back, and until when",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},run:e=>({script:"sandforge-checkpoint",args:["undo","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],"--json"]})}),k({name:"checkpoint_delete",title:"Delete a checkpoint",description:"Delete a checkpoint of org from this machine: the org is not touched, and can no longer be rewound to it, nor its last rewind to it undone. Needs confirm, the alias of org.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),checkpoint:fe("The checkpoint: its id or its name."),confirm:I("org").optional()}),writesTo:e=>e.org,writes:"deletes the checkpoint from this machine, and the org can no longer be rewound to it",run:e=>({script:"sandforge-checkpoint",args:["delete","--org",e.org,"--checkpoint",e.checkpoint,"--yes","--json"]})}),k({name:"checkpoint_replay",title:"Replay a checkpoint into another org",description:"Set a checkpoint's records up again in another org (target), parents first, with new Ids, as sandforge checkpoint replay --json does: the sandbox its org became once refreshed, another sandbox, a scratch org. The checkpoint's own org is never reached, and nothing target holds is changed or deleted. Run it with dryRun: true first: it reads target and says what it would create, link, leave and refuse \u2014 owners, record types, currencies, the files a checkpoint keeps no content of \u2014, writing nothing. dryRun: false replays, with confirm, the alias of target, and maxRecords, the count its dry run said. A checkpoint of a Partial Copy, a Full or a Staging sandbox replays masked only (mask: true). file replays a .sfcheckpoint a teammate sent, its key read from the server's environment by the variable keyEnv names, never given in an argument. verify: true counts what its last replay created there. again replays over what the replays before created there, which goes first. checkpoint_replay_remove takes a replay back. A production org and the checkpoint's own org are refused; the Staging mark the editor gives a sandbox is not seen here.",readOnly:!1,destructive:!0,args:i.strictObject({checkpoint:at.checkpoint.optional(),from:at.from,file:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe("In place of checkpoint: a .sfcheckpoint file a teammate sent, replayed without its org, the key standing for the teammate's consent; a relative path is read from where the server was started. With keyEnv."),keyEnv:i.string().regex(An,"the name of an environment variable").refine(e=>zt(e)===void 0,{message:"the name of the variable that holds the key, never the key: a key in the arguments stays in the agent's context and in its client's logs"}).optional().describe("With file: the name of the variable of the server's environment that holds its key, which the person using you set where the server is started. Never the key."),target:v("The org the records go into: its sf CLI alias. A sandbox, a scratch org or a Developer Edition org."),dryRun:i.boolean().optional().describe("true: read target and say what the replay would do, writing nothing; false: replay, with maxRecords and confirm. Not with verify."),verify:i.literal(!0).optional().describe("Read target and count what the last replay of the checkpoint created there against what it said it created; writes nothing. Not with dryRun."),maxRecords:i.number().int().min(1).max(kt).optional().describe("With dryRun: false: the most records it may create, the count its dry run said; more is refused before it writes."),confirm:I("target").optional(),objects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Replay these objects of the checkpoint alone, by API name (default: all)."),excludedObjects:i.array(i.string().regex(C,"an object API name")).min(1).max(500).optional().describe("Objects of the checkpoint to leave out, by API name."),owners:i.enum(["same","me"]).optional().describe('"same" (default): a record keeps its owner where target has that user active, and goes to the user who replays otherwise; "me": every record to that user.'),customSettings:u("Set up the custom settings the checkpoint holds too; a row target has already is kept, never written over."),mask:u("Mask personal data, as Forge's anonymization masks it: required of a checkpoint of a Partial Copy, a Full or a Staging sandbox, which may hold real data."),again:u("Replay over what the replays of this checkpoint before created in target, which goes first, deleted. Only once the person using you has agreed to it."),acceptAutomation:u("Write although target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:u("Write although target delivers the emails what still runs sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:pe("the replay"),checkpointFirst:he("the replay")}).superRefine($o),refuseFirst:e=>{let t=Object.keys(e).filter(n=>/key/i.test(n)&&n!=="keyEnv");return t.length>0?`checkpoint_replay takes no key (${t.join(", ")}): a key in the arguments stays in the agent's context and in its client's logs. keyEnv names the variable of the server's environment that holds it, which the person using you sets where the server is started. Nothing was run.`:void 0},writesTo:e=>e.dryRun===!1?e.target:void 0,writes:"creates there the records of the checkpoint, with new Ids",readFirst:"checkpoint_replay with dryRun: true says what it would create, link and leave",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},named:{"--dry-run":"is this tool's dryRun: true.","--verify":"is this tool's verify: true.","--remove":"is checkpoint_replay_remove, with the checkpoint and the target: preview: true first says what it would delete.","--again":"is this tool's again: true, once the person using you has agreed to it.","--mask":"is this tool's mask: true.","--max-records":"is this tool's maxRecords: the count the dry run said, once the person using you has agreed to that many.","--objects":"is this tool's objects, by API name.","--exclude-object":"is this tool's excludedObjects, by API name.","--owners":`is this tool's owners: "same" or "me".`,"--custom-settings":"is this tool's customSettings: true.","--checkpoint-first":"is this tool's checkpointFirst: {} takes it with the defaults.","--key-env":"is this tool's keyEnv: the name of a variable of the server's environment that holds the key, never the key.","--no-real-data":`is no parameter of any tool: the declaration that a sandbox's checkpoint holds no real data is the person's, on a terminal, kept in the audit trail (${$("checkpoint")} replay \u2026 --no-real-data). mask: true replays it masked.`},after:(e,t)=>e.dryRun===!0?Io(e,t):[],settle:async(e,t,{ran:n,parts:o})=>{let r=No(e,`${n.stderr}
10
+ ${n.stdout}`);return r===void 0?o:{...o,added:[...o.added,r]}},run:e=>({script:"sandforge-checkpoint",args:Tn(e)})}),k({name:"checkpoint_replay_remove",title:"Take a replay back",description:"Delete from target, into its recycle bin, what the replays of a checkpoint created there, children first, the checkpoint kept or not, as sandforge checkpoint replay --remove --json does; records changed since are kept, unless includeChanged. preview: true says what it would delete, deleting nothing and needing no confirm; otherwise it needs confirm, the alias of target. sweep takes too what the automation of target made for those records, and sweepList lists it, deleting nothing and needing no confirm; sweepLate and sweepUntied take too what the list says came late, or is tied to nothing of the replay. acceptAutomation lets it delete although target runs automation as the records go; muteAutomation keeps that automation quiet through target's own bypass. checkpoint_list names the replays into an org, by their checkpoint. A replay this server still runs into target is refused: run_stop stops it first. A production org is refused.",readOnly:!1,destructive:!0,args:i.strictObject({...at,target:v("The org the replay went into: its sf CLI alias."),preview:u("Say what the removal would delete, and delete nothing: it reads target, and takes no confirm."),confirm:I("target").optional(),sweep:u("Take too what target's automation made for the records of the replay. Only once the person using you has seen, in a preview with it, what it takes."),sweepList:u("List what sweep would take, per object, and delete nothing: it reads target, and takes no confirm. Not with sweep, nor with preview, which lists it with sweep."),sweepLate:u("With sweep, take too what the list says came late, after the replay ended; with sweepList, say what it would take. Only once the person using you has seen it."),sweepUntied:u("With sweep, take too what the list says is tied to nothing of the replay, refused when another run of this machine wrote to target meanwhile; with sweepList, say what it would take. Only once the person using you has seen it."),includeChanged:u("Take also the records changed since the replay, and what was added under them since: on a shared sandbox, others' work. Only once the person using you has accepted it."),acceptAutomation:u("Delete although target runs flows, Apex triggers, processes or workflow rules as the records go, or would not say what it runs: only once the person using you has accepted it."),muteAutomation:me("the removal")}).superRefine(On).superRefine(Po),prepare:(e,t)=>{let n=t.runs.busyWith(e.target);return Promise.resolve(!dt(e)&&n?.meta.tool==="checkpoint_replay"?{refusal:Rr(n,e.target)}:{prepared:void 0})},writesTo:e=>dt(e)?void 0:e.target,writes:"deletes from it, into its recycle bin, what the replays of the checkpoint created",readFirst:"checkpoint_replay_remove with preview: true says what it would delete, deleting nothing",flags:{"--include-changed":"includeChanged","--sweep":"sweep","--sweep-late":"sweepLate","--sweep-untied":"sweepUntied","--accept-automation":"acceptAutomation","--mute-automation":"muteAutomation"},named:{"--preview":"is this tool's preview: true: it says what it would delete, and deletes nothing.","--sweep-list":"is this tool's sweepList: true: it lists what the sweep would take, and deletes nothing."},run:e=>({script:"sandforge-checkpoint",args:["replay",...Pn(e),"--target",e.target,"--remove",...e.preview===!0?["--preview"]:[],...e.sweep===!0?["--sweep"]:[],...e.sweepList===!0?["--sweep-list"]:[],...e.sweepLate===!0?["--sweep-late"]:[],...e.sweepUntied===!0?["--sweep-untied"]:[],...e.includeChanged===!0?["--include-changed"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...dt(e)?[]:["--yes"],"--json"]})}),k({name:"empty_preview",title:"Preview an emptying",description:"What emptying objects of org, or every object people work in there, would do: per object the records it deletes and what the org deletes along with them, in the order it takes them; what will likely refuse, what blocks, what no undo would bring back, what it leaves out and why; the API requests, Bulk API batches and time against what the org has left today, and the recycle bin; what the user is not proven to see; what the org runs as the records go, and its emails; and every refusal a run with the same parameters would meet now. Reads the org, deletes nothing.",readOnly:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),...hn}).refine(pn,{message:"give objects or wholeOrg, one of them"}),flags:mn,named:gn,run:e=>({script:"sandforge-empty",args:["--target",e.org,...fn(e),...it(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--dry-run","--json"]})}),k({name:"empty_run",title:"Empty objects or an org",description:"Delete every record of the objects named of org, or of every object people work in there, with what the org deletes along with them: to the recycle bin, which empty_undo brings them back from, or for good with hardDelete. It reads the org as empty_preview does, says it all first in its answer, and deletes only when nothing refuses it. Given resume, the run id of the org's last emptying stopped part way, it takes that run up instead. Needs confirm, the alias of org: empty_preview first. Refused without acceptAutomation when the org runs automation as the records go, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back some records, without acceptPeopleActive while someone else changed records of these objects in the last hour, past the day's API requests or Bulk API batches, and on a production org, always.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),confirm:I("org").optional(),...hn,resume:i.string().regex(un,"the run id of an emptying, em-...").optional().describe("Take up the org's last emptying stopped part way, by its run id, in place of objects or wholeOrg: on what its journal confirmed.")}).refine(pn,{message:"give objects, wholeOrg or resume, one of them"}),writesTo:e=>e.org,writes:"deletes every record of the objects named, or of every object people work in, with what the org deletes along with them",readFirst:"empty_preview says what it would delete and meet, deleting nothing",flags:mn,named:gn,after:(e,t)=>Ao(t),run:e=>({script:"sandforge-empty",args:["--target",e.org,...e.resume!==void 0?["--resume",e.resume]:fn(e),...it(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--yes","--json"]})}),k({name:"empty_undo",title:"Undo an emptying",description:"Bring back from the recycle bin what org's last emptying deleted, parents first, while the bin holds them; the answer names what could not come back and why. Refused for a run that deleted for good. Needs confirm, the alias of org. acceptAutomation, acceptEmails and muteAutomation as for empty_run.",readOnly:!1,destructive:!0,args:i.strictObject({org:v("The org: its sf CLI alias."),run:i.string().regex(un,"the run id of an emptying, em-...").describe("The org's last emptying, by the run id its answer gave."),confirm:I("org").optional(),acceptAutomation:u("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are brought back, or would not say what it runs."),acceptEmails:u("Undo although the org delivers every email what still runs as records come back sends, or would not say whether it does. Only once the person using you has accepted that these emails go out."),muteAutomation:me("the undo")}),writesTo:e=>e.org,writes:"brings back from the recycle bin what the org's last emptying deleted",readFirst:"empty_run's answer names the run and whether its undo is offered",flags:xn,run:e=>({script:"sandforge-empty",args:["--target",e.org,"--undo",e.run,...it(e),"--yes","--json"]})}),k({name:"env_plan",title:"Plan an environment",description:"What env_apply would do to org from a sandforge.yaml (file), as sandforge env plan --json says it: per resource, create, keep, replace, delete, or why it is blocked; what an earlier apply left there and what changed since; per object the records it would write; the API requests, storage and emails it takes. Each resource is dry-run by its own script. Reads the org and the sources its resources clone from, writes nothing to an org. failOnDrift: true ends it exit 3 when the org no longer holds the environment as applied \u2014 records deleted or changed since. replace, replaceDrifted and acceptNoState plan what env_apply would do with them.",readOnly:!0,args:i.strictObject({file:Ie(),org:v("The org to fill: its sf CLI alias."),failOnDrift:i.boolean().optional().describe("true: exit 3 when records the environment holds were deleted or changed since."),replace:yn("Plan what env_apply would do with replace: these resources replaced although kept or drifted, by their names in the file."),replaceDrifted:u("Plan what env_apply would do with replaceDrifted: every drifted resource replaced."),acceptNoState:u("Plan what env_apply would do with acceptNoState: an apply to a Developer Edition or a sandbox this machine has no state of is otherwise refused."),acceptEmails:u("Plan what env_apply would do with acceptEmails: a seed or a clone is otherwise blocked where the org delivers the emails what still runs sends, or would not say whether it does."),acceptUserEmails:wn("Plan what env_apply would do with acceptUserEmails: a users resource that asks addresses back otherwise blocks the apply (USERS_EMAILS_NOT_ACCEPTED), Salesforce emailing each of those people the link that confirms their address.")}),flags:{"--accept-no-state":"acceptNoState","--accept-emails":"acceptEmails","--accept-user-emails":"acceptUserEmails"},named:bn("plan"),exits:{3:"drift: the org no longer holds the environment as applied, records deleted or changed since, each said above"},run:e=>({script:"sandforge-env",args:["plan","--file",e.file,"--org",e.org,...e.failOnDrift===!0?["--fail-on-drift"]:[],...(e.replace??[]).flatMap(t=>["--replace",t]),...e.replaceDrifted===!0?["--replace-drifted"]:[],...e.acceptNoState===!0?["--accept-no-state"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.acceptUserEmails===!0?["--accept-user-emails"]:[],"--json"]})}),k({name:"env_apply",title:"Apply an environment",description:"Do to org what env_plan says, as sandforge env apply --yes --json does: plans again, then creates what the file declares, replaces what it is told to (replace: the resources, by name; replaceDrifted: every drifted resource) and deletes the resources the file no longer holds, each by its own script, into the state kept on this machine; applied again, it writes nothing. A production org is refused, and a sandbox the file does not list. Needs confirm, the alias of org: env_plan first. acceptNoState lets it apply to an org this machine has no state of, where records an earlier apply left would be created twice. A resource's accept: { automation: true } in the file is what lets its runs be taken back although the org runs automation. acceptEmails lets its resources write although the org delivers the emails what still runs sends, or would not say whether it does; acceptUserEmails lets Salesforce email the people whose address a users resource asks back, which no file accepts. The answer ends with the env_destroy call that takes the environment back.",readOnly:!1,destructive:!0,args:i.strictObject({file:Ie(),org:v("The org to fill: its sf CLI alias."),confirm:I("org").optional(),replace:yn("Resources to replace although kept or drifted, by their names in the file: their earlier runs are taken back, then run again."),replaceDrifted:u("Replace every drifted resource: its earlier runs are taken back, then run again. Only once the person using you has agreed to it."),acceptNoState:u("Apply to a Developer Edition or a sandbox this machine has no state of: records an earlier apply left there would be created twice. Only once the person using you has accepted it."),acceptEmails:u("Apply although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as its resources write sends some. Only once the person using you has accepted that these emails go out."),acceptUserEmails:wn("Let Salesforce email the people whose address a users resource asks back: the link that confirms each address, a system email, which leaves under System email only too. Without it the plan refuses the apply (USERS_EMAILS_NOT_ACCEPTED), and no file accepts it.")}),writesTo:e=>e.org,writes:"creates, replaces and deletes the resources of the file there as its plan says, taking back the earlier runs a replace or a delete takes back",readFirst:"env_plan of the same file says what it would do, writing nothing",flags:{"--accept-no-state":"acceptNoState","--accept-emails":"acceptEmails","--accept-user-emails":"acceptUserEmails"},named:{...bn("apply"),"--accept-automation":cn("env_apply"),"--save":`is env_audit's save, with the same file and org: ${kn}`},after:e=>[`env_destroy with file "${e.file}" and org "${e.org}" takes this environment back.`],run:e=>({script:"sandforge-env",args:["apply","--file",e.file,"--org",e.org,...(e.replace??[]).flatMap(t=>["--replace",t]),...e.replaceDrifted===!0?["--replace-drifted"]:[],...e.acceptNoState===!0?["--accept-no-state"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.acceptUserEmails===!0?["--accept-user-emails"]:[],"--yes","--json"]})}),k({name:"env_destroy",title:"Destroy an environment",description:"Take back from org what env_apply created there from file, the last resource first, into its recycle bin, as sandforge env destroy --yes --json does; what it cannot take back is named, with why. Records changed since the apply are kept unless includeChanged: on a shared sandbox, a colleague\u2019s work. A production org is refused. Needs confirm, the alias of org. It takes back by removal alone: no rewind to a checkpoint.",readOnly:!1,destructive:!0,args:i.strictObject({file:Ie(),org:v("The org the environment was applied to: its sf CLI alias."),confirm:I("org").optional(),includeChanged:u("Take also the records changed since the apply, and what was created under them since: on a shared sandbox, others' work. Only once the person using you has accepted it.")}),writesTo:e=>e.org,writes:"deletes the records its applies created, into the recycle bin, the last resource first",readFirst:"env_plan of the same file says what the org holds of the environment and what changed since",flags:{"--include-changed":"includeChanged"},named:{"--accept-automation":cn("env_destroy")},run:e=>({script:"sandforge-env",args:["destroy","--file",e.file,"--org",e.org,...e.includeChanged===!0?["--include-changed"]:[],"--yes","--json"]})}),k({name:"env_audit",title:"Audit an environment",description:"Read org as sandforge env audit --json reads it, writing nothing to it: whether it delivers email, its scheduled jobs against the inventory this machine kept of it before its refresh, and the endpoints that still name production, each part the file's audits do not turn off. An audit that could not be read is said not read, with why, never taken for one that found nothing; no URL is given with its query or its credentials. save: true keeps the jobs read on this machine, to compare with after the next refresh: the day before it. failOnFindings: true ends it exit 3 on what it found. A production org is refused, and a sandbox the file does not list. SandForge changes none of what it finds: Setup, sf or a deployment puts it right.",readOnly:!1,destructive:!1,args:i.strictObject({file:Ie(),org:v("The org to audit: its sf CLI alias."),save:i.boolean().optional().describe("true: keep the scheduled jobs read, in audits/ of the journal directory by the org's host, its owner's alone, to compare with after its next refresh. Refused, exit 2, when the file's audits read no scheduled jobs."),failOnFindings:i.boolean().optional().describe("true: exit 3 on a job gone or run as a user who can no longer run it, an endpoint that names production, or a deliverability open to all email.")}),named:{"--save":`is this tool's save: ${kn}`},exits:{3:"findings: a job gone or run as a user who can no longer run it, an endpoint that names production, or a deliverability open to all email, each said above"},run:e=>({script:"sandforge-env",args:["audit","--file",e.file,"--org",e.org,...e.save===!0?["--save"]:[],...e.failOnFindings===!0?["--fail-on-findings"]:[],"--json"]})}),k({name:"pipeline_plan",title:"Plan a pipeline",description:"What a run of a pipeline exported from the Automation page would do and refuse, as sandforge pipeline plan --json says it: each org of the file reached by its alias and typed, each step, and every refusal a run would meet before its first step, with what lifts it. It reads the orgs, on a copy of the pipeline's store, and writes nothing. No tool runs a pipeline: its run is the person's, on a terminal, where its Approval steps are asked. approve answers one ahead, as a run with no terminal is answered; vars and varEnvs give its variables, a secret by varEnvs, a variable of the server's environment; acceptOrgs takes an org whose Organization Id changed since the export, a sandbox refreshed, once the person using you checked it is the one.",readOnly:!0,args:i.strictObject({file:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').describe("The pipeline file the Automation page exported (<name>.sandforge-pipeline.json), by its path; a relative path is read from where the server was started."),approve:i.array(i.string().min(1).max(200).regex(F,'one line, not starting with "-"')).min(1).max(200).optional().describe("Approval steps, by name, answered ahead, yes, as --approve answers them for a run with no terminal; never one before a write to a sandbox marked Staging."),vars:i.array(i.strictObject({name:i.string().regex(vn,"a variable of the pipeline, by its name"),value:i.string().min(1).max(2e3).regex(/^[^\r\n]*$/,"one line")})).min(1).max(200).optional().describe("Variables of the pipeline and their values. A secret goes by varEnvs."),varEnvs:i.array(i.strictObject({name:i.string().regex(vn,"a variable of the pipeline, by its name"),env:i.string().regex(An,"the name of an environment variable")})).min(1).max(200).optional().describe("Variables of the pipeline, each read from a variable of the server's environment: a secret, which neither the file nor the arguments hold."),acceptOrgs:i.array(i.strictObject({key:i.string().regex(jo,"an org of the file, by its alias or its key in its orgs"),organizationId:i.string().regex(So,"an Organization Id, 00D and 12 or 15 letters and digits")})).min(1).max(50).optional().describe("Orgs of the file whose alias reaches an org of another Organization Id than the file's \u2014 a sandbox refreshed since \u2014, taken for it once the person using you checked it is the one: the org by its alias, or by its key in the file, and the Id the plan said, as its refusal (ORG_MOVED) names them."),store:i.string().min(1).max(4096).regex(F,'one line, not starting with "-"').optional().describe("Where the pipeline's runs keep their state, as its runs are given it: the plan reads a copy of it. The default is the pipeline's folder under the journal folder.")}),refuseFirst:e=>{if("org"in e||"orgs"in e)return`pipeline_plan plans the orgs the file names, each by its alias in the file: a person maps one to another alias on a terminal, ${$("pipeline")} plan --file <file> --org <key>=<alias>. Nothing was run.`;if(["dryRun","run","confirm"].some(t=>t in e))return`pipeline_plan only plans: no tool runs a pipeline. Its run is the person's, on a terminal, ${$("pipeline")} run --file <file> --dry-run first. Nothing was run.`},named:{"--approve":"is this tool's approve: the Approval steps answered ahead, by name; never one before a write to a sandbox marked Staging, which a person answers at a terminal.","--accept-org":"is this tool's acceptOrgs: the org by its alias, or by its key in the file, and the Organization Id taken for it, once the person using you checked it is the one.","--var":"is this tool's vars, a name and its value; a secret goes by varEnvs.","--var-env":"is this tool's varEnvs, a name and the variable of the server's environment that holds its value.","--store":"is this tool's store.","--org":`is no parameter of pipeline_plan, which plans the aliases the file names: a person maps an org of the file to another alias on a terminal, ${$("pipeline")} plan --file <file> --org <key>=<alias>.`,"--confirm-rewind":`is no parameter of any tool: a Rewind step is confirmed by the person, on a terminal, ${$("pipeline")} confirm --file <file>.`},exits:{2:"the plan refuses: a run would be refused before its first step, or the file does not read, each refusal said above with what lifts it; nothing ran"},run:e=>({script:"sandforge-pipeline",args:_o(e)}),settle:(e,t,n)=>Promise.resolve({...n.parts,added:[...n.parts.added,xo(e.file)]})})],ur=new Map(Me.map(e=>[e.definition.name,e]));async function hr(){let{templateDisplayName:e}=await import("./sandforge-seed.mjs"),t=Et.map(n=>{let o=n.objects.map(r=>({objectApiName:r.objectApiName,records:r.recordCount}));return{id:n.id,name:e(n),description:e({name:n.description}),objects:o,records:o.reduce((r,s)=>r+s.records,0)}});return V(t.map(n=>`${n.id} \u2014 ${n.name}: ${n.records} records at most in ${n.objects.length} objects (${n.objects.map(o=>`${o.objectApiName} ${o.records}`).join(", ")})`),{templates:t},!1)}function V(e,t,n){return{content:[{type:"text",text:e.join(`
11
+ `)},{type:"text",text:JSON.stringify(t)}],structuredContent:t,isError:n}}function lt(e,t){return V([t],{refusal:{code:e,message:t}},!0)}function pr(e){switch(e){case 0:return"done";case 1:return"refused before it wrote, could not start, or did nothing but fail";case 2:return"a request the script could not take, or a question for the person using you: nothing was written";case 3:return"partial: records were left, refused or not checked, each said with why";case 4:return"unstable: someone else wrote to the records meanwhile";default:{let t=Ue.find(n=>Se(n)===e);return t!==void 0?`stopped by ${t} before it was through`:"ended on an error"}}}var ut=new Set([0,3,4]),In=new Set(Ue.map(e=>Se(e))),fr="no terminal to answer",ht=(e,t)=>new RegExp(`(?<![\\w-])${t}(?![\\w-])`).test(e);function ke(e,t){let n=t.map(o=>ie(o));return["npx sandforge",e.replace(/^sandforge-/,""),...n].join(" ")}function mr(e){let t=/^refused \(([A-Z][A-Z0-9_]*)\): (.+)$/m.exec(e);return t?{code:t[1]??"",message:(t[2]??"").trim()}:void 0}function pt(e){let t=e.trim();if(t!=="")try{return JSON.parse(t)}catch{return}}function Ne(e){let t=[...e.head,...e.head.length>0?[""]:[],...e.said];return e.added.length>0&&t.push("",...e.added),V(t,e.structured,e.isError)}function ii(e,t,n,o=()=>[]){return Ne(Cn(e,t,n,o))}function Cn(e,t,n,o=()=>[]){let r=pt(n.stdout),s=[`ran: ${ke(t.script,t.args)}`,`exit ${n.code}: ${e.exits?.[n.code]??pr(n.code)}`],a=n.stderr.trimEnd();a!==""&&s.push("",a),r===void 0&&n.stdout.trim()!==""&&s.push("",n.stdout.trimEnd());let d=[];n.code===2&&n.stderr.includes(fr)&&d.push("The script asked the question above and had no terminal to answer it on, so it stopped having written nothing. It is a question for the person using you: no parameter of this tool answers it.");let l=`${n.stderr}
12
+ ${n.stdout}`;for(let[c,A]of Object.entries(e.flags))ht(l,c)&&d.push(`${c}, named above, is this tool's ${A}: true. Give it only once the person using you has accepted what it lets through.`);for(let[c,A]of Object.entries(e.named??{}))ht(l,c)&&d.push(`${c}, named above, ${typeof A=="function"?A(l):A}`);if(ut.has(n.code))d.push(...o(r));else if(In.has(n.code)){let c=o(r);c.length>0&&d.push("It stopped part way, between two calls to the org: what it wrote is kept, and said above.",...c)}let h=r===void 0?mr(n.stderr):void 0;return{head:[],said:s,added:d,structured:{exitCode:n.code,...r!==void 0?{answer:r}:{},...h!==void 0?{refused:h}:{}},answer:r,isError:!ut.has(n.code)}}var gr=30;async function ft(e,t){let n,o=new Promise(r=>{n=setTimeout(()=>r(void 0),Math.max(0,t))});try{return await Promise.race([e,o])}finally{clearTimeout(n)}}function wr(e,t){let{handle:n,meta:o}=e;return V([`ran: ${ke(t.script,t.args)}`,`still running: run_status with run "${n}" follows it (waitSeconds up to ${de}), and gives its answer once it has ended; run_stop with run "${n}" stops it as Ctrl-C would, what it wrote kept. It runs as long as this server: closing the agent's session stops it the same way.`],{running:{run:n,tool:o.tool,startedAt:o.startedAt,...o.expectedSeconds!==void 0?{expectedSeconds:o.expectedSeconds}:{},...o.plan!==void 0?{plan:o.plan}:{},...o.summary!==void 0?{summary:o.summary}:{}}},!1)}function Nn(e,t){let n={...e.structuredContent,run:{run:t,state:"ended"}};return V([e.content[0]?.text??""],n,e.isError)}function Dn(e,t){return`${e.written} records written`+(t!==void 0?` of the ${t} its plan counted`:"")+`, of ${e.objectsWritten} objects`+(e.failed>0?`, ${e.failed} refused by the org`:"")+(e.journal!==void 0?`; its journal is ${e.journal}`:"")}async function Fn(e,t,n=!1){let o=await e.runs.progress(t),r=t.meta.plan!==void 0?await le(e.journalDir,t.meta.plan):void 0,{handle:s}=t,a=[`run "${s}" of ${t.meta.tool} `+(t.running?n?"is stopping: it stops before its next call to the org, and says what it wrote":"is still running":"has ended, and what the server does after it \u2014 the verification of a clone \u2014 is under way")+`: ${o.elapsedSeconds} seconds since it started`+(o.expectedSeconds!==void 0?`, its plan said its writes take about ${o.expectedSeconds}`:"")+".",...o.summary?[`So far: ${Dn(o.summary,r?.totalRows)}.`]:[],...o.tail.length>0?["Its last lines:",...o.tail]:[],`run_status with run "${s}" follows it`+(t.running&&!n?`; run_stop with run "${s}" stops it.`:".")];return V(a,{running:{run:s,tool:t.meta.tool,startedAt:t.meta.startedAt,state:t.running?n?"stopping":"running":"settling",elapsedSeconds:o.elapsedSeconds,...o.expectedSeconds!==void 0?{expectedSeconds:o.expectedSeconds}:{},...r?{plan:{id:r.id,records:r.totalRows}}:{},...o.summary?{summary:o.summary}:{},tail:o.tail}},!1)}async function Mn(e,t,n){let{meta:o,summary:r}=n,s=r?.state==="running"?"its summary was last written while it ran: it was cut without saying it stopped":r?.state==="interrupted"?"it stopped part way, as its summary says":r?.state==="failed"?"it ended on an error, as its summary says":r?.state==="ended"?"it ended, as its summary says":"no summary of it is left",a=o.plan!==void 0?await le(e.journalDir,o.plan):void 0,d=r?.journal,l=[`run "${t}" of ${o.tool} is not one of this server's: the server that started it at ${o.startedAt} has ended, which stopped it as Ctrl-C stops it. ${s}`+(r?`: ${Dn(r,a?.totalRows)}`:"")+".",...o.tool==="clone_org"&&o.plan!==void 0&&o.target!==void 0?[`clone_org with plan "${o.plan}", resume: true and confirm "${o.target}" takes it up, writing nothing twice.`]:[],...d!==void 0&&o.target!==void 0?[`run_remove with module "forge", org "${o.target}" and run "${d}" takes it back: preview: true first says what it would delete.`]:[]];return V(l,{run:{run:t,state:"gone",tool:o.tool,startedAt:o.startedAt,...o.target!==void 0?{target:o.target}:{},...o.plan!==void 0?{plan:o.plan}:{},...r?{summary:r}:{}}},!1)}function Ln(e){return lt("RUN_UNKNOWN",`No run "${e}" on this machine: this server holds none by that handle, and no server before it left one. A call answers with the handle of its run only when it is still running after its hold; the handle is in that answer.`)}async function yr(e,t,n){let o=e.runs.get(t);if(o){let s=e.finalOf(t),a=Math.min(Math.max(0,n),de),d=s?await ft(s,a*1e3):void 0;return d?Nn(d,t):Fn(e,o)}let r=await e.runs.readOnDisk(t);return r?Mn(e,t,r):Ln(t)}async function br(e,t){let n=e.runs.get(t);if(n){let r=n.running;r&&(e.log(`sandforge mcp: run_stop stops ${t} as Ctrl-C stops its script`),n.stop());let s=e.finalOf(t),a=s?await ft(s,e.runs.holdMs):void 0;if(!a)return Fn(e,n,r);let d=Nn(a,t);return r?d:V([`run "${t}" had already ended: nothing was stopped.`,"",d.content[0]?.text??""],d.structuredContent,d.isError)}let o=await e.runs.readOnDisk(t);return o?Mn(e,t,o):Ln(t)}async function kr(e,t){let n=on(t);return e.all().find(r=>r.running&&r.meta.summary!==void 0&&on(r.meta.summary)===n)??await e.underWayWith(t)}function vr(e,t){return{code:"RUN_UNDER_WAY",message:`run_remove: ${t} is the run "${e.handle}" of ${e.meta.tool}, which this server still runs: a removal now would delete under it what it goes on writing. run_stop with run "${e.handle}" stops it, and run_status says when it has ended; then run_remove takes back what it wrote. Refused: nothing was read or written.`}}function Rr(e,t){return{code:"RUN_UNDER_WAY",message:`checkpoint_replay_remove: run "${e.handle}" of checkpoint_replay, which this server still runs, writes into ${t}: a removal now would delete under it what it goes on creating. run_stop with run "${e.handle}" stops it, and run_status says when it has ended; then checkpoint_replay_remove takes back what it created. Refused: nothing was read or written.`}}async function Wn(e,t,n,o){try{let r=new Set(t.all().filter(s=>s.running).map(s=>s.meta.plan));await nn(e,n,s=>r.has(s)),await t.sweep()}catch(r){o(`sandforge mcp: the plans and runs past their day could not all be removed: ${r instanceof Error?r.message:String(r)}`)}}var G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ce=e=>typeof e=="string"||typeof e=="number"&&Number.isInteger(e);function Ar(e){let t=e.runCommand??yo,n=e.log??(f=>{process.stderr.write(`${f}
13
+ `)}),o=e.journalDir??Be(),r=e.now??(()=>new Date),s=new ae({dir:Oe(o),holdMs:e.holdMs??xe(),now:r}),a=new Map,d=new AbortController,l={journalDir:o,runs:s,now:r,log:n,runCommand:t,stopping:d.signal,finalOf:f=>a.get(f)},h,c=new Map,A=new Set,y=new Set,L=new Set,B=f=>{let m=f.then(()=>{},()=>{}).finally(()=>{L.delete(m)});return L.add(m),f},T=f=>{e.send(JSON.stringify({jsonrpc:"2.0",...f}))},N=(f,m)=>f==="perRequest"?{resultType:"complete",...m,_meta:{[ue.serverInfo]:sn}}:m,W=f=>{let m=G(f)?f.protocolVersion:void 0;if(typeof m!="string")return{error:{code:E.invalidParams,message:"initialize names the protocol version it asks for in protocolVersion."}};let p=we.includes(m)?m:we[0];return h=p,n(`sandforge mcp: ${m===p?"agreed on":`asked for ${m}, offered`} ${p}`),{result:{protocolVersion:p,capabilities:{tools:{}},serverInfo:sn,instructions:an}}},ve=async(f,m,p)=>{if(!G(m)||typeof m.name!="string")return{error:{code:E.invalidParams,message:"tools/call names its tool in name."}};let g=ur.get(m.name);if(!g)return{error:{code:E.invalidParams,message:`Unknown tool: ${m.name}`}};if(m.arguments!==void 0&&!G(m.arguments))return{error:{code:E.invalidParams,message:"tools/call takes its arguments as an object."}};let x=s.newHandle(),_={handle:x,summary:s.summaryPathOf(x)};A.add(f);try{let O=await g.read(m.arguments??{},l,_);if(y.has(f))return;if("refusal"in O)return{result:N(p,{...lt(O.refusal.code,O.refusal.message)})};let{call:j}=O;if(j.writesTo!==void 0&&j.confirm!==j.writesTo)return{result:N(p,{...lt("CONFIRM",Oo(g,j.writesTo,j.confirm))})};if("local"in j.run){let Re=await j.run.local(l);return y.has(f)?void 0:{result:N(p,{...Re})}}return await zn(f,p,g,j,j.run,_)}finally{A.delete(f),y.delete(f)}},zn=async(f,m,p,g,x,_)=>{let{handle:O}=_,{script:j,args:Re,relayedBy:wt,follow:te}=x;await g.beforeStart(),n(`sandforge mcp: ${p.definition.name} runs ${ke(j,Re)}`);let oe=s.start({handle:O,tool:p.definition.name,...g.writesTo!==void 0?{target:g.writesTo}:{},...te?.plan!==void 0?{plan:te.plan}:{},...te?.summary!==void 0?{summary:te.summary}:{},...te?.expectedSeconds!==void 0?{expectedSeconds:te.expectedSeconds}:{}},({signal:J,onStderr:M})=>{let re={...wt!==void 0?{relayedBy:wt}:{},onStderr:M};return t(j,Re,J,re).catch(We=>({code:1,stdout:"",stderr:`${Ae(j)} could not be started: ${We instanceof Error?We.message:String(We)}`}))}),Le=B(oe.settled(async J=>{let M=Cn(p,x,J,g.after);if(!g.settle)return Ne(M);try{return Ne(await g.settle({ran:J,run:x,launch:_,parts:M,context:l}))}catch(re){return Ne({...M,added:[...M.added,`What the server does once ${p.definition.name} has ended failed: ${re instanceof Error?re.message:String(re)}.`],isError:!0})}}));a.set(O,Le),c.set(f,oe),y.has(f)&&oe.stop();try{let J=await ft(Le,s.holdMs);if(y.has(f)){await Le,a.delete(O);return}return J!==void 0?(a.delete(O),{result:N(m,{...J})}):(await s.handBack(oe).catch(M=>{n(`sandforge mcp: what a later server reads of ${O} could not be written: ${M instanceof Error?M.message:String(M)}`)}),n(`sandforge mcp: ${p.definition.name} handed back as ${O}, still running`),{result:N(m,{...wr(oe,x)})})}finally{c.delete(f)}},qn=async(f,m,p)=>{if(m==="initialize")return W(p);let g=G(p)&&G(p._meta)?p._meta:void 0,x=g?.[ue.version],_;if(x!==void 0){if(x!==ee)return{error:{code:E.unsupportedVersion,message:"Unsupported protocol version",data:{supported:[ee],requested:String(x)}}};if(!G(g?.[ue.capabilities]))return{error:{code:E.invalidParams,message:`A request of ${ee} names its client's capabilities in _meta["${ue.capabilities}"].`}};_="perRequest"}else{if(m==="ping")return{result:{}};if(h!==void 0)_="handshake";else return{error:{code:E.invalidParams,message:`Name the protocol version in _meta["${ue.version}"] (${ee}), or open with initialize (${we.join(", ")}).`}}}switch(m){case"server/discover":if(_!=="perRequest")break;return{result:N(_,{supportedVersions:[ee],capabilities:{tools:{}},instructions:an,ttlMs:rn,cacheScope:"public"})};case"ping":return{result:N(_,{})};case"tools/list":return{result:N(_,{tools:Me.map(O=>O.definition),..._==="perRequest"?{ttlMs:rn,cacheScope:"public"}:{}})};case"tools/call":return ve(f,p,_)}return{error:{code:E.methodNotFound,message:`${m} is not a method of this server: it serves tools/list and tools/call.`}}},Un=(f,m)=>{if(f!=="notifications/cancelled"||!G(m))return;let{requestId:p}=m;if(!Ce(p)||!A.has(p))return;y.add(p);let g=c.get(p);g&&(n(`sandforge mcp: request ${String(p)} cancelled: its script is stopped as Ctrl-C stops it`),g.stop())},Bn=f=>{let m=f.trim();if(m==="")return;let p;try{p=JSON.parse(m)}catch{T({error:{code:E.parse,message:"Parse error: a line that is not JSON."}});return}if(Array.isArray(p)){T({error:{code:E.invalidRequest,message:"A batch is not a message of this protocol: send one message a line."}});return}if(!G(p)){T({error:{code:E.invalidRequest,message:"A message is a JSON-RPC object."}});return}let{id:g,method:x,params:_}=p;if(x===void 0&&("result"in p||"error"in p))return;if(p.jsonrpc!=="2.0"||typeof x!="string"){T({...Ce(g)?{id:g}:{},error:{code:E.invalidRequest,message:'A message has jsonrpc "2.0" and a method.'}});return}if(g===void 0){Un(x,_);return}if(!Ce(g)||A.has(g)){T({error:{code:E.invalidRequest,message:Ce(g)?`A request with the id ${String(g)} is still under way: give each its own.`:"A request id is a string or a whole number."}});return}let O=qn(g,x,_).then(j=>{j!==void 0&&T({id:g,...j})}).catch(j=>{T({id:g,error:{code:E.internal,message:j instanceof Error?j.message:String(j)}})}).finally(()=>{L.delete(O)});L.add(O)},mt=async()=>{for(d.abort(),await s.stopAll();L.size>0;)await Promise.allSettled([...L])},gt=mo({input:e.input,crlfDelay:1/0});return gt.on("line",Bn),{done:new Promise(f=>{gt.once("close",()=>{mt().then(f)})}),stop:mt}}function jr(e,t){let n=e.write.bind(e);return e.write=t.write.bind(t),o=>{n(`${o}
14
14
  `)}}var Sr=`sandforge mcp \u2014 Seed, Forge's clone of a record, of the records a query chooses or of the
15
15
  whole org, the removal of a run, the emptying of objects or of a whole org, Checkpoints and their
16
16
  replay into another org, the environments of a sandforge.yaml and the plan of an Automation
@@ -24,9 +24,9 @@ Usage:
24
24
  claude mcp add sandforge -- npx -y sandforge mcp
25
25
 
26
26
  Protocol: MCP ${ee}, each request naming it in _meta; and the initialize handshake of
27
- ${ge.join(", ")}.
27
+ ${we.join(", ")}.
28
28
 
29
- Tools: ${Fe.map(e=>e.definition.name).join(", ")}.
29
+ Tools: ${Me.map(e=>e.definition.name).join(", ")}.
30
30
  Each one but seed_templates runs the script of this folder that does the same, with --json, in a
31
31
  process of its own, and answers with its JSON, its exit code and its lines: every guard of the
32
32
  script holds. A tool that writes to an org needs confirm, the alias of that org exactly, or it is
@@ -53,7 +53,7 @@ Environment:
53
53
  a call before it cancels it
54
54
 
55
55
  --help this text
56
- `;async function _r(e=process.argv){let t=e.slice(2);if(t.includes("--help")||t.includes("-h")){process.stdout.write(Sr);return}It(t,{switches:[],values:[]});let n=jr(process.stdout,process.stderr),o=Be();await Wn(o,new se({dir:xe(o),holdMs:0}),new Date,a=>{process.stderr.write(`${a}
57
- `)});let r=Ar({input:process.stdin,send:n,journalDir:o});process.stdout.on("error",()=>{r.stop().then(()=>process.exit(0))});let s=Nt(a=>{r.stop().then(()=>process.exit(je(a)))});process.stderr.write(`sandforge mcp: ${Fe.length} tools on stdio, MCP ${ee} (and ${ge.join(", ")} by initialize)
56
+ `;async function _r(e=process.argv){let t=e.slice(2);if(t.includes("--help")||t.includes("-h")){process.stdout.write(Sr);return}It(t,{switches:[],values:[]});let n=jr(process.stdout,process.stderr),o=Be();await Wn(o,new ae({dir:Oe(o),holdMs:0}),new Date,a=>{process.stderr.write(`${a}
57
+ `)});let r=Ar({input:process.stdin,send:n,journalDir:o});process.stdout.on("error",()=>{r.stop().then(()=>process.exit(0))});let s=Nt(a=>{r.stop().then(()=>process.exit(Se(a)))});process.stderr.write(`sandforge mcp: ${Me.length} tools on stdio, MCP ${ee} (and ${we.join(", ")} by initialize)
58
58
  `),await r.done,s()}/sandforge-mcp\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(Wt(),_r().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
59
- `),process.exit(1)}));export{E as ERROR,ge as HANDSHAKE_VERSIONS,an as INSTRUCTIONS,ee as PROTOCOL_VERSION,Fe as TOOLS,Tn as checkpointReplayLine,jr as claimStdout,Ko as cloneOrgPlanLine,En as cloneRecordsLine,be as commandText,Oo as confirmRefusal,pr as exitWords,_r as main,_o as pipelinePlanLine,nr as planLines,er as planSummaryOf,No as replayConfigWords,Mo as requiredFieldWords,ii as resultOf,$n as rootsQueryOf,qo as rootsQueryWords,Ar as serve,wo as toolRunner};
59
+ `),process.exit(1)}));export{E as ERROR,we as HANDSHAKE_VERSIONS,an as INSTRUCTIONS,ee as PROTOCOL_VERSION,Me as TOOLS,Tn as checkpointReplayLine,jr as claimStdout,Ko as cloneOrgPlanLine,En as cloneRecordsLine,ke as commandText,Oo as confirmRefusal,pr as exitWords,_r as main,_o as pipelinePlanLine,nr as planLines,er as planSummaryOf,No as replayConfigWords,Mo as requiredFieldWords,ii as resultOf,$n as rootsQueryOf,qo as rootsQueryWords,Ar as serve,wo as toolRunner};