@testmuai/kane-cli 0.10.0-rc.1 → 0.10.0-rc.3

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 (231) hide show
  1. package/dist/{ChatSurface-VPD5G67Q.js → ChatSurface-6NZGMNHL.js} +1 -1
  2. package/dist/{ChromeProfilePicker-CRKQEFYD.js → ChromeProfilePicker-M4WXOB5O.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-M7BMWLKK.js → CliFeedbackPrompt-6MJA7DF6.js} +1 -1
  4. package/dist/{CliUploadProgress-OP7DXMC2.js → CliUploadProgress-6NLS7XHH.js} +1 -1
  5. package/dist/{ConfigView-XI74BCCH.js → ConfigView-O4WKZ5PU.js} +1 -1
  6. package/dist/{EvidenceViewOffer-HAAK6DS5.js → EvidenceViewOffer-WIEWCZUP.js} +1 -1
  7. package/dist/FolderPicker-AF7ZMV3M.js +2 -0
  8. package/dist/InfoBox-D7GGZJU4.js +2 -0
  9. package/dist/{LinksBox-PNSESNCU.js → LinksBox-DXP66H3H.js} +1 -1
  10. package/dist/{ProfilesView-PYDZZHKO.js → ProfilesView-TWOY5PVC.js} +1 -1
  11. package/dist/ProjectPicker-OBYHJJLU.js +2 -0
  12. package/dist/SaveSessionPrompt-7XSHS4NL.js +2 -0
  13. package/dist/SingleShotApp-XQUDR36R.js +2 -0
  14. package/dist/{SummaryBox-FALOODAQ.js → SummaryBox-IA2KS6GT.js} +1 -1
  15. package/dist/TestMdRunView-LS2QUFWR.js +2 -0
  16. package/dist/TestrunEvidenceTable-HNDVJDIF.js +2 -0
  17. package/dist/{WhoamiView-6WXGRANY.js → WhoamiView-SNL75TEF.js} +1 -1
  18. package/dist/{app-download-RXVZB6MM.js → app-download-UI4ABEIX.js} +1 -1
  19. package/dist/{assurance-job-C3TXZGLL.js → assurance-job-FFSSS4XV.js} +1 -1
  20. package/dist/{binary-DJCDMGPX.js → binary-THPLXCOD.js} +1 -1
  21. package/dist/{bind-XVO4CQYV.js → bind-4XWK3DG2.js} +1 -1
  22. package/dist/{bootstrap-TY5RANJ7.js → bootstrap-6ACT4ALI.js} +1 -1
  23. package/dist/{catalog-RRQF4TCA.js → catalog-MYPS2BXY.js} +1 -1
  24. package/dist/{changelog-GBEVIUFJ.js → changelog-SU674BVE.js} +1 -1
  25. package/dist/{chunk-AA674WLL.js → chunk-2DYHAP4E.js} +1 -1
  26. package/dist/{chunk-VG44B5JD.js → chunk-36N3EHW5.js} +1 -1
  27. package/dist/{chunk-P7MSVLAH.js → chunk-3E4ZO73O.js} +1 -1
  28. package/dist/{chunk-NWD54VV5.js → chunk-3F5FMH76.js} +1 -1
  29. package/dist/{chunk-I5NSJBOZ.js → chunk-3OQW2GTA.js} +1 -1
  30. package/dist/{chunk-LRS5MGBY.js → chunk-3RJHXOZH.js} +1 -1
  31. package/dist/{chunk-DDJNYQBH.js → chunk-3YTCKCBG.js} +1 -1
  32. package/dist/{chunk-252FWF2G.js → chunk-457Y5TEC.js} +1 -1
  33. package/dist/{chunk-DD5TULWQ.js → chunk-4QFTHUJA.js} +1 -1
  34. package/dist/{chunk-672CQECV.js → chunk-4YW767UV.js} +7 -7
  35. package/dist/{chunk-7LKCWO2R.js → chunk-5AKJPYUW.js} +3 -3
  36. package/dist/{chunk-VQLH63X7.js → chunk-6DZX5HLZ.js} +1 -1
  37. package/dist/{chunk-QHRUBG7J.js → chunk-6EB5VRAN.js} +1 -1
  38. package/dist/{chunk-QS5ZJFGF.js → chunk-734ORT6O.js} +1 -1
  39. package/dist/{chunk-57MDWTON.js → chunk-7AET4JKQ.js} +1 -1
  40. package/dist/{chunk-W3OVSDBN.js → chunk-7HMSMAUG.js} +1 -1
  41. package/dist/{chunk-FFL55I2M.js → chunk-7NPTL66J.js} +1 -1
  42. package/dist/{chunk-T7H4LBFK.js → chunk-7SY34IIL.js} +1 -1
  43. package/dist/{chunk-RFIIM33J.js → chunk-7YT4TTKL.js} +1 -1
  44. package/dist/{chunk-CPBBYNL7.js → chunk-ACMBMZDQ.js} +1 -1
  45. package/dist/{chunk-UALJTPSA.js → chunk-AEWNWAXW.js} +1 -1
  46. package/dist/{chunk-V7S6S5W3.js → chunk-AVSMXDTX.js} +1 -1
  47. package/dist/{chunk-MGNRNLBE.js → chunk-C2RUDJ46.js} +1 -1
  48. package/dist/{chunk-QQ4TKLWP.js → chunk-C62QWG4B.js} +1 -1
  49. package/dist/{chunk-OEWYXCTA.js → chunk-CCP4X75B.js} +1 -1
  50. package/dist/{chunk-LRXBJTD4.js → chunk-CGITGJ3I.js} +1 -1
  51. package/dist/{chunk-QCKA665H.js → chunk-CM4CHYSN.js} +1 -1
  52. package/dist/{chunk-2OOFURWD.js → chunk-CUXY6KQ2.js} +1 -1
  53. package/dist/{chunk-I6OQISK4.js → chunk-D36V5OX6.js} +1 -1
  54. package/dist/{chunk-LNNWCBPQ.js → chunk-D7TKE7LK.js} +1 -1
  55. package/dist/{chunk-2IZRPMZN.js → chunk-D7U2M26S.js} +1 -1
  56. package/dist/{chunk-SONMD3W5.js → chunk-DDZLCAEO.js} +1 -1
  57. package/dist/{chunk-NWBLYMH7.js → chunk-DJC7NTLA.js} +1 -1
  58. package/dist/{chunk-TW63WWEN.js → chunk-DZOYYWOW.js} +1 -1
  59. package/dist/{chunk-UAWWLLTI.js → chunk-EBPRPNSA.js} +1 -1
  60. package/dist/{chunk-T3HEJASG.js → chunk-ECPFI75W.js} +1 -1
  61. package/dist/{chunk-JQSLUGD4.js → chunk-EECDDDSB.js} +1 -1
  62. package/dist/{chunk-7EXDYXXD.js → chunk-ETZMFRD6.js} +1 -1
  63. package/dist/{chunk-5BUIIFLC.js → chunk-F22K3RRX.js} +1 -1
  64. package/dist/{chunk-BJJUKB5K.js → chunk-F5NHG7VB.js} +1 -1
  65. package/dist/{chunk-B2HXPGIZ.js → chunk-FWDUVFS6.js} +3 -3
  66. package/dist/{chunk-T4AVLJCW.js → chunk-FWUPJORV.js} +1 -1
  67. package/dist/{chunk-VYHT2IET.js → chunk-GQRU3B54.js} +1 -1
  68. package/dist/{chunk-AIXJYMSP.js → chunk-GXKY5A46.js} +1 -1
  69. package/dist/{chunk-QTZBVDPR.js → chunk-HCJ2N3XB.js} +1 -1
  70. package/dist/{chunk-XBEYWXPV.js → chunk-HJMCXSUJ.js} +1 -1
  71. package/dist/{chunk-ZZP5SHUV.js → chunk-HK62JVQM.js} +1 -1
  72. package/dist/{chunk-3UVSAAES.js → chunk-I4RVVBG3.js} +1 -1
  73. package/dist/{chunk-JPYW6U4D.js → chunk-I4WXALQR.js} +1 -1
  74. package/dist/{chunk-OVNRRI4E.js → chunk-ICLUC44J.js} +1 -1
  75. package/dist/{chunk-DHQ4SQWA.js → chunk-IGEAET7M.js} +1 -1
  76. package/dist/{chunk-IXW7FOGX.js → chunk-IJ2AHSWW.js} +1 -1
  77. package/dist/{chunk-2S3W2JT3.js → chunk-IUQOG7Z5.js} +1 -1
  78. package/dist/{chunk-IBBD36FQ.js → chunk-JZP3Y4ZM.js} +1 -1
  79. package/dist/{chunk-NDEI7R4K.js → chunk-KODJVOCN.js} +1 -1
  80. package/dist/{chunk-IMDMRJQ6.js → chunk-KXHJMAZU.js} +1 -1
  81. package/dist/{chunk-OQ5G773E.js → chunk-L5DALV5N.js} +1 -1
  82. package/dist/{chunk-S53AQU7R.js → chunk-LAOTVZHV.js} +1 -1
  83. package/dist/{chunk-NQTYWHPB.js → chunk-LIGTP3A3.js} +1 -1
  84. package/dist/{chunk-7RPKHKA3.js → chunk-LQQNPMOD.js} +1 -1
  85. package/dist/{chunk-OZNBTSW5.js → chunk-LUR7JFPP.js} +1 -1
  86. package/dist/{chunk-QNLVC5ZB.js → chunk-LUZBGTYB.js} +1 -1
  87. package/dist/{chunk-N3TCNZSX.js → chunk-M43WH5DQ.js} +1 -1
  88. package/dist/{chunk-432ZOE42.js → chunk-MEKPGQAM.js} +1 -1
  89. package/dist/{chunk-GZFLJORM.js → chunk-NIVFEACM.js} +1 -1
  90. package/dist/{chunk-SA6IKFFD.js → chunk-NXAJBSIF.js} +1 -1
  91. package/dist/{chunk-MII3JOO3.js → chunk-NZ6AV2TA.js} +1 -1
  92. package/dist/{chunk-2SWSVJUP.js → chunk-OCDBTAYS.js} +1 -1
  93. package/dist/{chunk-SLKYD44Y.js → chunk-OGFU4YY4.js} +1 -1
  94. package/dist/{chunk-4LPX2OLV.js → chunk-P3JXJ4BW.js} +1 -1
  95. package/dist/{chunk-Y4T4SLDO.js → chunk-PAWQ4AKN.js} +1 -1
  96. package/dist/{chunk-6NWT2TEJ.js → chunk-QBYENBMB.js} +1 -1
  97. package/dist/{chunk-XIPKSXRQ.js → chunk-QDXKEOKI.js} +3 -3
  98. package/dist/{chunk-T6K2MEWP.js → chunk-QENCC2ZS.js} +1 -1
  99. package/dist/{chunk-SWMTXMKB.js → chunk-RF37IJNN.js} +1 -1
  100. package/dist/{chunk-XJ7HCXKW.js → chunk-RHGW7B5Q.js} +1 -1
  101. package/dist/{chunk-H3HHSTEK.js → chunk-RTVHJ23A.js} +1 -1
  102. package/dist/{chunk-OAKYUBD3.js → chunk-SGPAM5DZ.js} +1 -1
  103. package/dist/{chunk-RG372DON.js → chunk-TU42YZOJ.js} +1 -1
  104. package/dist/{chunk-V5JGXOV7.js → chunk-TU7TVFBK.js} +1 -1
  105. package/dist/{chunk-AJQZ3ST5.js → chunk-TW5AA5A7.js} +1 -1
  106. package/dist/{chunk-WI7K6VKQ.js → chunk-URH4FX3H.js} +1 -1
  107. package/dist/{chunk-BVO4C5F2.js → chunk-V7USCQWO.js} +1 -1
  108. package/dist/{chunk-4D5PC6QE.js → chunk-VSVWNRI2.js} +1 -1
  109. package/dist/{chunk-BZVNI44O.js → chunk-VUFIL5VR.js} +2 -2
  110. package/dist/{chunk-74W4AOT2.js → chunk-VX657KIK.js} +1 -1
  111. package/dist/{chunk-A6TJOZ24.js → chunk-VXGN3IV7.js} +1 -1
  112. package/dist/{chunk-2OSFI33O.js → chunk-VZ4A6WMK.js} +3 -3
  113. package/dist/{chunk-M6MBMRFR.js → chunk-W4QSZNMB.js} +1 -1
  114. package/dist/{chunk-EXFDIVNI.js → chunk-W54OT2FU.js} +2 -2
  115. package/dist/{chunk-NFRA64NU.js → chunk-W6HZF56M.js} +1 -1
  116. package/dist/{chunk-MZOIHUVX.js → chunk-W72ACCFL.js} +2 -2
  117. package/dist/{chunk-JD52IXON.js → chunk-WAOUE7MP.js} +1 -1
  118. package/dist/{chunk-WYSZ6TPW.js → chunk-WEIPY3CI.js} +10 -9
  119. package/dist/{chunk-I2KOGINW.js → chunk-WXJCJL5L.js} +1 -1
  120. package/dist/{chunk-LWJRSUE2.js → chunk-WZXPF3BI.js} +1 -1
  121. package/dist/{chunk-OF7WPCTQ.js → chunk-XLEGGC4Y.js} +1 -1
  122. package/dist/{chunk-6LIC2R22.js → chunk-XQMWHPZI.js} +1 -1
  123. package/dist/{chunk-D4FFXCX6.js → chunk-XRNQSXOM.js} +2 -2
  124. package/dist/{chunk-RW3Z2HMB.js → chunk-XZGEN4NU.js} +1 -1
  125. package/dist/{chunk-DNGOT65K.js → chunk-Y7E5L42F.js} +1 -1
  126. package/dist/{chunk-K45BKGB5.js → chunk-YAW6JW6D.js} +1 -1
  127. package/dist/{chunk-ENL4XTQ2.js → chunk-YGRULEZY.js} +1 -1
  128. package/dist/{chunk-F3U6T4YD.js → chunk-YHFZFV3A.js} +2 -2
  129. package/dist/{chunk-RX47NRSM.js → chunk-YLXWAY7D.js} +1 -1
  130. package/dist/{chunk-WEM3MOAL.js → chunk-YPFQ4UGF.js} +1 -1
  131. package/dist/{chunk-6U7ID777.js → chunk-YQ5C6UDG.js} +1 -1
  132. package/dist/{chunk-HFJSP4KD.js → chunk-ZAFJQ3SM.js} +1 -1
  133. package/dist/{chunk-2NFS4KE4.js → chunk-ZTRRFG52.js} +1 -1
  134. package/dist/{chunk-L4UVUFL6.js → chunk-ZU4W2QGM.js} +1 -1
  135. package/dist/{config-5ZOALGKE.js → config-754B73XK.js} +1 -1
  136. package/dist/{cover-cmd-UA2SVIZZ.js → cover-cmd-NBNZCR6C.js} +1 -1
  137. package/dist/{credentials-MRG452Y6.js → credentials-F7DYLVWY.js} +1 -1
  138. package/dist/{deps-bundle-FWINW4XM.js → deps-bundle-PW3WEQJ7.js} +1 -1
  139. package/dist/{deps-resolve-IET4KIBO.js → deps-resolve-SQYVN76L.js} +1 -1
  140. package/dist/{design-chat-MM5PJD2N.js → design-chat-F3OEZPNJ.js} +1 -1
  141. package/dist/{design-headless-FZONCKHW.js → design-headless-OTHYOX3E.js} +1 -1
  142. package/dist/{design-remote-SPVRIY2H.js → design-remote-2BEGCVCX.js} +2 -2
  143. package/dist/device-env-CHFRRV6W.js +2 -0
  144. package/dist/{doctor-VAX2BWQF.js → doctor-XY26Z35T.js} +1 -1
  145. package/dist/{evidence-LVVK7ROT.js → evidence-P6FFKC7B.js} +1 -1
  146. package/dist/{evolve-cmd-AGRKG7T3.js → evolve-cmd-WWOB3QJR.js} +1 -1
  147. package/dist/{evolve-remote-BGHULJTL.js → evolve-remote-WLVY3QID.js} +1 -1
  148. package/dist/{explain-cmd-WOBGS6KX.js → explain-cmd-OP5I5W3O.js} +1 -1
  149. package/dist/explore-K5YBGHK6.js +2 -0
  150. package/dist/{explore-context-tty-JTZVZFOE.js → explore-context-tty-RZ7D2TBV.js} +1 -1
  151. package/dist/{explore-entry-5OGNLFAU.js → explore-entry-EKXJ67BD.js} +4 -4
  152. package/dist/{explore-live-2XZHUYFS.js → explore-live-2YVRAQZO.js} +1 -1
  153. package/dist/{explore-run-tty-LGTIK2NA.js → explore-run-tty-D47FGPX7.js} +2 -2
  154. package/dist/{extract-bind-NM2BBK4I.js → extract-bind-W2NET364.js} +3 -3
  155. package/dist/{extract-chat-HLQMJJIC.js → extract-chat-M65NWGUK.js} +1 -1
  156. package/dist/{extract-cmd-T2TSAC3N.js → extract-cmd-FTFLETOP.js} +2 -2
  157. package/dist/{extract-headless-OQTQ3FJK.js → extract-headless-G6W6JQ27.js} +1 -1
  158. package/dist/{folder-flags-WXUR6OPJ.js → folder-flags-KKIH654K.js} +1 -1
  159. package/dist/{gaps-cmd-PTSKPTF7.js → gaps-cmd-OIDDLRYL.js} +1 -1
  160. package/dist/{gate-P57VP4E5.js → gate-7AKRPRMK.js} +1 -1
  161. package/dist/{generate-headless-JYZP6VXZ.js → generate-headless-RURIEKVS.js} +2 -2
  162. package/dist/index.js +19 -19
  163. package/dist/{ingest-cmd-LHCBMO4Z.js → ingest-cmd-4G2AK4Y2.js} +3 -3
  164. package/dist/{ingest-remote-D5TO5JQP.js → ingest-remote-SSLUHQVG.js} +1 -1
  165. package/dist/install-ZVBHPXGP.js +2 -0
  166. package/dist/{interactive-bind-5EJQUGKI.js → interactive-bind-SI2ZS55Q.js} +2 -2
  167. package/dist/{interactive-remote-D77ULJGL.js → interactive-remote-J56EWJGA.js} +1 -1
  168. package/dist/{lattice-auth-74XGF77Y.js → lattice-auth-6FEVSR7E.js} +1 -1
  169. package/dist/{lifecycle-cmd-7SM6UCMH.js → lifecycle-cmd-HJ37LTXE.js} +1 -1
  170. package/dist/{list-cmd-Z6FZXMFU.js → list-cmd-6XL2FYLQ.js} +1 -1
  171. package/dist/{list-commands-CZYZ7GIG.js → list-commands-5DCCKU3L.js} +1 -1
  172. package/dist/{list-remote-WOPOC6KK.js → list-remote-LXPQNXYN.js} +1 -1
  173. package/dist/login-flow-WEK3E476.js +2 -0
  174. package/dist/{maintenance-cmd-VRTGZVRE.js → maintenance-cmd-BXXHP36K.js} +1 -1
  175. package/dist/{mobile-prompts-KNAHU64X.js → mobile-prompts-CECJ5UY2.js} +1 -1
  176. package/dist/{onboarding-LGT6PMDZ.js → onboarding-PDVYMTY5.js} +1 -1
  177. package/dist/{persist-recorded-session-BX7II5P7.js → persist-recorded-session-A3ID7JFA.js} +1 -1
  178. package/dist/{pipeline-IXVTVRS5.js → pipeline-GX3LKPI5.js} +1 -1
  179. package/dist/{prepare-target-ULMKVKMC.js → prepare-target-FMT6QFHZ.js} +1 -1
  180. package/dist/{pull-cmd-6AL2WYHB.js → pull-cmd-UPFQYUND.js} +1 -1
  181. package/dist/{pull-route-TTVARJMV.js → pull-route-FWBXJMR7.js} +1 -1
  182. package/dist/real-device-run-X7JJWOIK.js +2 -0
  183. package/dist/{reconcile-cmd-R6H37SQR.js → reconcile-cmd-JBH365JL.js} +4 -4
  184. package/dist/{reconcile-remote-GWDV5CUT.js → reconcile-remote-BCX6SWFC.js} +2 -2
  185. package/dist/{recording-banner-ACC67Q2U.js → recording-banner-YKBAL6UB.js} +1 -1
  186. package/dist/registry-VQC757MJ.js +2 -0
  187. package/dist/remote-entry-X6JMPC2K.js +2 -0
  188. package/dist/{remote-mode-7G6PLJCW.js → remote-mode-FDPA7EWG.js} +1 -1
  189. package/dist/{remote-words-45USLRVN.js → remote-words-YVB66R3F.js} +1 -1
  190. package/dist/{require-project-folder-A3UDRELU.js → require-project-folder-MLMEQJYP.js} +1 -1
  191. package/dist/{resolve-run-intent-ZGPSUBXV.js → resolve-run-intent-PC7TQZUL.js} +1 -1
  192. package/dist/{resolver-IPM6R7U4.js → resolver-EID34LQE.js} +1 -1
  193. package/dist/{review-cmd-NNT5C5RZ.js → review-cmd-EUHFLFMY.js} +1 -1
  194. package/dist/{run-remote-3AYYVPKX.js → run-remote-SJCRTL7O.js} +1 -1
  195. package/dist/{run-startup-gate-NKRMKYBB.js → run-startup-gate-YO66G6LS.js} +1 -1
  196. package/dist/{run-test-md-HE6DUWQR.js → run-test-md-BLNBK4MH.js} +2 -2
  197. package/dist/session-worker.js +2 -2
  198. package/dist/{sessions-cmd-GYMETJHG.js → sessions-cmd-S7WZBUCN.js} +1 -1
  199. package/dist/{sessions-remote-GI7GOBMH.js → sessions-remote-IWHWIQ2T.js} +1 -1
  200. package/dist/{skill-installer-3QAVQGDH.js → skill-installer-MAVQY6GW.js} +1 -1
  201. package/dist/{store-X6XPFSKF.js → store-MSA7KASS.js} +1 -1
  202. package/dist/{store-choice-RT73HAI7.js → store-choice-3OJCV26J.js} +1 -1
  203. package/dist/{store-guard-SNWKLHQV.js → store-guard-OOSDLMEC.js} +1 -1
  204. package/dist/{sync-cmd-NBPPDG3B.js → sync-cmd-RDFDMVKQ.js} +1 -1
  205. package/dist/{sync-setup-5NUCH6N3.js → sync-setup-RBRDUV7Q.js} +1 -1
  206. package/dist/tcg-generate-KIECTZ2C.js +2 -0
  207. package/dist/{testmd-actions-GH5BW5V5.js → testmd-actions-CMAG6HWI.js} +1 -1
  208. package/dist/{testmd-sync-ACKCIOL3.js → testmd-sync-UPAA5UMD.js} +1 -1
  209. package/dist/token-refresh-KP3AYMYK.js +2 -0
  210. package/dist/{validate-basic-RE2WLIGQ.js → validate-basic-M5JHHNZA.js} +1 -1
  211. package/dist/{version-check-4FJVZP3K.js → version-check-Q737BE65.js} +1 -1
  212. package/dist/{view-cmd-N47BQZPD.js → view-cmd-XSNL5DGI.js} +1 -1
  213. package/dist/{walk-session-DA7QWXSW.js → walk-session-SHGYLFRB.js} +1 -1
  214. package/dist/{with-telemetry-7V4LY2BG.js → with-telemetry-PM2HVN2B.js} +1 -1
  215. package/package.json +11 -11
  216. package/dist/FolderPicker-W5S6RFCP.js +0 -2
  217. package/dist/InfoBox-OWUEHV2D.js +0 -2
  218. package/dist/ProjectPicker-BGFCUGT5.js +0 -2
  219. package/dist/SaveSessionPrompt-SUJE54GS.js +0 -2
  220. package/dist/SingleShotApp-4TDXZEUA.js +0 -2
  221. package/dist/TestMdRunView-4GPRWHEU.js +0 -2
  222. package/dist/TestrunEvidenceTable-OBVQJ6IO.js +0 -2
  223. package/dist/device-env-LXJ65AVF.js +0 -2
  224. package/dist/explore-LOKNOVNP.js +0 -2
  225. package/dist/install-Z6K2D2VY.js +0 -2
  226. package/dist/login-flow-2FZEOVHM.js +0 -2
  227. package/dist/real-device-run-2LFS5WE2.js +0 -2
  228. package/dist/registry-6IJYQXQC.js +0 -2
  229. package/dist/remote-entry-YL7O2NJQ.js +0 -2
  230. package/dist/tcg-generate-Z23CUISY.js +0 -2
  231. package/dist/token-refresh-4UCYAG6A.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as A,d as C}from"./chunk-T4AVLJCW.js";import{e as x}from"./chunk-5D7ENQTQ.js";import{b,e as R}from"./chunk-RFIIM33J.js";import{f as D,h as S,l as E}from"./chunk-NFRA64NU.js";import{b as I,c as _,g as N,h as k}from"./chunk-Y6Y6RAY4.js";import{b as h}from"./chunk-SA6IKFFD.js";import{a as v}from"./chunk-MGNRNLBE.js";import{h as y}from"./chunk-A7RJQJNT.js";import{mkdirSync as H,writeFileSync as q}from"fs";import{join as z}from"path";function P(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||v(e).mobileAppBaseUrl}var J="device-config.json",$=new WeakMap;function G(e,t){let r=$.get(e)??new Map;$.set(e,r);let o=JSON.stringify([t.path,t.type,t.env,t.orgId]),i=r.get(o);if(i)return i;let n=e(t).finally(()=>r.delete(o));return r.set(o,n),n}function T(e){return e.startsWith("lt://")?e:`lt://${e}`}async function X(e,t){let r=await E(e.env,e.platform,{...e.selection.deviceName?{deviceName:e.selection.deviceName.value}:{},...e.selection.osVersion?{osVersion:e.selection.osVersion.value}:{}},t);if(r.kind==="unchecked"&&e.onWarning?.(`${r.reason} \u2014 the run continues, but the device and OS version are not checked before the session is requested.`),r.kind==="refused")throw new Error(r.detail)}async function Y(e,t){let r=e.selection.app.value.trim();if(h(r))return T(r);let o=e.credentials;if(!o?.orgId)throw new Error(`${r} has to be uploaded before it can run on a real device, but your account's org id was not found. Run kane-cli login, or set app: to an app ID from \`kane-cli apps list --target ${e.platform}\`.`);let i=await G(t,{path:r,type:e.platform,env:e.env,orgId:o.orgId,userId:o.userId??"",auth:{username:o.username,accessKey:o.accessKey,orgId:o.orgId},baseUrl:P(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if(b(i))throw new Error(`could not upload ${r} for this real-device run: ${i.reason}`);return T(i.appUrl??i.appId)}async function U(e,t={}){if(!e.credentials)throw new Error("a real-device run needs your TestMu AI username and access key, and none were found. Run kane-cli login, or pass --username and --access-key.");await X(e,t.fetchCatalog??S);let r=await Y(e,t.upload??R),{deviceName:o,osVersion:i}=e.selection,n={platform_name:e.platform,device_name:o?.value??D,...i?{platform_version:i.value}:{},app:r,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},s=z(e.outDir,J);return H(e.outDir,{recursive:!0}),q(s,`${JSON.stringify(n,null,2)}
2
+ import{c as A,d as C}from"./chunk-FWUPJORV.js";import{e as x}from"./chunk-5D7ENQTQ.js";import{b,e as R}from"./chunk-7YT4TTKL.js";import{f as D,h as S,l as E}from"./chunk-W6HZF56M.js";import{b as I,c as _,g as N,h as k}from"./chunk-Y6Y6RAY4.js";import{b as h}from"./chunk-NXAJBSIF.js";import{a as v}from"./chunk-C2RUDJ46.js";import{h as y}from"./chunk-A7RJQJNT.js";import{mkdirSync as H,writeFileSync as q}from"fs";import{join as z}from"path";function P(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||v(e).mobileAppBaseUrl}var J="device-config.json",$=new WeakMap;function G(e,t){let r=$.get(e)??new Map;$.set(e,r);let o=JSON.stringify([t.path,t.type,t.env,t.orgId]),i=r.get(o);if(i)return i;let n=e(t).finally(()=>r.delete(o));return r.set(o,n),n}function T(e){return e.startsWith("lt://")?e:`lt://${e}`}async function X(e,t){let r=await E(e.env,e.platform,{...e.selection.deviceName?{deviceName:e.selection.deviceName.value}:{},...e.selection.osVersion?{osVersion:e.selection.osVersion.value}:{}},t);if(r.kind==="unchecked"&&e.onWarning?.(`${r.reason} \u2014 the run continues, but the device and OS version are not checked before the session is requested.`),r.kind==="refused")throw new Error(r.detail)}async function Y(e,t){let r=e.selection.app.value.trim();if(h(r))return T(r);let o=e.credentials;if(!o?.orgId)throw new Error(`${r} has to be uploaded before it can run on a real device, but your account's org id was not found. Run kane-cli login, or set app: to an app ID from \`kane-cli apps list --target ${e.platform}\`.`);let i=await G(t,{path:r,type:e.platform,env:e.env,orgId:o.orgId,userId:o.userId??"",auth:{username:o.username,accessKey:o.accessKey,orgId:o.orgId},baseUrl:P(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if(b(i))throw new Error(`could not upload ${r} for this real-device run: ${i.reason}`);return T(i.appUrl??i.appId)}async function U(e,t={}){if(!e.credentials)throw new Error("a real-device run needs your TestMu AI username and access key, and none were found. Run kane-cli login, or pass --username and --access-key.");await X(e,t.fetchCatalog??S);let r=await Y(e,t.upload??R),{deviceName:o,osVersion:i}=e.selection,n={platform_name:e.platform,device_name:o?.value??D,...i?{platform_version:i.value}:{},app:r,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},s=z(e.outDir,J);return H(e.outDir,{recursive:!0}),q(s,`${JSON.stringify(n,null,2)}
3
3
  `),{device:{platform:e.platform,target:e.platform,device_config_path:s},...o?{deviceName:o.value}:{},...i?{osVersion:i.value}:{},app:r}}import{createServer as Q}from"http";import{randomBytes as Z}from"crypto";import{spawn as ee}from"child_process";import{mkdtempSync as re,readdirSync as te,readFileSync as oe,rmSync as ie,writeFileSync as ne}from"fs";import{tmpdir as W}from"os";import{join as w}from"path";function M(e,t,r,o){let i=Buffer.from(`${o.username}:${o.accessKey}`).toString("base64"),n=new URLSearchParams({session:r,auth:i});return t==="ios"&&n.set("mode","webrtc"),`${e.replace(/\/+$/,"")}/?${n.toString()}`}function V(e){return e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}function ae(e){return`<!doctype html>
4
4
  <html lang="en">
5
5
  <head>
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as Ut}from"./chunk-74W4AOT2.js";import{a as lt,b as ut}from"./chunk-S53AQU7R.js";import{b as xt,c as bt,d as yt,e as vt,f as _t}from"./chunk-WYSZ6TPW.js";import{a as wt,b as kt,c as Rt,d as Et,e as St}from"./chunk-VYHT2IET.js";import{c as q,d as Ie,f as It,g as Lt,k as At,l as ce,m as pe,q as J,v as Ot}from"./chunk-2SWSVJUP.js";import{b as Ee,d as se}from"./chunk-ZUZ6QJRA.js";import{b as Se,c as ct,d as pt,e as dt,f as ie,g as ae,h as mt,i as ft,j as gt,k as ht,m as h,n as X,o as $t,p as je,q as Te,r as Ce,s as Pe}from"./chunk-JD52IXON.js";import{a as le,b as S}from"./chunk-KGNE5CIM.js";import{e as W,l as ue,n as Le,q as jt,r as Tt,s as Ct,t as Pt}from"./chunk-ZZP5SHUV.js";import{a as st,b as it}from"./chunk-DNGOT65K.js";import{d as Re,f as H}from"./chunk-P7MSVLAH.js";import{a as nt}from"./chunk-AA674WLL.js";import{l as at}from"./chunk-QTZBVDPR.js";import{a as ot}from"./chunk-UTM7D4PI.js";import{a as Ze,b as ke,d as et}from"./chunk-I2KOGINW.js";import{a as tt}from"./chunk-DREQ3RAA.js";import{b as Ye}from"./chunk-LRXBJTD4.js";import{e as ze}from"./chunk-T4AVLJCW.js";import{d as Qe}from"./chunk-C6HI6Y3S.js";import{a as qe}from"./chunk-FCD3NYOM.js";import{a as rt}from"./chunk-XZYA7DNH.js";import{n as Xe,o as Je}from"./chunk-NC7D7GOM.js";import{a as oe}from"./chunk-MGNRNLBE.js";import{a as K}from"./chunk-4QTH7VYE.js";import{a as F}from"./chunk-RZ4F3BHX.js";import{a as ne}from"./chunk-XBEYWXPV.js";import{a as We}from"./chunk-FOJHSG5M.js";import{a as M,b as re,y as Ke}from"./chunk-I6OQISK4.js";import{join as Ne}from"path";import{appendFileSync as or,mkdirSync as sr}from"fs";import{dirname as ir}from"path";function Nt(e,t,n){if(t)try{sr(ir(t),{recursive:!0})}catch{}let r="",o=c=>{if(!(!t||!c))try{or(t,n(c))}catch{}};e.child.stderr?.on("data",c=>{r+=c.toString();let g=r.lastIndexOf(`
2
+ import{c as Ut}from"./chunk-VX657KIK.js";import{a as lt,b as ut}from"./chunk-LAOTVZHV.js";import{b as xt,c as bt,d as yt,e as vt,f as _t}from"./chunk-WEIPY3CI.js";import{a as wt,b as kt,c as Rt,d as Et,e as St}from"./chunk-GQRU3B54.js";import{c as q,d as Ie,f as It,g as Lt,k as At,l as ce,m as pe,q as J,v as Ot}from"./chunk-OCDBTAYS.js";import{b as Ee,d as se}from"./chunk-ZUZ6QJRA.js";import{b as Se,c as ct,d as pt,e as dt,f as ie,g as ae,h as mt,i as ft,j as gt,k as ht,m as h,n as X,o as $t,p as je,q as Te,r as Ce,s as Pe}from"./chunk-WAOUE7MP.js";import{a as le,b as S}from"./chunk-KGNE5CIM.js";import{e as W,l as ue,n as Le,q as jt,r as Tt,s as Ct,t as Pt}from"./chunk-HK62JVQM.js";import{a as st,b as it}from"./chunk-Y7E5L42F.js";import{d as Re,f as H}from"./chunk-3E4ZO73O.js";import{a as nt}from"./chunk-2DYHAP4E.js";import{l as at}from"./chunk-HCJ2N3XB.js";import{a as ot}from"./chunk-UTM7D4PI.js";import{a as Ze,b as ke,d as et}from"./chunk-WXJCJL5L.js";import{a as tt}from"./chunk-DREQ3RAA.js";import{b as Ye}from"./chunk-CGITGJ3I.js";import{e as ze}from"./chunk-FWUPJORV.js";import{d as Qe}from"./chunk-C6HI6Y3S.js";import{a as qe}from"./chunk-FCD3NYOM.js";import{a as rt}from"./chunk-XZYA7DNH.js";import{n as Xe,o as Je}from"./chunk-NC7D7GOM.js";import{a as oe}from"./chunk-C2RUDJ46.js";import{a as K}from"./chunk-4QTH7VYE.js";import{a as F}from"./chunk-RZ4F3BHX.js";import{a as ne}from"./chunk-HJMCXSUJ.js";import{a as We}from"./chunk-FOJHSG5M.js";import{a as M,b as re,y as Ke}from"./chunk-D36V5OX6.js";import{join as Ne}from"path";import{appendFileSync as or,mkdirSync as sr}from"fs";import{dirname as ir}from"path";function Nt(e,t,n){if(t)try{sr(ir(t),{recursive:!0})}catch{}let r="",o=c=>{if(!(!t||!c))try{or(t,n(c))}catch{}};e.child.stderr?.on("data",c=>{r+=c.toString();let g=r.lastIndexOf(`
3
3
  `);g<0||(o(r.slice(0,g+1)),r=r.slice(g+1))}),e.child.stderr?.on("end",()=>{o(r),r=""});let i=e.getStderr.bind(e);return Object.assign(e,{getStderr:()=>n(i())})}var ar={seeding:"seeding",replay:"replaying",walking:"walking",settling:"settling",verifying:"verifying"},lr=8,ur=6,k=e=>typeof e=="string"&&e?e:null,V=e=>typeof e=="number"&&Number.isFinite(e)?e:null,de=class{s={run_id:null,exploration_id:null,status:"running",stop_reason:null,progress:null,browsers:[],version:0,updated_at:0};subs=new Set;now;constructor(t={}){this.now=t.now??Date.now}snapshot(){return structuredClone(this.s)}subscribe(t){return this.subs.add(t),()=>{this.subs.delete(t)}}end(t){this.s.status!=="ended"&&(this.s.status="ended",this.s.stop_reason=t,this.s.browsers=[],this.changed())}apply(t){this.reduce(t)&&this.changed()}changed(){if(this.s.version+=1,this.s.updated_at=this.now(),!this.subs.size)return;let t=this.snapshot();for(let n of this.subs)try{n(t)}catch{}}browser(t,n){let r=this.s.browsers.find(o=>o.worker===t)??null;return!r&&n&&(r={worker:t,state:"opening",since:this.now(),lease:null,step:null,steps:[],trail:[],held:null},this.s.browsers.push(r),this.s.browsers.sort((o,i)=>o.worker-i.worker)),r}setState(t,n){t.state!==n&&(t.state=n,t.since=this.now())}reduce(t){let n=V(t.worker_index);switch(t.type){case"explore_start":return this.s.run_id=k(t.run_id),this.s.exploration_id=k(t.exploration_id),this.s.status="running",!0;case"browser_request":return n===null?!1:(this.browser(n,!0),!0);case"browser_release":{if(n===null)return!1;let r=this.s.browsers.length;return this.s.browsers=this.s.browsers.filter(o=>o.worker!==n),this.s.browsers.length!==r}case"lease_start":{if(n===null||!k(t.lease_id))return!1;let r=this.browser(n,!0),o=t.reach&&typeof t.reach=="object"&&!Array.isArray(t.reach)?t.reach:null;return r.lease={id:String(t.lease_id),kind:String(t.kind??""),target:k(t.target),reach:o,started_at:this.now()},r.step=null,r.steps=[],this.setState(r,"starting"),!0}case"lease_step":{if(n===null)return!1;let r=this.browser(n,!1);if(!r||!r.lease||r.lease.id!==t.lease_id)return!1;let o={ordinal:V(t.ordinal)??r.steps.length,phase:String(t.phase??""),intent:k(t.intent),junction_id:k(t.junction_id),known:t.known===!0,url_pattern:k(t.url_pattern),flow_id:k(t.flow_id),navigated:t.navigated===!0,at:this.now()};return r.step=o,r.steps=[...r.steps,o].slice(-lr),o.junction_id&&r.trail[r.trail.length-1]!==o.junction_id&&(r.trail=[...r.trail,o.junction_id].slice(-ur)),this.setState(r,ar[o.phase]??"walking"),!0}case"lease_end":{let r=this.s.browsers.find(o=>o.lease?.id===t.lease_id);return r?(r.lease=null,r.step=null,r.steps=[],this.setState(r,r.held?"holding":"idle"),!0):!1}case"session_held":{if(n===null)return!1;let r=this.browser(n,!0);return r.held={kind:String(t.kind??""),start_flow:k(t.start_flow),junction_id:k(t.junction_id),url_pattern:k(t.url_pattern)},r.lease||this.setState(r,"holding"),!0}case"session_released":{if(n===null)return!1;let r=this.browser(n,!1);return!r||!r.held?!1:(r.held=null,r.lease||this.setState(r,"idle"),!0)}case"progress":return this.s.progress={frontier:V(t.frontier)??0,visited:V(t.visited)??0,active_workers:V(t.active_workers)??0,elapsed_s:V(t.elapsed_s)??0},!0;case"explore_control":return t.control!=="stop"||this.s.status!=="running"?!1:(this.s.status="paused",!0);case"explore_end":return this.s.status="ended",this.s.stop_reason=k(t.stop_reason),this.s.browsers=[],!0;default:return!1}}};var me=class{link=null;wanted=new Map;source=async(t,n)=>(this.wanted.set(t,n),this.link?.start(t),{stop:async()=>{this.wanted.get(t)===n&&(this.wanted.delete(t),this.link?.stop(t))}});attach(t){if(this.link=t,t)for(let n of this.wanted.keys())t.start(n)}frame(t,n){this.wanted.get(t)?.(n)}};var cr=500,pr=1e4,Bt=5e3,dr=async(e,t)=>{let n=new AbortController,r=()=>n.abort(),o=setTimeout(r,t.timeoutMs);t.signal.addEventListener("abort",r,{once:!0});try{let i=await F(e,{method:"POST",headers:t.headers,body:t.body,signal:n.signal}),c=null;try{c=await i.json()}catch{}return{status:i.status,body:c}}finally{clearTimeout(o),t.signal.removeEventListener("abort",r)}},fe=class{constructor(t){this.opts=t;this.post=t.post??dr,this.unsubscribeModel=t.model.subscribe(()=>this.stateChanged())}post;target=null;off=!1;framesOff=!1;abort=new AbortController;unsubscribeModel;stateInFlight=!1;stateDirty=!1;lastStateAt=0;stateTimer=null;heartbeat=null;watched=new Map;stopAsked=!1;waiting=new Map;sending=new Set;arm(t){this.off||(this.letAllGo(),this.abort.abort(),this.abort=new AbortController,this.stateInFlight=!1,this.target=t,this.framesOff=!1,this.stateDirty=!0,this.sendState())}async close(){this.off=!0,this.unsubscribeModel(),this.clearTimers(),this.letAllGo(),this.abort.abort()}url(t,n=""){let r=this.target;return`${r.baseUrl.replace(/\/+$/,"")}${n}/exploration/${encodeURIComponent(r.explorationId)}/runs/${encodeURIComponent(r.runId)}/live/${t}`}stateChanged(){if(this.off||!this.target||(this.stateDirty=!0,this.stateInFlight||this.stateTimer))return;let t=cr-(Date.now()-this.lastStateAt);t<=0?this.sendState():this.stateTimer=setTimeout(()=>{this.stateTimer=null,this.sendState()},t)}sendState(){if(this.off||!this.target||this.stateInFlight)return;let t=this.target;this.stateDirty=!1,this.stateInFlight=!0,this.lastStateAt=Date.now(),this.heartbeat&&clearTimeout(this.heartbeat),this.heartbeat=null;let n;try{n=JSON.stringify(this.opts.model.snapshot())}catch{this.stateInFlight=!1;return}this.post(this.url("state"),{headers:{Authorization:t.authHeader,"Content-Type":"application/json"},body:n,timeoutMs:Bt,signal:this.abort.signal}).then(r=>{if(this.target===t){if(r.status===404||r.status===403||r.status===401)return this.turnOff(r.status);r.status>=200&&r.status<300&&(this.stopIfAsked(r.body),this.follow(r.body))}},()=>{}).finally(()=>{this.target!==t||this.off||(this.stateInFlight=!1,this.heartbeat=setTimeout(()=>{this.heartbeat=null,this.stateDirty=!0,this.sendState()},pr),this.stateDirty&&this.stateChanged())})}turnOff(t){this.off||(this.off=!0,this.clearTimers(),this.letAllGo(),this.abort.abort(),this.opts.onWarn?.(`live view is off for this run: the controller has no live routes (HTTP ${t})`))}stopIfAsked(t){this.stopAsked||!t||typeof t!="object"||t.stop!==!0||(this.stopAsked=!0,this.opts.onStop?.())}follow(t){let n=t&&typeof t=="object"?t.watched:void 0;if(!Array.isArray(n)||this.framesOff)return;let r=new Set(n.filter(o=>Number.isInteger(o)&&o>=0));for(let o of[...this.watched.keys()])r.has(o)||this.letGo(o);for(let o of r)this.watched.has(o)||this.watched.set(o,this.opts.frames.subscribe(new Map([[o,Rt]]),i=>this.frame(i)))}frame(t){t.kind!=="frame"||this.off||!this.watched.has(t.worker)||(this.waiting.set(t.worker,{data:t.data,at:t.at}),this.sendFrame(t.worker))}sendFrame(t){if(this.sending.has(t)||!this.target)return;let n=this.waiting.get(t);if(n===void 0)return;this.waiting.delete(t);let r=this.target;this.sending.add(t);let o=Number.isFinite(n.at)?`&at=${Math.round(n.at)}`:"";this.post(`${this.url("frames","/public")}?worker=${t}${o}`,{headers:{"X-Live-Token":r.liveToken,"Content-Type":"image/jpeg"},body:Buffer.from(n.data,"base64"),timeoutMs:Bt,signal:this.abort.signal}).then(i=>{this.target===r&&(i.status===410?this.letGo(t):i.status===401&&!this.framesOff&&(this.framesOff=!0,this.letAllGo(),this.opts.onWarn?.("live frames are off for this run: the controller refused its live token (HTTP 401)")))},()=>{}).finally(()=>{this.target===r&&(this.sending.delete(t),!this.off&&this.watched.has(t)&&this.sendFrame(t))})}letGo(t){let n=this.watched.get(t);this.watched.delete(t),this.waiting.delete(t),n?.()}letAllGo(){for(let t of[...this.watched.keys()])this.letGo(t);this.sending.clear()}clearTimers(){this.stateTimer&&clearTimeout(this.stateTimer),this.heartbeat&&clearTimeout(this.heartbeat),this.stateTimer=this.heartbeat=null}};function ge(e,t){return`watch live: kane-cli explore view --exploration-id ${e}${t?` --env ${t}`:""}`}async function Mt(e){let t=new de,n=new me,r=new kt({start:e.startSource??n.source}),o=new fe({model:t,frames:r,post:e.post,onWarn:e.onWarn,onStop:e.onStop}),i=!1,c=!1,g=!1;return{model:t,frames:r,onBrowser(a){c||r.addBrowser(a)},offBrowser(a){r.removeBrowser(a)},attachRunner(a){n.attach(c?null:a)},runnerFrame(a,u){c||n.frame(a,u)},onEvent(a){t.apply(a),a.type==="explore_start"&&!i&&typeof a.exploration_id=="string"&&a.exploration_id&&(i=!0,e.onExploration?.(a.exploration_id))},armRun(a){if(!c){if(!a.liveToken){g||e.onWarn?.("live view is off for this run: the controller handed out no live token"),g=!0;return}o.arm({...e.controller,explorationId:a.explorationId,runId:a.runId,liveToken:a.liveToken})}},async close(a){c||(c=!0,await o.close(),n.attach(null),t.end(a),await r.close())}}}import{readFileSync as fr}from"fs";import{basename as gr}from"path";import{randomUUID as Kt}from"crypto";function $e(e){let t=[];for(let[n,r]of Object.entries(e)){if(r.type==="parameter")continue;let o=n.replace(/^(secrets\.user\.|global\.|environment\.)/,"");t.push({name:o,secret:!!r.secret,value:String(r.value??"")})}return t}async function Ht(e,t){if(t.activeRun){let u=null;try{u=await t.activeRun()}catch{u=null}if(u)return{ok:!1,error:`RUN_ACTIVE: run ${u.runId} is ${u.state} on exploration ${u.explorationId}; stop it or wait for it to end`}}let n=e.variables.filter(u=>u.secret),r=e.variables.filter(u=>!u.secret),o=[["LT_USERNAME",e.login.username],["LT_ACCESS_KEY",e.login.accessKey],...n.map(u=>[u.name,u.value])];for(let[u,l]of o){if(e.dev?.skipPush===u){e.onNote?.(`dev: not pushing secret ${u} (KANE_EXPLORE_DEV_SKIP_SECRET_PUSH)`);continue}try{await t.pushSecret(u,l)}catch(f){return{ok:!1,error:`could not push secret ${u} to HyperExecute Secrets: ${z(f)}`}}}for(let u of r)try{await t.upsertGlobal(u.name,u.value)}catch(l){return{ok:!1,error:`could not push variable ${u.name} to Test Manager: ${z(l)}`}}let i=o.map(([u])=>u);if(e.dev?.skipCheck)return e.onNote?.("dev: not checking the HyperExecute secrets list (KANE_EXPLORE_DEV_SKIP_SECRET_CHECK); the VM's check must refuse a missing secret"),a();let c;try{c=await t.hxSecretNames(i)}catch(u){return{ok:!1,error:`could not read your HyperExecute secrets to check them: ${z(u)}`}}let g=i.filter(u=>!c.includes(u));if(g.length)return{ok:!1,error:`HyperExecute Secrets does not list ${g.join(", ")} after the push; the VM would run without ${g.length===1?"it":"them"}`};return a();async function a(){let u=e.body;if(e.devBundle)try{let{kane_version:l,...f}=e.body;u={...f,dev:await e.devBundle()}}catch(l){return{ok:!1,error:`--dev-bundle: could not upload the bundle: ${z(l)}`}}try{return{ok:!0,reply:await t.remoteRun({...u,variables:e.variables.map(f=>({name:f.name,secret:f.secret}))})}}catch(l){if(l instanceof le&&l.code==="SECRETS_MISSING"){let f=l.body??{};return{ok:!1,secretsMissing:!0,error:typeof f.error=="string"&&f.error?f.error:"HyperExecute refused the job: a secret it names is missing",explorationId:typeof f.exploration_id=="string"?f.exploration_id:null,runId:typeof f.run_id=="string"?f.run_id:null}}return{ok:!1,error:`could not launch the remote run: ${z(l)}`}}}}async function Vt(e,t,n){let r={Authorization:K(t.username,t.accessKey),Accept:"application/json"},o=new URLSearchParams({username:t.username});for(let a of n)o.append("secretKey",a);let i=await F(`${e}/logistics/v1.0/all-secrets/list?${o}`,{method:"GET",headers:r});if(i.status===404&&(i=await F(`${e}/logistics/v1.0/secrets/list/${encodeURIComponent(t.username)}`,{method:"GET",headers:r})),!i.ok)throw new Error(`HTTP ${i.status}`);let c=null;try{c=await i.json()}catch{c=null}let g=mr(c);return n.filter(a=>g.has(a))}function mr(e){let t=new Set,n=e&&typeof e=="object"?e:{},r=Array.isArray(n.Data)?n.Data:Array.isArray(n.data)?n.data:Array.isArray(e)?e:[];for(let o of r)if(typeof o=="string")t.add(o);else if(o&&typeof o=="object"){let i=o,c=i.key??i.secretKey??i.Key??i.name;typeof c=="string"&&t.add(c)}return t}var Dt=["allowDomain","deny","allowPost","depthCaps","slowBudget","recheck","focus","hpsRegion","tunnel","tunnelName"];function Ae(e,t){let n={};t&&(n.deps=t);for(let r of Dt){let o=e[r];o===void 0||Array.isArray(o)&&!o.length||(n[r]=o)}return n}function Gt(e){let t=e.args&&typeof e.args=="object"?e.args:{},n={url:e.url,prompt:e.prompt,browser:"remote",headless:!0};typeof e.max_parallel=="number"&&e.max_parallel>0&&(n.maxParallel=e.max_parallel),typeof e.max_leases=="number"&&e.max_leases>0&&(n.maxLeases=e.max_leases),Array.isArray(e.allowed_domains)&&(n.allowDomain=e.allowed_domains),typeof e.policy=="string"&&e.policy&&(n.policy=e.policy);for(let r of Dt)t[r]!==void 0&&(n[r]=t[r]);return typeof t.deps=="string"&&t.deps&&(n.depsText=t.deps),n}function Ft(e,t){let n={},r=[];for(let o of e){if(!o.secret){n[o.name]={value:"",secret:!1};continue}let i=t[o.name];if(!i||i.includes("${{.secrets.")){r.push(o.name);continue}n[o.name]={value:i,secret:!0}}return r.length?{ok:!1,missing:r}:{ok:!0,variables:n}}function z(e){return e instanceof Error?e.message:String(e)}function Wt(e){let t=$e(e.variables).map(n=>({name:n.name,secret:n.secret}));return{url:e.url,prompt:e.prompt,policy:e.policy??ue,...t.length?{variables:t}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Ae({...e.opts,allowDomain:e.allowedDomains},e.depsText)}}function hr(e){let t={},n=(e.KANE_EXPLORE_DEV_SKIP_SECRET_PUSH??"").trim();return n&&(t.skipPush=n),(e.KANE_EXPLORE_DEV_SKIP_SECRET_CHECK??"").trim()==="1"&&(t.skipCheck=!0),t}async function wr(e,t){let n=fr(t),r=new qe(e.controllerBaseUrl,{username:e.basic.username,accessKey:e.basic.access_key}),o=`${Kt()}-${gr(t)}`,c=(await r.getPresignedUrls("explore-dev",Kt(),[{key:"bundle",content_type:"application/gzip",filename:o}])).urls.bundle;if(!c)throw new Error("the presign reply named no URL for the bundle");return await ot(c.upload_url,n,"application/gzip"),c.blob_url}function xr(e){return{project_id:e.projectId,url:e.url,prompt:e.prompt,policy:e.policy??ue,...e.allowedDomains.length?{allowed_domains:e.allowedDomains}:{},...e.contextEnabled===!1?{context_enabled:!1}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Ae(e.opts,e.depsText),kane_version:e.kaneVersion}}async function qt(e,t){let n=new S({baseUrl:e.controllerBaseUrl,auth:e.basic}),r=new st(e.secretsBaseUrl),o=new it(e.tmsBaseUrl,e.basic.username,e.basic.access_key),i={username:e.basic.username,accessKey:e.basic.access_key},c=xr(t),g=t.dev,a=await Ht({variables:$e(t.variables),login:i,body:c,...g?{dev:hr(process.env),onNote:u=>e.emit({type:"warning",message:u}),devBundle:async()=>({bundle_url:await wr(e,g.bundlePath),controller_url:g.controllerUrl})}:{}},{pushSecret:(u,l)=>r.pushSecret({secretKey:u,secretValue:l,username:i.username,accessKey:i.accessKey,orgId:e.orgId}),upsertGlobal:async(u,l)=>{await o.upsertVariable({name:u,value:l})},hxSecretNames:u=>Vt(e.secretsBaseUrl,i,u),remoteRun:u=>n.remoteRun(u),activeRun:async()=>{if(!t.projectId)return null;let l=(await n.listExplorations({state:"running",project:t.projectId,limit:1})).explorations.find(f=>f.project_id===t.projectId&&f.current_session);return l&&l.current_session?{explorationId:l.exploration_id,runId:l.current_session.run_id,state:l.current_session.state}:null}});if(!a.ok&&a.secretsMissing)return{ok:!1,error:a.error,exitCode:2,stopped:{explorationId:a.explorationId,runId:a.runId}};if(!a.ok){if(t.contextEnabled===!1&&vt(a.error))return{ok:!1,error:yt,exitCode:2};let u=/could not launch/.test(a.error)||a.error.startsWith("RUN_ACTIVE:");return{ok:!1,error:a.error,exitCode:u?1:2}}return e.emit({type:"explore_remote_started",exploration_id:a.reply.exploration_id,run_id:a.reply.run_id,state:a.reply.state,hx_job_id:a.reply.hx_job_id,job_link:a.reply.job_link,created:a.reply.created,policy:c.policy??ue}),t.contextEnabled===!1&&!a.reply.created&&e.emit({type:"warning",message:`exploration ${a.reply.exploration_id} already exists; its assurance context is unchanged \u2014 use \`kane-cli explore context off ${a.reply.exploration_id}\``}),e.terminal||(process.stderr.write(`exploration ${a.reply.exploration_id}, run ${a.reply.run_id}: queued on HyperExecute
4
4
  `),a.reply.job_link&&process.stderr.write(`job: ${a.reply.job_link}
5
5
  `),process.stderr.write(ge(a.reply.exploration_id,e.env)+`
@@ -25,23 +25,23 @@ On a terminal, plain \`kane-cli explore\` opens the project picker, then the
25
25
  exploration's card (run again, watch, stop, map, sessions, context, delete);
26
26
  with --agent or a pipe it prints this help. Each command's --help lists its
27
27
  options, grouped, with their values, defaults and examples.
28
- `).action(async(n,r)=>{if(r.args.length>0&&r.error(`error: unknown command '${r.args[0]}'`,{exitCode:2}),ce(n,At()))return r.help();let{runExploreEntryAction:o}=await import("./explore-entry-5OGNLFAU.js");process.exitCode=await o(n)});t.command("run").description("Run one exploration of an app into its project's map: on HyperExecute by default (exits once the run is queued; stop it with explore stop), or on this machine with --local-orchestration. A terminal opens a setup form and a review first; --agent or a pipe gets NDJSON on stdout, done last").option("--url <url>",h("url")).option("--project <id>",h("project")).option("--exploration-id <id>",h("explorationId")).option("--prompt <text>",h("prompt"),"Explore the app").option("--max-leases <n>",h("maxLeases"),zt).option("--max-parallel <n>",h("maxParallel"),zt).option("--depth-caps <depth:cap,\u2026>",h("depthCaps")).option("--slow-budget <spec>",h("slowBudget")).option("--no-recheck",h("recheck")).option("--policy <policy>",h("policy")).option("--allow-domain <host>",h("allowDomain"),we,[]).option("--deny <name>",h("deny"),we,[]).option("--allow-post <host/path>",h("allowPost"),we,[]).option("--focus <screen>",h("focus")).option("--local-orchestration",h("localOrchestration")).option("--browser <where>",h("browser"),"local").option("--headless",h("headless")).option("--tunnel",h("tunnel")).option("--tunnel-name <name>",h("tunnelName")).option("--deps <text>",h("deps"),we,[]).option("--variables <json>",h("variables")).option("--variables-file <path>",h("variablesFile")).option("--no-context",h("context")).option("--agent",h("agent")).option("--env <name>",h("env")).option("--username <user>",h("username")).option("--access-key <key>",h("accessKey")).addOption(new se("--claim-run <run-id>","On a HyperExecute VM: take over this queued run (the job's own command; needs --exploration-id)").hideHelp()).addOption(new se("--dev-bundle <tgz>","Dev only: the VM installs this kane-cli bundle and talks to EXPLORE_DEV_CONTROLLER_URL").hideHelp()).addOption(new se("--hps-region <region>",`With remote browsers on prod: the regional host (${ae.join(", ")})`).hideHelp()).configureHelp(pe($t())).addHelpText("after",Er).configureOutput({outputError:(n,r)=>r(/\'--setup(?:-check)?(?:=|\')/.test(n)?Rr:n)}).action(async n=>{process.exitCode=await Or(n)}),t.command("view").description("Serve a live graph of an exploration's map on 127.0.0.1 (polls the service; Ctrl-C to stop)").option("--exploration-id <id>",X({purpose:"The exploration to view",values:"an id from kane-cli explore list --all"})).option("--project <id>",X({purpose:"View this project's exploration instead (a project has one)",values:"a project id"})).option("--port <n>",X({purpose:"The port on 127.0.0.1",values:"1-65535",dflt:"the first free of 7420-7429"}),Sr).option("--agent",je).option("--env <name>",Te).option("--username <user>",Ce).option("--access-key <key>",Pe).configureHelp(pe([{title:"Target",flags:["--exploration-id","--project"]},{title:"Server",flags:["--port"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])).addHelpText("after",`
28
+ `).action(async(n,r)=>{if(r.args.length>0&&r.error(`error: unknown command '${r.args[0]}'`,{exitCode:2}),ce(n,At()))return r.help();let{runExploreEntryAction:o}=await import("./explore-entry-EKXJ67BD.js");process.exitCode=await o(n)});t.command("run").description("Run one exploration of an app into its project's map: on HyperExecute by default (exits once the run is queued; stop it with explore stop), or on this machine with --local-orchestration. A terminal opens a setup form and a review first; --agent or a pipe gets NDJSON on stdout, done last").option("--url <url>",h("url")).option("--project <id>",h("project")).option("--exploration-id <id>",h("explorationId")).option("--prompt <text>",h("prompt"),"Explore the app").option("--max-leases <n>",h("maxLeases"),zt).option("--max-parallel <n>",h("maxParallel"),zt).option("--depth-caps <depth:cap,\u2026>",h("depthCaps")).option("--slow-budget <spec>",h("slowBudget")).option("--no-recheck",h("recheck")).option("--policy <policy>",h("policy")).option("--allow-domain <host>",h("allowDomain"),we,[]).option("--deny <name>",h("deny"),we,[]).option("--allow-post <host/path>",h("allowPost"),we,[]).option("--focus <screen>",h("focus")).option("--local-orchestration",h("localOrchestration")).option("--browser <where>",h("browser"),"local").option("--headless",h("headless")).option("--tunnel",h("tunnel")).option("--tunnel-name <name>",h("tunnelName")).option("--deps <text>",h("deps"),we,[]).option("--variables <json>",h("variables")).option("--variables-file <path>",h("variablesFile")).option("--no-context",h("context")).option("--agent",h("agent")).option("--env <name>",h("env")).option("--username <user>",h("username")).option("--access-key <key>",h("accessKey")).addOption(new se("--claim-run <run-id>","On a HyperExecute VM: take over this queued run (the job's own command; needs --exploration-id)").hideHelp()).addOption(new se("--dev-bundle <tgz>","Dev only: the VM installs this kane-cli bundle and talks to EXPLORE_DEV_CONTROLLER_URL").hideHelp()).addOption(new se("--hps-region <region>",`With remote browsers on prod: the regional host (${ae.join(", ")})`).hideHelp()).configureHelp(pe($t())).addHelpText("after",Er).configureOutput({outputError:(n,r)=>r(/\'--setup(?:-check)?(?:=|\')/.test(n)?Rr:n)}).action(async n=>{process.exitCode=await Or(n)}),t.command("view").description("Serve a live graph of an exploration's map on 127.0.0.1 (polls the service; Ctrl-C to stop)").option("--exploration-id <id>",X({purpose:"The exploration to view",values:"an id from kane-cli explore list --all"})).option("--project <id>",X({purpose:"View this project's exploration instead (a project has one)",values:"a project id"})).option("--port <n>",X({purpose:"The port on 127.0.0.1",values:"1-65535",dflt:"the first free of 7420-7429"}),Sr).option("--agent",je).option("--env <name>",Te).option("--username <user>",Ce).option("--access-key <key>",Pe).configureHelp(pe([{title:"Target",flags:["--exploration-id","--project"]},{title:"Server",flags:["--port"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])).addHelpText("after",`
29
29
  Name the exploration with --exploration-id or --project, not both.
30
30
 
31
31
  Examples:
32
32
  $ kane-cli explore view --project <id>
33
33
  $ kane-cli explore view --exploration-id <id> --port 7430
34
- `).action(async n=>{process.exitCode=await Nr(n)}),Ot(t),Ut(t),t.command("assurance-job",{hidden:!0}).description("One cut of an exploration into its project's assurance (the controller's job; input from the environment)").action(async()=>{let{runAssuranceJob:n}=await import("./assurance-job-C3TXZGLL.js");process.exitCode=await n()})}function Sr(e){let t=Number(e);if(!Number.isInteger(t)||t<1||t>65535)throw new Ee("must be an integer 1-65535");return t}function we(e,t){return[...t,e]}function Qt(e){let t=new Set;for(let n of e){let r=n.trim().toLowerCase();if(r){try{r.includes("://")&&(r=new URL(r).hostname)}catch{}r=r.replace(/\/.*$/,"").replace(/^www\./,"").replace(/\.$/,""),r&&t.add(r)}}return[...t]}function Ir(e,t){if(e.some(r=>r.trim()==="*"))return{posts:["*"]};let n=new Set;for(let r of e){let o=r.trim();if(!o)continue;let i=y=>({error:`--allow-post ${JSON.stringify(o)}: ${y}; write it as host/path, e.g. api.example.com/v1/flags`});if(o.includes("://"))return i("no scheme");if(/[?#]/.test(o))return i("no query or fragment (the match is on host and path only)");if(o.includes("*"))return i("no partial wildcards (name the endpoint exactly, or pass a bare * for every POST)");if(/\s/.test(o))return i("no whitespace");let c=o.indexOf("/");if(c<=0)return i("a host followed by a path starting with /");let g=o.slice(0,c).toLowerCase(),a=o.slice(c),u=/^([^:]+?)\.?(?::(\d+))?$/.exec(g);if(!u)return i("an invalid host");let l=u[1],f=u[2]&&u[2]!=="80"&&u[2]!=="443"?`:${u[2]}`:"";if(g=l+f,!t.some(y=>l===y||l.endsWith(`.${y}`)))return i(`host ${l} is outside the run's domains (${t.join(", ")||"none"}); add it with --allow-domain first`);n.add(g+a)}return{posts:[...n]}}function Lr(e){if(e===void 0)return{caps:{}};let t={};for(let n of e.split(",").map(r=>r.trim()).filter(Boolean)){let r=/^(\d+):(\d+)$/.exec(n);if(!r)return{error:`--depth-caps "${e}": each entry is depth:cap with whole numbers, e.g. 0:0,1:3,2:1`};t[String(Number(r[1]))]=Number(r[2])}return Object.keys(t).length?{caps:t}:{error:`--depth-caps "${e}": give at least one depth:cap pair`}}var jr={response:"response_ms",page:"page_ready_ms",step:"step_ms"};function Tr(e){if(e===void 0)return{budgets:{}};let t={};for(let n of e.split(",").map(r=>r.trim()).filter(Boolean)){let r=/^(response|page|step)=(\d+(?:\.\d+)?)(s|ms)$/.exec(n);if(!r)return{error:`--slow-budget "${e}": each entry is response|page|step=<number>s or ms, e.g. response=3s,page=4s,step=2.5s`};let o=Math.round(Number(r[2])*(r[3]==="s"?1e3:1));if(o<1)return{error:`--slow-budget "${e}": a budget is more than 0`};t[jr[r[1]]]=o}return Object.keys(t).length?{budgets:t}:{error:`--slow-budget "${e}": give at least one budget`}}function Yt(e){return e.context===!1?{contextEnabled:!1}:{}}function Cr(e){let t=e.tunnelName;if(t!==void 0){let n=String(t).trim();return!n||/[\u0000-\u001f\u007f]/.test(n)?{error:"--tunnel-name: the name the LT tunnel was started with (--tunnelName)"}:{tunnel:{name:n}}}return{tunnel:e.tunnel===!0?{name:null}:null}}var Pr="--tunnel on a remote run: the remote browsers reach your apps through the LT tunnel on this machine; keep it (and this machine) up until the run ends, or its pages fail to load";function Be(e){return async t=>{let n=await J(e,"explore run");return n.ok?Oe(new S({baseUrl:n.controllerBaseUrl,auth:n.basic,timeoutMs:5e3}),t):null}}async function tr(e){let t=typeof e.project=="string"?e.project:"";if(!t)return null;try{let n=await J(e,"explore run");if(!n.ok)return null;let r=oe(e.env??new ne().getDefaultEnv()??"prod"),o=new Qe(r.tmsBaseUrl,n.basic.username,n.basic.access_key);return await wt((async()=>{try{let c=await o.getProject(t);if(c?.name)return c.name}catch{}return(await o.listProjects()).find(c=>String(c.project_id)===t)?.name??null})(),4e3,()=>null)}catch{return null}}var $r=async(e,t=Be(e))=>{let n=null,r=typeof e.project=="string"?e.project:"",o=he(e,!!e.localOrchestration,r||null),i=null;if(o)try{i=await t(o)}catch{i=null}if(i){let g=Ue(i,typeof e.url=="string"?e.url:"");if(g){for(let a of Ie(g.error,g.next))process.stderr.write(a+`
35
- `);return 2}n=i.target_url??null}let c=await(await import("./explore-run-tty-LGTIK2NA.js")).setupRunOpts(e,n,await tr(e));return"opts"in c?c.opts:c.code};function Ar(e){if(e.startsWith("RUN_ACTIVE:"))return"watch it (kane-cli explore view) or stop it (kane-cli explore stop) first \u2014 one run per exploration";if(/HyperExecute Secrets does not list/.test(e))return"check the secret's name in HyperExecute Secrets and your variables files, then launch again; or run it here with --local-orchestration";if(/a secret it names is missing|SECRETS_MISSING/.test(e))return"add the missing secret to your variables files (secret: true) and launch again";if(/REMOTE_UNAVAILABLE|503|could not launch the remote run|could not read your HyperExecute secrets|could not push/.test(e))return"try again in a minute, or run it on this machine with --local-orchestration"}async function Or(e,t,n={}){let r=ce(e,t),o=r?Re("explore"):null,i=s=>s,c=null,g=s=>{o?o.emit(i(s)):c?.(i(s))},a=s=>{o?H(i(s)):process.stderr.write(`${s.type}: ${i(s).message}
34
+ `).action(async n=>{process.exitCode=await Nr(n)}),Ot(t),Ut(t),t.command("assurance-job",{hidden:!0}).description("One cut of an exploration into its project's assurance (the controller's job; input from the environment)").action(async()=>{let{runAssuranceJob:n}=await import("./assurance-job-FFSSS4XV.js");process.exitCode=await n()})}function Sr(e){let t=Number(e);if(!Number.isInteger(t)||t<1||t>65535)throw new Ee("must be an integer 1-65535");return t}function we(e,t){return[...t,e]}function Qt(e){let t=new Set;for(let n of e){let r=n.trim().toLowerCase();if(r){try{r.includes("://")&&(r=new URL(r).hostname)}catch{}r=r.replace(/\/.*$/,"").replace(/^www\./,"").replace(/\.$/,""),r&&t.add(r)}}return[...t]}function Ir(e,t){if(e.some(r=>r.trim()==="*"))return{posts:["*"]};let n=new Set;for(let r of e){let o=r.trim();if(!o)continue;let i=y=>({error:`--allow-post ${JSON.stringify(o)}: ${y}; write it as host/path, e.g. api.example.com/v1/flags`});if(o.includes("://"))return i("no scheme");if(/[?#]/.test(o))return i("no query or fragment (the match is on host and path only)");if(o.includes("*"))return i("no partial wildcards (name the endpoint exactly, or pass a bare * for every POST)");if(/\s/.test(o))return i("no whitespace");let c=o.indexOf("/");if(c<=0)return i("a host followed by a path starting with /");let g=o.slice(0,c).toLowerCase(),a=o.slice(c),u=/^([^:]+?)\.?(?::(\d+))?$/.exec(g);if(!u)return i("an invalid host");let l=u[1],f=u[2]&&u[2]!=="80"&&u[2]!=="443"?`:${u[2]}`:"";if(g=l+f,!t.some(y=>l===y||l.endsWith(`.${y}`)))return i(`host ${l} is outside the run's domains (${t.join(", ")||"none"}); add it with --allow-domain first`);n.add(g+a)}return{posts:[...n]}}function Lr(e){if(e===void 0)return{caps:{}};let t={};for(let n of e.split(",").map(r=>r.trim()).filter(Boolean)){let r=/^(\d+):(\d+)$/.exec(n);if(!r)return{error:`--depth-caps "${e}": each entry is depth:cap with whole numbers, e.g. 0:0,1:3,2:1`};t[String(Number(r[1]))]=Number(r[2])}return Object.keys(t).length?{caps:t}:{error:`--depth-caps "${e}": give at least one depth:cap pair`}}var jr={response:"response_ms",page:"page_ready_ms",step:"step_ms"};function Tr(e){if(e===void 0)return{budgets:{}};let t={};for(let n of e.split(",").map(r=>r.trim()).filter(Boolean)){let r=/^(response|page|step)=(\d+(?:\.\d+)?)(s|ms)$/.exec(n);if(!r)return{error:`--slow-budget "${e}": each entry is response|page|step=<number>s or ms, e.g. response=3s,page=4s,step=2.5s`};let o=Math.round(Number(r[2])*(r[3]==="s"?1e3:1));if(o<1)return{error:`--slow-budget "${e}": a budget is more than 0`};t[jr[r[1]]]=o}return Object.keys(t).length?{budgets:t}:{error:`--slow-budget "${e}": give at least one budget`}}function Yt(e){return e.context===!1?{contextEnabled:!1}:{}}function Cr(e){let t=e.tunnelName;if(t!==void 0){let n=String(t).trim();return!n||/[\u0000-\u001f\u007f]/.test(n)?{error:"--tunnel-name: the name the LT tunnel was started with (--tunnelName)"}:{tunnel:{name:n}}}return{tunnel:e.tunnel===!0?{name:null}:null}}var Pr="--tunnel on a remote run: the remote browsers reach your apps through the LT tunnel on this machine; keep it (and this machine) up until the run ends, or its pages fail to load";function Be(e){return async t=>{let n=await J(e,"explore run");return n.ok?Oe(new S({baseUrl:n.controllerBaseUrl,auth:n.basic,timeoutMs:5e3}),t):null}}async function tr(e){let t=typeof e.project=="string"?e.project:"";if(!t)return null;try{let n=await J(e,"explore run");if(!n.ok)return null;let r=oe(e.env??new ne().getDefaultEnv()??"prod"),o=new Qe(r.tmsBaseUrl,n.basic.username,n.basic.access_key);return await wt((async()=>{try{let c=await o.getProject(t);if(c?.name)return c.name}catch{}return(await o.listProjects()).find(c=>String(c.project_id)===t)?.name??null})(),4e3,()=>null)}catch{return null}}var $r=async(e,t=Be(e))=>{let n=null,r=typeof e.project=="string"?e.project:"",o=he(e,!!e.localOrchestration,r||null),i=null;if(o)try{i=await t(o)}catch{i=null}if(i){let g=Ue(i,typeof e.url=="string"?e.url:"");if(g){for(let a of Ie(g.error,g.next))process.stderr.write(a+`
35
+ `);return 2}n=i.target_url??null}let c=await(await import("./explore-run-tty-D47FGPX7.js")).setupRunOpts(e,n,await tr(e));return"opts"in c?c.opts:c.code};function Ar(e){if(e.startsWith("RUN_ACTIVE:"))return"watch it (kane-cli explore view) or stop it (kane-cli explore stop) first \u2014 one run per exploration";if(/HyperExecute Secrets does not list/.test(e))return"check the secret's name in HyperExecute Secrets and your variables files, then launch again; or run it here with --local-orchestration";if(/a secret it names is missing|SECRETS_MISSING/.test(e))return"add the missing secret to your variables files (secret: true) and launch again";if(/REMOTE_UNAVAILABLE|503|could not launch the remote run|could not read your HyperExecute secrets|could not push/.test(e))return"try again in a minute, or run it on this machine with --local-orchestration"}async function Or(e,t,n={}){let r=ce(e,t),o=r?Re("explore"):null,i=s=>s,c=null,g=s=>{o?o.emit(i(s)):c?.(i(s))},a=s=>{o?H(i(s)):process.stderr.write(`${s.type}: ${i(s).message}
36
36
  `)},u=s=>(g({...bt({state:s.state??null,remark:s.remark??null,exitCode:s.exitCode,explorationId:s.explorationId??null,runId:s.runId??null,committed:s.committed??0,pending:s.pending??0,lastSeq:s.lastSeq??0,stopReason:s.stopReason??null,complete:s.complete??!1,runDir:s.runDir??null,error:s.error}),...s.teardown?{teardown:s.teardown}:{},...s.credits?{credits:s.credits}:{},...typeof s.creditsConsumed=="number"?{credits_consumed:s.creditsConsumed}:{},...s.focus?{focus:s.focus}:{},...s.refused?{refused:s.refused}:{},...s.parallelism?{parallelism:s.parallelism}:typeof s.peakParallel=="number"?{peak_parallel:s.peakParallel}:{}}),s.exitCode),l=(s,p)=>(a({type:"error",message:s}),p&&!o&&process.stderr.write(`next: ${p}
37
37
  `),u({exitCode:2,error:s})),f=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null;if(f&&!r)return l("--claim-run is the HyperExecute VM's own mode; it never runs on a terminal");let y=Le(e);if("error"in y)return l(y.error,y.next);if(!r){let s=await(n.setup??(p=>$r(p,n.lookupExploration??Be(p))))(e);if(s===null)return 0;if(typeof s=="number")return s;e=s}if(!f&&!(typeof e.url=="string"&&e.url.trim())){let s=he(e,!!e.localOrchestration,typeof e.project=="string"&&e.project?e.project:null),p=null;if(s)try{p=await(n.lookupExploration??Be(e))(s)}catch{p=null}p?.target_url&&(e={...e,url:p.target_url})}if(!f&&!(typeof e.url=="string"&&e.url.trim()))return l("required option '--url <url>' not specified");let I=!!e.localOrchestration||!!f;if(f&&e.localOrchestration)return l("--claim-run is the VM's own mode; it takes no --local-orchestration");if(e.devBundle&&I)return l("--dev-bundle is for a remote run (the default), not --local-orchestration or --claim-run");if(f){let s=String(e.explorationId??"").trim();if(!s)return l("--claim-run needs --exploration-id");let p=await J(e,"explore run --claim-run");if(!p.ok)return l(p.error);let m=String(e.env??new ne().getDefaultEnv()??"prod"),d=await Xt(er(m,p.basic,"",A=>g(A)),s,f,process.env);if(!d.ok)return H(i({type:"error",message:d.error})),d.stopped?u({exitCode:d.exitCode,error:d.error,state:"stopped",remark:W("secrets_missing",d.error),explorationId:s,runId:f}):u({exitCode:d.exitCode,error:d.error,explorationId:s,runId:f});e={...e,...d.opts,env:e.env,username:e.username,accessKey:e.accessKey}}let _=Le(e);if("error"in _)return l(_.error,_.next);let x=_.policy,U={prompt:"",deps:""},R={},N="";try{let s=typeof e.depsText=="string"?e.depsText:lt(e.deps??[]);N=s;let p=ut({prompt:e.prompt??"Explore the app",deps:s},{globalDir:Ne(re,"variables"),localDir:Ne(process.cwd(),".testmuai","variables"),file:e.variablesFile,inline:e.variables,onLoadError:m=>a({type:"warning",message:m})});if("error"in p)return l(p.error);U={prompt:p.prompt,deps:p.deps},R=p.variables}catch(s){return l(`variables: ${s.message}`)}let w=Qt(e.allowDomain??[]);if(U.deps&&w.length===0)return l("--deps needs --allow-domain for every host the app signs in or writes on (e.g. --allow-domain testmuai.com --allow-domain lambdatest.com)");let L=[...new Set([...w,...Qt([String(e.url??"")])])],b=I?String(e.browser??"local"):"remote";if(!I&&e.browser!==void 0&&e.browser!=="local")return l("--browser applies to --local-orchestration; a remote run always uses remote browsers");if(b!=="local"&&b!=="remote")return l(`--browser ${b}: local or remote`);let j=e.hpsRegion;if(j!==void 0&&b!=="remote")return l("--hps-region needs --browser remote");if(j!==void 0&&!ae.includes(j))return l(`--hps-region ${j}: one of ${ae.join(", ")}`);let T=Cr(e);if("error"in T)return l(T.error);if(T.tunnel&&b!=="remote")return l("--tunnel needs remote browsers (a remote run, or --browser remote): a local Chrome already reaches this machine");let D=e.maxParallel??1;if(b==="local"&&D>Se)return l(`--max-parallel ${D}: at most ${Se} browsers run on this machine at once (--browser remote runs up to ${ie})`);if(b==="remote"&&D>ie)return l(`--max-parallel ${D}: at most ${ie} remote browsers at once`);let xe=Lr(e.depthCaps);if("error"in xe)return l(xe.error);let be=Tr(e.slowBudget);if("error"in be)return l(be.error);let Q=Ir(e.allowPost??[],L);if("error"in Q)return l(Q.error);x==="mutating"&&Q.posts.length&&a({type:"warning",code:"allow_post_ignored",message:jt});let Y=new ne,E=e.env??Y.getDefaultEnv()??"prod",O=oe(E),G=new Ye().load(),rr=Y.loadProfileConfig(Y.getActiveProfile()??"default",E)?.project_id??null,C=e.project??G.project_id??rr??null;if(x==="mutating"){let s=Tt(String(e.url??"")),p=Ct(String(e.url??""));o?H(i({type:"warning",code:"policy_mutating",policy:x,host:s,message:p})):process.stderr.write((process.stderr.columns?at(p,process.stderr.columns):p)+`
38
- `);let m=n.mutatingMemory??Pt();if(!r&&!(C&&m.confirmed(C))){let A=await(n.confirmMutating??(async B=>(await import("./explore-run-tty-LGTIK2NA.js")).confirmMutatingRun({...B,projectName:B.projectName??(B.projectId?await tr({...e,project:B.projectId}):null)})))({host:s,projectId:C,projectName:C===G.project_id?G.project_name??null:null});if(A!==!0)return process.stderr.write(`setup discarded; nothing launched
38
+ `);let m=n.mutatingMemory??Pt();if(!r&&!(C&&m.confirmed(C))){let A=await(n.confirmMutating??(async B=>(await import("./explore-run-tty-D47FGPX7.js")).confirmMutatingRun({...B,projectName:B.projectName??(B.projectId?await tr({...e,project:B.projectId}):null)})))({host:s,projectId:C,projectName:C===G.project_id?G.project_name??null:null});if(A!==!0)return process.stderr.write(`setup discarded; nothing launched
39
39
  `),A===null?130:0;C&&m.remember(C)}}if(!r&&n.afterChecks)return n.afterChecks();let Me=new Set;r||(c=s=>{s.type==="explore_remote_started"?process.stderr.write(q("queued on HyperExecute",` \xB7 run ${String(s.run_id).slice(0,8)}${s.job_link?` \xB7 ${String(s.job_link)}`:""}`,"done")+`
40
40
  `):(s.type==="warning"||s.type==="error")&&process.stderr.write(`${String(s.type)}: ${String(s.message)}
41
41
  `);for(let p of Me)p(s)});let He=(s,p)=>{if(o)H(i({type:"error",message:s}));else for(let m of Ie(i({message:s}).message,p??Ar(s)))process.stderr.write(m+`
42
42
  `)},v,Ve="";try{let s=await nt({creds:Y,env:E,usernameFlag:e.username,accessKeyFlag:e.accessKey,log:()=>{}});v=s.basicAuth,Ve=String(s.resolvedCreds?.org_id??"")}catch(s){return s instanceof rt&&s.code==="not_authenticated"?l("not authenticated: pass --username/--access-key or run 'kane-cli login'"):l(`auth resolution failed: ${s.message}`)}if(!v)return l("explore needs Basic credentials (username + access key); none resolved");if(!f){let s=he(e,I,C),p=null,m=v;if(s)try{p=await(n.lookupExploration??(A=>Oe(new S({baseUrl:O.controllerBaseUrl,auth:m,timeoutMs:5e3}),A)))(s)}catch{p=null}let d=p?Ue(p,String(e.url??"")):null;if(d)return He(d.error,d.next),u({exitCode:2,error:d.error})}if(n.afterUrlCheck)return n.afterUrlCheck();if(!I){T.tunnel&&g({type:"warning",message:Pr});let s={...er(E,v,Ve,te=>g(te)),terminal:!r},p;if(typeof e.devBundle=="string"&&e.devBundle){let te=(process.env.EXPLORE_DEV_CONTROLLER_URL??"").trim();if(!te)return l("--dev-bundle needs EXPLORE_DEV_CONTROLLER_URL (the controller the VM talks to: the tunnel URL)");if(!kr(e.devBundle))return l(`--dev-bundle ${e.devBundle}: no such file`);p={bundlePath:e.devBundle,controllerUrl:te}}let m=C;if(!m)return l("a remote run needs a project: pass --project <id> or set one (kane-cli config set-project); one project has one exploration");r||process.stderr.write(q("launching on HyperExecute")+`
43
- `);let d=await qt(s,{opts:e,variables:R,depsText:N,prompt:e.prompt??"Explore the app",url:String(e.url),projectId:m,allowedDomains:w,policy:x,...Yt(e),maxParallel:e.maxParallel,maxLeases:e.maxLeases,kaneVersion:M,...p?{dev:p}:{}});if(!d.ok)return He(d.error,d.stopped?"add the missing secret to your variables files (secret: true) or HyperExecute Secrets, then launch again":void 0),d.stopped?u({exitCode:d.exitCode,error:d.error,state:"stopped",remark:W("secrets_missing",d.error),explorationId:d.stopped.explorationId,runId:d.stopped.runId}):u({exitCode:d.exitCode,error:d.error});let A=u({exitCode:0,state:"queued",explorationId:d.explorationId,runId:d.runId});if(r)return A;let{runLiveView:B}=await import("./explore-live-2XZHUYFS.js");return(await B({client:new S({baseUrl:O.controllerBaseUrl,auth:v}),explorationId:d.explorationId,runId:d.runId,mode:"remote",env:E,policy:x})).exitCode}let ye=Ze();if(!ye)return l("v16-runner not found");let De=G.window_size?.width??1280,Ge=G.window_size?.height??800,Fe=C,$,Z={explorationId:null,runId:null};if(b==="remote"){if(E!=="stage"&&E!=="prod")return l(`--browser remote: no remote browsers for env ${E}`);let s;try{s=mt(E,j??null)}catch(m){return l(m.message)}let p=v;i=dt([p.access_key]),$=ht({hpsBase:s,auth:p,forge:ft(O.tmsBaseUrl,p,()=>({exploration_id:Z.explorationId,run_id:Z.runId,project_id:Fe,hx_job_id:tt().jobId??null,kane_version:M,region:j??null,tunnel:!!T.tunnel,tunnel_name:T.tunnel?.name??null})),tunnel:T.tunnel,releaseSync:m=>gt(O.tmsBaseUrl,p,m),onEvent:m=>g({type:"remote_browser",...m})})}else $=ct({launch:ze,width:De,height:Ge,headless:!!e.headless});Xe("explore-browsers",()=>$.releaseAllSync());let P=null,ve=null;try{P=await Mt({controller:{baseUrl:O.controllerBaseUrl,authHeader:K(v.username,v.access_key)},onWarn:s=>g({type:"warning",message:s}),onExploration:s=>{process.stderr.write(ge(s,e.env)+`
44
- `)},onStop:()=>{g({type:"warning",message:"explore stop: the run is stopping cleanly"}),ve?.()}})}catch(s){g({type:"warning",message:`live mode is off for this run: ${s.message}`})}let _e=()=>{},nr=new Promise(s=>{_e=s}),ee=null;r||Me.add(s=>{s.type!=="explore_run_started"||ee||(ee=import("./explore-live-2XZHUYFS.js").then(({runLiveView:p})=>p({client:new S({baseUrl:O.controllerBaseUrl,auth:v}),explorationId:String(s.exploration_id),runId:String(s.run_id),mode:"local",env:E,policy:x,ended:nr})))});try{let s=await _t({url:e.url,prompt:U.prompt,maxLeases:e.maxLeases,explorationId:e.explorationId,...typeof e.claimRunId=="string"?{claimRunId:e.claimRunId}:{requested:Wt({opts:e,url:String(e.url),prompt:e.prompt??"Explore the app",depsText:N,variables:R,allowedDomains:w,policy:x,maxParallel:e.maxParallel,maxLeases:e.maxLeases})},projectId:Fe,policy:x,context:U,variables:R,allowedDomains:w,...Yt(e),allowPosts:x==="read_only"?Q.posts:[],depthCaps:xe.caps,slowBudgets:be.budgets,recheck:e.recheck!==!1,maxParallel:D,...typeof e.focus=="string"?{focus:e.focus}:{},denyNames:(e.deny??[]).map(m=>m.trim()).filter(Boolean),headless:!!e.headless,width:De,height:Ge,auth:v,clientRelease:M},{client:new S({baseUrl:O.controllerBaseUrl,auth:v}),spawnRunner:m=>{let d=et({environment:E,username:v.username,accessKey:v.access_key,sessionId:m});return $.kind==="local"?ke({env:d,runner:ye,sessionId:m}):Nt(ke({env:d,runner:ye}),Ne(re,"sessions",m,"runner-stderr.log"),pt([v.access_key]))},acquireBrowser:async m=>{let d=await $.acquire(m);return P?.onBrowser(m),{cdpEndpoint:d.cdpEndpoint,release:()=>{P?.offBrowser(m),d.release()}}},releaseBrowsersOnInterrupt:$.kind==="remote",frameLink:m=>P?.attachRunner(m),onFrame:(m,d)=>P?.runnerFrame(m,d),onLiveRun:m=>{Z.explorationId=m.explorationId,Z.runId=m.runId,P?.armRun(m)},emit:m=>{let d=i(m);o?o.emit(d):c?.(d),P?.onEvent(d)},baseDir:re,onInterrupt:m=>{ve=m;let d=Mr(m);return()=>{ve=null,d()}}});await $.releaseAll(),await P?.close(s.stopReason??s.remark?.code??"stopped");let p=u(f?{...s,exitCode:xt(s)}:s);return _e(p),ee&&await ee,p}finally{_e(1),await P?.close("stopped"),await $.releaseAll(),Je("explore-browsers")}}var Ur=3e3;async function Nr(e,t={}){let n=t.tty??!ce(e),r=t.out??(w=>{process.stdout.write(w+`
43
+ `);let d=await qt(s,{opts:e,variables:R,depsText:N,prompt:e.prompt??"Explore the app",url:String(e.url),projectId:m,allowedDomains:w,policy:x,...Yt(e),maxParallel:e.maxParallel,maxLeases:e.maxLeases,kaneVersion:M,...p?{dev:p}:{}});if(!d.ok)return He(d.error,d.stopped?"add the missing secret to your variables files (secret: true) or HyperExecute Secrets, then launch again":void 0),d.stopped?u({exitCode:d.exitCode,error:d.error,state:"stopped",remark:W("secrets_missing",d.error),explorationId:d.stopped.explorationId,runId:d.stopped.runId}):u({exitCode:d.exitCode,error:d.error});let A=u({exitCode:0,state:"queued",explorationId:d.explorationId,runId:d.runId});if(r)return A;let{runLiveView:B}=await import("./explore-live-2YVRAQZO.js");return(await B({client:new S({baseUrl:O.controllerBaseUrl,auth:v}),explorationId:d.explorationId,runId:d.runId,mode:"remote",env:E,policy:x})).exitCode}let ye=Ze();if(!ye)return l("v16-runner not found");let De=G.window_size?.width??1280,Ge=G.window_size?.height??800,Fe=C,$,Z={explorationId:null,runId:null};if(b==="remote"){if(E!=="stage"&&E!=="prod")return l(`--browser remote: no remote browsers for env ${E}`);let s;try{s=mt(E,j??null)}catch(m){return l(m.message)}let p=v;i=dt([p.access_key]),$=ht({hpsBase:s,auth:p,forge:ft(O.tmsBaseUrl,p,()=>({exploration_id:Z.explorationId,run_id:Z.runId,project_id:Fe,hx_job_id:tt().jobId??null,kane_version:M,region:j??null,tunnel:!!T.tunnel,tunnel_name:T.tunnel?.name??null})),tunnel:T.tunnel,releaseSync:m=>gt(O.tmsBaseUrl,p,m),onEvent:m=>g({type:"remote_browser",...m})})}else $=ct({launch:ze,width:De,height:Ge,headless:!!e.headless});Xe("explore-browsers",()=>$.releaseAllSync());let P=null,ve=null;try{P=await Mt({controller:{baseUrl:O.controllerBaseUrl,authHeader:K(v.username,v.access_key)},onWarn:s=>g({type:"warning",message:s}),onExploration:s=>{process.stderr.write(ge(s,e.env)+`
44
+ `)},onStop:()=>{g({type:"warning",message:"explore stop: the run is stopping cleanly"}),ve?.()}})}catch(s){g({type:"warning",message:`live mode is off for this run: ${s.message}`})}let _e=()=>{},nr=new Promise(s=>{_e=s}),ee=null;r||Me.add(s=>{s.type!=="explore_run_started"||ee||(ee=import("./explore-live-2YVRAQZO.js").then(({runLiveView:p})=>p({client:new S({baseUrl:O.controllerBaseUrl,auth:v}),explorationId:String(s.exploration_id),runId:String(s.run_id),mode:"local",env:E,policy:x,ended:nr})))});try{let s=await _t({url:e.url,prompt:U.prompt,maxLeases:e.maxLeases,explorationId:e.explorationId,...typeof e.claimRunId=="string"?{claimRunId:e.claimRunId}:{requested:Wt({opts:e,url:String(e.url),prompt:e.prompt??"Explore the app",depsText:N,variables:R,allowedDomains:w,policy:x,maxParallel:e.maxParallel,maxLeases:e.maxLeases})},projectId:Fe,policy:x,context:U,variables:R,allowedDomains:w,...Yt(e),allowPosts:x==="read_only"?Q.posts:[],depthCaps:xe.caps,slowBudgets:be.budgets,recheck:e.recheck!==!1,maxParallel:D,...typeof e.focus=="string"?{focus:e.focus}:{},denyNames:(e.deny??[]).map(m=>m.trim()).filter(Boolean),headless:!!e.headless,width:De,height:Ge,auth:v,clientRelease:M},{client:new S({baseUrl:O.controllerBaseUrl,auth:v}),spawnRunner:m=>{let d=et({environment:E,username:v.username,accessKey:v.access_key,sessionId:m});return $.kind==="local"?ke({env:d,runner:ye,sessionId:m}):Nt(ke({env:d,runner:ye}),Ne(re,"sessions",m,"runner-stderr.log"),pt([v.access_key]))},acquireBrowser:async m=>{let d=await $.acquire(m);return P?.onBrowser(m),{cdpEndpoint:d.cdpEndpoint,release:()=>{P?.offBrowser(m),d.release()}}},releaseBrowsersOnInterrupt:$.kind==="remote",frameLink:m=>P?.attachRunner(m),onFrame:(m,d)=>P?.runnerFrame(m,d),onLiveRun:m=>{Z.explorationId=m.explorationId,Z.runId=m.runId,P?.armRun(m)},emit:m=>{let d=i(m);o?o.emit(d):c?.(d),P?.onEvent(d)},baseDir:re,onInterrupt:m=>{ve=m;let d=Mr(m);return()=>{ve=null,d()}}});await $.releaseAll(),await P?.close(s.stopReason??s.remark?.code??"stopped");let p=u(f?{...s,exitCode:xt(s)}:s);return _e(p),ee&&await ee,p}finally{_e(1),await P?.close("stopped"),await $.releaseAll(),Je("explore-browsers")}}var Ur=3e3;async function Nr(e,t={}){let n=t.tty??!ce(e),r=t.out??(w=>{process.stdout.write(w+`
45
45
  `)}),o=n?null:Re("explore"),i=String(e.explorationId??"").trim(),c=String(e.project??"").trim(),g=(w,L,b)=>(o?.emit({type:"done",status:L,exit_code:w,exploration_id:i||null,...b?{error:b}:{}}),w),a=(w,L)=>{if(o)H({type:"error",message:w});else{let b=t.err??(j=>{process.stderr.write(j+`
46
46
  `)});b(`error: ${w}`),L&&b(`next: ${L}`)}return g(2,"error",w)};if(i&&c)return a("--exploration-id or --project, not both","kane-cli explore view --exploration-id <id>");if(!i&&!c)return a("name the exploration: --exploration-id or --project","kane-cli explore list --all names them (or plain kane-cli explore to pick one)");let u=await J(e,"explore view");if(!u.ok)return a(u.error,"kane-cli login");let l=u.basic,f={controllerBaseUrl:u.controllerBaseUrl};if(c){try{i=(await new S({baseUrl:f.controllerBaseUrl,auth:l}).listExplorations({state:"all",project:c})).explorations.find(L=>L.project_id===c)?.exploration_id??""}catch(w){return a(`could not find project ${c}'s exploration: ${w.message}`)}if(!i)return a(`project ${c} has no exploration`,`start one: kane-cli explore run --project ${c} --url <app>`)}let y=K(l.username,l.access_key),I={controllerBaseUrl:f.controllerBaseUrl,authHeader:y,explorationId:i,port:e.port,live:{controller:{baseUrl:f.controllerBaseUrl,authHeader:y}}},_=await Et(I);if(_.kind==="not_found")return a(`exploration ${i} not found`,"kane-cli explore list --all");if(_.kind==="error")return a(`could not read the map: ${_.message}`);let x;try{x=await St(I)}catch(w){return a(`could not bind 127.0.0.1${I.port?`:${I.port}`:""}: ${w.message}`,"pass another --port, or leave it out for the first free one")}let U=t.hold?null:Hr(),R=null;try{R=await new S({baseUrl:f.controllerBaseUrl,auth:l,timeoutMs:Ur}).getContext(i)}catch{}o&&o.emit({type:"explore_view_started",url:x.url,exploration_id:i,context:R});let N=null;if(!o){let w=!t.out&&!!process.stdin.isTTY&&!!process.stdout.isTTY;w&&Zt(x.url),r(q("map viewer ready",` \xB7 ${x.url}`)),r(_r(` ${w?"opened in your browser \xB7 ":""}live when a run is going`)),r("");let L=_.kind==="ok"&&_.body.counts&&typeof _.body.counts=="object"?_.body.counts:null,b=R?`context ${R.enabled?"on":"off"}${R.last_job?` \xB7 ${R.last_job.status}`:""}`:"";for(let j of It({status:q("serving"),meta:["explore",i.slice(0,8),u.environment??""],tallies:[...Lt(L).filter(T=>!T.endsWith("findings")&&!T.endsWith("finding")),...b?[b]:[]],keys:[...w?["o open again"]:[],"ctrl+c stop serving"]}))r(j);w&&!t.hold&&(N=Br(()=>{Zt(x.url)}))}t.onStarted?.(x);try{await(U??t.hold())}finally{N?.()}return await x.close(),g(0,"stopped")}async function Zt(e){try{let{default:t}=await import("./open-MQLQKFAW.js");await t(e)}catch{process.stderr.write(`could not open a browser: open ${e}
47
47
  `)}}function Br(e){let t=process.stdin;if(!t.isTTY)return()=>{};let n=r=>{let o=r.toString("utf8");o===""?process.kill(process.pid,"SIGINT"):(o==="o"||o==="O")&&e()};return t.setRawMode(!0),t.resume(),t.on("data",n),()=>{t.off("data",n);try{t.setRawMode(!1)}catch{}t.pause()}}function Mr(e){let t=process.listeners("SIGINT");for(let n of t)process.removeListener("SIGINT",n);return process.on("SIGINT",e),()=>{process.removeListener("SIGINT",e);for(let n of t)process.on("SIGINT",n)}}function Hr(){return new Promise(e=>{let t=process.listeners("SIGINT"),n=process.listeners("SIGTERM");process.removeAllListeners("SIGINT"),process.removeAllListeners("SIGTERM");let r=()=>{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r);for(let o of t)process.on("SIGINT",o);for(let o of n)process.on("SIGTERM",o);e()};process.once("SIGINT",r),process.once("SIGTERM",r)})}function er(e,t,n,r){let o=oe(e);return{env:e,controllerBaseUrl:o.controllerBaseUrl,secretsBaseUrl:o.secretsBaseUrl,tmsBaseUrl:o.tmsBaseUrl,basic:t,orgId:n,emit:r}}export{Rr as a,Er as b,uo as c,Qt as d,Ir as e,Lr as f,Tr as g,Yt as h,Cr as i,Pr as j,Or as k,Ur as l,Nr as m,Mr as n};
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as V,e as P,f as Ve,k as He}from"./chunk-LRS5MGBY.js";import{b as Pe}from"./chunk-QCKA665H.js";import{j as Oe,k as X}from"./chunk-QTZBVDPR.js";import{e as Re}from"./chunk-NWD54VV5.js";import{e as ge,i as he}from"./chunk-XMPTFXPW.js";import{h as Y}from"./chunk-L4UVUFL6.js";import{a as Me,b as Ue,c as De,d as te,g as Ce,m as ne,n as G,o as Ae,p as se,q as Be,r as je,s as re,t as Fe,u as Ge}from"./chunk-252FWF2G.js";import{e as Te}from"./chunk-FFL55I2M.js";import{a as ee,b as Se,c as _e}from"./chunk-JNSWKGTB.js";import{c as Ne,h as Ee}from"./chunk-UUJIGOEO.js";import{j as Le,k as $e}from"./chunk-ZTHYAHDN.js";import{f as xe,g as q,j as Z,n as ve}from"./chunk-AZLNLHUA.js";import{j as ke}from"./chunk-REKHAN53.js";import{b as F}from"./chunk-ZFM77AQU.js";import{b as Q}from"./chunk-SWMTXMKB.js";import{B as we,Ha as m,f as pe,p as Ie,w as be}from"./chunk-W3OVSDBN.js";import{a as E,e as ye}from"./chunk-I2MC6VVX.js";import{j as J}from"./chunk-UEE3RZN4.js";import{d as j}from"./chunk-DBMW3VUN.js";import{a as me}from"./chunk-FOJHSG5M.js";import{existsSync as oe,readFileSync as ae,statSync as H}from"fs";import{basename as de,extname as K}from"path";var ie=1024*1024,qe=1e3,Ze=e=>12e4+Math.ceil(e/ie)*1e3,v=e=>e>=ie?`${(e/ie).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,et=e=>new Promise(i=>setTimeout(i,e)),tt=e=>/^[a-z][a-z0-9+.-]*:/i.test(e)&&!oe(e);async function Ke(e,i,s,l){let o=new Map(l.map(a=>[a.sourceId,a.head])),d=[];for(let a of s){let r=o.get(a.sourceId);(r?await e.mainNode(i,r).then(f=>f.content.blob,()=>null):null)!==F(a.bytes)&&d.push(a)}return d}var nt=new Set(["KIND_MISMATCH","SITE_MOVED","UUID_MOVED","WEB_URL_CHANGED"]);function T(e){let i=e.code==="PLUGIN_HOOK_FAILED"||e.code==="PLUGIN_HOOK_TIMEOUT";return{refusal:{code:e.code,message:e.message,remedy:e.remedy??"check the source, then run the command again",...i?{support:!0}:{}},exit:i?1:2}}async function st(e,i,s){let l=i.plugin.manifest.id,o=ee(e),d;try{d=await _e(i.plugin,"claim",j.hookMs,()=>i.plugin.claim({ref:i.ref,named:i.named,isFile:o}))}catch(t){if(t instanceof Ne)return T(t.refusal);throw t}if(d==null)return T({code:"PLUGIN_NOT_CLAIMED",message:`plugin ${l} does not read ${i.ref}`,remedy:i.named?`drop the ${l}: prefix, or name the plugin that reads it`:"ingest it as a file of a built-in kind"});let a=d.sourceId;if(typeof a!="string")return T({code:"PLUGIN_HOOK_FAILED",message:`plugin ${l} answered claim with something that is not a claim`});let r=s??a;if(!Se(r))return T({code:"PLUGIN_SOURCE_ID_INVALID",message:`${JSON.stringify(r)} is not an id a source may have: it starts with a letter or digit and holds letters, digits and . _ -, at most 128 characters`,remedy:s===void 0?"give the source an id with --as <id>":"give another id with --as <id>"});let y={id:l,ref:i.ref,named:i.named,isFile:o},f=v(j.contentBytes);if(!o)return{item:{kind:"file",path:e,node:`ref:${e}`,file:e,bytes:Buffer.alloc(0),sourceId:r,limit:f,plugin:y}};let I=de(e),c;try{c=ae(e)}catch{return{refusal:m.ingestCantOpen(I),exit:2}}if(c.byteLength>j.contentBytes)return{refusal:m.ingestTooLarge(I,v(c.byteLength),f),exit:2};let{dev:u,ino:p}=H(e);return{item:{kind:"file",path:e,node:`${u}:${p}`,file:I,bytes:c,sourceId:r,limit:f,plugin:y}}}var S=e=>e.kind==="file"?e.path:e.address;function We(e){if(e.provider.name==="web")return`web|${e.sourceId}`;let i=new URL(e.address),s=e.provider.name.startsWith("linear")?`${i.host}/${i.pathname.split("/")[1]??""}`:i.host;return`${e.provider.name}|${s.toLowerCase()}|${e.sourceId}`}var rt=(e,i)=>e.kind==="file"?i.kind==="file"&&e.node===i.node:i.kind==="link"&&We(e)===We(i);async function it(e,i,s){let l=new Map;for(let t of e)l.set(t.sourceId,[...l.get(t.sourceId)??[],t]);let o=[...l.values()].filter(t=>t.length>1);if(o.length===0)return null;let d=i?.map(t=>t.sourceId)??null,a=new Set(o.flatMap(t=>t.slice(1))),r=new Set([...l.keys(),...d??[]]),y=t=>{if(d===null)return null;let R=2;for(;r.has(`${t}-${R}`);)R++;return r.add(`${t}-${R}`),`${t}-${R}`},f=t=>t.kind==="file"?t.path:te(t.provider.name,t.address),I=new Set(i?.filter(t=>t.head!==null).map(t=>t.sourceId)),c=e.filter(t=>!a.has(t)&&I.has(t.sourceId)),u=await s(c.flatMap(t=>t.kind==="file"?[t]:[])),p=e.filter(t=>!a.has(t)&&!u.includes(t));return je(o.map(t=>({names:t.map(f),id:t[0].sourceId})),p.map(S),e.filter(t=>a.has(t)).map(t=>({ref:S(t),as:y(t.sourceId),place:l.get(t.sourceId).indexOf(t)+1})),{reviews:u.flatMap(t=>t.kind==="file"?[{name:t.file,ref:t.path,id:t.sourceId}]:[]),link:c.some(t=>t.kind==="link"),firstTwin:p.some(t=>l.get(t.sourceId).length>1)})}async function Ft(e){try{return await ot(e)}finally{await be()}}async function ot(e){let i=e.mode==="agent",s=n=>i?ke(ge("ndjson",n,e.testing?.agentLines?{stdout:e.testing.agentLines,stderr:()=>{}}:void 0),{atQuestionsOnly:!0}):null,l=s("extract");l&&e.choice.onboarded&&l.event({type:"folder_linked",project_id:e.choice.projectId,project:e.choice.projectName});let o=(n,h,g=!1,O=l)=>O?(O.event({type:"error",code:n.code,message:n.message,...we(n),...n.notAdded?{not_added:n.notAdded}:{}}),O.done(h,"refused")):(g&&e.choice.onboarded?process.stdout.write(`${Oe(e.choice.projectName)}
2
+ import{d as V,e as P,f as Ve,k as He}from"./chunk-3RJHXOZH.js";import{b as Pe}from"./chunk-CM4CHYSN.js";import{j as Oe,k as X}from"./chunk-HCJ2N3XB.js";import{e as Re}from"./chunk-3F5FMH76.js";import{e as ge,i as he}from"./chunk-XMPTFXPW.js";import{h as Y}from"./chunk-ZU4W2QGM.js";import{a as Me,b as Ue,c as De,d as te,g as Ce,m as ne,n as G,o as Ae,p as se,q as Be,r as je,s as re,t as Fe,u as Ge}from"./chunk-457Y5TEC.js";import{e as Te}from"./chunk-7NPTL66J.js";import{a as ee,b as Se,c as _e}from"./chunk-JNSWKGTB.js";import{c as Ne,h as Ee}from"./chunk-UUJIGOEO.js";import{j as Le,k as $e}from"./chunk-ZTHYAHDN.js";import{f as xe,g as q,j as Z,n as ve}from"./chunk-AZLNLHUA.js";import{j as ke}from"./chunk-REKHAN53.js";import{b as F}from"./chunk-ZFM77AQU.js";import{b as Q}from"./chunk-RF37IJNN.js";import{B as we,Ha as m,f as pe,p as Ie,w as be}from"./chunk-7HMSMAUG.js";import{a as E,e as ye}from"./chunk-I2MC6VVX.js";import{j as J}from"./chunk-UEE3RZN4.js";import{d as j}from"./chunk-DBMW3VUN.js";import{a as me}from"./chunk-FOJHSG5M.js";import{existsSync as oe,readFileSync as ae,statSync as H}from"fs";import{basename as de,extname as K}from"path";var ie=1024*1024,qe=1e3,Ze=e=>12e4+Math.ceil(e/ie)*1e3,v=e=>e>=ie?`${(e/ie).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,et=e=>new Promise(i=>setTimeout(i,e)),tt=e=>/^[a-z][a-z0-9+.-]*:/i.test(e)&&!oe(e);async function Ke(e,i,s,l){let o=new Map(l.map(a=>[a.sourceId,a.head])),d=[];for(let a of s){let r=o.get(a.sourceId);(r?await e.mainNode(i,r).then(f=>f.content.blob,()=>null):null)!==F(a.bytes)&&d.push(a)}return d}var nt=new Set(["KIND_MISMATCH","SITE_MOVED","UUID_MOVED","WEB_URL_CHANGED"]);function T(e){let i=e.code==="PLUGIN_HOOK_FAILED"||e.code==="PLUGIN_HOOK_TIMEOUT";return{refusal:{code:e.code,message:e.message,remedy:e.remedy??"check the source, then run the command again",...i?{support:!0}:{}},exit:i?1:2}}async function st(e,i,s){let l=i.plugin.manifest.id,o=ee(e),d;try{d=await _e(i.plugin,"claim",j.hookMs,()=>i.plugin.claim({ref:i.ref,named:i.named,isFile:o}))}catch(t){if(t instanceof Ne)return T(t.refusal);throw t}if(d==null)return T({code:"PLUGIN_NOT_CLAIMED",message:`plugin ${l} does not read ${i.ref}`,remedy:i.named?`drop the ${l}: prefix, or name the plugin that reads it`:"ingest it as a file of a built-in kind"});let a=d.sourceId;if(typeof a!="string")return T({code:"PLUGIN_HOOK_FAILED",message:`plugin ${l} answered claim with something that is not a claim`});let r=s??a;if(!Se(r))return T({code:"PLUGIN_SOURCE_ID_INVALID",message:`${JSON.stringify(r)} is not an id a source may have: it starts with a letter or digit and holds letters, digits and . _ -, at most 128 characters`,remedy:s===void 0?"give the source an id with --as <id>":"give another id with --as <id>"});let y={id:l,ref:i.ref,named:i.named,isFile:o},f=v(j.contentBytes);if(!o)return{item:{kind:"file",path:e,node:`ref:${e}`,file:e,bytes:Buffer.alloc(0),sourceId:r,limit:f,plugin:y}};let I=de(e),c;try{c=ae(e)}catch{return{refusal:m.ingestCantOpen(I),exit:2}}if(c.byteLength>j.contentBytes)return{refusal:m.ingestTooLarge(I,v(c.byteLength),f),exit:2};let{dev:u,ino:p}=H(e);return{item:{kind:"file",path:e,node:`${u}:${p}`,file:I,bytes:c,sourceId:r,limit:f,plugin:y}}}var S=e=>e.kind==="file"?e.path:e.address;function We(e){if(e.provider.name==="web")return`web|${e.sourceId}`;let i=new URL(e.address),s=e.provider.name.startsWith("linear")?`${i.host}/${i.pathname.split("/")[1]??""}`:i.host;return`${e.provider.name}|${s.toLowerCase()}|${e.sourceId}`}var rt=(e,i)=>e.kind==="file"?i.kind==="file"&&e.node===i.node:i.kind==="link"&&We(e)===We(i);async function it(e,i,s){let l=new Map;for(let t of e)l.set(t.sourceId,[...l.get(t.sourceId)??[],t]);let o=[...l.values()].filter(t=>t.length>1);if(o.length===0)return null;let d=i?.map(t=>t.sourceId)??null,a=new Set(o.flatMap(t=>t.slice(1))),r=new Set([...l.keys(),...d??[]]),y=t=>{if(d===null)return null;let R=2;for(;r.has(`${t}-${R}`);)R++;return r.add(`${t}-${R}`),`${t}-${R}`},f=t=>t.kind==="file"?t.path:te(t.provider.name,t.address),I=new Set(i?.filter(t=>t.head!==null).map(t=>t.sourceId)),c=e.filter(t=>!a.has(t)&&I.has(t.sourceId)),u=await s(c.flatMap(t=>t.kind==="file"?[t]:[])),p=e.filter(t=>!a.has(t)&&!u.includes(t));return je(o.map(t=>({names:t.map(f),id:t[0].sourceId})),p.map(S),e.filter(t=>a.has(t)).map(t=>({ref:S(t),as:y(t.sourceId),place:l.get(t.sourceId).indexOf(t)+1})),{reviews:u.flatMap(t=>t.kind==="file"?[{name:t.file,ref:t.path,id:t.sourceId}]:[]),link:c.some(t=>t.kind==="link"),firstTwin:p.some(t=>l.get(t.sourceId).length>1)})}async function Ft(e){try{return await ot(e)}finally{await be()}}async function ot(e){let i=e.mode==="agent",s=n=>i?ke(ge("ndjson",n,e.testing?.agentLines?{stdout:e.testing.agentLines,stderr:()=>{}}:void 0),{atQuestionsOnly:!0}):null,l=s("extract");l&&e.choice.onboarded&&l.event({type:"folder_linked",project_id:e.choice.projectId,project:e.choice.projectName});let o=(n,h,g=!1,O=l)=>O?(O.event({type:"error",code:n.code,message:n.message,...we(n),...n.notAdded?{not_added:n.notAdded}:{}}),O.done(h,"refused")):(g&&e.choice.onboarded?process.stdout.write(`${Oe(e.choice.projectName)}
3
3
  `):e.mode==="interactive"&&process.stdout.write(`
4
4
  `),X(n),process.stdout.write(`
5
- `),h),d=(n,h)=>o(n,h,!0),a=(n,h)=>h.length>0?{...n,detail:Fe(h.map(g=>g.name)),notAdded:h.map(g=>g.ref)}:n;if(e.opts.plan)return d(m.notYet("context ingest --plan"),2);if(e.opts.as!==void 0&&e.paths.length>1)return d(Be(e.paths),2);let r=[],y=n=>{r.some(h=>rt(h,n))||r.push(n)},f=q.flatMap(n=>n.extensions).join(" ");for(let n of e.paths){let h=r.map(k=>({name:k.kind==="file"?k.file:te(k.provider.name,k.address),ref:S(k)})),g=(k,Ye)=>d(a(k,h),Ye),O=Ee().route(n,ee);if(O!==null){let k=await st(n,O,e.opts.as);if("refusal"in k)return g(k.refusal,k.exit);y(k.item);continue}if(Le(n)){let k=$e(n);if(!k?.fetch)return g(se(n),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);y({kind:"link",address:n,provider:k,sourceId:e.opts.as??k.sourceIdFor(n)??n});continue}if(tt(n))return g(se(n),2);let w=de(n),L=Z(n);if(!L.ok)return g(m.ingestUnsupported(`${w} is a file type kane can't ingest (${K(n)||"no extension"}) \u2014 supported: ${f}`),2);if(!oe(n)||!H(n).isFile())return g(m.ingestNoFile(n),2);let D;try{D=ae(n)}catch{return g(m.ingestCantOpen(w),2)}if(D.byteLength>L.media.maxBytes)return g(m.ingestTooLarge(w,v(D.byteLength),v(L.media.maxBytes)),2);if(L.media.sniff&&!L.media.sniff(D))return g(m.ingestNotItsType(w,K(n).slice(1)),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);let fe;try{fe=e.opts.as??ve(n)}catch{return g(m.ingestNoSourceId(w),2)}let{dev:Je,ino:Qe}=H(n);y({kind:"file",path:n,node:`${Je}:${Qe}`,file:w,bytes:D,sourceId:fe,limit:v(L.media.maxBytes)})}let I=r[0],c;try{c=e.testing?.basicAuth??await Re()}catch(n){if(!(n instanceof he))throw n;return d({code:n.code,message:n.message,...n.remedy?{remedy:n.remedy}:{}},2)}let u=pe({url:e.choice.latticeUrl,basicAuth:c,...e.testing?.run?.fetch?{fetch:e.testing.run.fetch}:{}}),p=e.choice.projectId,t=null,R=null;try{t=await u.sources(p)}catch(n){n instanceof E&&(n.code==="NO_CONTEXT"||n.code==="NOT_FOUND")?t=[]:R=n}let b=await it(r,t,n=>Ke(u,p,n,t??[]));if(b)return d(b,2);if(t===null){let{exit:n,...h}=Pe(R,e.choice,null);return d(h,n)}let x=new Set(t.filter(n=>n.head!==null).map(n=>n.sourceId)),$=r.filter(n=>x.has(n.sourceId)),N=$.flatMap(n=>n.kind==="file"?[n]:[]);if(r.length>1&&N.length>0&&N.length===$.length){let n=await Ke(u,p,N,t);if(n.length>0){let h=n.map(g=>({name:g.file,ref:S(g),id:g.sourceId}));return d(re(h,r.filter(g=>!n.includes(g)).map(S),e.choice.projectName),2)}}let M=r.length===1?$[0]:void 0;if(M){let{reviewNewVersion:n}=await import("./reconcile-remote-GWDV5CUT.js"),h=e.mode==="interactive";h&&!e.choice.onboarded&&process.stdout.write(`using project "${e.choice.projectName}", shared with your team
6
- `);let g=s("reconcile");return n({choice:e.choice,person:u,basicAuth:c,item:M,...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,mode:e.mode==="agent"?"agent":h?"interactive":"ci",io:g,refuse:(O,w=2)=>o(O,w,!1,g),projectLine:h,nothing:(O,w)=>`${h?` ${me.green("\u2714")} `:""}${O} is already in "${w}", unchanged`,...e.testing?{testing:e.testing}:{}})}let C=e.testing?.run?.retryDeadlineMs??12e4,ze=dt(e.testing?.remoteDeps),le=[],_=r.map((n,h)=>{let g=at({person:u,choice:e.choice,item:n,first:h===0,then:e.mode==="ci"?"pause":"extract",...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,retryMs:C,remoteDeps:ze,refusal:O=>a(O,_.slice(0,h).map(w=>({name:w.name??w.file,ref:w.path??w.file}))),alone:O=>re(O.map(w=>{let L=_[w].remote;return{name:_[w].name??_[w].file,ref:S(r[w]),id:r[w].sourceId,...L?{shown:Te({source:r[w].sourceId,page:Ce({...L,address:L.origin.url})})}:{}}}),r.filter((w,L)=>!O.includes(L)).map(S),e.choice.projectName),...e.testing?{testing:e.testing}:{}});return le.push(g.ended),g.step}),ce={verb:"extract",choice:e.choice,start:{kind:"new",body:{projectId:p,verb:"extract",mode:e.mode==="interactive"?"interactive":"agent",sourceId:I.sourceId}},run:{source:I.sourceId,...e.opts.force?{force:!0}:{},...e.opts.trust!==void 0?{trust:e.opts.trust}:{}}},A=e.testing?.remoteDeps?{...e.testing.run,remoteDeps:e.testing.remoteDeps}:e.testing?.run,U;if(e.mode==="interactive"){let{runInteractiveRemote:n}=await import("./interactive-remote-D77ULJGL.js");U=await n({...ce,subject:I.kind==="link"?De(I.provider.name,I.address):I.sourceId,ingest:_,testing:{basicAuth:c,...e.testing?.check?{check:e.testing.check}:{},...A?{run:A}:{},...e.testing?.mount?{mount:e.testing.mount}:{},...e.testing?.onController?{onController:e.testing.onController}:{}}})}else U=await He({...ce,mode:"agent",basicAuth:c,io:l,check:e.testing?.check??Ve,onProgress:()=>{},ingest:_,signals:!0,onRefusal:n=>{X(n),process.stdout.write(`
5
+ `),h),d=(n,h)=>o(n,h,!0),a=(n,h)=>h.length>0?{...n,detail:Fe(h.map(g=>g.name)),notAdded:h.map(g=>g.ref)}:n;if(e.opts.plan)return d(m.notYet("context ingest --plan"),2);if(e.opts.as!==void 0&&e.paths.length>1)return d(Be(e.paths),2);let r=[],y=n=>{r.some(h=>rt(h,n))||r.push(n)},f=q.flatMap(n=>n.extensions).join(" ");for(let n of e.paths){let h=r.map(k=>({name:k.kind==="file"?k.file:te(k.provider.name,k.address),ref:S(k)})),g=(k,Ye)=>d(a(k,h),Ye),O=Ee().route(n,ee);if(O!==null){let k=await st(n,O,e.opts.as);if("refusal"in k)return g(k.refusal,k.exit);y(k.item);continue}if(Le(n)){let k=$e(n);if(!k?.fetch)return g(se(n),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);y({kind:"link",address:n,provider:k,sourceId:e.opts.as??k.sourceIdFor(n)??n});continue}if(tt(n))return g(se(n),2);let w=de(n),L=Z(n);if(!L.ok)return g(m.ingestUnsupported(`${w} is a file type kane can't ingest (${K(n)||"no extension"}) \u2014 supported: ${f}`),2);if(!oe(n)||!H(n).isFile())return g(m.ingestNoFile(n),2);let D;try{D=ae(n)}catch{return g(m.ingestCantOpen(w),2)}if(D.byteLength>L.media.maxBytes)return g(m.ingestTooLarge(w,v(D.byteLength),v(L.media.maxBytes)),2);if(L.media.sniff&&!L.media.sniff(D))return g(m.ingestNotItsType(w,K(n).slice(1)),2);if(e.opts.as!==void 0&&!J(e.opts.as))return g(m.ingestBadSourceId(e.opts.as),2);let fe;try{fe=e.opts.as??ve(n)}catch{return g(m.ingestNoSourceId(w),2)}let{dev:Je,ino:Qe}=H(n);y({kind:"file",path:n,node:`${Je}:${Qe}`,file:w,bytes:D,sourceId:fe,limit:v(L.media.maxBytes)})}let I=r[0],c;try{c=e.testing?.basicAuth??await Re()}catch(n){if(!(n instanceof he))throw n;return d({code:n.code,message:n.message,...n.remedy?{remedy:n.remedy}:{}},2)}let u=pe({url:e.choice.latticeUrl,basicAuth:c,...e.testing?.run?.fetch?{fetch:e.testing.run.fetch}:{}}),p=e.choice.projectId,t=null,R=null;try{t=await u.sources(p)}catch(n){n instanceof E&&(n.code==="NO_CONTEXT"||n.code==="NOT_FOUND")?t=[]:R=n}let b=await it(r,t,n=>Ke(u,p,n,t??[]));if(b)return d(b,2);if(t===null){let{exit:n,...h}=Pe(R,e.choice,null);return d(h,n)}let x=new Set(t.filter(n=>n.head!==null).map(n=>n.sourceId)),$=r.filter(n=>x.has(n.sourceId)),N=$.flatMap(n=>n.kind==="file"?[n]:[]);if(r.length>1&&N.length>0&&N.length===$.length){let n=await Ke(u,p,N,t);if(n.length>0){let h=n.map(g=>({name:g.file,ref:S(g),id:g.sourceId}));return d(re(h,r.filter(g=>!n.includes(g)).map(S),e.choice.projectName),2)}}let M=r.length===1?$[0]:void 0;if(M){let{reviewNewVersion:n}=await import("./reconcile-remote-BCX6SWFC.js"),h=e.mode==="interactive";h&&!e.choice.onboarded&&process.stdout.write(`using project "${e.choice.projectName}", shared with your team
6
+ `);let g=s("reconcile");return n({choice:e.choice,person:u,basicAuth:c,item:M,...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,mode:e.mode==="agent"?"agent":h?"interactive":"ci",io:g,refuse:(O,w=2)=>o(O,w,!1,g),projectLine:h,nothing:(O,w)=>`${h?` ${me.green("\u2714")} `:""}${O} is already in "${w}", unchanged`,...e.testing?{testing:e.testing}:{}})}let C=e.testing?.run?.retryDeadlineMs??12e4,ze=dt(e.testing?.remoteDeps),le=[],_=r.map((n,h)=>{let g=at({person:u,choice:e.choice,item:n,first:h===0,then:e.mode==="ci"?"pause":"extract",...e.opts.as!==void 0?{as:e.opts.as}:{},supported:f,retryMs:C,remoteDeps:ze,refusal:O=>a(O,_.slice(0,h).map(w=>({name:w.name??w.file,ref:w.path??w.file}))),alone:O=>re(O.map(w=>{let L=_[w].remote;return{name:_[w].name??_[w].file,ref:S(r[w]),id:r[w].sourceId,...L?{shown:Te({source:r[w].sourceId,page:Ce({...L,address:L.origin.url})})}:{}}}),r.filter((w,L)=>!O.includes(L)).map(S),e.choice.projectName),...e.testing?{testing:e.testing}:{}});return le.push(g.ended),g.step}),ce={verb:"extract",choice:e.choice,start:{kind:"new",body:{projectId:p,verb:"extract",mode:e.mode==="interactive"?"interactive":"agent",sourceId:I.sourceId}},run:{source:I.sourceId,...e.opts.force?{force:!0}:{},...e.opts.trust!==void 0?{trust:e.opts.trust}:{}}},A=e.testing?.remoteDeps?{...e.testing.run,remoteDeps:e.testing.remoteDeps}:e.testing?.run,U;if(e.mode==="interactive"){let{runInteractiveRemote:n}=await import("./interactive-remote-J56EWJGA.js");U=await n({...ce,subject:I.kind==="link"?De(I.provider.name,I.address):I.sourceId,ingest:_,testing:{basicAuth:c,...e.testing?.check?{check:e.testing.check}:{},...A?{run:A}:{},...e.testing?.mount?{mount:e.testing.mount}:{},...e.testing?.onController?{onController:e.testing.onController}:{}}})}else U=await He({...ce,mode:"agent",basicAuth:c,io:l,check:e.testing?.check??Ve,onProgress:()=>{},ingest:_,signals:!0,onRefusal:n=>{X(n),process.stdout.write(`
7
7
  `)},...A?{testing:A}:{}});let W=le.map(n=>n()),B=[...W].reverse().find(n=>n.sid!==null)?.sid??null,ue=W.flatMap(n=>n.added!==null?[{name:n.name,status:n.added}]:[]),z=W.find(n=>n.refused!==null)?.refused??null;if(z!==null)return o(z.refusal,z.exit);if(e.mode==="ci"&&ue.length>0&&B!==null){let n=ue.map(({name:h,status:g})=>g==="unchanged"?`${h} is already in "${e.choice.projectName}", unchanged`:g==="versioned"?`added a new version of ${h} to session ${B}, not saved yet`:`added ${h} to session ${B}, not saved yet`);return process.stdout.write(`${n.join(`
8
8
  `)}
9
9
  extract: kane-cli context extract --resume ${B}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as d,d as p,e as g}from"./chunk-N3TCNZSX.js";import{b as m}from"./chunk-I6OQISK4.js";import{mkdirSync as y,writeFileSync as o,existsSync as u,readFileSync as M}from"fs";import{join as a}from"path";var E={name:"remote-execution",version:"0.5.0",backendId:"hyper",kaneCompat:">=0.4.0",defaults:{runson:"mac",concurrency:1}},f={runson:"mac",concurrency:1,timeoutMinutes:120,mobile:{runson:"mac26",queueTimeout:300,appiumPort:4739,androidHome:"$HOME/android-sdk-shim",globalTimeout:90,testSuiteTimeout:90,testSuiteStep:45,ios:{runson:{}},realDevice:{runson:"linux"}}},v=`version: "0.1"
2
+ import{c as d,d as p,e as g}from"./chunk-M43WH5DQ.js";import{b as m}from"./chunk-D36V5OX6.js";import{mkdirSync as y,writeFileSync as o,existsSync as u,readFileSync as M}from"fs";import{join as a}from"path";var E={name:"remote-execution",version:"0.5.0",backendId:"hyper",kaneCompat:">=0.4.0",defaults:{runson:"mac",concurrency:1}},f={runson:"mac",concurrency:1,timeoutMinutes:120,mobile:{runson:"mac26",queueTimeout:300,appiumPort:4739,androidHome:"$HOME/android-sdk-shim",globalTimeout:90,testSuiteTimeout:90,testSuiteStep:45,ios:{runson:{}},realDevice:{runson:"linux"}}},v=`version: "0.1"
3
3
  runson: {{runson}}
4
4
  autosplit: true
5
5
  concurrency: {{concurrency}}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as C}from"./chunk-NQTYWHPB.js";import{h as Q}from"./chunk-7RPKHKA3.js";import{b as G}from"./chunk-SA6IKFFD.js";import{c as O}from"./chunk-SMXABALN.js";import{a as E}from"./chunk-HFJSP4KD.js";import{a as z}from"./chunk-2OOFURWD.js";import{a as B}from"./chunk-OVNRRI4E.js";import{e as q}from"./chunk-Z7S3IWUX.js";import{l as M,q as R,t as Z}from"./chunk-A7RJQJNT.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as r,i as N}from"./chunk-33DWJV67.js";import{a as L}from"./chunk-6YGTRKDT.js";import{y as o}from"./chunk-I6OQISK4.js";import{e as g}from"./chunk-UR6MHSHU.js";var H=g(L(),1);var y=g(A(),1);function ie(e){return[{value:"local",label:"Local build",hint:R(e).join(" / "),available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function he({kind:e,onSelect:i,onCancel:m}){let s=ie(e),[b,f]=(0,H.useState)(0),[l,d]=(0,H.useState)(null);return N((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(t=>Math.max(0,t-1)),a.downArrow&&f(t=>Math.min(s.length-1,t+1)),a.return){let t=s[b];if(!t.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(t.value)}}),(0,y.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,y.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,y.jsx)(n,{marginTop:1,flexDirection:"column",children:s.map((p,a)=>{let t=a===b,S=p.available?t?o.orange:void 0:o.muted;return(0,y.jsxs)(n,{children:[(0,y.jsxs)(r,{color:S,children:[t?"\u276F ":" ",p.label]}),(0,y.jsxs)(r,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,y.jsx)(n,{marginTop:1,children:(0,y.jsx)(r,{color:o.red,children:l})}),(0,y.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var x=g(L(),1);var u=g(A(),1),j=50,J=500;function ae(e){return`${e.name} (${e.appId})`}function Re({kind:e,listApps:i,onSelect:m,onManualEntry:s,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[t,S]=(0,x.useState)(!1),[ee,$]=(0,x.useState)(!1),[w,V]=(0,x.useState)(null),[X,oe]=(0,x.useState)(""),[re,_]=(0,x.useState)(!1),F=(0,x.useRef)(!0),D=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let T=++D.current,k=X.trim();F.current?a(!0):k&&$(!0),S(!0),V(null),_(!1),(async()=>{let I=[];try{for(let P=0;;P+=j){let Y=await i({limit:j,offset:P,search:k});if(T!==D.current)return;if(I.push(...Y.apps),d([...I]),F.current&&(a(!1),F.current=!1),$(!1),Y.apps.length===0||I.length>=Y.total)break;if(I.length>=J){_(!0);break}}}catch(P){if(T!==D.current)return;V(P instanceof Error?P.message:String(P)),a(!1),$(!1)}finally{T===D.current&&S(!1)}})()},[X,i]),N((T,k)=>{if(k.tab){s();return}k.escape&&b()},{isActive:!!w&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(r,{color:o.secondary,children:[" ",f]})]})]});if(w)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(r,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(r,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(r,{color:o.dim,children:w})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let te=new Map(l.map(T=>[T.appId,T])),ne=l.map(T=>({id:T.appId,label:ae(T)})),W=!p&&!t&&l.length===0&&!X.trim()?`No builds for ${M(e)} uploaded to this account yet \u2014 press Tab to enter an app id.`:null;return(0,u.jsx)(E,{title:"App under test",items:ne,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:t,searching:ee,itemNoun:"uploads",preserveSelectionById:!0,onSearch:oe,onTab:s,extraHint:"tab to enter an id",footer:W?(0,u.jsx)(r,{color:o.dim,children:W}):re?(0,u.jsx)(r,{color:o.dim,children:`Showing the first ${J} \u2014 type to search the rest.`}):void 0,onSelect:T=>{let k=te.get(T.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var U=g(L(),1);var c=g(A(),1);function we({busyMessage:e,onSubmit:i,onBack:m}){let[s,b]=(0,U.useState)(""),[f,l]=(0,U.useState)(null);return e?(0,c.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,c.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,c.jsxs)(n,{marginTop:1,children:[(0,c.jsx)(C,{}),(0,c.jsxs)(r,{color:o.secondary,children:[" ",e]})]})]}):(0,c.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,c.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,c.jsx)(n,{marginTop:1,children:(0,c.jsx)(r,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,c.jsxs)(n,{marginTop:1,children:[(0,c.jsx)(r,{color:o.dim,children:" "}),(0,c.jsx)(O,{value:s,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!G(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,c.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,c.jsx)(r,{color:o.red,children:f}),(0,c.jsx)(r,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,c.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}var K=g(L(),1);var h=g(A(),1);function le(e){return Q(e.trim())}function _e({kind:e,onBack:i,onSelect:m,onCancel:s}){let[b,f]=(0,K.useState)(""),[l,d]=(0,K.useState)(null),p=R(e).join(" / ");return(0,h.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,h.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{color:o.dim,children:`Path to a build (${p}): `})}),(0,h.jsxs)(n,{marginTop:1,children:[(0,h.jsx)(r,{color:o.dim,children:" "}),(0,h.jsx)(O,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let t=le(a);if(!t){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!Z(e,t.value)){d(`${t.kind} builds don't run on ${M(e)} \u2014 expected ${p}.`);return}d(null),m(t).then(S=>{!S.ok&&S.error&&d(S.error)})},onCancel:i,placeholder:`/path/to/app${R(e)[0]}`})]}),l&&(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{color:o.red,children:l})}),(0,h.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var v=g(A(),1);function pe(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function ce(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function se(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,s=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return q(s,m)}function de(e){return e.virtualName??e.displayName}function ue(e,i){let m=e.state==="ready"||e.state==="stopped",s=ce(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${de(e)}${b} \xB7 ${pe(e)}`,...i&&se(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&s?{disabledHint:s}:{}}}function me(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function eo({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:s,onSelect:b,onCancel:f,kind:l}){if(s)return(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(r,{color:o.orange,bold:!0,children:"Device"}),(0,v.jsxs)(n,{marginTop:1,children:[(0,v.jsx)(C,{}),(0,v.jsxs)(r,{color:o.secondary,children:[" ",s]})]})]});if(e.length===0)return(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(r,{color:o.orange,bold:!0,children:"Device"}),(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(r,{color:o.dim,children:me(l)})})]});let d=e.map(t=>ue(t,i)),p=i?d.find(t=>t.isActive)?.id??null:m?e.find(t=>t.id===m||t.virtualName===m)?.id??null:null,a=new Map(e.map(t=>[t.id,t]));return(0,v.jsx)(E,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:t=>{let S=a.get(t.id);S&&b(S)},onCancel:f})}export{he as a,Re as b,we as c,_e as d,eo as e};
2
+ import{a as C}from"./chunk-LIGTP3A3.js";import{h as Q}from"./chunk-LQQNPMOD.js";import{b as G}from"./chunk-NXAJBSIF.js";import{c as O}from"./chunk-SMXABALN.js";import{a as E}from"./chunk-ZAFJQ3SM.js";import{a as z}from"./chunk-CUXY6KQ2.js";import{a as B}from"./chunk-ICLUC44J.js";import{e as q}from"./chunk-Z7S3IWUX.js";import{l as M,q as R,t as Z}from"./chunk-A7RJQJNT.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as r,i as N}from"./chunk-33DWJV67.js";import{a as L}from"./chunk-6YGTRKDT.js";import{y as o}from"./chunk-D36V5OX6.js";import{e as g}from"./chunk-UR6MHSHU.js";var H=g(L(),1);var y=g(A(),1);function ie(e){return[{value:"local",label:"Local build",hint:R(e).join(" / "),available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function he({kind:e,onSelect:i,onCancel:m}){let s=ie(e),[b,f]=(0,H.useState)(0),[l,d]=(0,H.useState)(null);return N((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(t=>Math.max(0,t-1)),a.downArrow&&f(t=>Math.min(s.length-1,t+1)),a.return){let t=s[b];if(!t.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(t.value)}}),(0,y.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,y.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,y.jsx)(n,{marginTop:1,flexDirection:"column",children:s.map((p,a)=>{let t=a===b,S=p.available?t?o.orange:void 0:o.muted;return(0,y.jsxs)(n,{children:[(0,y.jsxs)(r,{color:S,children:[t?"\u276F ":" ",p.label]}),(0,y.jsxs)(r,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,y.jsx)(n,{marginTop:1,children:(0,y.jsx)(r,{color:o.red,children:l})}),(0,y.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var x=g(L(),1);var u=g(A(),1),j=50,J=500;function ae(e){return`${e.name} (${e.appId})`}function Re({kind:e,listApps:i,onSelect:m,onManualEntry:s,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[t,S]=(0,x.useState)(!1),[ee,$]=(0,x.useState)(!1),[w,V]=(0,x.useState)(null),[X,oe]=(0,x.useState)(""),[re,_]=(0,x.useState)(!1),F=(0,x.useRef)(!0),D=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let T=++D.current,k=X.trim();F.current?a(!0):k&&$(!0),S(!0),V(null),_(!1),(async()=>{let I=[];try{for(let P=0;;P+=j){let Y=await i({limit:j,offset:P,search:k});if(T!==D.current)return;if(I.push(...Y.apps),d([...I]),F.current&&(a(!1),F.current=!1),$(!1),Y.apps.length===0||I.length>=Y.total)break;if(I.length>=J){_(!0);break}}}catch(P){if(T!==D.current)return;V(P instanceof Error?P.message:String(P)),a(!1),$(!1)}finally{T===D.current&&S(!1)}})()},[X,i]),N((T,k)=>{if(k.tab){s();return}k.escape&&b()},{isActive:!!w&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(r,{color:o.secondary,children:[" ",f]})]})]});if(w)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(r,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(r,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(r,{color:o.dim,children:w})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let te=new Map(l.map(T=>[T.appId,T])),ne=l.map(T=>({id:T.appId,label:ae(T)})),W=!p&&!t&&l.length===0&&!X.trim()?`No builds for ${M(e)} uploaded to this account yet \u2014 press Tab to enter an app id.`:null;return(0,u.jsx)(E,{title:"App under test",items:ne,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:t,searching:ee,itemNoun:"uploads",preserveSelectionById:!0,onSearch:oe,onTab:s,extraHint:"tab to enter an id",footer:W?(0,u.jsx)(r,{color:o.dim,children:W}):re?(0,u.jsx)(r,{color:o.dim,children:`Showing the first ${J} \u2014 type to search the rest.`}):void 0,onSelect:T=>{let k=te.get(T.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var U=g(L(),1);var c=g(A(),1);function we({busyMessage:e,onSubmit:i,onBack:m}){let[s,b]=(0,U.useState)(""),[f,l]=(0,U.useState)(null);return e?(0,c.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,c.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,c.jsxs)(n,{marginTop:1,children:[(0,c.jsx)(C,{}),(0,c.jsxs)(r,{color:o.secondary,children:[" ",e]})]})]}):(0,c.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,c.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,c.jsx)(n,{marginTop:1,children:(0,c.jsx)(r,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,c.jsxs)(n,{marginTop:1,children:[(0,c.jsx)(r,{color:o.dim,children:" "}),(0,c.jsx)(O,{value:s,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!G(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,c.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,c.jsx)(r,{color:o.red,children:f}),(0,c.jsx)(r,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,c.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}var K=g(L(),1);var h=g(A(),1);function le(e){return Q(e.trim())}function _e({kind:e,onBack:i,onSelect:m,onCancel:s}){let[b,f]=(0,K.useState)(""),[l,d]=(0,K.useState)(null),p=R(e).join(" / ");return(0,h.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,h.jsx)(r,{color:o.orange,bold:!0,children:"App under test"}),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{color:o.dim,children:`Path to a build (${p}): `})}),(0,h.jsxs)(n,{marginTop:1,children:[(0,h.jsx)(r,{color:o.dim,children:" "}),(0,h.jsx)(O,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let t=le(a);if(!t){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!Z(e,t.value)){d(`${t.kind} builds don't run on ${M(e)} \u2014 expected ${p}.`);return}d(null),m(t).then(S=>{!S.ok&&S.error&&d(S.error)})},onCancel:i,placeholder:`/path/to/app${R(e)[0]}`})]}),l&&(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{color:o.red,children:l})}),(0,h.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var v=g(A(),1);function pe(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function ce(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function se(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,s=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return q(s,m)}function de(e){return e.virtualName??e.displayName}function ue(e,i){let m=e.state==="ready"||e.state==="stopped",s=ce(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${de(e)}${b} \xB7 ${pe(e)}`,...i&&se(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&s?{disabledHint:s}:{}}}function me(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function eo({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:s,onSelect:b,onCancel:f,kind:l}){if(s)return(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(r,{color:o.orange,bold:!0,children:"Device"}),(0,v.jsxs)(n,{marginTop:1,children:[(0,v.jsx)(C,{}),(0,v.jsxs)(r,{color:o.secondary,children:[" ",s]})]})]});if(e.length===0)return(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(r,{color:o.orange,bold:!0,children:"Device"}),(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(r,{color:o.dim,children:me(l)})})]});let d=e.map(t=>ue(t,i)),p=i?d.find(t=>t.isActive)?.id??null:m?e.find(t=>t.id===m||t.virtualName===m)?.id??null:null,a=new Map(e.map(t=>[t.id,t]));return(0,v.jsx)(E,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:t=>{let S=a.get(t.id);S&&b(S)},onCancel:f})}export{he as a,Re as b,we as c,_e as d,eo as e};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ue,c as fe}from"./chunk-6LIC2R22.js";import{a as ae}from"./chunk-SONMD3W5.js";import{k as re,l as oe}from"./chunk-QTZBVDPR.js";import{a as C,b as k}from"./chunk-NLZZLANH.js";import{c as de,d as ce,f as le}from"./chunk-JQSLUGD4.js";import{B as A,Ba as ie,Ha as f,M as K,T as H,V as x,W as q,X as O,Z as B,ba as G,fa as z,ga as J,ia as Q,ja as V,ka as X,ma as Y,na as Z,pa as P,qa as ee,ra as ne,s as W,ua as te,va as se,y as D,z as U}from"./chunk-W3OVSDBN.js";import{a as w}from"./chunk-I2MC6VVX.js";import{a as S}from"./chunk-RPRXRKKR.js";import{oa as L}from"./chunk-UEE3RZN4.js";import{a as p}from"./chunk-FOJHSG5M.js";import{y as I}from"./chunk-I6OQISK4.js";var ve={usecase:"use_case",scenario:"scenario",test:"test",ac:"acceptance_criterion",source:"source"},b={use_case:"the use case",scenario:"the scenario",test:"the test",acceptance_criterion:"the acceptance criterion",source:"the document"};async function pe(e,n,s,i=()=>{}){let r=e,t=r?.entity;if(typeof t!="string"||t==="")return null;let c=async d=>{if(typeof d!="string")return null;try{let a=await n.mainNode(s,d),o=ve[a.label];if(!o)return null;let l=o==="acceptance_criterion"?a.content.text:a.content.title;return{kind:o,id:a.name,title:typeof l=="string"&&l!==""?l:null}}catch(a){return i(`the conflict's node couldn't be read, so the save's refusal names nothing: ${k(a)}`),null}};if(r?.kind==="source")return{kind:"source",id:t,title:typeof r.fileName=="string"&&r.fileName!==""?r.fileName:null};if(r?.kind==="edge"){let[d,a]=r.ends?await Promise.all([c(r.ends.from),c(r.ends.to)]):[null,null];return d||a?{kind:"link",from:d,to:a}:null}if(r?.kind==="node"||t.startsWith("sha256:"))return c(t);try{return(await n.sources(s)).some(d=>d.sourceId===t)?{kind:"source",id:t,title:null}:null}catch(d){return i(`the project's sources couldn't be read, so the save's refusal names nothing: ${k(d)}`),null}}function $(e){if(e.kind==="source")return e.title?`${b.source} "${e.title}"`:"a document this session reads";let n=e.id?L(e.id):null;return e.kind==="acceptance_criterion"&&n?`${b[e.kind]} ${n}`:e.title?`${b[e.kind]} "${e.title}"`:n?`${b[e.kind]} ${n}`:b[e.kind]}function me(e,n,s,i=[]){return{code:"PROJECT_CHANGED",message:`not saved \u2014 another save also changed ${e.kind!=="link"?$(e):e.from&&e.to?`the link between ${$(e.from)} and ${$(e.to)}`:`a link to ${$(e.from??e.to)}`}`,detail:`this session can't be saved now, so ${Z(n)} won't reach the project`,remedy:V(s,i)}}function ke(e){let n=le(e);return n!==null?de(n,S()):ce("save",S())}async function ge(e,n){if(n.verb!=="evolve")return{notUpdated:[],stillStale:0,repins:new Map};let s=await e.sessionLog?.().catch(()=>[])??[],i=s.filter(t=>t.kind==="evolve_not_updated").at(-1)?.body,r=t=>Array.isArray(t)?t.filter(c=>typeof c=="string"):[];return{notUpdated:r(i?.use_cases),stillStale:r(i?.still_stale).length,repins:q(s)}}function _(e,n){let s=n==="agent"?" --mode agent":"";return e.verb==="evolve"?`kane-cli maintain evolve ${e.useCase??"--from-stale"}${s}`:e.verb==="design"&&e.useCase?`kane-cli design tests --use-case ${e.useCase}${s}`:`kane-cli context extract${s}`}async function Ke(e){let n={...e,trace:e.trace??ke(e.sid)},s=n.mode==="agent",i=n.print??(c=>{process.stdout.write(`${c}
2
+ import{a as ue,c as fe}from"./chunk-XQMWHPZI.js";import{a as ae}from"./chunk-DDZLCAEO.js";import{k as re,l as oe}from"./chunk-HCJ2N3XB.js";import{a as C,b as k}from"./chunk-NLZZLANH.js";import{c as de,d as ce,f as le}from"./chunk-EECDDDSB.js";import{B as A,Ba as ie,Ha as f,M as K,T as H,V as x,W as q,X as O,Z as B,ba as G,fa as z,ga as J,ia as Q,ja as V,ka as X,ma as Y,na as Z,pa as P,qa as ee,ra as ne,s as W,ua as te,va as se,y as D,z as U}from"./chunk-7HMSMAUG.js";import{a as w}from"./chunk-I2MC6VVX.js";import{a as S}from"./chunk-RPRXRKKR.js";import{oa as L}from"./chunk-UEE3RZN4.js";import{a as p}from"./chunk-FOJHSG5M.js";import{y as I}from"./chunk-D36V5OX6.js";var ve={usecase:"use_case",scenario:"scenario",test:"test",ac:"acceptance_criterion",source:"source"},b={use_case:"the use case",scenario:"the scenario",test:"the test",acceptance_criterion:"the acceptance criterion",source:"the document"};async function pe(e,n,s,i=()=>{}){let r=e,t=r?.entity;if(typeof t!="string"||t==="")return null;let c=async d=>{if(typeof d!="string")return null;try{let a=await n.mainNode(s,d),o=ve[a.label];if(!o)return null;let l=o==="acceptance_criterion"?a.content.text:a.content.title;return{kind:o,id:a.name,title:typeof l=="string"&&l!==""?l:null}}catch(a){return i(`the conflict's node couldn't be read, so the save's refusal names nothing: ${k(a)}`),null}};if(r?.kind==="source")return{kind:"source",id:t,title:typeof r.fileName=="string"&&r.fileName!==""?r.fileName:null};if(r?.kind==="edge"){let[d,a]=r.ends?await Promise.all([c(r.ends.from),c(r.ends.to)]):[null,null];return d||a?{kind:"link",from:d,to:a}:null}if(r?.kind==="node"||t.startsWith("sha256:"))return c(t);try{return(await n.sources(s)).some(d=>d.sourceId===t)?{kind:"source",id:t,title:null}:null}catch(d){return i(`the project's sources couldn't be read, so the save's refusal names nothing: ${k(d)}`),null}}function $(e){if(e.kind==="source")return e.title?`${b.source} "${e.title}"`:"a document this session reads";let n=e.id?L(e.id):null;return e.kind==="acceptance_criterion"&&n?`${b[e.kind]} ${n}`:e.title?`${b[e.kind]} "${e.title}"`:n?`${b[e.kind]} ${n}`:b[e.kind]}function me(e,n,s,i=[]){return{code:"PROJECT_CHANGED",message:`not saved \u2014 another save also changed ${e.kind!=="link"?$(e):e.from&&e.to?`the link between ${$(e.from)} and ${$(e.to)}`:`a link to ${$(e.from??e.to)}`}`,detail:`this session can't be saved now, so ${Z(n)} won't reach the project`,remedy:V(s,i)}}function ke(e){let n=le(e);return n!==null?de(n,S()):ce("save",S())}async function ge(e,n){if(n.verb!=="evolve")return{notUpdated:[],stillStale:0,repins:new Map};let s=await e.sessionLog?.().catch(()=>[])??[],i=s.filter(t=>t.kind==="evolve_not_updated").at(-1)?.body,r=t=>Array.isArray(t)?t.filter(c=>typeof c=="string"):[];return{notUpdated:r(i?.use_cases),stillStale:r(i?.still_stale).length,repins:q(s)}}function _(e,n){let s=n==="agent"?" --mode agent":"";return e.verb==="evolve"?`kane-cli maintain evolve ${e.useCase??"--from-stale"}${s}`:e.verb==="design"&&e.useCase?`kane-cli design tests --use-case ${e.useCase}${s}`:`kane-cli context extract${s}`}async function Ke(e){let n={...e,trace:e.trace??ke(e.sid)},s=n.mode==="agent",i=n.print??(c=>{process.stdout.write(`${c}
3
3
  `)}),r=(c,d)=>(n.trace.line("save_refused",{sid:n.sid,...c.code?{code:c.code}:{},exit:d}),s?n.emit({type:"error",code:c.code,message:c.message,...A(c)}):(re(c),i("")),d),t=!1;try{return await be(n,s,i,r,()=>t=!0)}catch(c){return c instanceof w&&c.retryable?r(t?f.saveUnconfirmed():f.noConnectionToSave(),2):r(f.assuranceOffOr(c,n.projectName,f.saveFailed("your work is")),1)}}async function be(e,n,s,i,r){let t;try{t=await e.person.getSession(e.sid)}catch(u){if(u instanceof w&&u.code==="NOT_FOUND")return i(f.noSuchSession(e.sid),2);throw u}if(t.ended==="failed")return i(f.sessionFailed(e.sid),2);if(t.ended!=="complete")return i(f.notFinished(e.sid,P(t.verb==="design"||t.verb==="evolve"?"design":"extract",e.sid,n)),2);if(t.scope?.state==="finalized")return T(e,t,{},n,s,i,r,!0);let c=await G(e.person,e.projectId,e.sid);if(!z(c,(t.scope?.position??t.basePosition)>t.basePosition))return await e.person.discard(e.sid,t.generation).catch(()=>{}),n?e.onProgress({kind:"save",sid:e.sid,phase:"saved",landed:0}):s(f.nothingToSave),0;let{notUpdated:d,repins:a}=await ge(e,t),o=O(x(t.verb,c),a);if(e.trace?.line("save_check",{sid:e.sid,verb:t.verb,counts:c}),n)return e.onProgress({kind:"save",sid:e.sid,phase:"check",project:e.projectName,counts:c,...d.length>0?{notUpdated:d}:{},...o.replaces?{replaces:o.replaces}:{},...o.keeps?{keeps:o.keeps}:{}}),e.yes?T(e,t,c,n,s,i,r):i(f.confirmRequired(e.sid),2);let l=(await e.person.project(e.projectId))?.mainPosition??null,g=l!==null&&l>t.basePosition;for(let u of ye(e.projectName,o,g))s(u);s("");let m=e.yes||await e.confirm("save this session? (y/N)");return e.yes||s(""),m?T(e,t,c,n,s,i,r):(s(`not saved \u2014 your work is kept in session ${e.sid}`),0)}function ye(e,n,s){return[p.bold(`save this session to "${e}"`),...J(n,s).map(([i,r])=>`${p.dim(` ${i.padEnd(10)}`)}${r}`)]}function we(e,n="",s=process.stdout.columns,i=null,r=null){let t=[];if(e.receipt!==null&&t.push(`${n}${p.green(`\u2714 ${e.receipt}`)}`),i?.line&&t.push(`${n}${p.dim(i.line)}`),i?.replacedHead&&i.replaced){t.push(`${n}${p.dim(i.replacedHead)}`);for(let d of i.replaced){if(t.push(`${n}${p.dim(` ${d.file}`)}`),d.by.length===0)continue;let a=` replaced by ${d.by.length===1?d.by[0]:`${d.by.slice(0,-1).join(", ")} and ${d.by[d.by.length-1]}`}`;!s||n.length+a.length<=s?t.push(`${n}${p.dim(a)}`):d.by.forEach((o,l)=>t.push(`${n}${p.dim(l===0?` replaced by ${o}`:` and ${o}`)}`))}}if(i?.needed){let d=[...D(i.needed,{cwd:process.cwd(),tests:i.needed.tests,indent:0,...s?{columns:s-n.length}:{}}),...U(i.needed.noStartPage,{indent:0})];for(let a of d)t.push(`${n}${p.dim(a)}`)}let c=Re(e.lines,i?.lines??[],r);if(c.length>0){t.push("");let d=a=>s&&!a.startsWith(" kane-cli ")?oe(a,s):a;for(let a of c)t.push(a.tone==="warning"?p.hex(I.amber)(d(a.text)):a.tone==="detail"?p.dim(a.command?$e(a.text,s):a.text):d(a.text));(e.support||i?.support)&&t.push(`if this keeps failing, share this id with support: ${W(e.support?"refused_TEST_MANAGER":"refused_TEST_FILES")}`)}return t}function $e(e,n){let s=e.indexOf("run: kane-cli ");if(!n||e.length<=n||s<0)return e;let i=e.match(/^ */)[0];return`${e.slice(0,s+4)}
4
4
  ${i} ${e.slice(s+5)}`}function Re(e,n,s){if(n.length===0)return e;if(e.length===0)return n;let i=c=>c.text.startsWith("next: "),r=e.findIndex(i),t=n.findIndex(i);return s!==null&&r>=0&&t>=0?[...e.slice(0,r),...n.slice(0,t),{text:s,tone:"plain"},...e.slice(r+1),...n.slice(t+2)]:[...e,{text:"",tone:"plain"},...n]}async function T(e,n,s,i,r,t,c,d=!1){e.onProgress({kind:"save",sid:e.sid,phase:"saving"}),d&&!i&&r(f.savedBefore);let a=o=>{i||r(d?`finishing test cases in Test Manager\u2026 ${o}`:`saving\u2026 ${o}`)};try{c();let o=await e.person.land(e.sid,n.generation),l=n.verb==="design"||n.verb==="reconcile"||n.verb==="evolve"?await fe({person:e.person,projectId:n.projectId,landing:o,cwd:process.cwd()}):null,g=o.testManager?.notCovered?.length?await ue({person:e.person,projectId:n.projectId,landing:o}):void 0;e.trace?.line("save_landed",Ne(e.sid,o,l));let m=B(s),{stillStale:u,repins:R}=await ge(e,n),{changes:M,approves:j,archives:E,removes:F}=s,v=O(x(n.verb,s),R);if(e.onProgress({kind:"save",sid:e.sid,phase:"saved",landed:o.landed,...m>0?{heldChanges:m}:{},...M?{changes:M}:{},...j?{approves:j}:{},...E?{archives:E}:{},...F?{removes:F}:{},...v.replaces?{replaces:v.replaces}:{},...v.keeps?{keeps:v.keeps}:{},...s.uncounted?{uncounted:s.uncounted}:{},...o.testManager!==void 0?{testManager:o.testManager}:{},...g?{sessionUseCases:[...g]}:{},...l!==null?{testFiles:l}:{},...u>0?{stillStale:u}:{}}),!i){let y=ne(o.testManager,e.sid,e.projectName,g,ee(l)),N=l===null?null:te(l,e.sid,d,{testManager:o.testManager});if(d){let h=y.receipt===null&&y.lines.length===0;a(o.testManager?.error?"stopped":h?"nothing left to do":"done"),(y.receipt!==null||N?.line)&&r("")}else{a("saved"),r("");let h=H(v);r(p.green(`\u2714 saved to "${e.projectName}"${h?` \u2014 ${h}`:""}`));for(let he of K(v))r(p.dim(` ${he}`))}for(let h of we(y,"",void 0,N,se(o.testManager,N,e.projectName)))r(h);if(u>0)for(let h of ie.stillOutOfDate(u))r(h);r("")}return 0}catch(o){if(!(o instanceof w))throw o;if(o.retryable)return a("failed"),i||r(""),t(f.saveUnconfirmed(),2);if(o.code==="SESSION_NOT_FINISHED")return a("failed"),i||r(""),t(f.notFinished(e.sid,P(n.verb==="design"||n.verb==="evolve"?"design":"extract",e.sid,i)),2);if(o.code==="SCOPE_BEHIND_HEAD"){let g={kind:"save",sid:e.sid,phase:"behind"},m=await pe(o.extra.conflict,e.person,e.projectId,C("remote-save")),u=Y(n);if(i){let R=u.length>0?{cmd:`${X(u)} --mode agent`,why:"start again from the latest, adding this session's documents again"}:{cmd:_(n,e.mode),why:"start again from the latest"};return e.emit({...ae(g),...m?{conflict:m}:{},next:[R]}),2}return e.onProgress(g),a("failed"),r(""),t(m?me(m,s,_(n,e.mode),u):f.projectChanged(e.projectName,s,_(n,e.mode),u),2)}let l=o.code==="SCOPE_RECORD_REFUSED";return l&&C("remote-save")(`session ${e.sid}: the save was refused: ${k(o)}`),e.onProgress({kind:"save",sid:e.sid,phase:"failed",reason:"not_accepted",...l?{code:"SCOPE_RECORD_REFUSED"}:{}}),i?1:(a("failed"),r(""),t(f.saveFailed(Q(s)),1))}}function Ne(e,n,s){return{sid:e,landed:n.landed,...n.testManager!==void 0?{test_manager:n.testManager===null?null:{error:n.testManager.error??null}}:{},...s!==null?{test_files:s==="unread"?"unread":{written:s.wrote.length,refused:s.refused.length}}:{}}}export{pe as a,me as b,ke as c,Ke as d,we as e,Ne as f};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-RZ4F3BHX.js";import{a as s,b as o,e as c}from"./chunk-I6OQISK4.js";import{readFileSync as f,writeFileSync as d,mkdirSync as g,realpathSync as h}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function N(){try{let t=process.argv[1];if(t&&h(t).includes("/Cellar/"))return b}catch{}return C}var m=y(o,"version-check.json"),w=1440*60*1e3;function A(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<w)return t}catch{}return null}function k(t){try{g(o,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let i=0;i<3;i++){let a=(r[i]??0)-(n[i]??0);if(a!==0)return a}return 0}function p(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);return(r[0]??0)!==(n[0]??0)?"major":(r[1]??0)!==(n[1]??0)?"minor":"patch"}async function T(){try{let t=A();if(t)return u(s,t.latest)>0?{current:s,latest:t.latest,severity:p(s,t.latest)}:null;let e=new AbortController,n=setTimeout(()=>e.abort(),5e3),r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});if(clearTimeout(n),!r.ok)return null;let a=(await r.json())["dist-tags"]?.latest;return a?(k(a),u(s,a)>0?{current:s,latest:a,severity:p(s,a)}:null):null}catch{return null}}async function v(t=5e3){let e=new AbortController,n=setTimeout(()=>e.abort(),t);try{let r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});return r.ok?(await r.json())["dist-tags"]?.latest??null:null}catch{return null}finally{clearTimeout(n)}}export{N as a,u as b,p as c,T as d,v as e};
2
+ import{a as l}from"./chunk-RZ4F3BHX.js";import{a as s,b as o,e as c}from"./chunk-D36V5OX6.js";import{readFileSync as f,writeFileSync as d,mkdirSync as g,realpathSync as h}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function N(){try{let t=process.argv[1];if(t&&h(t).includes("/Cellar/"))return b}catch{}return C}var m=y(o,"version-check.json"),w=1440*60*1e3;function A(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<w)return t}catch{}return null}function k(t){try{g(o,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let i=0;i<3;i++){let a=(r[i]??0)-(n[i]??0);if(a!==0)return a}return 0}function p(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);return(r[0]??0)!==(n[0]??0)?"major":(r[1]??0)!==(n[1]??0)?"minor":"patch"}async function T(){try{let t=A();if(t)return u(s,t.latest)>0?{current:s,latest:t.latest,severity:p(s,t.latest)}:null;let e=new AbortController,n=setTimeout(()=>e.abort(),5e3),r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});if(clearTimeout(n),!r.ok)return null;let a=(await r.json())["dist-tags"]?.latest;return a?(k(a),u(s,a)>0?{current:s,latest:a,severity:p(s,a)}:null):null}catch{return null}}async function v(t=5e3){let e=new AbortController,n=setTimeout(()=>e.abort(),t);try{let r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});return r.ok?(await r.json())["dist-tags"]?.latest??null:null}catch{return null}finally{clearTimeout(n)}}export{N as a,u as b,p as c,T as d,v as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as v,b as be,d as B,e as Te}from"./chunk-I2MC6VVX.js";import{a as z}from"./chunk-RPRXRKKR.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-57MDWTON.js";import{b as we,c as ye,d as Re,e as Z,f as $e}from"./chunk-NWBLYMH7.js";import{na as ve,oa as P}from"./chunk-UEE3RZN4.js";import{g as fe}from"./chunk-NC7D7GOM.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),D=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:D(t.session),caseId:D(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:D(t.caseId)??"",internalId:D(t.internalId)??""};default:return{code:e.code,session:D(t.session),useCase:D(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],m=r;do{let c=await t("GET",`${s}${m===null?"":`&after=${encodeURIComponent(m)}`}`);l.push(...c.items),m=c.next}while(m!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:m,heldChanges:c,changes:p,approves:u,archives:g,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:m,heldChanges:c??0,changes:p??{},approves:u??{},archives:g??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:m,marked:c})=>({projectId:l,name:m,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(m=>m.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let m=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}=m;return{linked:{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(m){if(m instanceof v&&m.status===409&&nt.has(m.code))return{refused:st(m)};throw m}},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let m=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${m}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:g,origin:w,media:h})=>({sourceId:p,head:u,completeness:g,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:m,dst:c,other:p})=>({type:m,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let m=l.next===null?[]:await a(r,l.next);return[...l.items,...m].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],m=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${m===null?"":`&after=${encodeURIComponent(m)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),m=u.next}while(m!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,m)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...m?{onSend:m}:{}}),u=c.headers.get("etag");if(p.length>0)try{let g=JSON.parse(p.toString("utf8"));typeof g.etag=="string"&&(u=g.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:m}={}){let c=`${a(m)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,m=await o("GET",`${t}/events?${l}`);s.push(...m.items),r=m.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,L=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let g=await p();return t.imports?.answered(),g}catch(g){if(!(g instanceof v))throw g;if(_e(g)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),g)}if(Oe.has(g.code)&&t.onStopped?.(g),!g.retryable)throw new L(c,g.code,g.message,g.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(g)});if(!await u.again(w))throw t.onStopped?.(new v(g.status,g.code,`Lattice did not take ${c} within ${o/1e3} s: ${g.message}`,null,null,{},g.requestId)),te(new Error(`Lattice refused ${c} (${g.code}, still after ${o/1e3} s): ${g.message}`),g)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new L(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,g=t.log;if(!g)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;g.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${g.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(g.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,m=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},g=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(m(u),h),null}case R.mainNodes:{let h=l.get(m(u));if(l.delete(m(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(g));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof L?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(ye()).catch(()=>{}),new Promise(e=>setTimeout(e,we).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as Le}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function De(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(Le(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...De(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...De(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Ue(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&Le(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
2
+ import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as v,b as be,d as B,e as Te}from"./chunk-I2MC6VVX.js";import{a as z}from"./chunk-RPRXRKKR.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-7AET4JKQ.js";import{b as we,c as ye,d as Re,e as Z,f as $e}from"./chunk-DJC7NTLA.js";import{na as ve,oa as P}from"./chunk-UEE3RZN4.js";import{g as fe}from"./chunk-NC7D7GOM.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),D=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:D(t.session),caseId:D(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:D(t.caseId)??"",internalId:D(t.internalId)??""};default:return{code:e.code,session:D(t.session),useCase:D(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],m=r;do{let c=await t("GET",`${s}${m===null?"":`&after=${encodeURIComponent(m)}`}`);l.push(...c.items),m=c.next}while(m!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:m,heldChanges:c,changes:p,approves:u,archives:g,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:m,heldChanges:c??0,changes:p??{},approves:u??{},archives:g??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:m,marked:c})=>({projectId:l,name:m,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(m=>m.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let m=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}=m;return{linked:{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(m){if(m instanceof v&&m.status===409&&nt.has(m.code))return{refused:st(m)};throw m}},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let m=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${m}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:g,origin:w,media:h})=>({sourceId:p,head:u,completeness:g,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:m,dst:c,other:p})=>({type:m,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let m=l.next===null?[]:await a(r,l.next);return[...l.items,...m].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],m=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${m===null?"":`&after=${encodeURIComponent(m)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),m=u.next}while(m!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,m)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...m?{onSend:m}:{}}),u=c.headers.get("etag");if(p.length>0)try{let g=JSON.parse(p.toString("utf8"));typeof g.etag=="string"&&(u=g.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:m}={}){let c=`${a(m)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,m=await o("GET",`${t}/events?${l}`);s.push(...m.items),r=m.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,L=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let g=await p();return t.imports?.answered(),g}catch(g){if(!(g instanceof v))throw g;if(_e(g)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),g)}if(Oe.has(g.code)&&t.onStopped?.(g),!g.retryable)throw new L(c,g.code,g.message,g.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(g)});if(!await u.again(w))throw t.onStopped?.(new v(g.status,g.code,`Lattice did not take ${c} within ${o/1e3} s: ${g.message}`,null,null,{},g.requestId)),te(new Error(`Lattice refused ${c} (${g.code}, still after ${o/1e3} s): ${g.message}`),g)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new L(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,g=t.log;if(!g)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;g.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${g.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(g.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,m=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},g=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(m(u),h),null}case R.mainNodes:{let h=l.get(m(u));if(l.delete(m(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(g));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof L?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(ye()).catch(()=>{}),new Promise(e=>setTimeout(e,we).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as Le}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function De(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(Le(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...De(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...De(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Ue(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&Le(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
3
3
  `).filter(o=>!/^\s+kane-cli /.test(o)).join(" ").replace(/(, run)?:$/,"").replace(/[,;]\s*(then\s+)?run:\s*kane-cli\b.*$/,"").trim();return{...n?{remedy:n}:{},next:e.next.map(o=>({cmd:`${o.cmd} ${t}`,why:o.why}))}}function Gn(e){let t=e;return!t||typeof t.sessionId!="string"||typeof t.verb!="string"?null:{sessionId:t.sessionId,verb:t.verb,useCase:typeof t.useCase=="string"?t.useCase:null,mine:t.mine===!0,status:typeof t.status=="string"?t.status:"running"}}var Hn=e=>({sid:e.sessionId,verb:e.verb,use_case:e.useCase,mine:e.mine,status:e.status}),yt={useCases:["use-case","use-cases"],criteria:["acceptance criterion","acceptance criteria"],scenarios:["scenario","scenarios"],tests:["test","tests"],openQuestions:["open question","open questions"],sources:["source","sources"],styleNotes:["style note","style notes"]},ue=ne.map(e=>[e,...yt[e]]),X=(e,t=H)=>{let n=ue.filter(([d])=>(e[d]??0)>0),o=n.filter(([d])=>!t.has(d));return o.length>0?o:n},Rt=new Set(["styleNotes"]),le=e=>e?ue.filter(([t])=>(e[t]??0)>0).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`):[];function $t(e){let t=o=>o?I(X(o).map(([d,a,i])=>`${o[d]} ${o[d]===1?a:i}`)):"",n=[[t(e),"added"],...Ve.map(({key:o,done:d})=>[t(e[o]),o==="changes"?"changed":d])].filter(([o])=>o!=="").map(([o,d])=>`${o} ${d}`);return N(e)>0&&n.push(Ke(N(e))),n.length>0?n.join(", "):null}function Wn(e){let t=$t(e.counts),n=[G(e.durS),...t?[t]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 "),o=e.title?`"${e.title}"`:P(e.id??"");return t||(e.counts.uncounted??0)>0?`\u25CF updated ${o} \u2014 ${n}`:`\u25CF nothing changed in ${o} \u2014 ${n}`}function Vn(e){let t=e.title?`"${e.title}"`:P(e.id??""),n=[G(e.durS),`${e.tests} ${e.tests===1?"test":"tests"}`,...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];return`\u25CF designed ${t} \u2014 ${n.join(" \xB7 ")}`}function Jn(e){return`\u25CF finished ${e.title?`"${e.title}"`:P(e.id??"")} \u2014 ${[G(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ")}`}var I=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`,Ve=[{key:"changes",row:"updates",done:"updated",saving:"updates"},{key:"approves",row:"approves",done:"approved",saving:"approves"},{key:"archives",row:"archives",done:"archived",saving:"archives"},{key:"replaces",row:"replaces",done:"replaced",saving:"replaces"},{key:"removes",row:"removes",done:"removed",saving:"removes"}],Q=e=>Ve.filter(({key:t})=>j(e[t])),Je=e=>Q(e).length>0,ge=e=>e===1?"1 test":`${e} tests`,vt=e=>[...Q(e).map(({key:t,done:n})=>`${I(le(e[t]))} ${n}`),...e.keeps?[`${ge(e.keeps)} marked up to date`]:[]],qn=e=>[...Q(e).map(({key:t,saving:n})=>`saving it ${n} ${I(le(e[t]))}${t==="removes"?" from the project":""}`),...e.keeps?[`saving it marks ${ge(e.keeps)} up to date`]:[]],Kn=e=>[...vt(e),...N(e)>0?[Ye(N(e))]:[]],Yn=e=>ue.reduce((t,[n])=>t+(H.has(n)?0:e.changes?.[n]??0),0),Xn=e=>xe(e),bt=e=>F(e)!==""||j(e.changes)||j(e.approves)||j(e.archives),St="this session's work",Qn=e=>F(e)?"throw away what this session added":me(e)?"throw away this session's chat":"throw away this session's work",zn="already discarded \u2014 nothing was saved",Zn=e=>bt(e)?"your team can see it now":me(e)?Et:xt(e)?St:"",Et="this session's chat";function es(e,t){let n=t.removes;if(e==="extract"||!n||!((n.scenarios??0)>0||(n.tests??0)>0))return t;let o={...(n.scenarios??0)>0?{scenarios:n.scenarios}:{},...(n.tests??0)>0?{tests:n.tests}:{}},{scenarios:d,tests:a,...i}=n,{removes:s,...r}=t;return{...r,replaces:o,...j(i)?{removes:i}:{}}}function ts(e){let t=new Map;for(let n of e){if(n.kind!=="evolve_diff")continue;let o=n.payload??n.body;if(typeof o?.use_case!="string")continue;let d=o.repinned?.tests;typeof d=="number"&&d>0?t.set(o.use_case,d):t.delete(o.use_case)}return t}function ns(e,t){let n=[...t.values()].reduce((i,s)=>i+s,0);if(n===0)return e;let o=Math.max(0,(e.uncounted??0)-t.size),{uncounted:d,...a}=e;return{...a,keeps:n,...o>0?{uncounted:o}:{}}}var Tt=["changes","approves","archives","removes"],N=e=>e.heldChanges??0,j=e=>Object.values(e??{}).some(t=>(t??0)>0),qe=e=>!(e.adds??F(e))&&!Je(e)&&N(e)===0&&(e.keeps??0)===0,me=e=>qe(e)&&(e.chatTurns??0)>0&&(e.uncounted??0)===0,xt=e=>qe(e)&&!me(e);async function ss(e,t,n){let o=await e.counts(t,n),{proposes:d,heldChanges:a,chatTurns:i,uncounted:s}=o;return{...d,...a>0?{heldChanges:a}:{},...Object.fromEntries(Tt.flatMap(r=>j(o[r])?[[r,o[r]]]:[])),...i&&i>0?{chatTurns:i}:{},...typeof s=="number"?{exact:!0}:{},...typeof s=="number"&&s>0?{uncounted:s}:{}}}function Ke(e){return e===1?"1 change to an existing use-case":`${e} changes to existing use-cases`}function Ye(e){return`${Ke(e)}, saved but not applied`}var kt=e=>F(e)!==""||Je(e)||N(e)>0||(e.keeps??0)>0||(e.chatTurns??0)>0||(e.uncounted??0)>0,rs=(e,t)=>e.exact?kt(e):t;function os(e,t){let n=F(e),o=N(e),d=[];n&&d.push(["adds",n]);for(let{key:s,row:r}of Q(e))d.push([r,le(e[s]).join(", ")]);e.keeps&&d.push(["keeps",`${ge(e.keeps)}, marked up to date`]),o>0&&d.push(["held",Ye(o)]);let a=(e.chatTurns??0)>0;((e.uncounted??0)>0||!e.exact&&d.length===0&&!a)&&d.push(["other","work not counted here"]),a&&d.push(["chat","saved with the session; your team can read it"]),d.push(["project",t?"changed since this session started":"no changes since this session started"]);let i=s=>(s?.scenarios??0)+(s?.tests??0);return i(e)+i(e.changes)>0&&d.push(["then","its test cases are created or updated in Test Manager"]),d}function F(e){return X(e,Rt).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`).join(", ")}function is(e){let t=X(e);if(t.length!==1)return"your work is";let[n,o,d]=t[0];return e[n]===1?`your ${o} is`:`your ${e[n]} ${d} are`}function Ct(e,t=[]){return t.length>0?`start a new session from the latest project, adding this session's documents again; run:
4
4
  ${Xe(t)}`:`${e.startsWith("kane-cli design tests")?"to design it again from the latest project":"to start a new session from the latest project"}, run:
5
5
  ${e}`}var Xe=e=>`kane-cli context ingest ${e.map(Y).join(" ")}`;function as(e,t){return e.length>0?[...new Set(e)]:_t(t)}function _t(e){return[...new Set((e.uploads??[]).filter(t=>t.outcome==="created"&&t.filename).map(t=>t.filename))]}function It(e){let t=X(e);if(t.length!==1)return"its work";let[n,o,d]=t[0];return e[n]===1?`its ${o}`:`its ${e[n]} ${d}`}function ds(e){return e.replace(/\s*\([^()]*→[^()]*\)/g,"")}function cs(e,t,n){return`kane-cli ${e==="design"?"design tests":"context extract"} --resume ${t}${n?" --mode agent":""}`}var Me=e=>`updating kane-cli won't help \u2014 share this id with support: ${V(`refused_${e}`)}`,q="in a folder linked to a shared project",U="check the file, then run the command again",ie=e=>[`${e} has more inside it than kane-cli can read`,"save a smaller copy, or a PDF of it, then run the command again"],Pt={PDF_ENCRYPTED:e=>[`${e} is password-protected`,"remove the password, then run the command again"],PDF_NO_TEXT_LAYER:e=>[`${e} has no text to read; scanned PDFs aren't supported yet`,"use a PDF with text in it, then run the command again"],PDF_UNREADABLE:e=>[`${e} can't be read as a PDF`,U],DOCX_UNREADABLE:e=>[`${e} can't be read as a Word document`,U],DOCX_NOT_WORDPROCESSING:e=>[`${e} can't be read as a Word document`,U],DOCX_NO_TEXT:e=>[`${e} has no text to add`,U],DOCX_ENCRYPTED_OR_LEGACY:e=>[`${e} is password-protected or in the old Word format`,"save it as a .docx without a password, then run the command again"],DOCX_PART_TOO_LARGE:ie,DOCX_TOO_MANY_PARTS:ie,DOCX_BOMB:ie,SOURCE_ID_OWNED:e=>[`${e} can't become a version of that source: a source plugin reads it`,"add it under another id with --as <id>, then run the command again"]},Ot={changed_both_sides:"it was changed in Test Manager too; choose there which steps to keep",not_pushable:"its steps can't be changed from here; change them in Test Manager",archived:"it's archived in Test Manager; restore it there first",busy:"a test run is using it; wait until the run ends",not_accepted:"Test Manager has different steps for it; choose there which to keep"},O=e=>`${e} ${e===1?"test case":"test cases"}`,Fe={test_on_older_version:"it changed after its test was designed",test_unreadable:"its test can't be read",test_has_no_steps:"its test has no steps"},Qe=e=>ve.test(e)?e.toLowerCase():e,ze=e=>Object.hasOwn(Fe,e)?Fe[e]:void 0,Ze=e=>e.useCase&&ze(e.reason)!==void 0&&e.reason!=="test_unreadable"?Qe(e.useCase):null;function us(e){if(!e||e==="unread")return;let t=new Map([...e.wrote,...e.unchanged??[]].map(n=>[n.id.toLowerCase(),n.path]));for(let n of e.refused)n.file&&t.set(n.id.toLowerCase(),n.file);return n=>t.get(n.toLowerCase())}var de=e=>e.reason==="test_unreadable";function Nt(e,t){let n=ze(e.reason);if(n===void 0)return[{text:" it can't be sent to Test Manager yet",tone:"detail"}];if(e.reason==="test_unreadable"){let d=t?.(e.test);return[{text:` ${n}${d?`: ${pe(d)}`:""}`,tone:"detail"}]}let o=Ze(e);return o===null?[{text:` ${n}`,tone:"detail"}]:[{text:` ${n}; to design its tests again, run:`,tone:"detail"},{text:` kane-cli design tests --use-case ${o}`,tone:"detail",command:!0}]}var K=(e,t)=>t===void 0||typeof e.useCase!="string"||t.has(Qe(e.useCase));function At(e,t,n){let o=e===1,d=`to see ${o?"its use-case":"their use-cases"}, run: kane-cli context list --stale`,a=o?"1 scenario of another use-case":`${e} scenarios of other use-cases`;return n?[{text:` ${a} ${o?"isn't":"aren't"} in Test Manager either`,tone:"detail"},{text:` ${d}`,tone:"detail"}]:[{text:`${a} in ${y(t)} ${o?"isn't":"aren't"} in Test Manager`,tone:"detail"},{text:` ${d}`,tone:"detail"}]}var C="some test cases may not be there yet";function he(e,t){switch(e){case"TEST_MANAGER_TIMEOUT":return{why:`Test Manager took too long, so ${C}`,lead:`Test Manager took too long; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!1,agentCode:"TEST_MANAGER_TIMED_OUT"};case"FORGE_UNAVAILABLE":return{why:`Test Manager couldn't be reached, so ${C}`,lead:`Test Manager couldn't be reached; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_UNREACHABLE"};case"FORGE_REFUSED":return{why:`Test Manager refused your account, so ${C}`,lead:`Test Manager refused your account; ${C}`,next:"ask a Test Manager admin to grant your account access, then run:",remedy:!0,support:!1,agentCode:"PROJECT_NO_ACCESS"};case"PROJECT_NOT_MARKED":return{why:`assurance is now off for "${t}", so ${C}`,lead:`assurance is now off for "${t}"; ${C}`,next:"to try them again later (nothing is saved twice), run:",remedy:!0,support:!1,agentCode:"ASSURANCE_OFF"};default:return{why:"some test cases couldn't be created or updated in Test Manager",lead:"some test cases couldn't be created or updated in Test Manager",next:"to try them again (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_FAILED"}}}function ls(e,t,n,o,d){let a={receipt:null,summary:null,lines:[],support:!1};if(!e)return a;let{made:i,updated:s,waiting:r,error:l}=e,m=e.nextRun??[],c=e.notCovered??[],p=c.filter(b=>K(b,o)),u=c.length-p.length;if(i===0&&s===0&&r===0&&l===null&&m.length===0&&c.length===0)return a;let g=i>0&&s>0?`${O(i)} created and ${s} updated in Test Manager`:i>0?`${O(i)} created in Test Manager`:s>0?`${O(s)} updated in Test Manager`:null,w={text:` kane-cli context sessions save ${t}`,tone:"plain"},h=b=>b===1?"wasn't":"weren't",f=[];if(m.length>0){let b=m.length===1;f.push({text:`${O(m.length)} in Test Manager ${b?"updates on its":"update on their"} next kane-cli run:`,tone:"plain"});for(let A of m)f.push({text:` "${A.title}"`,tone:"detail"});(r>0||l!==null||c.length>0)&&f.push({text:"",tone:"plain"})}if(r>0){f.push({text:`warning: ${O(r)} in Test Manager ${h(r)} updated`,tone:"warning"});for(let b of e.waitingOn)f.push({text:` "${b.title}"`,tone:"detail"},{text:` ${Ot[b.reason]}`,tone:"detail"})}if(p.length>0){let b=p.length;f.push({text:`warning: ${b} ${b===1?"scenario wasn't":"scenarios weren't"} sent to Test Manager`,tone:"warning"});for(let A of p)f.push({text:` "${A.title}"`,tone:"detail"},...Nt(A,d))}u>0&&f.push(...At(u,n,p.length>0));let $=l===null?null:he(l.code,n);$&&f.push({text:`warning: the session was saved, but ${$.why}`,tone:"warning"});let S=$?$.remedy||r===0?$.next:"then, to finish them (nothing is saved twice), run:":r>0?`then, to update ${r===1?"it":"them"} (nothing is saved twice), run:`:null;S!==null&&f.push({text:`next: ${S}`,tone:"plain"},w);let E=[];if(g!==null&&E.push(g),r>0&&E.push(g!==null?`${r} ${h(r)} updated yet`:`${O(r)} in Test Manager ${h(r)} updated yet`),p.length>0){let b=p.length;E.push(`${E.length>0?b:`${b} ${b===1?"scenario":"scenarios"}`} ${b===1?"wasn't":"weren't"} sent to Test Manager`)}return $&&E.push(E.length>0?"some may not be there yet":$.lead),{receipt:g,summary:E.length>0?E.join("; "):null,...m.length>0?{nextRunSummary:`${O(m.length)} ${m.length===1?"updates on its":"update on their"} next kane-cli run`}:{},lines:f,support:($?.support??!1)||p.some(de)}}function gs(e,t,n,o){if(!e)return;let d=e.notCovered??[],a=[...new Set(d.flatMap(s=>{let r=K(s,n)?Ze(s):null;return r===null?[]:[r]}))],i=[...e.error!==null?[{cmd:`kane-cli context sessions save ${t} --mode agent`,why:"finishes the test cases that may not be there yet"}]:[],...a.map(s=>({cmd:`kane-cli design tests --use-case ${s} --force --mode agent`,why:"designs the use case's tests again, so its scenarios reach Test Manager"}))];return{total:e.total,created:e.made,updated:e.updated,already_there:e.linked,waiting:e.waiting,waiting_on:e.waitingOn.map(({scenario:s,title:r,reason:l})=>({scenario:s,title:r,reason:l})),next_run:(e.nextRun??[]).map(({scenario:s,title:r})=>({scenario:s,title:r})),...d.length>0?{not_covered:d.map(s=>{let r=de(s)?o?.(s.test):void 0;return{scenario:s.scenario,title:s.title,test:s.test,reason:s.reason,in_session:K(s,n),...r?{file:pe(r)}:{}}})}:{},...e.error!==null?{error:he(e.error.code,"").agentCode}:{},...d.some(s=>K(s,n)&&de(s))?{support_id:V("refused_TEST_UNREADABLE")}:{},...i.length>0?{next:i}:{}}}var Be=new Set(["duplicate","unwritable"]),et=e=>Be.has(e.kind)||e.kind==="import"&&e.via!==void 0&&Be.has(e.via),Dt=new Set(["unreadable","unresolved"]);function Lt(e,t){return!e||e.variables.length===0&&e.noStartPage.length===0?{}:{needed:{...e,tests:t},neededFacts:je(e,{tests:t})}}function Ut(e){if(!e||e.length===0)return{};let t=e.length===1?"1 test file here was replaced and won't run any more":`${e.length} test files here were replaced and won't run any more`;return{replacedHead:`\u2692 ${t}:`,replaced:e.map(n=>({file:ce(process.cwd(),n.file)||n.file,by:n.replacedBy.map(o=>wt(o))})),replacedSummary:t}}function jt(e){return e!=null&&e.error===null}var tt=(e,t)=>{if(!jt(t)||t.waitingOn.length>0)return[];let n=new Set((t.notCovered??[]).map(o=>o.test.toLowerCase()));return e.filter(o=>o.file&&!n.has(o.id.toLowerCase()))},pe=e=>M(ce(process.cwd(),e)||e);function ms(e,t,n,o={}){let d={text:` kane-cli context sessions save ${t}`,tone:"plain"};if(e==="unread")return{line:null,lines:[{text:"warning: the session was saved, but its test files couldn't be written here",tone:"warning"},{text:"next: to write them (nothing is saved twice), run:",tone:"plain"},d],support:!0,summary:"its test files aren't written here yet",kept:null,again:"all"};let a=e.wrote.length,i=e.refused.length,s=a+(e.unchanged?.length??0),r=s+i,l=e.saved?new Set(e.saved):null,m=l?e.wrote.filter(S=>!l.has(S.id)).length:0,c=S=>`${m} ${m===1?"test":"tests"} ${S?"it imports":"they import"}`,p=a===0?null:n||i===0&&s>a?`\u2692 wrote ${a===1?"1 test file that was":`${a} test files that were`} missing or out of date here`:i>0?`\u2692 wrote ${a} of the ${r} test files`:m>0?`\u2692 wrote ${a} test files, for ${a-m===1?`the saved test and ${c(!0)}`:`${a-m} saved tests and ${c(!1)}`}`:a===1?"\u2692 wrote 1 test file, for the saved test":`\u2692 wrote ${a} test files, one for each saved test`,u={...Ut(e.replaced),...Lt(e.needed,e.saved?.length??r)};if(i===0)return{line:p,lines:[],support:!1,summary:null,kept:null,again:0,...u};let w=[{text:`warning: ${i===r?`${i===1?"1 test file wasn't":`${i} test files weren't`} written`:`${i} of the ${r} test files ${i===1?"wasn't":"weren't"} written`}`,tone:"warning"}];for(let S of e.refused)w.push({text:S.title?` "${S.title}"`:" a test with no title",tone:"detail"},{text:` ${ee(S)}`,tone:"detail"});let h=e.refused.filter(et).length;h>0&&w.push({text:`next: then, to write ${h===1?"it":"them"} (nothing is saved twice), run:`,tone:"plain"},d);let f=e.refused.filter(S=>S.kind==="edited");if(f.length>0){let S=f.length===1,E=tt(f,o.testManager);if(E.length>0){w.push({text:E.length===1?"next: to send your edit to its test case in Test Manager, run:":"next: to send your edits to their test cases in Test Manager, run:",tone:"plain"});for(let A of E)w.push({text:` kane-cli testmd run ${pe(A.file)}`,tone:"plain"})}let b=`${E.length>0?"or, to":"next: to"} get the project's ${S?"version, move it":"versions, move them"} out of this folder`;h>0?w.push({text:`${b} and save again`,tone:"plain"}):w.push({text:`${b}, then run:`,tone:"plain"},d)}let $=i-f.length;return{line:p,lines:w,support:e.refused.some(S=>Dt.has(S.kind)),summary:s>0?`${s} of the ${r} test files written here`:$===0?null:f.length>0?`${$} of the ${r} test files ${$===1?"isn't":"aren't"} written here yet`:r===1?"its test file isn't written here yet":"its test files aren't written here yet",kept:f.length===0?null:f.length>1?`${f.length} test files here keep your edits`:r===1?"its test file here keeps your edit":"1 test file here keeps your edit",again:h,...u}}function hs(e,t,n){if(!e||!t||t.again===0)return null;let o=`write ${t.again===1?"the test file":"the test files"}`;return e.error!==null?he(e.error.code,n).remedy?null:`next: to finish them and ${o} (nothing is saved twice), run:`:e.waiting>0?`next: then, to update ${e.waiting===1?"the test case":"the test cases"} and ${o} (nothing is saved twice), run:`:null}function ps(e,t,n={}){let o=`kane-cli context sessions save ${t} --mode agent`;if(e==="unread")return{written:[],refused:[],error:"TEST_FILES_NOT_WRITTEN",next:[{cmd:o,why:"writes the test files here"}]};let d=e.refused.some(et),a=e.refused.filter(r=>r.kind==="edited"),i=a.length===0?"":a.length===1?", and the project's version of a kept file once it's moved out of its folder":", and the project's version of the kept files once they're moved out of their folder",s=[...d?[{cmd:o,why:`writes the test files not written here${i}`}]:[],...tt(a,n.testManager).map(r=>({cmd:`kane-cli testmd run ${M(r.file)} --agent`,why:"sends your edit to its test case in Test Manager"})),...a.length>0&&!d?[{cmd:o,why:"writes the project's version, once the file is moved out of its folder"}]:[]];return{written:e.wrote.map(r=>r.path),refused:e.refused.map(r=>({test:r.id,title:r.title,reason:ee(r),...r.kind==="edited"&&r.file?{file:r.file}:{}})),...e.replaced?.length?{replaced:e.replaced.map(r=>({test:r.test,file:r.file,replaced_by:r.replacedBy}))}:{},...e.needed?.variables.length?{variables_needed:{file:e.needed.file,variables:e.needed.variables}}:{},...e.needed?.noStartPage.length?{no_start_page:e.needed.noStartPage.map(r=>({test:r.test,...r.file?{file:r.file}:{}}))}:{},...s.length>0?{next:s}:{}}}var Mt={ac:"an acceptance criterion",scenario:"a scenario",test:"a test",gap:"an open question",source:"a source",stylenote:"a style note"},T=(e,t)=>e?`"${e}"`:P(t),Ge=(e,t,n)=>`${e} ${e===1?t:n}`,fs={trusted:"approved",derived:"proposed",archived:"archived"},ws={yes:"yes",source_changed:"no: its source changed",source_removed:"no: its source was removed",tests_out_of_date:"no: its tests are out of date",designed_from_changed:"no: what it was designed from changed",archived:"-"},ys={source_changed:"its source changed",source_removed:"its source was removed",tests_out_of_date:"changed after its tests were designed"},y=e=>e?`"${e}"`:"this session's project",_=(e,t)=>`kane-cli design tests --use-case ${e}${t}`,ae=e=>e?"its source's change was put off in an earlier review; to take it up":"to review its source's change",He=e=>e.split(`