@testmuai/kane-cli 0.10.2 → 0.10.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 (249) hide show
  1. package/dist/{ChatSurface-FIYDTZSI.js → ChatSurface-Z26BOE5U.js} +1 -1
  2. package/dist/{ChromeProfilePicker-Q6FIGVYU.js → ChromeProfilePicker-ODRIAXL3.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-2NV2G65E.js → CliFeedbackPrompt-JWCTMIGI.js} +1 -1
  4. package/dist/{CliUploadProgress-JZ5FXODE.js → CliUploadProgress-XFRRFRL4.js} +1 -1
  5. package/dist/{ConfigView-TZ4YINOE.js → ConfigView-6JF4DOJN.js} +1 -1
  6. package/dist/{EvidenceViewOffer-LKPN5BHX.js → EvidenceViewOffer-6344EX74.js} +1 -1
  7. package/dist/FolderPicker-4PCYHE75.js +2 -0
  8. package/dist/InfoBox-NJ2DL7YC.js +2 -0
  9. package/dist/{LinksBox-32TZOANP.js → LinksBox-HNDNFVUT.js} +1 -1
  10. package/dist/{ProfilesView-UC4MPM54.js → ProfilesView-DEJKJOHY.js} +1 -1
  11. package/dist/ProjectPicker-DTWMWOH7.js +2 -0
  12. package/dist/SaveSessionPrompt-3GCLB3ZT.js +2 -0
  13. package/dist/SingleShotApp-HMOXO5DW.js +2 -0
  14. package/dist/{SummaryBox-XGFO5X76.js → SummaryBox-7PPDMSSM.js} +1 -1
  15. package/dist/TestMdRunView-QLKRUU4V.js +2 -0
  16. package/dist/TestrunEvidenceTable-T2JUB4TE.js +2 -0
  17. package/dist/{WhoamiView-4XIJXMTU.js → WhoamiView-H7JNLLCY.js} +1 -1
  18. package/dist/{app-download-XEDO3EMV.js → app-download-GKRF2EIM.js} +1 -1
  19. package/dist/{assurance-job-MD65GQLC.js → assurance-job-F4L3T4VJ.js} +1 -1
  20. package/dist/{binary-NVYLR36K.js → binary-K3XMILST.js} +1 -1
  21. package/dist/{bind-H3ALI2NG.js → bind-SSHAZAB3.js} +1 -1
  22. package/dist/{bootstrap-JEVSVPQ2.js → bootstrap-XGKU4WXB.js} +1 -1
  23. package/dist/{catalog-5UYBWA4W.js → catalog-YCU6OHNV.js} +1 -1
  24. package/dist/{catalog-client-VVKV4JKW.js → catalog-client-MVEEHTG2.js} +1 -1
  25. package/dist/{changelog-FPWJXERY.js → changelog-5UB3AQT6.js} +1 -1
  26. package/dist/{chunk-GJ7MO2FW.js → chunk-2JFRN62I.js} +2 -2
  27. package/dist/chunk-2RBMQTYS.js +26 -0
  28. package/dist/{chunk-44SIFDNY.js → chunk-2TK4MDF2.js} +1 -1
  29. package/dist/{chunk-P4VFC6HO.js → chunk-35WUYKGO.js} +1 -1
  30. package/dist/{chunk-XCUF5AVM.js → chunk-3MD2XLE7.js} +2 -2
  31. package/dist/{chunk-TMH4TPMB.js → chunk-3NWUXRSI.js} +1 -1
  32. package/dist/{chunk-NVD2MXHQ.js → chunk-3RO2YGKH.js} +1 -1
  33. package/dist/{chunk-QUNIY6NN.js → chunk-3ZC7GSMM.js} +1 -1
  34. package/dist/{chunk-LXCTV75T.js → chunk-4CJQ7XZP.js} +1 -1
  35. package/dist/{chunk-LWCP4GLY.js → chunk-4KL3TSTT.js} +5 -5
  36. package/dist/{chunk-2ULYGALF.js → chunk-4UX5N7YI.js} +1 -1
  37. package/dist/{chunk-5KJU4MG4.js → chunk-5YYCCM6K.js} +1 -1
  38. package/dist/{chunk-IT5JVCZN.js → chunk-6FFX4S7N.js} +1 -1
  39. package/dist/{chunk-HM6LZ2KM.js → chunk-6HRNG4CK.js} +1 -1
  40. package/dist/{chunk-OK6NLITG.js → chunk-6QCCTZO3.js} +1 -1
  41. package/dist/{chunk-ZZZGTDYE.js → chunk-6QH75BPJ.js} +1 -1
  42. package/dist/{chunk-6SWHEBPR.js → chunk-7RELCXRW.js} +1 -1
  43. package/dist/{chunk-S7XCOBYD.js → chunk-7SU53QGU.js} +1 -1
  44. package/dist/{chunk-6JUS2ULI.js → chunk-7Y55CO42.js} +1 -1
  45. package/dist/{chunk-B57ZRHEQ.js → chunk-7YV2FCN4.js} +1 -1
  46. package/dist/{chunk-PC22QRIY.js → chunk-A2DODRHG.js} +1 -1
  47. package/dist/{chunk-ABMM37L2.js → chunk-AHT2ORJT.js} +1 -1
  48. package/dist/{chunk-A7IMHUFY.js → chunk-AT7AT3AR.js} +2 -2
  49. package/dist/{chunk-5WLXAQ4H.js → chunk-AVLYSNEG.js} +1 -1
  50. package/dist/{chunk-ZO3ZAMUU.js → chunk-BBJAKSA7.js} +1 -1
  51. package/dist/{chunk-DLP5S3TO.js → chunk-BJO6J5X2.js} +1 -1
  52. package/dist/{chunk-EEOAU43D.js → chunk-BLVDV3QQ.js} +1 -1
  53. package/dist/{chunk-I52NWH4U.js → chunk-C4KAPGBS.js} +1 -1
  54. package/dist/{chunk-7O2FIZB7.js → chunk-CB2BWDHG.js} +2 -2
  55. package/dist/{chunk-HWPWCCEV.js → chunk-CNHKZE4F.js} +1 -1
  56. package/dist/{chunk-5F44KH3R.js → chunk-CTHUX7O4.js} +1 -1
  57. package/dist/{chunk-FYPIF3BE.js → chunk-DC5F2ADJ.js} +1 -1
  58. package/dist/chunk-DIOK3SER.js +34 -0
  59. package/dist/{chunk-NCP54AIQ.js → chunk-DQXQJJOP.js} +2 -2
  60. package/dist/{chunk-W2HRX3DR.js → chunk-EBJW6POT.js} +1 -1
  61. package/dist/{chunk-GZQAETB2.js → chunk-EJGCIGQY.js} +1 -1
  62. package/dist/{chunk-7ZR5CQY3.js → chunk-ERRIDBE7.js} +1 -1
  63. package/dist/chunk-F2F257PU.js +6 -0
  64. package/dist/{chunk-EAWU2TOG.js → chunk-GQAWZEA4.js} +1 -1
  65. package/dist/{chunk-2QKBXRLI.js → chunk-GXQYFOBD.js} +1 -1
  66. package/dist/{chunk-RRKYHUOD.js → chunk-HBLHKQR7.js} +1 -1
  67. package/dist/chunk-HC6VLPUB.js +5 -0
  68. package/dist/{chunk-JUVY6PHY.js → chunk-HRIDAK6Y.js} +1 -1
  69. package/dist/{chunk-5MFPQYW3.js → chunk-HV2CDY4K.js} +1 -1
  70. package/dist/{chunk-YO6SNXBJ.js → chunk-IEHJG6J4.js} +1 -1
  71. package/dist/{chunk-FAMQ4DHU.js → chunk-J4FIESTB.js} +1 -1
  72. package/dist/{chunk-UICJ2KLJ.js → chunk-JBKHX5ES.js} +1 -1
  73. package/dist/{chunk-6CS23F3E.js → chunk-KBGMQYMD.js} +1 -1
  74. package/dist/{chunk-ZDQYGLCZ.js → chunk-KCXLRR3Q.js} +1 -1
  75. package/dist/{chunk-KN7GZWKK.js → chunk-KL7XFNSD.js} +1 -1
  76. package/dist/{chunk-V3OZJO7Y.js → chunk-KQ4XKTIZ.js} +1 -1
  77. package/dist/{chunk-PR5EGLEI.js → chunk-LHJSIHLC.js} +1 -1
  78. package/dist/{chunk-75FF7J5R.js → chunk-LPJKNX6D.js} +1 -1
  79. package/dist/{chunk-3V4J65GN.js → chunk-LRNUGKYH.js} +1 -1
  80. package/dist/{chunk-POA336CU.js → chunk-LUA25RYS.js} +1 -1
  81. package/dist/{chunk-BHQIH2FE.js → chunk-LV7224DG.js} +1 -1
  82. package/dist/{chunk-73HMW2WA.js → chunk-LXK4B2FE.js} +1 -1
  83. package/dist/{chunk-PWNYTIVA.js → chunk-M2E5CPPV.js} +1 -1
  84. package/dist/{chunk-OVNTCBNS.js → chunk-M7A66MSK.js} +1 -1
  85. package/dist/{chunk-MP6NCJFE.js → chunk-MD3RABID.js} +1 -1
  86. package/dist/{chunk-AUSLHNXQ.js → chunk-MEBEVHGP.js} +1 -1
  87. package/dist/{chunk-C6P6YUCR.js → chunk-N7IWR45S.js} +1 -1
  88. package/dist/{chunk-M3TFOFUQ.js → chunk-ND6OP3O2.js} +1 -1
  89. package/dist/{chunk-226AGYHB.js → chunk-NHGPMYM3.js} +1 -1
  90. package/dist/{chunk-VE4HLIGA.js → chunk-NI3TIAD7.js} +1 -1
  91. package/dist/{chunk-GQARXS6F.js → chunk-NPAUSUNM.js} +1 -1
  92. package/dist/{chunk-HX5OLRKU.js → chunk-NRAPCFI2.js} +2 -2
  93. package/dist/{chunk-RAVAJZV2.js → chunk-NZJSGINB.js} +16 -16
  94. package/dist/{chunk-X3A4QPA3.js → chunk-OBNVGD5H.js} +1 -1
  95. package/dist/{chunk-Q5AKIQIE.js → chunk-OCMPWCKQ.js} +1 -1
  96. package/dist/{chunk-BJT6PZXL.js → chunk-OCVDMZWB.js} +1 -1
  97. package/dist/{chunk-XZ6J3Y2W.js → chunk-OHGL4GEJ.js} +1 -1
  98. package/dist/{chunk-54NJJVG5.js → chunk-OOGKX4Y6.js} +1 -1
  99. package/dist/{chunk-UMNCM4RJ.js → chunk-OTMHCHH6.js} +2 -2
  100. package/dist/{chunk-45NM23EQ.js → chunk-OZNYQONA.js} +1 -1
  101. package/dist/{chunk-D4QXYAYA.js → chunk-PB6RXDWQ.js} +2 -2
  102. package/dist/{chunk-2GEAKFAV.js → chunk-PCQK62MP.js} +1 -1
  103. package/dist/{chunk-HHOVANJ7.js → chunk-PTLOOVV4.js} +1 -1
  104. package/dist/{chunk-QB77LRF4.js → chunk-Q4ALB7SH.js} +1 -1
  105. package/dist/{chunk-A474TUCE.js → chunk-Q4SMITTV.js} +1 -1
  106. package/dist/{chunk-HNF3PWF3.js → chunk-QE4AWNOV.js} +3 -3
  107. package/dist/{chunk-6YBH3WUW.js → chunk-QEM5ZRDN.js} +1 -1
  108. package/dist/{chunk-MSYRAPDK.js → chunk-QHH42RH5.js} +1 -1
  109. package/dist/{chunk-IB5WG5YY.js → chunk-RNHSULQM.js} +1 -1
  110. package/dist/chunk-SB26HQO7.js +2 -0
  111. package/dist/{chunk-QVMXL675.js → chunk-SJQTTEXQ.js} +1 -1
  112. package/dist/{chunk-UCVP7ZY4.js → chunk-SMGRXKXX.js} +1 -1
  113. package/dist/{chunk-RDAIOJCR.js → chunk-SXBPUUQ5.js} +1 -1
  114. package/dist/{chunk-K75WIRI5.js → chunk-TM45NPWL.js} +1 -1
  115. package/dist/{chunk-7DLDADQR.js → chunk-TUSG7DIL.js} +1 -1
  116. package/dist/{chunk-K4K2BGQC.js → chunk-UJ37XGSP.js} +3 -3
  117. package/dist/{chunk-DXLZCJH5.js → chunk-ULIIYKZB.js} +1 -1
  118. package/dist/{chunk-7PCLHURF.js → chunk-UXGMKRS4.js} +61 -60
  119. package/dist/{chunk-IH73ZCBB.js → chunk-VCVEZEVS.js} +1 -1
  120. package/dist/{chunk-XNXJXGVB.js → chunk-VKVYT6KZ.js} +2 -2
  121. package/dist/{chunk-PEUIHME2.js → chunk-VO2NNXKR.js} +1 -1
  122. package/dist/{chunk-H4TIVILC.js → chunk-WE7HRAGO.js} +1 -1
  123. package/dist/{chunk-O5KTMDTH.js → chunk-WIVKLNIO.js} +1 -1
  124. package/dist/chunk-WLEWXE6L.js +2 -0
  125. package/dist/{chunk-3YIA3DSL.js → chunk-X2MDL6S4.js} +1 -1
  126. package/dist/{chunk-M7Y5GGVJ.js → chunk-X45RZIAJ.js} +1 -1
  127. package/dist/{chunk-4LGQHTXM.js → chunk-XKOVEMVZ.js} +1 -1
  128. package/dist/{chunk-4HARMERK.js → chunk-Y2HQMJGS.js} +1 -1
  129. package/dist/{chunk-B226SFOV.js → chunk-Y3RJHWNK.js} +1 -1
  130. package/dist/{chunk-4HYPMGDF.js → chunk-YCVEI7BT.js} +1 -1
  131. package/dist/{chunk-HG2ILWCE.js → chunk-YILRYMMG.js} +1 -1
  132. package/dist/{chunk-2COXO5LQ.js → chunk-YNDELIXL.js} +1 -1
  133. package/dist/{chunk-4NEPHIAO.js → chunk-YPGZ5E4I.js} +1 -1
  134. package/dist/{chunk-GT3JDX5H.js → chunk-YQZ736IQ.js} +1 -1
  135. package/dist/{chunk-XHFU5TGS.js → chunk-YVVFXBT5.js} +1 -1
  136. package/dist/{chunk-ET5EK2CM.js → chunk-YWWVF5OU.js} +1 -1
  137. package/dist/{chunk-OKA6FPJM.js → chunk-Z47ZEFH7.js} +1 -1
  138. package/dist/{chunk-FI2DVNRT.js → chunk-ZCBOHWN3.js} +1 -1
  139. package/dist/{chunk-7XJNYLQW.js → chunk-ZIHQ5JGB.js} +4 -4
  140. package/dist/{chunk-Z6SI7YNV.js → chunk-ZMIKNNO6.js} +1 -1
  141. package/dist/{chunk-O3TXAMFW.js → chunk-ZPU3WAC4.js} +1 -1
  142. package/dist/{commands-R5AYK6XM.js → commands-JBFLLT7A.js} +1 -1
  143. package/dist/{config-YMHI3H3Y.js → config-7WTZPMAH.js} +1 -1
  144. package/dist/{cover-cmd-DVQIGFDY.js → cover-cmd-DU6ZYJFL.js} +1 -1
  145. package/dist/{credentials-BCR73VGS.js → credentials-5WIFF5DG.js} +1 -1
  146. package/dist/{deps-bundle-6WLX44OA.js → deps-bundle-BLLJ2BQ4.js} +1 -1
  147. package/dist/{deps-resolve-DSAKPZ3T.js → deps-resolve-WQ6J6RLI.js} +1 -1
  148. package/dist/{design-chat-YUI2JPO6.js → design-chat-ZICGVYIH.js} +1 -1
  149. package/dist/{design-headless-KIP6R7UV.js → design-headless-HYWZIIDS.js} +1 -1
  150. package/dist/{design-remote-XMSHDDUX.js → design-remote-HPX4VZ63.js} +2 -2
  151. package/dist/device-env-4P4GUVBW.js +2 -0
  152. package/dist/{doctor-PGTNOMSP.js → doctor-Z2YQ2DBX.js} +1 -1
  153. package/dist/{evidence-RO3RDZXO.js → evidence-BJIID6VT.js} +1 -1
  154. package/dist/{evolve-cmd-U2ALVGMT.js → evolve-cmd-GZCUSCEK.js} +1 -1
  155. package/dist/{evolve-remote-K2MCCVMM.js → evolve-remote-LILOAHYH.js} +1 -1
  156. package/dist/{explain-cmd-UWK5YVXG.js → explain-cmd-LXIVHGN7.js} +1 -1
  157. package/dist/explore-SA2P3SGX.js +2 -0
  158. package/dist/{explore-context-tty-WJHUSP3A.js → explore-context-tty-PERKIWXD.js} +1 -1
  159. package/dist/{explore-entry-3EX2T3NS.js → explore-entry-E6EY3VV3.js} +4 -4
  160. package/dist/{explore-live-TRY5A2ME.js → explore-live-XIWWUV52.js} +1 -1
  161. package/dist/{explore-run-tty-ZV5XFKZA.js → explore-run-tty-M56I23IF.js} +2 -2
  162. package/dist/{extract-bind-TXUBMK3T.js → extract-bind-LZ22VFKB.js} +3 -3
  163. package/dist/{extract-chat-VPYDGQKO.js → extract-chat-Z64LEAJ5.js} +1 -1
  164. package/dist/{extract-cmd-YUOYMVF5.js → extract-cmd-46E2XDWZ.js} +2 -2
  165. package/dist/{extract-headless-UWTAPOET.js → extract-headless-XLS56LMN.js} +1 -1
  166. package/dist/{folder-flags-WV7UV3JG.js → folder-flags-ZIDJVDKX.js} +1 -1
  167. package/dist/{gaps-cmd-PFV3FZCM.js → gaps-cmd-XYOBJVTO.js} +1 -1
  168. package/dist/{gate-7ALXLCNB.js → gate-AK44VDHC.js} +1 -1
  169. package/dist/{generate-headless-KMBBZTLS.js → generate-headless-HXAVEAEZ.js} +2 -2
  170. package/dist/{impact-cmd-PW33L5RF.js → impact-cmd-TJTUFAFO.js} +2 -2
  171. package/dist/index.js +162 -157
  172. package/dist/{ingest-cmd-MXYILQLV.js → ingest-cmd-OJSKTSQK.js} +3 -3
  173. package/dist/{ingest-remote-2EEJP6ML.js → ingest-remote-2WM6PYUW.js} +1 -1
  174. package/dist/install-JBWBF3WX.js +2 -0
  175. package/dist/{interactive-bind-FDWJUTI6.js → interactive-bind-SOD7VTAY.js} +2 -2
  176. package/dist/{interactive-remote-O2Q2FNOH.js → interactive-remote-7ZSTI66T.js} +1 -1
  177. package/dist/{lattice-auth-TXNDLHM6.js → lattice-auth-UQPFQSG7.js} +1 -1
  178. package/dist/{lifecycle-cmd-GFHDBRXX.js → lifecycle-cmd-DGIO3VAO.js} +1 -1
  179. package/dist/{list-cmd-RR75PMPE.js → list-cmd-HQIN3HX4.js} +1 -1
  180. package/dist/{list-commands-3QGZWJ5P.js → list-commands-OFRRBU3D.js} +1 -1
  181. package/dist/{list-remote-AA3VSWOI.js → list-remote-EFCET42K.js} +1 -1
  182. package/dist/login-flow-SYKXXDLH.js +2 -0
  183. package/dist/{maintenance-cmd-OHGVARQ2.js → maintenance-cmd-X5247RSJ.js} +1 -1
  184. package/dist/{mobile-prompts-FZRKLLTN.js → mobile-prompts-I66ENBDW.js} +1 -1
  185. package/dist/{onboarding-NXGMV3VG.js → onboarding-6HIP3KW6.js} +1 -1
  186. package/dist/{persist-recorded-session-INFN4JZT.js → persist-recorded-session-RSSMTVF3.js} +1 -1
  187. package/dist/pipeline-NTJDH5TC.js +2 -0
  188. package/dist/{policy-commands-3YJ6YCDN.js → policy-commands-4PUGESCW.js} +1 -1
  189. package/dist/{prepare-target-DII5WZCX.js → prepare-target-AI3GGZF6.js} +1 -1
  190. package/dist/{pull-cmd-XZN53XFZ.js → pull-cmd-NRVB5ZN7.js} +1 -1
  191. package/dist/{pull-route-R33BVADE.js → pull-route-FWCZW76M.js} +1 -1
  192. package/dist/real-device-run-NQ7RNH7C.js +2 -0
  193. package/dist/{reconcile-cmd-KFPRCCJB.js → reconcile-cmd-7B7THAFJ.js} +4 -4
  194. package/dist/{reconcile-remote-6WISFGRG.js → reconcile-remote-3W6ZTO3G.js} +2 -2
  195. package/dist/{recording-banner-XOX2CDCF.js → recording-banner-WVDTWTSE.js} +1 -1
  196. package/dist/registry-PFOSXOIH.js +2 -0
  197. package/dist/remote-entry-BZU4NFNS.js +2 -0
  198. package/dist/{remote-mode-4HN27MD4.js → remote-mode-NXUKDUXG.js} +1 -1
  199. package/dist/{remote-words-LFDYKIZ7.js → remote-words-JRDDNOZ6.js} +1 -1
  200. package/dist/{require-project-folder-ZK4JJCDB.js → require-project-folder-3DTI2CVB.js} +1 -1
  201. package/dist/{resolve-run-intent-LYLVNNDZ.js → resolve-run-intent-QCL7QXIB.js} +1 -1
  202. package/dist/{resolver-RMHGGYRP.js → resolver-CDF7QKVD.js} +1 -1
  203. package/dist/{review-cmd-UGF2FC5Y.js → review-cmd-XBK3TGRE.js} +1 -1
  204. package/dist/{run-remote-BGKQDAOA.js → run-remote-SFR3F2T5.js} +1 -1
  205. package/dist/{run-startup-gate-4XE73OON.js → run-startup-gate-QSFJRYUY.js} +1 -1
  206. package/dist/run-test-md-ZSREINDQ.js +20 -0
  207. package/dist/session-worker.js +2 -2
  208. package/dist/{sessions-cmd-CABAX7BO.js → sessions-cmd-TLUITRG5.js} +1 -1
  209. package/dist/{sessions-remote-Y4FTZL7Y.js → sessions-remote-INO7AWKB.js} +1 -1
  210. package/dist/{skill-installer-FS2AV7GX.js → skill-installer-7JH5QCJF.js} +1 -1
  211. package/dist/{store-PLKJZTGC.js → store-X4UK4AP7.js} +1 -1
  212. package/dist/{store-choice-UAB6Z4AL.js → store-choice-27HDIFTU.js} +1 -1
  213. package/dist/{store-guard-DUN2X3SR.js → store-guard-ZXKB5DQH.js} +1 -1
  214. package/dist/{sync-cmd-AGTOGPYM.js → sync-cmd-2PCO7LZA.js} +1 -1
  215. package/dist/{sync-setup-4KIY3PDO.js → sync-setup-5WQO73Y5.js} +1 -1
  216. package/dist/tcg-generate-DGJD5KSM.js +2 -0
  217. package/dist/{testmd-actions-UD6PAWUX.js → testmd-actions-XE2JPQHB.js} +1 -1
  218. package/dist/{testmd-sync-EEJ7GPLR.js → testmd-sync-LYHEXWCT.js} +1 -1
  219. package/dist/{tms-client-XWCR7O7J.js → tms-client-J4OCD3EP.js} +1 -1
  220. package/dist/token-refresh-E4FTJVHY.js +2 -0
  221. package/dist/{validate-basic-3JZRZL45.js → validate-basic-66XDPA3S.js} +1 -1
  222. package/dist/{version-check-IY3YSQIP.js → version-check-SHNVYTMU.js} +1 -1
  223. package/dist/{view-cmd-WUIGTRFX.js → view-cmd-QOB3O6YW.js} +1 -1
  224. package/dist/{walk-session-EH7227WR.js → walk-session-WIEROYOT.js} +1 -1
  225. package/dist/{with-telemetry-7JMZUBUZ.js → with-telemetry-T2PWI5CY.js} +1 -1
  226. package/package.json +11 -11
  227. package/dist/FolderPicker-H5K74PCH.js +0 -2
  228. package/dist/InfoBox-DNSOAK5L.js +0 -2
  229. package/dist/ProjectPicker-ZJ5RW6XL.js +0 -2
  230. package/dist/SaveSessionPrompt-F327WC7A.js +0 -2
  231. package/dist/SingleShotApp-OMLRYOSI.js +0 -2
  232. package/dist/TestMdRunView-ZZ77QTAQ.js +0 -2
  233. package/dist/TestrunEvidenceTable-G7MPF55X.js +0 -2
  234. package/dist/chunk-6K5BEEAJ.js +0 -2
  235. package/dist/chunk-6LEHGRRG.js +0 -34
  236. package/dist/chunk-A4ZV2SHL.js +0 -5
  237. package/dist/chunk-O2Y46A3G.js +0 -26
  238. package/dist/chunk-Y6Y6RAY4.js +0 -2
  239. package/dist/device-env-K7J5NN66.js +0 -2
  240. package/dist/explore-S2BGQUIF.js +0 -2
  241. package/dist/install-7J34AYB6.js +0 -2
  242. package/dist/login-flow-ZQ6UFTS2.js +0 -2
  243. package/dist/pipeline-MVZRI6YZ.js +0 -2
  244. package/dist/real-device-run-DGENHGUV.js +0 -2
  245. package/dist/registry-NV3EMDMK.js +0 -2
  246. package/dist/remote-entry-BCTFT643.js +0 -2
  247. package/dist/run-test-md-G6U3RU2Q.js +0 -19
  248. package/dist/tcg-generate-CUY4AZ2V.js +0 -2
  249. package/dist/token-refresh-K6PVBBFE.js +0 -2
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B}from"./chunk-4HARMERK.js";import{a as N}from"./chunk-A474TUCE.js";import{a as ie,b as ae,c as ce}from"./chunk-W3USRQX6.js";import{b as oe}from"./chunk-NVD2MXHQ.js";import{a as H}from"./chunk-6YBH3WUW.js";import{d as le}from"./chunk-FYPIF3BE.js";import{a as $,b as X,e as M,g as se}from"./chunk-77ZZQJLX.js";import{b as L}from"./chunk-BHQIH2FE.js";import{a as te}from"./chunk-73HMW2WA.js";import{a as ee}from"./chunk-FCD3NYOM.js";import{a as re,b as ne}from"./chunk-B7ZX5HEN.js";import{a as j}from"./chunk-PVN64537.js";import{a as K}from"./chunk-FI2DVNRT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-K75WIRI5.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as b,b as p,i as Z}from"./chunk-33DWJV67.js";import{a as q}from"./chunk-6YGTRKDT.js";import{z as y}from"./chunk-FAMQ4DHU.js";import{e as S}from"./chunk-UR6MHSHU.js";var D=S(q(),1);import{existsSync as P,readFileSync as Ye,rmSync as we,unlinkSync as ze}from"fs";import{resolve as Q}from"path";import{promises as ue,realpathSync as Re}from"fs";import{homedir as Pe}from"os";import{join as V,parse as Me,relative as de,resolve as fe}from"path";var me=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ge(e){try{return Re(fe(e))}catch{return fe(e)}}function De(e){let r=ge(e),s=ge(Pe()),n=Me(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(De(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await ue.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(me.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:de(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await ue.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let k=d.name,w=V(_,k);if(d.isDirectory()){if(m>=20||k.startsWith(".")||k.startsWith("output-")||me.has(k))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&k.endsWith("_test.md")&&(o.push({path:w,relPath:de(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Ce}from"fs";function Y(e){let r;try{r=Ce(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{let s=$e(r);return{tags:[],...s?{mobileTarget:s}:{}}}}var pe={platform:"",app:""};function $e(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return;let s=r[1].split(/\r?\n/);for(let o of s){let t=/^target:\s*['"]?(emulator|simulator|android|ios)['"]?\s*$/.exec(o);if(t)return t[1]==="android"||t[1]==="ios"?{platform:t[1],app:"",realDevice:!0}:pe}let n=s.findIndex(o=>/^target:\s*$/.test(o));if(!(n<0))return s.slice(n+1).some(o=>/^\s+\S/.test(o))?pe:void 0}function W(e){return Y(e).tags}import{mkdirSync as Ie,writeFileSync as Fe}from"fs";import{join as Oe}from"path";function he(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ae(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:he(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Le(e){let r=ce({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:he(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ie(e.outDir,{recursive:!0});for(let c of a.url){let l=Oe(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();Fe(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function _e(e){return await Ae(e),await Le(e)}var E=S(q(),1);import{existsSync as je,readFileSync as Be}from"fs";var h=S(F(),1);function Ne(e){B(e);let r=M(e);if(!je(r))return null;try{return JSON.parse(Be(r,"utf8"))}catch{return{}}}function Ue(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function We(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Je(e){return e==="tests-dir"?"\u2726":" "}function Ge(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function qe(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function ye({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),k=[];for(let w of d.results){let G=Ne(w.path);G?.org_id!==void 0&&G.org_id!==r||k.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Ue(G),source:w.source,tags:W(w.path)})}t(k),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>Ge(d,l)).map(d=>({id:d.path,label:`${We(d.status)} ${Je(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Xe(l,o),[l,o]);if(i)return(0,h.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(b,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ke(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let k=o.find(w=>w.path===d.id);k&&s(k)},onCancel:n,onTab:()=>g(d=>qe(d)),extraHint:"cycle filter",footer:m})}function Ke(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Xe(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(b,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=S(q(),1);import{existsSync as He,readFileSync as Ve}from"fs";var f=S(F(),1);function xe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(He(l))try{i(JSON.parse(Ve(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(b,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ye(r,"utf8"))}catch{return null}}function ke(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return ke(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as B}from"./chunk-Y2HQMJGS.js";import{a as N}from"./chunk-Q4SMITTV.js";import{a as ie,b as ae,c as ce}from"./chunk-W3USRQX6.js";import{b as oe}from"./chunk-3RO2YGKH.js";import{a as H}from"./chunk-QEM5ZRDN.js";import{d as le}from"./chunk-DC5F2ADJ.js";import{a as $,b as X,e as M,g as se}from"./chunk-77ZZQJLX.js";import{b as L}from"./chunk-LV7224DG.js";import{a as te}from"./chunk-LXK4B2FE.js";import{a as ee}from"./chunk-FCD3NYOM.js";import{a as re,b as ne}from"./chunk-B7ZX5HEN.js";import{a as j}from"./chunk-PVN64537.js";import{a as K}from"./chunk-ZCBOHWN3.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-TM45NPWL.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as b,b as p,i as Z}from"./chunk-33DWJV67.js";import{a as q}from"./chunk-6YGTRKDT.js";import{z as y}from"./chunk-J4FIESTB.js";import{e as S}from"./chunk-UR6MHSHU.js";var D=S(q(),1);import{existsSync as P,readFileSync as Ye,rmSync as we,unlinkSync as ze}from"fs";import{resolve as Q}from"path";import{promises as ue,realpathSync as Re}from"fs";import{homedir as Pe}from"os";import{join as V,parse as Me,relative as de,resolve as fe}from"path";var me=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ge(e){try{return Re(fe(e))}catch{return fe(e)}}function De(e){let r=ge(e),s=ge(Pe()),n=Me(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(De(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await ue.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(me.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:de(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await ue.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let k=d.name,w=V(_,k);if(d.isDirectory()){if(m>=20||k.startsWith(".")||k.startsWith("output-")||me.has(k))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&k.endsWith("_test.md")&&(o.push({path:w,relPath:de(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Ce}from"fs";function Y(e){let r;try{r=Ce(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{let s=$e(r);return{tags:[],...s?{mobileTarget:s}:{}}}}var pe={platform:"",app:""};function $e(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return;let s=r[1].split(/\r?\n/);for(let o of s){let t=/^target:\s*['"]?(emulator|simulator|android|ios)['"]?\s*$/.exec(o);if(t)return t[1]==="android"||t[1]==="ios"?{platform:t[1],app:"",realDevice:!0}:pe}let n=s.findIndex(o=>/^target:\s*$/.test(o));if(!(n<0))return s.slice(n+1).some(o=>/^\s+\S/.test(o))?pe:void 0}function W(e){return Y(e).tags}import{mkdirSync as Ie,writeFileSync as Fe}from"fs";import{join as Oe}from"path";function he(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ae(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:he(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Le(e){let r=ce({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:he(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ie(e.outDir,{recursive:!0});for(let c of a.url){let l=Oe(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();Fe(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function _e(e){return await Ae(e),await Le(e)}var E=S(q(),1);import{existsSync as je,readFileSync as Be}from"fs";var h=S(F(),1);function Ne(e){B(e);let r=M(e);if(!je(r))return null;try{return JSON.parse(Be(r,"utf8"))}catch{return{}}}function Ue(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function We(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Je(e){return e==="tests-dir"?"\u2726":" "}function Ge(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function qe(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function ye({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),k=[];for(let w of d.results){let G=Ne(w.path);G?.org_id!==void 0&&G.org_id!==r||k.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Ue(G),source:w.source,tags:W(w.path)})}t(k),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>Ge(d,l)).map(d=>({id:d.path,label:`${We(d.status)} ${Je(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Xe(l,o),[l,o]);if(i)return(0,h.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(b,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ke(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let k=o.find(w=>w.path===d.id);k&&s(k)},onCancel:n,onTab:()=>g(d=>qe(d)),extraHint:"cycle filter",footer:m})}function Ke(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Xe(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(b,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=S(q(),1);import{existsSync as He,readFileSync as Ve}from"fs";var f=S(F(),1);function xe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(He(l))try{i(JSON.parse(Ve(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(b,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ye(r,"utf8"))}catch{return null}}function ke(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return ke(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}function be(){return oe(process.cwd()).kind==="remote"?{authOnly:!0}:{}}async function zt(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n,...be()});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Qt(e,r){if(process.stdin.isTTY&&!e.json)return await et(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=C(o.path);if(!ke(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:$(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var Te=-1001,Ee=-1002,ve=-1003,x={action:null,path:null};function Qe(e,r){return x.action=e,x.path=r,e==="run"?Te:e==="export"?Ee:ve}function Ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(ye,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(xe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Qe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function et(e,r){let s=r??process.cwd(),{render:n}=await import("./build-5ZN47FAT.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(Ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===Te&&x.path){let{runTestMdFile:t}=await import("./run-test-md-G6U3RU2Q.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===Ee&&x.path){let t=await rt(x.path,{},e);return x.action=null,x.path=null,t}if(o===ve&&x.path){let t=await tt(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Zt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var Te=-1001,Ee=-1002,ve=-1003,x={action:null,path:null};function Qe(e,r){return x.action=e,x.path=r,e==="run"?Te:e==="export"?Ee:ve}function Ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(ye,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(xe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Qe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function et(e,r){let s=r??process.cwd(),{render:n}=await import("./build-5ZN47FAT.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(Ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===Te&&x.path){let{runTestMdFile:t}=await import("./run-test-md-ZSREINDQ.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===Ee&&x.path){let t=await rt(x.path,{},e);return x.action=null,x.path=null,t}if(o===ve&&x.path){let t=await tt(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Zt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=C(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:$(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function tt(e,r,s){let n=Q(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=C(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-4HYPMGDF.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-33DWJV67.js";import{a as B}from"./chunk-6YGTRKDT.js";import{z as l}from"./chunk-FAMQ4DHU.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
2
+ import{a as h}from"./chunk-YCVEI7BT.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-33DWJV67.js";import{a as B}from"./chunk-6YGTRKDT.js";import{z as l}from"./chunk-J4FIESTB.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{e as g}from"./chunk-6K5BEEAJ.js";import{a as m}from"./chunk-FI2DVNRT.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new g(m(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
2
+ import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{e as g}from"./chunk-SB26HQO7.js";import{a as m}from"./chunk-ZCBOHWN3.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new g(m(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
3
3
 
4
4
  discover IDs:
5
5
  kane-cli projects list --search "<keyword>" --limit 10
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-72KYMWQ5.js";import{a as m}from"./chunk-CCOD4GQJ.js";import{a as d}from"./chunk-JQ64X2TO.js";import{a as p}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as y}from"./chunk-FI2DVNRT.js";import{a as g}from"./chunk-4QTH7VYE.js";import{a as c}from"./chunk-RZ4F3BHX.js";var u=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=g(e.username,e.accessKey),n=await c(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:e.secretKey,secretValue:e.secretValue,orgId:e.orgId,username:e.username,scope:"user",type:"user",accessKey:e.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(e){let s=e.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let t of s)n.add(t[1]);return[...n]}};var f=class extends p{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await c(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:e.name,value:String(e.value),type:"variable",value_type:"string",is_persist:e.isPersist??!1,environment_id:s})});if(n.ok){let o=await n.json().catch(()=>({}));if(o.type==="Success"&&o.id!=null)return{id:Number(o.id)||0}}let t=await c(`${this.baseUrl}/v1/variables/${encodeURIComponent(e.name)}?environment_id=${s}`,{method:"GET",headers:this.headers()});if(!t.ok)return{id:0};let i=(await t.json().catch(()=>({}))).data?.id;return i==null?{id:0}:(await c(`${this.baseUrl}/v1/variables/${i}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(e.value),value_type:"string"})})).ok?{id:Number(i)||0}:{id:0}}};import{readdirSync as P,readFileSync as E,existsSync as S}from"fs";import{join as A}from"path";function b(r,e){let s=e.type==="parameter";return{value:typeof e.value=="number"?String(e.value):e.value,secret:e.secret??!1,syntax:e.syntax??(s?"${"+r+"}":`{{${r}}}`),...typeof e.type=="string"?{type:e.type}:{},...typeof e.description=="string"?{description:e.description}:{}}}function v(r,e){if(!S(r))return{};let s={},n;try{n=P(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=E(A(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[l,o]of Object.entries(i))o&&typeof o=="object"&&"value"in o&&(s[l]=b(l,o))}catch{e?e("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:t}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${t}
2
+ import{a as h}from"./chunk-72KYMWQ5.js";import{a as m}from"./chunk-CCOD4GQJ.js";import{a as d}from"./chunk-JQ64X2TO.js";import{a as p}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as y}from"./chunk-ZCBOHWN3.js";import{a as g}from"./chunk-4QTH7VYE.js";import{a as c}from"./chunk-RZ4F3BHX.js";var u=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=g(e.username,e.accessKey),n=await c(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:e.secretKey,secretValue:e.secretValue,orgId:e.orgId,username:e.username,scope:"user",type:"user",accessKey:e.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(e){let s=e.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let t of s)n.add(t[1]);return[...n]}};var f=class extends p{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await c(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:e.name,value:String(e.value),type:"variable",value_type:"string",is_persist:e.isPersist??!1,environment_id:s})});if(n.ok){let o=await n.json().catch(()=>({}));if(o.type==="Success"&&o.id!=null)return{id:Number(o.id)||0}}let t=await c(`${this.baseUrl}/v1/variables/${encodeURIComponent(e.name)}?environment_id=${s}`,{method:"GET",headers:this.headers()});if(!t.ok)return{id:0};let i=(await t.json().catch(()=>({}))).data?.id;return i==null?{id:0}:(await c(`${this.baseUrl}/v1/variables/${i}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(e.value),value_type:"string"})})).ok?{id:Number(i)||0}:{id:0}}};import{readdirSync as P,readFileSync as E,existsSync as S}from"fs";import{join as A}from"path";function b(r,e){let s=e.type==="parameter";return{value:typeof e.value=="number"?String(e.value):e.value,secret:e.secret??!1,syntax:e.syntax??(s?"${"+r+"}":`{{${r}}}`),...typeof e.type=="string"?{type:e.type}:{},...typeof e.description=="string"?{description:e.description}:{}}}function v(r,e){if(!S(r))return{};let s={},n;try{n=P(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=E(A(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[l,o]of Object.entries(i))o&&typeof o=="object"&&"value"in o&&(s[l]=b(l,o))}catch{e?e("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:t}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${t}
3
3
  `)}return s}function R(r){if(!S(r))throw new Error(`Variables file not found: ${r}`);let e=E(r,"utf-8"),s=V(e,r),n={};if(s&&typeof s=="object")for(let[t,a]of Object.entries(s))a&&typeof a=="object"&&"value"in a&&(n[t]=b(t,a));return n}function w(r){let e;try{e=JSON.parse(r)}catch{throw new Error("Invalid --variables JSON")}let s={};if(e&&typeof e=="object")for(let[n,t]of Object.entries(e))t&&typeof t=="object"&&"value"in t&&(s[n]=b(n,t));return s}function j(r,e,s){let n=v(r,s),t=v(e,s);return{...n,...t}}function G(r,e){if(Object.keys(r).length===0)return{};let s={};for(let[n,t]of Object.entries(r)){let a=t.syntax??`{{${n}}}`;k(e,a)&&(s[n]=t)}return s}function I(r){let e=r.trim();return e.startsWith("{{")&&e.endsWith("}}")?e.slice(2,-2).trim():e.startsWith("${")&&e.endsWith("}")?e.slice(2,-1).trim():e}function k(r,e){if(!e||!r)return!1;if(r.includes(e))return!0;let s=I(e);if(!s)return!1;let n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${n}(?=\\s*\\}|[.\\[])`).test(r)}function M(r){let e=j(r.globalDir,r.localDir,r.onLoadError),s=r.file?R(r.file):{},n=r.inline?w(r.inline):{},t={...e,...s,...n,...r.parameters??{}},a=Object.keys(t).length>0,{variables:i,objective:l}=a?h(t,r.objective):{variables:{},objective:r.objective},o=_(t);return m(o.secretEntries.map(([,x])=>x.value)),{raw:t,auteur:i,auteurObjective:l,...o}}function _(r){let e=Object.entries(r),s=e.filter(([,t])=>d(t)),n=e.filter(([,t])=>!d(t));return{secretEntries:n.filter(([,t])=>t.secret),nonSecretEntries:n.filter(([,t])=>!t.secret),parameterEntries:s}}async function Q(r){if(r.localMode)return{};let e=y(r.env);if(r.variables.secretEntries.length>0){let n=new u(e.secretsBaseUrl);for(let[t,a]of r.variables.secretEntries)n.pushSecret({secretKey:t,secretValue:a.value,username:r.auth.username,accessKey:r.auth.access_key,orgId:r.orgId}).then(()=>r.log("info","SECRET_PUSH_OK","Secret pushed",{key:t})).catch(i=>r.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:t,error:String(i)}))}let s={};if(r.variables.nonSecretEntries.length>0){let n=new f(e.tmsBaseUrl,r.auth.username,r.auth.access_key);for(let[t,a]of r.variables.nonSecretEntries)try{let i=await n.upsertVariable({name:t,value:a.value});s[t]=i.id,r.log("info","VAR_PUSH_OK","Variable pushed",{name:t,id:i.id})}catch(i){r.log("error","VAR_PUSH_FAILED","Variable push failed",{name:t,error:String(i)})}}return s}export{u as a,f as b,G as c,M as d,_ as e,Q as f};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $e,b as we,g as Ee}from"./chunk-LWCP4GLY.js";import{a as te}from"./chunk-UCVP7ZY4.js";import{a as G}from"./chunk-5Y2G4NC7.js";import{b as ye}from"./chunk-WN5VKKJ3.js";import{a as Be}from"./chunk-XHFU5TGS.js";import{a as Te}from"./chunk-M3TFOFUQ.js";import{a as E}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as ve,k as ee}from"./chunk-33DWJV67.js";import{a as z}from"./chunk-6YGTRKDT.js";import{z as i}from"./chunk-FAMQ4DHU.js";import{e as R}from"./chunk-UR6MHSHU.js";var M=R(z(),1);var I=R(z(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function ke(e){let t=Ee(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,I.useState)(0),[a,u]=(0,I.useState)("idle"),c=(0,I.useRef)("idle"),B=(0,I.useRef)(0),S=(0,I.useRef)(!1),v=(0,I.useRef)(null),d=(0,I.useRef)(null),O=(0,I.useCallback)(m=>{c.current=m,u(m)},[]),P=(0,I.useCallback)(async m=>{e.reportVerdictOnComplete&&await t.shutdownRunner($e(e.runVerdict?.()??(m?"failed":"passed"))),e.onAllComplete?.()},[t,e]),T=(0,I.useCallback)(async m=>{let b=await e.getNextConfig(m);if(!b){O("done"),await P(!1);return}let C=m?B.current+1:0;B.current=C,l(C),e.onStepStart?.(b,C),v.current=null,d.current=null,O("running"),await t.startRun(b,e.spawnOpts)},[t,e,O]);(0,I.useEffect)(()=>{S.current||(S.current=!0,T(null))},[]),(0,I.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===v.current||c.current!=="running")return;v.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let m=t.lastRunEnd,b=de(t.steps),C=t.bifurcationInfo,A={status:m.status==="passed"?"passed":"failed",duration_s:m.duration??0,reason:m.reason,runEnd:m,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:C&&!C.isSingleFlow?C.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(A,B.current)??!0)){O("done"),P(A.status==="failed");return}T(A)},[t.lastRunEnd]),(0,I.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let m=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:m.passed,stepsFailed:m.failed,stepsTotal:m.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,B.current)??!0)){O("done"),P(!0);return}T(b)},[t.runError,t.lastRunEnd]);let k=(0,I.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:k}}var pe=R(z(),1);var ne=R(E(),1),Ce=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Le({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);G(()=>{l(B=>(B+1)%Ce.length)},80),G(()=>{u(B=>(B+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ce[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Oe(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var L=R(z(),1);var Pe=R(z(),1);var re=R(E(),1),Ue="#ffc580",We="#ffd9a8",Ie="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Pe.useState)(0),a=4;if(G(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Ie,children:e});let u=e.split("").map((c,B)=>{let S=n-a,v=Math.abs(B-S-a/2),d;return v<=a/2?d=Ue:v<=a?d=We:d=Ie,(0,re.jsx)(o,{color:d,children:c},B)});return(0,re.jsx)(o,{children:u})}var _=R(E(),1),ze={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=ze[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Xe={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function De(e){return Xe[e]??"\u25CF"}var q=R(E(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let B=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return B?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(v=>(0,q.jsx)(s,{marginLeft:2,children:l(v,`${S}-${v.childId??"p"}-${v.index}`)},`${S}-${v.childId??"p"}-${v.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var K=R(E(),1);function je({label:e,shimmer:t=!1}){return(0,K.jsxs)(s,{marginLeft:6,children:[(0,K.jsx)(te,{}),(0,K.jsx)(o,{children:" "}),t?(0,K.jsx)(oe,{text:e,active:!0}):(0,K.jsx)(o,{color:i.dim,children:e})]})}var Fe=R(z(),1);var me=R(E(),1);function Ye(e,t){let n=[];for(let l of e.split(`
2
+ import{a as $e,b as we,g as Ee}from"./chunk-4KL3TSTT.js";import{a as te}from"./chunk-SMGRXKXX.js";import{a as G}from"./chunk-5Y2G4NC7.js";import{b as ye}from"./chunk-WN5VKKJ3.js";import{a as Be}from"./chunk-YVVFXBT5.js";import{a as Te}from"./chunk-ND6OP3O2.js";import{a as E}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as ve,k as ee}from"./chunk-33DWJV67.js";import{a as z}from"./chunk-6YGTRKDT.js";import{z as i}from"./chunk-J4FIESTB.js";import{e as R}from"./chunk-UR6MHSHU.js";var M=R(z(),1);var I=R(z(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function ke(e){let t=Ee(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,I.useState)(0),[a,u]=(0,I.useState)("idle"),c=(0,I.useRef)("idle"),B=(0,I.useRef)(0),S=(0,I.useRef)(!1),v=(0,I.useRef)(null),d=(0,I.useRef)(null),O=(0,I.useCallback)(m=>{c.current=m,u(m)},[]),P=(0,I.useCallback)(async m=>{e.reportVerdictOnComplete&&await t.shutdownRunner($e(e.runVerdict?.()??(m?"failed":"passed"))),e.onAllComplete?.()},[t,e]),T=(0,I.useCallback)(async m=>{let b=await e.getNextConfig(m);if(!b){O("done"),await P(!1);return}let C=m?B.current+1:0;B.current=C,l(C),e.onStepStart?.(b,C),v.current=null,d.current=null,O("running"),await t.startRun(b,e.spawnOpts)},[t,e,O]);(0,I.useEffect)(()=>{S.current||(S.current=!0,T(null))},[]),(0,I.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===v.current||c.current!=="running")return;v.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let m=t.lastRunEnd,b=de(t.steps),C=t.bifurcationInfo,A={status:m.status==="passed"?"passed":"failed",duration_s:m.duration??0,reason:m.reason,runEnd:m,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:C&&!C.isSingleFlow?C.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(A,B.current)??!0)){O("done"),P(A.status==="failed");return}T(A)},[t.lastRunEnd]),(0,I.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let m=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:m.passed,stepsFailed:m.failed,stepsTotal:m.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,B.current)??!0)){O("done"),P(!0);return}T(b)},[t.runError,t.lastRunEnd]);let k=(0,I.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:k}}var pe=R(z(),1);var ne=R(E(),1),Ce=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Le({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);G(()=>{l(B=>(B+1)%Ce.length)},80),G(()=>{u(B=>(B+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ce[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Oe(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var L=R(z(),1);var Pe=R(z(),1);var re=R(E(),1),Ue="#ffc580",We="#ffd9a8",Ie="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Pe.useState)(0),a=4;if(G(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Ie,children:e});let u=e.split("").map((c,B)=>{let S=n-a,v=Math.abs(B-S-a/2),d;return v<=a/2?d=Ue:v<=a?d=We:d=Ie,(0,re.jsx)(o,{color:d,children:c},B)});return(0,re.jsx)(o,{children:u})}var _=R(E(),1),ze={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=ze[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Xe={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function De(e){return Xe[e]??"\u25CF"}var q=R(E(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let B=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return B?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(v=>(0,q.jsx)(s,{marginLeft:2,children:l(v,`${S}-${v.childId??"p"}-${v.index}`)},`${S}-${v.childId??"p"}-${v.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var K=R(E(),1);function je({label:e,shimmer:t=!1}){return(0,K.jsxs)(s,{marginLeft:6,children:[(0,K.jsx)(te,{}),(0,K.jsx)(o,{children:" "}),t?(0,K.jsx)(oe,{text:e,active:!0}):(0,K.jsx)(o,{color:i.dim,children:e})]})}var Fe=R(z(),1);var me=R(E(),1);function Ye(e,t){let n=[];for(let l of e.split(`
3
3
  `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function _e({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,Fe.useState)(!0);G(()=>c(v=>!v),500);let B=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=Ye(B,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((v,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:v.length?v:" "},d))})}var H=R(E(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,H.jsxs)(H.Fragment,{children:[e?(0,H.jsx)(je,{label:e.label,shimmer:e.shimmer}):null,n?(0,H.jsx)(_e,{text:t??""}):null]})}var r=R(E(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function X(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Ae(e){let t=[];for(let n of e)X(n)||(n.children&&n.children.length>0?t.push({...n,children:Ae(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function D({step:e,indent:t=2}){let n=e.actionType?De(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:B}=ee(),S=B?.columns??80,v=Math.max(20,S-t-21),d=e.objective??"",O=d.length>v?d.slice(0,v-1)+"\u2026":d,P=(e.duration??0)*1e3,T=e.duration!=null?P<1e3?`${Math.round(P)}ms`:`${(P/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:O,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:O}):c?(0,r.jsx)(o,{color:i.dim,children:O}):(0,r.jsx)(o,{color:i.dim,children:O})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:T})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((k,m)=>(0,r.jsx)(D,{step:k,indent:t+2},`child-${m}`))})]})}function Je(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(D,{step:e.step})})}function Me({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:B,describeVisible:S,describeRevealing:v}){let d=(0,L.useRef)(new Set),O=(0,L.useRef)(!1),P=(0,L.useRef)(new Set),T=(0,L.useRef)(!1),k=(0,L.useRef)(new Set),m=(0,L.useRef)(0);(0,L.useEffect)(()=>{e.length===0&&m.current>0&&(d.current.clear(),O.current=!1,P.current.clear(),T.current=!1,k.current.clear()),m.current=e.length},[e.length]);let b=e.flatMap(p=>[p,...p.children??[]]),C=b.some(p=>p.status==="running"),A=b.some(p=>p.status==="failed"),W=b.length===0||b.every(p=>p.status==="pending"),Y=b.filter(p=>p.status==="passed"||p.status==="failed").length,N;W?N="starting":C?N="running":A?N="failed":N="passed";let J=(0,L.useRef)(null),[ce,he]=(0,L.useState)(0);(0,L.useEffect)(()=>{b.length===0||W?(J.current=null,he(0)):C&&J.current==null&&(J.current=Date.now())},[C,W,b.length]),(0,L.useEffect)(()=>{if(!C)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[C]);let ae=(0,L.useRef)(new Set),[,xe]=(0,L.useState)(0),be=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let h of e)(h.status==="passed"||h.status==="failed")&&!ae.current.has(h.index)&&(ae.current.add(h.index),p.push({key:`step_${h.index}`,type:"step",step:{...h,children:h.children?[...h.children]:void 0}}));if(p.length>0){for(let h of p)c(Je(h));xe(h=>h+1)}},[e,t,l,u,c]),(0,L.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!T.current&&l&&l[0]!=null&&(T.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!O.current&&(O.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let h=e.flatMap((x,f)=>{let g=x.children??[];return!P.current.has(f)&&g.length>0&&(P.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!k.current.has(f)&&(k.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&P.current.has(f)&&!k.current.has(f)&&(k.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),g});for(let x of h){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...x,children:void 0}})})));for(let y of x.children??[]){let $=`child-${x.childId??"p"}-${x.index}-${y.childId??"p"}-${y.index}-${y.objective}`;d.current.has($)||(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(D,{step:y})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:x})})))}}else for(let h of e){let x=`${h.index}-${h.objective}`,f=!!h.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...h,children:void 0}})})));for(let g of h.children??[]){let y=`child-${h.index}-${g.childId??"p"}-${g.index}-${g.objective}`;d.current.has(y)||(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(y),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(D,{step:g})})))}!f&&!d.current.has(x)&&(h.status==="passed"||h.status==="failed"||h.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...h,children:void 0}})})))}d.current.size>p&&xe(h=>h+1)},[e,c,t,n,l]);let V=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||V.push(p);else if(c&&!u)if(t)for(let p of e){let h=p.children??[],x=[];for(let f of h){let g=`${f.childId??"p"}-${f.index}-${f.objective}`,y=d.current.has(g);if(f.branchObjective){let $=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!y||$.length>0)&&x.push({...f,children:$})}else y||x.push(f)}x.length>0&&V.push({...p,children:x})}else for(let p of e){let h=`${p.index}-${p.objective}`,x=d.current.has(h),f=(p.children??[]).filter(g=>{let y=`child-${p.index}-${g.childId??"p"}-${g.index}-${g.objective}`;return!d.current.has(y)});x?f.length>0&&V.push({...p,children:f}):V.push({...p,children:f})}if(!u){let p=c?V:e,h=le(p),x=ge(h,v);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((g,y)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:y>0?1:0,children:g.children&&g.children.length>0?g.children.map($=>{if(X($))return null;let Q=!!$.branchObjective,ue=`${$.childId??"p"}-${$.index}-${$.objective}`,He=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!He&&(0,r.jsx)(D,{step:{...$,children:void 0}}),($.children??[]).filter(Z=>!X(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:Z})},`f${y}-${$.index}-${Z.childId??"p"}-${Z.index}`))]},`f${y}-host-${$.childId??"p"}-${$.index}`):(0,r.jsx)(D,{step:$},`f${y}-${$.childId??"p"}-${$.index}`)}):g.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},y))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(g,y)=>X(g)?null:(0,r.jsx)(D,{step:g},y)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(g=>!(g.status==="running"&&(!g.children||g.children.length===0))).map(g=>{let y=`${g.index}-${g.objective}`;return c&&d.current.has(y)?(0,r.jsx)(s,{flexDirection:"column",children:(g.children??[]).filter($=>!X($)).map($=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:$})},`${$.childId??"p"}-${$.index}`))},`branch-children-${g.index}`):(0,r.jsx)(D,{step:g},g.index)})]}),(0,r.jsx)(se,{activity:x,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),h=ge(p,v);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>X(x)?null:(0,r.jsx)(D,{step:x},f)}),(0,r.jsx)(se,{activity:h,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ge=le(V),Ke=ge(Ge,v),Re=Ae(V);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(D,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ke,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var U=R(E(),1);function qe({runner:e,runKey:t,onStepCommit:n}){let l=Oe({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,U.jsxs)(U.Fragment,{children:[l&&(0,U.jsx)(Le,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,U.jsx)(Me,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var j=R(E(),1),Qe=64;function Ze(e){return e.split(`
4
4
  `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function Ne({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:B}){let S=e==="passed",v=S?i.green:i.red,d=S?"\u2713":"\u2717",O=e.toUpperCase(),P=a??(S?l:Math.max(0,l-1)),T=u??(S?0:1),k=T>0?`${l} steps (${P} passed, ${T} failed)`:`${l} steps`,m=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,b=Ze(t);return(0,j.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,j.jsxs)(s,{borderStyle:"round",borderColor:v,flexDirection:"column",paddingX:2,paddingY:1,width:Qe+6,children:[(0,j.jsxs)(s,{flexDirection:"column",children:[(0,j.jsxs)(o,{bold:!0,color:v,children:[d," ",O]}),(0,j.jsxs)(o,{color:i.dim,wrap:"wrap",children:[k," \xB7 ",m,typeof B=="number"&&B>0?` \xB7 ${parseFloat(B.toFixed(4))} credits`:""]})]}),b.length>0&&(0,j.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:b.map((C,A)=>(0,j.jsxs)(s,{marginBottom:A<b.length-1?1:0,children:[(0,j.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,j.jsx)(s,{flexShrink:1,children:(0,j.jsx)(o,{wrap:"wrap",children:C})})]},A))}),c&&!S&&(0,j.jsx)(s,{marginTop:1,children:(0,j.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var F=R(E(),1);function Ve({message:e,code:t,remediation:n,docsUrl:l}){return(0,F.jsx)(Te,{title:"Error",variant:"error",children:(0,F.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,F.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,F.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,F.jsx)(o,{color:i.muted,children:"Code: "}),(0,F.jsx)(o,{color:i.dim,children:t})]}),n&&(0,F.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,F.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,F.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,F.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,F.jsx)(o,{color:i.muted,children:"Docs: "}),(0,F.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var w=R(E(),1),et=1e4;function gn(e){let{exit:t}=ve(),{append:n}=ye(),l=(0,M.useRef)(!1);(0,M.useEffect)(()=>{l.current||(l.current=!0,n((0,w.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,w.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,w.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,w.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,w.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,w.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,w.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,w.jsx)(tt,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,w.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,M.useRef)(null),u=(0,M.useCallback)(async T=>{let k=await e.getNextStep(T);return k?(a.current=k,k.config):(a.current=null,null)},[e]),c=(0,M.useCallback)((T,k)=>{let m=a.current;if(!m)return;let b=m.mode==="replay"?"cyan":"#dc4e08",C=m.modeReason?` (${m.modeReason})`:"",A=m.perStepOverrides?Object.entries(m.perStepOverrides):[];n((0,w.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,w.jsxs)(o,{children:[(0,w.jsxs)(o,{color:i.dim,children:[m.banner.stepLabel," "]}),(0,w.jsxs)(o,{color:b,children:["[",m.mode,"]"]}),(0,w.jsx)(o,{color:i.dim,children:C})]}),(0,w.jsx)(o,{color:i.dim,children:m.banner.objective}),A.length>0&&(0,w.jsxs)(o,{color:i.dim,children:["overrides: ",A.map(([W,Y])=>`${W}=${Y}`).join(", ")]})]}))},[n]),B=(0,M.useRef)(0),S=(0,M.useRef)(!1),v=(0,M.useCallback)((T,k)=>(T.hadError?n((0,w.jsx)(Ve,{message:T.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,w.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,w.jsx)(Ne,{status:T.status,summary:T.runEnd?.summary??"",duration:T.runEnd?.duration??0,steps:T.stepsTotal,stepsPassed:T.stepsPassed,stepsFailed:T.stepsFailed,reason:T.runEnd?.reason,creditsConsumed:T.runEnd?.credits_consumed})})),e.onStepEnd?.(T,k)??!0),[n,e]),d=ke({getNextConfig:u,onStepStart:c,onStepEnd:v,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts,...e.reportVerdictOnComplete?{reportVerdictOnComplete:!0}:{},...e.runVerdict?{runVerdict:e.runVerdict}:{}}),O=250,P=5e3;return Se((T,k)=>{if(k.ctrl&&T==="c"){let m=Date.now(),b=m-B.current;if(b<O)return;if(S.current&&b<P){d.cancel(),e.onCancel?.();let C=e.reportVerdictOnComplete?d.runner.shutdownRunner(we,{timeoutMs:et}):Promise.resolve();e.exitOnComplete!==!1&&C.then(()=>setImmediate(()=>t()))}else S.current=!0,n((0,w.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}));B.current=m}}),(0,w.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,w.jsx)(qe,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function tt({data:e}){return(0,w.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{Me as a,Le as b,Oe as c,de as d,Ne as e,Ve as f,gn as g};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-HX5OLRKU.js";import{c as ie,e as ne,i as re,j as K}from"./chunk-Z7S3IWUX.js";import{d as $,e as oe}from"./chunk-4JOD47QI.js";import{a as se}from"./chunk-RZ4F3BHX.js";import{spawn as ze}from"child_process";import{closeSync as Xe,existsSync as Ge,mkdirSync as We,openSync as Ye,readFileSync as Ze,rmSync as Qe}from"fs";import{homedir as ge}from"os";import{dirname as X,join as S}from"path";import{access as Re,mkdir as de,readFile as Le}from"fs/promises";import{homedir as Ce}from"os";import{arch as Fe,platform as Be}from"process";import{join as M}from"path";var Ue=35,qe="google_apis",Ve="KaneCLI_Pixel_API35",He="KaneAI_Pixel_API35";function Ht(t){return t===He?Ve:t}var je=1;function Ke(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function Je(){return{home:Ce(),os:Be,arch:Fe}}async function le(t){try{return await Re(t),!0}catch{return!1}}var J=class{deps;constructor(e={}){this.deps={...Je(),...e}}paths(){let e=M(this.deps.home,".testmuai","kaneai","mobile"),r=M(e,"android-sdk");return{root:r,emulatorDir:M(r,"emulator"),systemImageDir:M(r,"system-images",`android-${Ue}`,qe,Ke(this.deps.os,this.deps.arch)),avdHome:M(e,"avd"),manifest:M(r,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await de(M(e,"platforms"),{recursive:!0}),await de(M(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),r=null;try{r=JSON.parse(await Le(e.manifest,"utf8"))}catch{}if(!r||r.schemaVersion!==je)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!r.components.emulator&&await le(M(e.emulatorDir,o)),systemImage:!!r.components.systemImage&&await le(M(e.systemImageDir,"system.img"))}}},ue;function B(){return ue??=new J,ue}var G="android",et="http://127.0.0.1:4723/status",tt=2e3,z=(()=>{let t=Number(process.env.KANE_CLI_EMULATOR_BOOT_TIMEOUT_MS);return Number.isFinite(t)&&t>=3e4?t:3e5})(),it=1e3,nt=3e5;var rt=5,ce="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",st={device:"ready",unauthorized:"unauthorized",offline:"offline"};function ot(t){let e={};for(let r of t){let o=r.indexOf(":");o<=0||(e[r.slice(0,o)]=r.slice(o+1))}return e}function at(t){let e=[];for(let r of t.split(`
2
+ import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-NRAPCFI2.js";import{c as ie,e as ne,i as re,j as K}from"./chunk-Z7S3IWUX.js";import{d as $,e as oe}from"./chunk-4JOD47QI.js";import{a as se}from"./chunk-RZ4F3BHX.js";import{spawn as ze}from"child_process";import{closeSync as Xe,existsSync as Ge,mkdirSync as We,openSync as Ye,readFileSync as Ze,rmSync as Qe}from"fs";import{homedir as ge}from"os";import{dirname as X,join as S}from"path";import{access as Re,mkdir as de,readFile as Le}from"fs/promises";import{homedir as Ce}from"os";import{arch as Fe,platform as Be}from"process";import{join as M}from"path";var Ue=35,qe="google_apis",Ve="KaneCLI_Pixel_API35",He="KaneAI_Pixel_API35";function Ht(t){return t===He?Ve:t}var je=1;function Ke(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function Je(){return{home:Ce(),os:Be,arch:Fe}}async function le(t){try{return await Re(t),!0}catch{return!1}}var J=class{deps;constructor(e={}){this.deps={...Je(),...e}}paths(){let e=M(this.deps.home,".testmuai","kaneai","mobile"),r=M(e,"android-sdk");return{root:r,emulatorDir:M(r,"emulator"),systemImageDir:M(r,"system-images",`android-${Ue}`,qe,Ke(this.deps.os,this.deps.arch)),avdHome:M(e,"avd"),manifest:M(r,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await de(M(e,"platforms"),{recursive:!0}),await de(M(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),r=null;try{r=JSON.parse(await Le(e.manifest,"utf8"))}catch{}if(!r||r.schemaVersion!==je)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!r.components.emulator&&await le(M(e.emulatorDir,o)),systemImage:!!r.components.systemImage&&await le(M(e.systemImageDir,"system.img"))}}},ue;function B(){return ue??=new J,ue}var G="android",et="http://127.0.0.1:4723/status",tt=2e3,z=(()=>{let t=Number(process.env.KANE_CLI_EMULATOR_BOOT_TIMEOUT_MS);return Number.isFinite(t)&&t>=3e4?t:3e5})(),it=1e3,nt=3e5;var rt=5,ce="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",st={device:"ready",unauthorized:"unauthorized",offline:"offline"};function ot(t){let e={};for(let r of t){let o=r.indexOf(":");o<=0||(e[r.slice(0,o)]=r.slice(o+1))}return e}function at(t){let e=[];for(let r of t.split(`
3
3
  `)){let o=r.trim();if(!o||o.startsWith("*"))continue;let u=o.toLowerCase();if(u.startsWith("list of devices")||u.startsWith("adb server"))continue;let g=o.split(/\s+/),p=g[0],w=g[1];if(!p||!w)continue;let v=ot(g.slice(2)),x=/^(localhost|127\.0\.0\.1):\d{1,5}$/.test(p),P=/^[A-Za-z0-9._-]+:\d{1,5}$/.test(p),C=/^sdk_/.test(v.product??"")||/^sdk_/.test(v.model??"")||/^emu/.test(v.device??"");if(!p.startsWith("emulator-")&&!x&&!(P&&C))continue;let l=v.model?v.model.replace(/_/g," "):void 0;e.push({platform:G,kind:"emulator",id:p,displayName:l??p,state:st[w]??"offline"})}return e}function me(t){let e=[];for(let r of t.split(`
4
4
  `)){let o=r.trim();o&&/^[A-Za-z0-9._-]+$/.test(o)&&(e.includes(o)||e.push(o))}return e}function dt(t){for(let e of t.split(`
5
5
  `)){let r=e.trim();if(!(!r||r==="OK"))return r}}function lt(t){let e=/^Version\s+(\S+)/m.exec(t);return e?.[1]?e[1].split("-")[0]:/Android Debug Bridge version\s+(\S+)/.exec(t)?.[1]}function ut(t){let e=[];for(let r of t.split(`
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Je}from"./chunk-DREQ3RAA.js";import{b as ne,c as $,d as ie,e as oe}from"./chunk-P4VFC6HO.js";import{h as jt,i as Ot}from"./chunk-YO6SNXBJ.js";import{b as mt,c as ft,d as gt,e as _t,f as vt,j as yt,l as ht,m as wt,n as x,o as bt,p as kt,r as xt}from"./chunk-MEMXFTLD.js";import{c as St,d as It}from"./chunk-SSOUYKVG.js";import{a as N}from"./chunk-HVOXMCKE.js";import{a as At,b as Ct}from"./chunk-TAY7J5VS.js";import{b as Dt}from"./chunk-NVD2MXHQ.js";import{a as X,c as qe,d as Ge,e as We,f as Z}from"./chunk-IINZZ4BZ.js";import{a as T}from"./chunk-73Y6T2UK.js";import{e as Pt}from"./chunk-VE4HLIGA.js";import{b as et,e as tt,g as rt,h as nt,i as it,j as ot}from"./chunk-GJ7MO2FW.js";import{b as h,c as ee,d as Qe,g as te}from"./chunk-Z36KVIRR.js";import{a as Q,b as C,d as Xe,e as Ze}from"./chunk-Q4JV4U65.js";import{a as Be,b as Ve}from"./chunk-44SIFDNY.js";import{c as ze,d as Ye,e as He}from"./chunk-5KJU4MG4.js";import{g as Ue}from"./chunk-Y6Y6RAY4.js";import{b as Ke,d as U,e as z}from"./chunk-226AGYHB.js";import{a as F}from"./chunk-FOLUB336.js";import{d as pt}from"./chunk-XB6BJPDL.js";import{h as Y,k as st,m as at,o as ct}from"./chunk-7V34ZMMS.js";import{f as Et}from"./chunk-H4TIVILC.js";import{a as Rt}from"./chunk-4C7WVQOD.js";import{M as dt,vb as lt}from"./chunk-PI7OXS62.js";import{f as re,g as ut}from"./chunk-KU3YHPWZ.js";import{b as A,c as b}from"./chunk-VZ7KXRXB.js";import{c as $e}from"./chunk-FI2DVNRT.js";import{f as Ne}from"./chunk-A7RJQJNT.js";import{a as Te}from"./chunk-FAMQ4DHU.js";function j(e){if(e===null)return"broken";let t=Math.floor(e/100);return t===1?"passed":t===7?"failed":t===2?"skipped":"broken"}var D={failed:3,broken:2,passed:1,skipped:0};function se(e){let t="skipped";for(let r of e)D[r]>D[t]&&(t=r);return t}import{createHash as ur}from"crypto";import{basename as dr}from"path";function ae(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return t.length>0?t:"session"}function ce(e){return ur("sha256").update(e).digest("hex").slice(0,8)}function ue(e){let t=dr(e).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${ae(t)}-${ce(e)}`}function de(e,t){return`${ae(e)}-${ce(t)}`}function le(e,t=process.env){let r=Je(t),n={...r.testInstanceId?{hyper_test_instance_id:r.testInstanceId}:{},...r.jobId?{hyper_job_id:r.jobId}:{},...r.taskId?{hyper_task_id:r.taskId}:{},...e},o={};for(let[i,s]of Object.entries(n))typeof s=="string"&&s.length>0&&(o[i]=s);return o}function lr(e,t){return{pack_test_dir:e,ordinal_offset:t}}import{promises as S}from"fs";import{join as I}from"path";function pe(e){let t={evidence:"0.1",run_id:e.execution_id,status:"running",title:e.title,started:e.started,environment:{producer:{name:"kane-cli",version:e.producerVersion},...e.surfaces?{surfaces:e.surfaces}:{},run_kind:e.run_kind,origin:e.origin,pid:e.pid,...e.overrideStartUrl?{override_start_url:e.overrideStartUrl}:{}},...e.credits!==void 0?{metrics:{credits:{value:e.credits,type:"count"}}}:{}};return b(t,{lineWidth:-1})}async function me(e,t,r,n=process.cwd(),o){let i=o??h(e.execution_id,n),s=I(i,"tests",t);return await S.mkdir(I(i,"coverage"),{recursive:!0}),await S.writeFile(I(i,"coverage",".keep"),""),await S.mkdir(s,{recursive:!0}),await S.writeFile(I(i,"run.yaml"),pe(e)),r&&await S.writeFile(I(s,r.path),r.content),i}async function pr(e,t=process.cwd()){let r=h(e.execution_id,t);await S.mkdir(I(r,"coverage"),{recursive:!0}),await S.writeFile(I(r,"coverage",".keep"),"");let n=A(pe(e));return n.environment&&delete n.environment.run_kind,await S.writeFile(I(r,"run.yaml"),b(n,{lineWidth:-1})),r}async function mr(e,t=process.cwd()){return C(h(e,t),new Date().toISOString())}async function fe(e,t=process.cwd()){await S.rm(h(e,t),{recursive:!0,force:!0})}import{promises as ge}from"fs";import{join as _e}from"path";function H(e){let t={evidence:"0.1",test:e.testId,status:e.status,...e.durationMs!==void 0?{duration_ms:e.durationMs}:{},...e.attempts&&e.attempts.length?{attempts:e.attempts}:{},...e.flaky!==void 0?{flaky:e.flaky}:{},...e.adaptiveHeal?{adaptive_heal:e.adaptiveHeal}:{},...e.definitionPath?{definition:{path:e.definitionPath}}:{},...e.definitionId?{definition_id:e.definitionId}:{},...e.assuranceId?{assurance_id:e.assuranceId}:{},...e.assuranceBase?{assurance_base:e.assuranceBase}:{},...Object.keys(e.externalId).length?{external_id:e.externalId}:{},...e.tags&&e.tags.length?{tags:e.tags}:{},...Object.keys(e.environment).length?{environment:e.environment}:{},steps:e.steps};return b(t,{lineWidth:-1})}function ve(e){return b({logs:e},{lineWidth:-1})}async function ye(e,t,r){await ge.writeFile(_e(e,"tests",t,"result.yaml"),r)}async function he(e,t,r){let n=_e(e,"tests",t,"logs");await ge.mkdir(n,{recursive:!0}),await ge.writeFile(_e(n,"meta.yaml"),r)}import{promises as K}from"fs";import{join as Lt}from"path";function Mt(e){return Lt(e,".internal","meta.json")}async function Ft(e){let t;try{t=await K.readFile(Mt(e),"utf8")}catch(n){if(n?.code==="ENOENT")return null;throw n}let r=JSON.parse(t);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("meta.json is not a JSON object");return r}async function we(e,t){let r;try{r=await Ft(e)??{}}catch(s){console.warn(`evidence: meta.json at ${e} unreadable \u2014 skipping execution-pointer append to preserve identity`,s);return}let n=Array.isArray(r.executions)?r.executions:[];n.push(t),r.executions=n,await K.mkdir(Lt(e,".internal"),{recursive:!0});let o=Mt(e),i=`${o}.tmp-${process.pid}-${Date.now()}`;await K.writeFile(i,JSON.stringify(r,null,2)+`
2
+ import{a as Je}from"./chunk-DREQ3RAA.js";import{b as ne,c as $,d as ie,e as oe}from"./chunk-35WUYKGO.js";import{h as jt,i as Ot}from"./chunk-IEHJG6J4.js";import{b as mt,c as ft,d as gt,e as _t,f as vt,j as yt,l as ht,m as wt,n as x,o as bt,p as kt,r as xt}from"./chunk-MEMXFTLD.js";import{c as St,d as It}from"./chunk-SSOUYKVG.js";import{a as N}from"./chunk-HVOXMCKE.js";import{a as At,b as Ct}from"./chunk-TAY7J5VS.js";import{b as Dt}from"./chunk-3RO2YGKH.js";import{a as X,c as qe,d as Ge,e as We,f as Z}from"./chunk-IINZZ4BZ.js";import{a as T}from"./chunk-73Y6T2UK.js";import{e as Pt}from"./chunk-NI3TIAD7.js";import{b as et,e as tt,g as rt,h as nt,i as it,j as ot}from"./chunk-2JFRN62I.js";import{b as h,c as ee,d as Qe,g as te}from"./chunk-Z36KVIRR.js";import{a as Q,b as C,d as Xe,e as Ze}from"./chunk-Q4JV4U65.js";import{a as Be,b as Ve}from"./chunk-2TK4MDF2.js";import{c as ze,d as Ye,e as He}from"./chunk-5YYCCM6K.js";import{g as Ue}from"./chunk-WLEWXE6L.js";import{b as Ke,d as U,e as z}from"./chunk-NHGPMYM3.js";import{a as F}from"./chunk-FOLUB336.js";import{d as pt}from"./chunk-XB6BJPDL.js";import{h as Y,k as st,m as at,o as ct}from"./chunk-7V34ZMMS.js";import{f as Et}from"./chunk-WE7HRAGO.js";import{a as Rt}from"./chunk-4C7WVQOD.js";import{M as dt,vb as lt}from"./chunk-PI7OXS62.js";import{f as re,g as ut}from"./chunk-KU3YHPWZ.js";import{b as A,c as b}from"./chunk-VZ7KXRXB.js";import{c as $e}from"./chunk-ZCBOHWN3.js";import{f as Ne}from"./chunk-A7RJQJNT.js";import{a as Te}from"./chunk-J4FIESTB.js";function j(e){if(e===null)return"broken";let t=Math.floor(e/100);return t===1?"passed":t===7?"failed":t===2?"skipped":"broken"}var D={failed:3,broken:2,passed:1,skipped:0};function se(e){let t="skipped";for(let r of e)D[r]>D[t]&&(t=r);return t}import{createHash as ur}from"crypto";import{basename as dr}from"path";function ae(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return t.length>0?t:"session"}function ce(e){return ur("sha256").update(e).digest("hex").slice(0,8)}function ue(e){let t=dr(e).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${ae(t)}-${ce(e)}`}function de(e,t){return`${ae(e)}-${ce(t)}`}function le(e,t=process.env){let r=Je(t),n={...r.testInstanceId?{hyper_test_instance_id:r.testInstanceId}:{},...r.jobId?{hyper_job_id:r.jobId}:{},...r.taskId?{hyper_task_id:r.taskId}:{},...e},o={};for(let[i,s]of Object.entries(n))typeof s=="string"&&s.length>0&&(o[i]=s);return o}function lr(e,t){return{pack_test_dir:e,ordinal_offset:t}}import{promises as S}from"fs";import{join as I}from"path";function pe(e){let t={evidence:"0.1",run_id:e.execution_id,status:"running",title:e.title,started:e.started,environment:{producer:{name:"kane-cli",version:e.producerVersion},...e.surfaces?{surfaces:e.surfaces}:{},run_kind:e.run_kind,origin:e.origin,pid:e.pid,...e.overrideStartUrl?{override_start_url:e.overrideStartUrl}:{}},...e.credits!==void 0?{metrics:{credits:{value:e.credits,type:"count"}}}:{}};return b(t,{lineWidth:-1})}async function me(e,t,r,n=process.cwd(),o){let i=o??h(e.execution_id,n),s=I(i,"tests",t);return await S.mkdir(I(i,"coverage"),{recursive:!0}),await S.writeFile(I(i,"coverage",".keep"),""),await S.mkdir(s,{recursive:!0}),await S.writeFile(I(i,"run.yaml"),pe(e)),r&&await S.writeFile(I(s,r.path),r.content),i}async function pr(e,t=process.cwd()){let r=h(e.execution_id,t);await S.mkdir(I(r,"coverage"),{recursive:!0}),await S.writeFile(I(r,"coverage",".keep"),"");let n=A(pe(e));return n.environment&&delete n.environment.run_kind,await S.writeFile(I(r,"run.yaml"),b(n,{lineWidth:-1})),r}async function mr(e,t=process.cwd()){return C(h(e,t),new Date().toISOString())}async function fe(e,t=process.cwd()){await S.rm(h(e,t),{recursive:!0,force:!0})}import{promises as ge}from"fs";import{join as _e}from"path";function H(e){let t={evidence:"0.1",test:e.testId,status:e.status,...e.durationMs!==void 0?{duration_ms:e.durationMs}:{},...e.attempts&&e.attempts.length?{attempts:e.attempts}:{},...e.flaky!==void 0?{flaky:e.flaky}:{},...e.adaptiveHeal?{adaptive_heal:e.adaptiveHeal}:{},...e.definitionPath?{definition:{path:e.definitionPath}}:{},...e.definitionId?{definition_id:e.definitionId}:{},...e.assuranceId?{assurance_id:e.assuranceId}:{},...e.assuranceBase?{assurance_base:e.assuranceBase}:{},...Object.keys(e.externalId).length?{external_id:e.externalId}:{},...e.tags&&e.tags.length?{tags:e.tags}:{},...Object.keys(e.environment).length?{environment:e.environment}:{},steps:e.steps};return b(t,{lineWidth:-1})}function ve(e){return b({logs:e},{lineWidth:-1})}async function ye(e,t,r){await ge.writeFile(_e(e,"tests",t,"result.yaml"),r)}async function he(e,t,r){let n=_e(e,"tests",t,"logs");await ge.mkdir(n,{recursive:!0}),await ge.writeFile(_e(n,"meta.yaml"),r)}import{promises as K}from"fs";import{join as Lt}from"path";function Mt(e){return Lt(e,".internal","meta.json")}async function Ft(e){let t;try{t=await K.readFile(Mt(e),"utf8")}catch(n){if(n?.code==="ENOENT")return null;throw n}let r=JSON.parse(t);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("meta.json is not a JSON object");return r}async function we(e,t){let r;try{r=await Ft(e)??{}}catch(s){console.warn(`evidence: meta.json at ${e} unreadable \u2014 skipping execution-pointer append to preserve identity`,s);return}let n=Array.isArray(r.executions)?r.executions:[];n.push(t),r.executions=n,await K.mkdir(Lt(e,".internal"),{recursive:!0});let o=Mt(e),i=`${o}.tmp-${process.pid}-${Date.now()}`;await K.writeFile(i,JSON.stringify(r,null,2)+`
3
3
  `),await K.rename(i,o)}async function fr(e){try{let t=await Ft(e);return t&&Array.isArray(t.executions)?t.executions:[]}catch{return[]}}function be(e){let t=[];for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(o=>o.resultCode):[r.resultCode];for(let o of n)t.push(j(o))}return se(t)}function gr(e){let t=null;for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(o=>o.resultCode):[r.resultCode];for(let o of n)o!=null&&(t==null||D[j(o)]>D[j(t)]||D[j(o)]===D[j(t)]&&o>t)&&(t=o)}return t}import{promises as _r}from"fs";import{extname as Tt,basename as vr}from"path";var yr={".ndjson":"ndjson",".log":"log",".json":"json",".har":"har"};async function ke(e){let t;try{t=await _r.readdir(e)}catch{return[]}return t.filter(r=>r!=="meta.yaml"&&!r.startsWith(".")).sort().map(r=>({name:vr(r,Tt(r)),file:r,format:yr[Tt(r)]??"txt"}))}import{mkdirSync as hr,appendFileSync as wr}from"fs";import{join as Nt}from"path";function xe(e,t){return Nt(e,"tests",t,"logs")}function Se(e,t,r,n={},o){try{o?.(t,r,r,n)}catch{}if(e)try{hr(e,{recursive:!0});let i=JSON.stringify({ts:new Date().toISOString(),level:t,event:r,...n})+`
4
4
  `;wr(Nt(e,"diagnostics.ndjson"),i)}catch{}}import{promises as R}from"fs";import{dirname as Ar,join as O}from"path";import{statSync as br}from"fs";import{promises as Ie}from"fs";import{basename as kr,join as xr}from"path";var Sr=1e6,Ir=2e6;function Rr(){return Be.map(e=>Ve(e))}function $t(e=Rr()){return e.map(t=>{let r=0;try{r=br(t).size}catch{}return{path:t,offset:r}})}var Er=/\x1b\[[0-9;]*[A-Za-z]/g;async function Pr(e,t,r){let n;try{n=await Ie.open(e,"r");let o=(await n.stat()).size,i=t<=o?t:0,s=o-i;if(s<=0)return null;let a=s>r?o-r:i,c=Buffer.alloc(Math.min(s,r));return await n.read(c,0,c.length,a),c.toString("utf8")}catch{return null}finally{await n?.close().catch(()=>{})}}async function Bt(e,t){let r=t.caps?.stderr??Sr,n=t.caps?.appium??Ir,o=[];t.runnerStderrPath&&o.push({src:t.runnerStderrPath,from:0,cap:r});for(let i of t.appiumMarks??[])o.push({src:i.path,from:i.offset,cap:n});for(let i of o){let s=await Pr(i.src,i.from,i.cap);if(s===null)continue;let a=s.replace(Er,"");if(a!=="")try{await Ie.mkdir(e,{recursive:!0}),await Ie.writeFile(xr(e,kr(i.src)),a)}catch{}}}async function Cr(e){try{let t=O(e,"tests"),r=await R.readdir(t).catch(()=>[]);for(let n of r){let o=O(t,n,"steps"),i=await R.readdir(o).catch(()=>[]);for(let s of i){let a=await R.readFile(O(o,s,"failure.yaml"),"utf8").catch(()=>null);if(a!=null)try{let c=A(a);if(c&&typeof c=="object"&&c.triage)return!0}catch{}}}}catch{}return!1}async function Vt(e,t,r,n={}){let o=O(e,"tests",t,"logs");if(r)try{await R.mkdir(o,{recursive:!0}),await R.copyFile(r,O(o,"tui.log"))}catch{}await Bt(o,{runnerStderrPath:r?O(Ar(r),"runner-stderr.log"):void 0,appiumMarks:n.appiumMarks});let i=await ke(o);if(!i.length&&n.requireRealLog)throw new Error(`evidence test ${t} has no real log to declare`);i.length&&await he(e,t,ve(i))}async function Re(e){let t=e.cwd??process.cwd(),r=e.packDir??h(e.executionId,t);if(!e.saved&&!e.packDir)return await fe(e.executionId,t),{sealed:!1};await Vt(r,e.testId,e.tuiLogPath,{requireRealLog:e.requireRealLog,appiumMarks:e.appiumMarks}),await z(r,await e.catalog??Ke());let n=O(r,"run.yaml"),o=A(await R.readFile(n,"utf8"));o.environment={...o.environment??{},saved:e.saved,run_kind:e.runKind},await R.writeFile(n,b(o,{lineWidth:-1}));let i=await R.open(n,"r+");try{await i.sync()}finally{await i.close()}let s=await Cr(r);await C(r,new Date().toISOString());let a;try{let u=await Q(r,"L1");a=u.valid;let p=(u.diagnostics??[]).filter(f=>String(f?.code??"").includes("failure.status_disagrees"));if(p.length>0)if(e.expectStatusDisagrees||s){let f=e.expectStatusDisagrees?"expected under --bug-detection continue":"self-explained by triaged failure record(s)";console.warn(`evidence: ${p.length} status_disagrees advisory(ies) \u2014 ${f}`)}else console.warn(`evidence: ${p.length} status_disagrees advisory(ies) \u2014 step verdicts disagree with their failure records`,p);if(!u.valid){console.warn(`evidence: sealed pack ${e.executionId} failed L1 validation`,u.diagnostics);let f=String(u.diagnostics?.[0]?.code??"");Se(xe(r,e.testId),"warn","EVIDENCE_INVALID",{execution_id:e.executionId,first_code:f,surface:e.surface??"testmd"},e.log)}}catch(u){console.warn(`evidence: validation error for ${e.executionId}`,u)}let c;if(e.saved&&e.packDir)try{c=await Qe(r,e.executionId,t)}catch(u){console.warn(`evidence: store install failed for ${e.executionId}`,u)}if(e.outputStemDir)try{await we(e.outputStemDir,{execution_id:e.executionId,run_kind:e.runKind,status:e.verdict,valid:a,at:new Date().toISOString()})}catch(u){console.warn(`evidence: execution-pointer append failed for ${e.executionId} (pack is sealed)`,u)}return{sealed:!0,valid:a,storePath:c}}import{release as Ut}from"os";import{execFileSync as Dr}from"child_process";var zt=!1,q;function jr(){if(!zt)if(zt=!0,process.platform==="darwin")try{q=Dr("sw_vers",["-productVersion"],{timeout:2e3}).toString().trim()||void 0}catch{q=Ut()||void 0}else q=Ut()||void 0;return q}function Ee(e){let t={os:X(process.platform)},r=jr();if(r&&(t.os_version=r),e.cdpBrowser){let i=/^([A-Za-z]+)\/(\d+)/.exec(e.cdpBrowser);i&&(t.browser=i[1].replace(/^Headless/,""),t.browser_version=i[2])}e.resolution&&(t.resolution=e.resolution);let n=Ge(t,e.runnerEnvironment);if(!n.native_platform)return n;e.deviceName&&(n.device=e.deviceName),!n.os_version&&e.deviceOsVersion&&(n.os_version=e.deviceOsVersion);let o=ze(e.deviceApp);if(o&&(n.app=o),Ne(n.target)){let i=Ue(e.runnerEnvironment?.device);i&&(n.device=i)}return e.pixelResolution&&(n.viewport=n.resolution??Or(e.pixelResolution,n.pixel_ratio)??e.pixelResolution,n.resolution=e.pixelResolution),n}function Or(e,t){if(!t||!Number.isFinite(t)||t<=0)return;let r=/^(\d+)x(\d+)$/.exec(e);if(r)return`${Math.round(Number(r[1])/t)}x${Math.round(Number(r[2])/t)}`}async function Yt(e){if(e)try{let t=await fetch(`${e}/json/version`,{signal:AbortSignal.timeout(2e3)});if(!t.ok)return;let r=await t.json();return typeof r.Browser=="string"?r.Browser:void 0}catch{return}}function Lr(e){let t;return()=>(t||(t=Yt(e)),t)}import{promises as w,existsSync as E,readFileSync as Nr}from"fs";import{basename as $r,join as v}from"path";import{readFileSync as Mr}from"fs";import{dirname as Fr,resolve as Tr}from"path";function Ht(e,t){let r=Tr(e),n=Mr(r,"utf8");return Y(t?st(n,at(Fr(r),t)):n)}async function Kt(e){for(let t of await w.readdir(e,{withFileTypes:!0})){let r=v(e,t.name);if(t.isDirectory()){await Kt(r);continue}try{await w.unlink(r)}catch{await w.truncate(r,0)}}await w.rmdir(e).catch(()=>{})}function Br(e){let t=e.authorBoundary<0||e.authorBoundary>e.totalSteps?e.totalSteps:e.authorBoundary;return{shrink_count:e.shrinkCount,complete_reauthor:t===0&&e.totalSteps>0,author_boundary:t,total_steps:e.totalSteps,reauthored_steps:e.totalSteps-t,credits_consumed:Math.round(e.creditsConsumed*100)/100}}var B=class e{constructor(t){this.opts=t}executionId;testId;definitionPath=null;definitionContent=null;accumulatedSteps=[];maxOrdinal=0;_attempts=[];_packDirOverride;_attached=!1;appiumMarks=$t();get attached(){return this._attached}static async attach(t){let r=$r(t.packDir).replace(/\.evidence$/,""),n=new e({origin:"testrun",runKind:"author",pid:process.pid,title:t.testId,started:new Date().toISOString(),producerVersion:Te,cwd:t.cwd});n.executionId=r,n.testId=t.testId,n._packDirOverride=t.packDir,n._attached=!0;let o=v(t.packDir,"tests",t.testId);return await w.mkdir(o,{recursive:!0}),t.definition&&(await w.writeFile(v(o,t.definition.path),t.definition.content),n.definitionPath=t.definition.path,n.definitionContent=t.definition.content),n}async start(){if(this._attached)throw new Error("attach-mode session is already started");this.executionId=ee(),this.testId=this.opts.testmdRelPath?ue(this.opts.testmdRelPath):de(this.opts.objectiveOrName??"session",this.opts.sessionId??this.executionId);let t=this.opts.definition??null;return await me({execution_id:this.executionId,title:this.opts.title,started:this.opts.started,producerVersion:this.opts.producerVersion,surfaces:this.opts.surfaces,run_kind:this.opts.runKind,origin:this.opts.origin,pid:this.opts.pid,...this.opts.credits!==void 0?{credits:this.opts.credits}:{},...this.opts.overrideStartUrl?{overrideStartUrl:this.opts.overrideStartUrl}:{}},this.testId,t,this.opts.cwd,this.opts.packRootDir?this.pack:void 0),t&&(this.definitionPath=t.path,this.definitionContent=t.content),{executionId:this.executionId,testId:this.testId,packTestDir:this.packTestDir}}get pack(){return this._packDirOverride?this._packDirOverride:this.opts.packRootDir?v(this.opts.packRootDir,`${this.executionId}.evidence`):h(this.executionId,this.opts.cwd)}get packTestDir(){return v(this.pack,"tests",this.testId)}async writeDefinition(t,r="test.md"){await w.writeFile(v(this.packTestDir,r),t),this.definitionPath=r,this.definitionContent=t}computeEngineBlock(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=v(this.opts.cwd,this.opts.testmdRelPath);if(E(t))return ct(Nr(t,"utf8"))??{}}}catch{}return{}}computeDefinitionId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=v(this.opts.cwd,this.opts.testmdRelPath),r=v(this.opts.cwd,".context"),n=E(r)?lt(r):void 0;if(E(t))return Ht(t,n)}if(this.definitionContent!=null)return Y(this.definitionContent)}catch{}}noteSpawn(t){this.accumulatedSteps.push(...t.steps),this.maxOrdinal=Math.max(this.maxOrdinal,t.maxOrdinal)}nextOrdinalOffset(){return this.maxOrdinal}get steps(){return this.accumulatedSteps}get attempts(){return this._attempts}async archiveAttempt(t,r,n={}){let o=this._attempts.length+1,i=v(this.packTestDir,String(o)),s=n.log,a=(u,l)=>s?.("warn","ARCHIVE_ATTEMPT_FAILED",`Attempt ${o}: ${u} could not be archived into ${o}/; the next attempt will mingle with it`,{attempt:o,dir:u,error:String(l)}),c;try{await w.mkdir(i,{recursive:!0})}catch(u){a(`${o}/`,u)}for(let u of["steps","logs","v16-trajectory"]){let l=v(this.packTestDir,u);if(!E(l))continue;let p=v(i,u);try{await w.rename(l,p);continue}catch(f){s?.("warn","ARCHIVE_ATTEMPT_RENAME_FAILED",`Attempt ${o}: rename of ${u}/ refused; copying it into ${o}/ and emptying the originals in place`,{attempt:o,dir:u,error:String(f),fallback:"copy+truncate"})}try{await w.cp(l,p,{recursive:!0}),await Kt(l)}catch(f){a(u,f)}}try{this.definitionPath&&E(v(this.packTestDir,this.definitionPath))&&await w.copyFile(v(this.packTestDir,this.definitionPath),v(i,this.definitionPath));let u=v(i,"steps");if(E(u)){for(let l of await w.readdir(u))if(E(v(u,l,"failure.yaml"))){c=`${o}/steps/${l}/failure.yaml`;break}}}catch(u){a("definition + failure pointer",u)}return this._attempts.push({n:o,status:t,steps:this.accumulatedSteps,...r!==void 0?{failedAt:r}:{},...c?{failure:c}:{}}),this.accumulatedSteps=[],this.maxOrdinal=0,o}async writeResult(t){let r=be(t.spawns),n=this._attempts.length?[...this._attempts.map(m=>({status:m.status})),{status:r,...t.durationMs!==void 0?{duration_ms:t.durationMs}:{}}]:void 0,o=n?new Set(n.map(m=>m.status)).size>1:void 0,i=this._attempts.length>0,s=t.heal,a=i||s?.forced?{triggered:i,...i?{outcome:r==="passed"?"healed":"exhausted"}:{},...s?Br(s):{},...i?{attempts:this._attempts.map(m=>({n:m.n,status:m.status,failed_at:m.failedAt??-1,...m.failure?{failure:m.failure}:{}}))}:{}}:void 0,c=this.pack,u=le(t.externalIdInput),l=Z(t.runnerEnv,t.intentEnv),p=this.computeDefinitionId(),{id:f,base:y}=this.computeEngineBlock();await ye(c,this.testId,H({testId:this.testId,status:r,durationMs:t.durationMs,definitionPath:this.definitionPath,definitionId:p,assuranceId:f,assuranceBase:y,externalId:u,environment:l,steps:t.steps,tags:t.tags,attempts:n,flaky:o,adaptiveHeal:a}));for(let m of this._attempts){let _=v(this.packTestDir,String(m.n));E(_)&&await w.writeFile(v(_,"result.yaml"),H({testId:this.testId,status:m.status,definitionPath:this.definitionPath,definitionId:p,assuranceId:f,assuranceBase:y,externalId:u,environment:l,steps:m.steps,tags:t.tags}))}let d=t.externalIdInput;return t.log&&(d.commit_id||d.test_id||d.testcase_id)&&t.log("info","EVIDENCE_EXTERNAL_ID","Evidence external-id mapping",{execution_id:this.executionId,commit_id:d.commit_id??null,test_id:d.test_id??null,testcase_id:d.testcase_id??null,tc_id:u.tc_id??null,project_id:d.project_id??null,session_id:d.session_id??null,session_name:d.session_name??null,hyper_test_instance_id:u.hyper_test_instance_id??null,hyper_job_id:u.hyper_job_id??null,hyper_task_id:u.hyper_task_id??null,dataset_id:u.dataset_id??null,dataset_row_id:u.dataset_row_id??null,dataset_version_id:u.dataset_version_id??null}),r}get id(){return this.executionId}get test(){return this.testId}};async function Vr(e,t,r=te){try{let n=await r(e);if(n.aborted.length>0||n.removed.length>0)try{t?.("info","EVIDENCE_RECOVERY","Startup evidence recovery swept incomplete packs",{aborted:n.aborted,removed:n.removed,origin:"startup"})}catch{}return n}catch(n){return console.warn("evidence: startup recovery failed",n),{aborted:[],removed:[]}}}import{promises as dn}from"fs";import{existsSync as tn,mkdirSync as rn,rmSync as nn,writeFileSync as on}from"fs";import{join as Ce}from"path";import{mkdirSync as Ur,renameSync as zr,rmSync as Yr,writeFileSync as Hr}from"fs";import{join as qt}from"path";var Kr=5e6;function Gt(e,t,r){let n=qt(e,"coverage","sources"),o=new Map,i=!1;try{for(let s of r.usecases)for(let a of s.sources){if(o.has(a.id)){a.file=o.get(a.id);continue}if(!a.cid)continue;let c=t.getBlob(a.cid);if(c===null||c.byteLength>Kr)continue;i||(Ur(n,{recursive:!0}),i=!0);let u=qt(n,a.id),l=`${u}.tmp-${process.pid}`;Hr(l,c),zr(l,u);let p=`coverage/sources/${a.id}`;o.set(a.id,p),a.file=p}}catch{for(let s of r.usecases)for(let a of s.sources)delete a.file;if(i)try{Yr(n,{recursive:!0,force:!0})}catch{}}}function qr(e){return e.state==="proven"?"covered":e.proven>0?"partial":"uncovered"}function Gr(e,t,r){let n={};for(let s of e.perUc)n[s.id]={status:qr(s),state:s.state,pct:Math.round(s.pct)};let o={};for(let[s,a]of Object.entries(e.perAc)){let c=a.state==="proven";o[s]={score:c?1:0,verified:c,passes:t[s]?.passes??0,counted:t[s]?.counted??0}}let i=Object.values(n).map(s=>s.status);return{rollup_version:2,stale_sources:e.flags.stale_sources,high_risk_gaps:(r??[]).filter(s=>s.risk==="high").length,aspects:{coverage:{config:e.config,acs:o,usecases:n,summary:{coverage_pct:Math.round(e.pct),acs_verified:`${e.criteria.proven}/${e.criteria.total}`,usecases_covered:`${i.filter(s=>s==="covered").length}/${i.length}`,uncovered:i.filter(s=>s==="uncovered").length}}}}}var Wr={passed:"passed",failed:"failed",broken:"blocked"};function Jr(e,t,r){let n=e.edgesFrom(t).find(i=>i.type===ut.SCOPED_TO),o=n?e.tipOf(n.dst):r;return o===r?{type:"usecase",ref:x(e,r)}:{type:"scenario",ref:x(e,o)}}function Wt(e,t,r){let n=xt({graph:e,runs:t,thisRun:r}),{inScope:o}=ht(e),i=wt(e,new Set(o)),s=new Map(o.map(p=>[x(e,p),p])),a={},c=p=>F(e,p),u=n.perUc.map(p=>{let f=s.get(p.id),y=e.tipOf(f),d=mt(e,y,c).map(_=>gt(e,_,c,x)).sort((_,k)=>_.id<k.id?-1:1),m=(i.get(f)??[]).map(_=>{let k=x(e,_),L=e.getNode(_)?.content??{},V=bt(e,_).sort((g,P)=>x(e,g)<x(e,P)?-1:1),W=kt(e,t,_,V,r).sort((g,P)=>g.at<P.at?-1:g.at>P.at?1:0),M=n.perAc[k]?.this_run,J=V.length>0;a[k]={passes:W.filter(g=>g.verdict==="passed").length,counted:W.filter(g=>g.verdict==="passed"||g.verdict==="failed").length};let Fe=W.slice(-10).map(g=>({execution_id:g.executionId,ts:g.at,verdict:g.verdict,stale_at_run:!!g.fact.stale_at_run,oracle_mode:String(g.fact.oracle_mode),...g.fact.via_parent?{via_parent:String(g.fact.via_parent)}:{}}));return{id:k,text:String(L.text??""),risk:String(L.risk??""),scope:Jr(e,_,y),covered_by:V.map(g=>x(e,g)),...J?{link_type:"verifies"}:{},execution:M===void 0?"not-run":Wr[M]??"not-run",...M!==void 0?{this_run:M}:{},fresh:J&&M===void 0?"unknown":e.stale(_)==="fresh"?"fresh":"stale",derived:!!L.derived,..._t(L),...J?{satisfied_by:V.map(g=>{let P=e.getNode(g)?.content.check?.verified_against;return{test:x(e,g),...P?{step:P}:{}}})}:{},...Fe.length?{executions:Fe}:{}}}).sort((_,k)=>_.id<k.id?-1:1);return{...ft(e,f,x),scenarios:d,acceptance_criteria:m}}),l=vt(e);return{usecases:u,...l.length?{gaps:l}:{},rollup:Gr(n,a,l),coverage:n}}import{existsSync as Jt,readdirSync as Xr,readFileSync as Zr,statSync as Qr}from"fs";import{join as Pe}from"path";function Ae(e){let t=Pe(e,"tests");if(!Jt(t))return[];let r=[];for(let n of Xr(t).sort()){let o=Pe(t,n,"result.yaml");if(!Qr(Pe(t,n)).isDirectory()||!Jt(o))continue;let i=A(Zr(o,"utf8"));!i?.assurance_id&&!i?.definition_id||r.push({test:n,...i.assurance_id?{assuranceId:String(i.assurance_id)}:{},...i.definition_id?{definitionId:String(i.definition_id)}:{},...i.assurance_base?{base:String(i.assurance_base)}:{},verdict:String(i.status??""),acs:St(i.steps??[])})}return r}function en(e,t){if(t.assuranceId){let r=e.resolve(t.assuranceId),n=r?e.tipOf(r.cid):null;if(n!==null&&e.nodeLabel.get(n)===re.TEST&&F(e,n))return n}if(t.definitionId){for(let{cid:r,content:n}of e.byLabel(re.TEST))if(F(e,r)&&n.definitionId===t.definitionId)return r}return null}function Xt(e,t,r){let n=new Map,o=new Set;for(let i of t){let s=en(e,i);if(s===null||i.definitionId===void 0||r.definitionNow(e,s)!==i.definitionId)continue;let a=`${r.executionId}/${i.test}`;o.add(a);let c=n.get(s)??[];c.push({about:s,definition_id_at_run:i.definitionId,verdict:i.verdict,...i.acs.length?{per_ac:i.acs.map(u=>({ac_ref:u.ref,verdict:u.verdict}))}:{},drift_flag:!1,oracle_mode:"authored",stale_at_run:!1,execution_id:a,started_at:r.at,mode:"testmd",local:!0}),n.set(s,c)}return{runs:i=>n.get(e.tipOf(i))??[],thisRun:o}}var Zt=async(e,t,r)=>{if(t.kind==="grid")try{return Ae(e).some(i=>i.assuranceId)?{status:"pending",reason:"on_grid"}:{status:"skipped",reason:"not_assurance_project"}}catch{return{status:"pending",reason:"on_grid"}}if(t.kind==="none")return{status:"skipped",reason:t.reason};let n=Ce(e,"coverage"),o=tn(n);try{let i=Ae(e),s;if(t.kind==="lattice"){let a=await t.ask(i,r.executionId);if(a==="no_context")return{status:"skipped",reason:"no_use_cases_yet"};if(a==="no_answer")return{status:"pending",reason:"project_no_answer"};s=a}else{if(!t.store.exists())return{status:"skipped",reason:"not_assurance_project"};let a=dt(t.store);t.store.prefetch(pt(a),{token:null});let{runs:c,thisRun:u}=Xt(a,i,{executionId:r.executionId,at:new Date().toISOString(),definitionNow:yt});s=Wt(a,c,u);let l=new Set(s.coverage.this_run?.usecases??[]);Gt(e,t.store,{usecases:s.usecases.filter(p=>l.has(p.id))})}return rn(n,{recursive:!0}),on(Ce(n,"usecases.yaml"),b(s,{lineWidth:-1})),t.kind==="lattice"?{status:"written",computedBy:"project",project:t.project,doc:s.coverage}:{status:"written",computedBy:"local",doc:s.coverage}}catch(i){try{nn(o?Ce(n,"sources"):n,{recursive:!0,force:!0})}catch{}return{status:"failed",detail:i instanceof Error?i.message:String(i)}}};var sn=1e4,an=({url:e,basicAuth:t,projectId:r,body:n,budgetMs:o})=>Et({url:e,basicAuth:t,requestDeadlineMs:o}).coverageRun(r,n),cn=At("pack-coverage");function Qt(e,t={}){if((t.env??process.env).KANE_CLI_MODE==="hyperexecute")return{kind:"grid"};let r=Dt(e,t.address??$e());switch(r.kind){case"local":return{kind:"local",store:N(T(e))};case"refuse":return r.code==="BOTH_STORES"?{kind:"local",store:N(T(e))}:{kind:"none",reason:"project_file_unreadable"};case"remote":{let n=t.budgetMs??sn;return{kind:"lattice",project:r.projectName,ask:async(o,i)=>{try{let s=await(t.auth??Pt)(),a={execution_id:i,members:o.map(un)};return(await Ot((t.run??an)({url:r.latticeUrl,basicAuth:s,projectId:r.projectId,body:a,budgetMs:n}),n)).pack}catch(s){return s instanceof Rt&&s.code==="NO_CONTEXT"?"no_context":(cn(`the shared project's coverage wasn't read: ${s instanceof jt?s.message:Ct(s)}`),"no_answer")}}}}case"pick":return{kind:"none",reason:"not_assurance_project"}}}var un=e=>{let t=e.base??e.definitionId;return{...e.assuranceId?{assurance_id:e.assuranceId}:{},...t?{definition_id:t}:{},test:e.test,verdict:e.verdict,acs:e.acs}};async function ln(e){try{let t=new B({origin:"inline",runKind:"author",pid:e.pid,title:e.title,started:new Date().toISOString(),producerVersion:e.producerVersion,surfaces:e.surfaces,objectiveOrName:e.objectiveOrName,sessionId:e.sessionId,cwd:e.cwd,packRootDir:e.packRootDir}),r=await t.start();return{session:t,...r,packDir:t.pack,spawns:[],startedAtMs:Date.now(),cwd:e.cwd}}catch(t){return console.warn("evidence: inline pack creation failed",t),null}}function pn(e,t,r){if(!e)return;e.session.noteSpawn(t),t.resolution&&(e.resolution=t.resolution),e.runnerEnvironment=qe(e.runnerEnvironment,t.runnerEnvironment);let n=(r?.per_flow_metadata??[]).map(o=>({resultCode:o?.result_code!=null?Number(o.result_code):null}));e.spawns.push({resultCode:r?.result_code!=null?Number(r.result_code):null,...n.length?{perFlow:n}:{}})}function mn(e){if(e)return{packTestDir:e.packTestDir,ordinalOffset:e.session.nextOrdinalOffset()}}async function fn(e,t){if(!e)return null;if(e.finalized)return e.finalized;let r=(n,o,i)=>t.log?t.log("warn",n,o,i):console.warn(`evidence: ${o}`,i??"");try{if(t.recordedTestPath)try{await e.session.writeDefinition(await dn.readFile(t.recordedTestPath,"utf8"))}catch(c){r("EVIDENCE_DEFINITION_FAILED","could not attach synthesized test.md",{error:String(c)})}let n=t.cdpBrowserCapture?await t.cdpBrowserCapture():void 0,o=await e.session.writeResult({steps:e.session.steps,spawns:e.spawns.length?e.spawns:[{resultCode:null}],externalIdInput:{...t.externalIdInput,execution_id:e.executionId},runnerEnv:await He(Ee({cdpBrowser:n,resolution:e.resolution,runnerEnvironment:e.runnerEnvironment,deviceName:t.deviceName,deviceApp:t.deviceApp,pixelResolution:await Ye(e.packTestDir)}),{environment:t.environment,deviceModel:t.deviceModel,runnerEnvironment:e.runnerEnvironment}),intentEnv:We(t.model,e.runnerEnvironment),durationMs:t.durationMs??Date.now()-e.startedAtMs,log:t.log}),i=N(T(t.cwd??e.cwd??process.cwd()));try{if(t.recordedTestPath){let c=It({projectDir:t.cwd??e.cwd??process.cwd(),store:i,members:[{path:t.recordedTestPath,verdict:o,executionId:e.executionId,startedAt:new Date(e.startedAtMs).toISOString(),mode:"inline",local:t.local??!1}]});for(let u of c.warnings)r("EXEC_SYNC",u)}}catch(c){r("EXEC_SYNC","exec-sync failed",{error:String(c)})}let s;try{let c=t.cwd??e.cwd??process.cwd();s=await(t.coverageWriter??Zt)(e.packDir,(t.coverageSource??Qt)(c),{executionId:e.executionId}),(s.status==="skipped"||s.status==="failed")&&r("EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${s.status==="skipped"?s.reason:s.detail}`)}catch(c){s={status:"failed",detail:String(c)},r("EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(c)})}let a=await Re({executionId:e.executionId,testId:e.testId,saved:t.saved,runKind:"author",verdict:o,cwd:t.cwd??e.cwd,packDir:e.packDir,tuiLogPath:t.tuiLogPath,log:t.log,surface:"inline",requireRealLog:!!e.runnerEnvironment?.native_platform,appiumMarks:e.session.appiumMarks,catalog:t.environment?U(t.environment):void 0});return e.finalized={...a,coverage:s},t.log?.("info","EVIDENCE_SEALED","Inline pack sealed",{execution_id:e.executionId,verdict:o,valid:a.valid,pack:e.packDir,store_copy:a.storePath??null}),e.finalized}catch(n){return r("EVIDENCE_SEAL_FAILED","inline pack finalize failed",{error:String(n)}),null}}import{statSync as gn,openSync as _n,readSync as vn,closeSync as yn}from"fs";import{basename as hn,resolve as wn}from"path";async function bn(e,t,r={}){let n=r.out??(l=>process.stdout.write(l+`
5
5
  `)),o=l=>(n(`error: ${l}`),2);if(t.env!=="prod"&&t.env!=="stage")return o(`invalid --env: ${String(t.env)}`);if(t.port!==void 0&&(!Number.isInteger(t.port)||t.port<1||t.port>65535))return o("invalid --port: expected an integer 1-65535");let i;try{i=$(t.env,t.viewerUrl),new URL(i)}catch{return o(`invalid --viewer-url: ${t.viewerUrl}`)}if(e.length===0)return o("no pack paths given");let s=new Map;for(let l of e){let p=wn(l),f;try{f=gn(p)}catch{return o(`${l}: not found`)}if(f.isDirectory())return o(`${l}: is a directory \u2014 packs must be sealed .evidence files (run the execution to completion, or seal it, first)`);if(!f.isFile())return o(`${l}: not a regular file`);let y=Buffer.alloc(2),d=_n(p,"r");try{vn(d,y,0,2,0)}finally{yn(d)}if(y.toString("latin1")!=="PK")return o(`${l}: not a sealed evidence pack (zip magic missing)`);let m=hn(p);if(s.has(m))return o(`duplicate pack basename: ${m} (URL names collide \u2014 rename one)`);s.set(m,p)}let a=r.log??((l,p,f)=>process.stderr.write(`warn: ${p} reason=${f.reason} path=${f.path}
6
- `)),c;try{c=await ne({packs:s,allowedOrigins:[new URL(i).origin],port:t.port,log:a})}catch(l){return o(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${l.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${c.port}`);for(let l of s.keys()){let p=c.urlFor(l);n(l),n(` pack ${p}`),n(` viewer ${ie(p,i)}`)}return n("press Ctrl-C to stop"),await(r.hold??kn)(),await c.close(),0}function kn(){return new Promise(e=>{let t=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of t)process.on("SIGINT",r);e()})})}import{promises as G}from"fs";import{tmpdir as Rn}from"os";import{basename as En,join as rr,resolve as je}from"path";var xn=["error","prefer_first","prefer_latest","discard"],Sn=["external_id.commit_id","external_id.test_id","external_id.dataset_row_id","environment.os","environment.os_version","environment.browser","environment.browser_version","environment.device","environment.app"];function er(e){let t=e.replace(/-/g,"_");return xn.includes(t)?t:null}function tr(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...Sn],on_same:e??"nest",on_different:e?"error":"split"}};return b({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:t,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function De(e){try{if(!e.isTTY){e.log(oe(e.packPath));return}let t=$(e.env);await(e.renderPrompt??In)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function In(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-5ZN47FAT.js"),{EvidenceViewOffer:o}=await import("./EvidenceViewOffer-LKPN5BHX.js");await new Promise(i=>{let s=n(r.default.createElement(o,{packPath:e,viewerBase:t,onDone:()=>{s.unmount(),i()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}async function Pn(e,t,r=process.cwd(),n={}){let o=n.out??(d=>process.stdout.write(d+`
6
+ `)),c;try{c=await ne({packs:s,allowedOrigins:[new URL(i).origin],port:t.port,log:a})}catch(l){return o(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${l.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${c.port}`);for(let l of s.keys()){let p=c.urlFor(l);n(l),n(` pack ${p}`),n(` viewer ${ie(p,i)}`)}return n("press Ctrl-C to stop"),await(r.hold??kn)(),await c.close(),0}function kn(){return new Promise(e=>{let t=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of t)process.on("SIGINT",r);e()})})}import{promises as G}from"fs";import{tmpdir as Rn}from"os";import{basename as En,join as rr,resolve as je}from"path";var xn=["error","prefer_first","prefer_latest","discard"],Sn=["external_id.commit_id","external_id.test_id","external_id.dataset_row_id","environment.os","environment.os_version","environment.browser","environment.browser_version","environment.device","environment.app"];function er(e){let t=e.replace(/-/g,"_");return xn.includes(t)?t:null}function tr(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...Sn],on_same:e??"nest",on_different:e?"error":"split"}};return b({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:t,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function De(e){try{if(!e.isTTY){e.log(oe(e.packPath));return}let t=$(e.env);await(e.renderPrompt??In)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function In(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-5ZN47FAT.js"),{EvidenceViewOffer:o}=await import("./EvidenceViewOffer-6344EX74.js");await new Promise(i=>{let s=n(r.default.createElement(o,{packPath:e,viewerBase:t,onDone:()=>{s.unmount(),i()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}async function Pn(e,t,r=process.cwd(),n={}){let o=n.out??(d=>process.stdout.write(d+`
7
7
  `)),i=n.err??(d=>process.stderr.write(d+`
8
8
  `)),s=d=>(i(`evidence merge: ${d}`),2);if(!t.runId)return s("--run-id is required (merged identity is the caller's fact)");if(t.rules&&t.onCollision)return s("--rules and --on-collision are mutually exclusive");let a;if(t.onCollision!==void 0){let d=er(t.onCollision);if(!d)return s(`invalid --on-collision: ${t.onCollision} (expected error | prefer-first | prefer-latest | discard)`);a=d}let c=[];for(let d of e){let m=await Cn(d,r);if(!m)return s(`no pack found for "${d}"`);c.push(m)}let u=t.out?je(r,t.out):h(t.runId,r),l=[],p={files:t.policy??[],ids:t.policyId??[]};if(p.files.length+p.ids.length>0){if(!t.finalize)return s("--policy and --policy-id need a sealed merge (drop --no-finalize)");let d=await et(p,{cwd:r,fetchPolicy:n.fetchPolicy??tt({env:t.env})});if(!d.ok)return s(d.message);l=d.policies}let f=null,y;t.rules?y=je(r,t.rules):(f=await G.mkdtemp(rr(Rn(),"kane-merge-rules-")),y=rr(f,"merge-rules.yaml"),await G.writeFile(y,tr(a)));try{let d=await(n.mergeFn??Xe)(c,{runId:t.runId,out:u,rulesPath:y,title:t.title,finalize:!1});t.finalize&&(await(n.sealMergedFn??((k,L)=>An(k,L,U(t.env))))(u,Ze(d)),d={...d,output:{...d.output,finalized:!0}});let m=l.length?await nt(u,l,{judge:n.judge}):void 0;if(t.json)if(m){let{type:_,...k}=it(m,En(u,".evidence"));o(JSON.stringify({...d,verdict:{...k,verdicts:m.verdicts}}))}else o(JSON.stringify(d));else if(Dn(o,d),m){o(ot(m));for(let _ of m.files)o(` ${_}`)}return d.output.finalized&&!t.json&&await(n.offer??De)({packPath:u,env:t.env,isTTY:n.isTTY??(!!process.stdin.isTTY&&!!process.stderr.isTTY),log:i}),m?.filesError!==void 0?(i(`evidence merge: cannot write the verdict files: ${m.filesError}`),2):rt(0,m)}catch(d){let m=d instanceof Error?d.message:String(d);return d?.code==="ABORT"?(i(`evidence merge: aborted \u2014 ${m}`),1):s(m)}finally{f&&await G.rm(f,{recursive:!0,force:!0}).catch(()=>{})}}async function An(e,t,r){if(!t)throw new Error("cannot seal the merged pack: none of the merged packs records when it ended or started");await z(e,await r),await C(e,t)}async function Cn(e,t){let r=je(t,e);if(await nr(r))return r;let n=h(e,t);return await nr(n)?n:null}async function nr(e){try{return await G.stat(e),!0}catch{return!1}}function Dn(e,t){let{packs:r,tests:n,output:o}=t;e(`evidence: merged ${n.merged} tests from ${r.eligible.length} packs -> ${o.path} (${o.finalized?"sealed":"live"})`);for(let i of r.skipped)e(` skipped ${i.runId}: ${i.rule} \u2014 ${i.reason}`);for(let i of n.collisions){let s;i.action==="nest"?s=`nested into ${i.folder}, latest ${i.winner}`:i.action==="split"?s=`split into ${i.folder}`:s=`winner ${i.winner}`,e(` collision ${i.test}: ${s} (${i.rule})`)}for(let i of n.discarded)e(` discarded ${i}`)}import{copyFileSync as jn,existsSync as Oe,mkdirSync as On}from"fs";import{join as ir}from"path";function Ln(e,t,r){try{let n=ir(e,"auteur","execution.json");if(Oe(n))return!0;for(let o of t)if(!(!o||!Oe(o)))return On(ir(e,"auteur"),{recursive:!0}),jn(o,n),!0}catch(n){try{r?.("debug","EVIDENCE_BLOB_COPY_FAILED","auteur execution blob copy failed",{operation:"ensureAuteurExecution",source:t.find(o=>o&&Oe(o))??null,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{mkdirSync as Mn,writeFileSync as Fn}from"fs";import{join as or}from"path";function Tn(e,t,r){try{return Mn(or(e,"auteur"),{recursive:!0}),Fn(or(e,"auteur","dataset.json"),JSON.stringify(t,null,2)+`
9
9
  `,"utf8"),!0}catch(n){try{r?.("debug","EVIDENCE_DATASET_WRITE_FAILED","auteur dataset record write failed",{dataset_id:t.dataset_id,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{readFileSync as Nn}from"fs";import{join as $n}from"path";var sr="module_block";var Bn=new Set(["generative_block",sr]);function Me(e){let t=[],r=!0,n=i=>{if(i===null||typeof i!="object")return;let s=i;if(Array.isArray(s.operations))for(let a of s.operations){let c=a?.operation_id;typeof c=="string"&&c&&t.push(c)}if(Array.isArray(s.children)){Bn.has(s.content_type)||(r=!1);for(let a of s.children)n(a)}if(Array.isArray(s.branches)){r=!1;for(let a of s.branches){let c=a?.children;if(Array.isArray(c))for(let u of c)n(u)}}},o=e?.instructions;if(Array.isArray(o))for(let i of o)n(i);return{ids:t,linear:r}}function Vn(e){return Me(e).ids}function Le(e,t){let r=new Set(t.map(a=>a.action_id).filter(Boolean)),n=-1;for(let a of r){let c=e.indexOf(a);c>n&&(n=c)}let o=t.reduce((a,c)=>Math.max(a,c.ordinal),0),i=new Set,s=[];for(let a of e.slice(n+1))r.has(a)||i.has(a)||(i.add(a),s.push({id:a,ordinal:++o,status:"skipped",action_id:a}));return s}function ar(e,t){let r=new Set(t),n=e.filter(i=>i.action_id);if(n.some(i=>r.has(i.action_id))||n.length>t.length)return null;let o=0;return e.map(i=>i.action_id?{...i,action_id:t[o++]}:i)}function Un(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(t[r]!==e[r].action_id)return!1;return!0}function zn(e,t,r,n=!0){if(t.length===0)return{steps:e,tail:[]};let o=(r&&n?ar(e,t):null)??e,i=o.filter(a=>a.action_id),s=new Set(t);return i.length>0&&i.every(a=>s.has(a.action_id))?{steps:o,tail:Le(t,o)}:i.length>0&&!Un(i,t)?{steps:o,tail:[],unjoined:!0}:{steps:o,tail:Le(t,o)}}function cr(e){try{let t=Nn($n(e,"auteur","execution.json"),"utf8");return Me(JSON.parse(t))}catch{return{ids:[],linear:!0}}}function Yn(e){return cr(e).ids}export{j as a,se as b,ae as c,ce as d,ue as e,de as f,le as g,lr as h,pe as i,me as j,pr as k,mr as l,fe as m,H as n,ve as o,ye as p,he as q,we as r,fr as s,be as t,gr as u,ke as v,xe as w,Se as x,Vt as y,Re as z,Ee as A,Yt as B,Lr as C,B as D,Vr as E,Zt as F,Qt as G,ln as H,pn as I,mn as J,fn as K,bn as L,tr as M,De as N,Pn as O,Ln as P,Tn as Q,sr as R,Me as S,Vn as T,Le as U,ar as V,zn as W,cr as X,Yn as Y};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O,d as S}from"./chunk-P4VFC6HO.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-UJLULWSR.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-33DWJV67.js";import{a as B}from"./chunk-6YGTRKDT.js";import{z as s}from"./chunk-FAMQ4DHU.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
2
+ import{b as O,d as S}from"./chunk-35WUYKGO.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-UJLULWSR.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-33DWJV67.js";import{a as B}from"./chunk-6YGTRKDT.js";import{z as s}from"./chunk-J4FIESTB.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
@@ -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-PEUIHME2.js";import{a as ae}from"./chunk-RDAIOJCR.js";import{k as re,l as oe}from"./chunk-LXCTV75T.js";import{a as C,b as k}from"./chunk-TAY7J5VS.js";import{c as de,d as ce,f as le}from"./chunk-2COXO5LQ.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-H4TIVILC.js";import{a as S}from"./chunk-RQKMSNEU.js";import{a as w}from"./chunk-4C7WVQOD.js";import{oa as L}from"./chunk-PI7OXS62.js";import{a as p}from"./chunk-FOJHSG5M.js";import{z as I}from"./chunk-FAMQ4DHU.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-VO2NNXKR.js";import{a as ae}from"./chunk-SXBPUUQ5.js";import{k as re,l as oe}from"./chunk-4CJQ7XZP.js";import{a as C,b as k}from"./chunk-TAY7J5VS.js";import{c as de,d as ce,f as le}from"./chunk-YNDELIXL.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-WE7HRAGO.js";import{a as S}from"./chunk-RQKMSNEU.js";import{a as w}from"./chunk-4C7WVQOD.js";import{oa as L}from"./chunk-PI7OXS62.js";import{a as p}from"./chunk-FOJHSG5M.js";import{z as I}from"./chunk-J4FIESTB.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,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{f as y,h as z,j as U}from"./chunk-YDB72F4K.js";import{b as N,c as O,e as S,f as D,j as T}from"./chunk-77ZZQJLX.js";import{a as Y}from"./chunk-JIRNI5TB.js";import{a as M}from"./chunk-UTM7D4PI.js";import{a as R}from"./chunk-FCD3NYOM.js";import{a as F}from"./chunk-B7ZX5HEN.js";import{a as A}from"./chunk-FAMQ4DHU.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let a=[s];for(let n of l.steps)for(let c of n.trace.slice(1))a.includes(c.file)||a.push(c.file);Q(a);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let c=N(n.file);o.includes(c)||o.push(c),n.kind==="module"&&d.push(S(n.file))}let m=[...a],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let x=m.map(n=>{let c=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
2
+ import{f as y,h as z,j as U}from"./chunk-YDB72F4K.js";import{b as N,c as O,e as S,f as D,j as T}from"./chunk-77ZZQJLX.js";import{a as Y}from"./chunk-JIRNI5TB.js";import{a as M}from"./chunk-UTM7D4PI.js";import{a as R}from"./chunk-FCD3NYOM.js";import{a as F}from"./chunk-B7ZX5HEN.js";import{a as A}from"./chunk-J4FIESTB.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let a=[s];for(let n of l.steps)for(let c of n.trace.slice(1))a.includes(c.file)||a.push(c.file);Q(a);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let c=N(n.file);o.includes(c)||o.push(c),n.kind==="module"&&d.push(S(n.file))}let m=[...a],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let x=m.map(n=>{let c=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
3
3
  `):void 0,E=c??I(n);return{abs:n,rel:B(P(f,n)),sha256:q("sha256").update(E).digest("hex"),bytes:E.length,...c?{contents:c}:{}}}).sort((n,c)=>n.rel<c.rel?-1:1),w=B(P(f,s)),L={schema_version:2,entry:w,commit_id:t.identityOverride?.commit_id??i.commit_id,test_id:i.test_id,testcase_id:i.testcase_id??null,project_id:i.project_id??null,folder_id:i.folder_id??null,org_id:i.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:A},files:x.map(n=>({path:n.rel,sha256:n.sha256,bytes:n.bytes})),units:l.unitFiles.filter(n=>n.file!==s).map(n=>({path:B(P(f,n.file)),kind:n.kind}))};return{zipRoot:f,entry:w,files:x,manifest:L}}var g=e=>e instanceof Error?e.message:String(e);function W(e){return new Promise((t,s)=>{let r=(0,C.default)("zip",{zlib:{level:6}}),i=[];r.on("data",l=>i.push(l)),r.on("error",s),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
4
4
  `,{name:b});for(let l of e.files)l.contents?r.append(l.contents,{name:l.rel}):r.file(l.abs,{name:l.rel});r.finalize()})}async function X(e){let{plan:t,controller:s,testId:r,sessionId:i,commitId:l}=e,a;try{a=await W(t)}catch(d){return{ok:!1,stage:"zip",error:g(d)}}let o;try{let d={key:"testmd",content_type:"application/zip",filename:`${l}-testmd.zip`},p=(await s.getPresignedUrls(r,i,[d])).urls?.testmd?.upload_url;if(!p)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};o=p}catch(d){return{ok:!1,stage:"presign",error:g(d)}}try{await M(o,a,"application/zip")}catch(d){return{ok:!1,stage:"upload",error:g(d)}}return{ok:!0,bytes:a.length}}async function ee(e){let t;try{t=j(e.sourcePath,{identityOverride:e.identityOverride})}catch(s){return s instanceof u?{ok:!1,stage:"collect",error:s.message}:{ok:!1,stage:"collect",error:g(s)}}return X({...e,plan:t})}function ge(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}function te(e){return e.persisted?e.uploadSucceeded?e.local?"local":e.hasBasicAuth?!e.metaCommitId||!e.metaTestId?"not_authored":null:"no_auth":"upload_failed":"not_persisted"}async function ye(e){let t=e.recordedTestPath??null,s=t?y(t):null,r=te({persisted:!!t,uploadSucceeded:e.uploadSucceeded,local:e.local,hasBasicAuth:!!e.basicAuth,metaCommitId:s?.commit_id,metaTestId:s?.test_id});if(r)return e.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:r,...t?{path:t}:{}}),{skipped:r};let i=s.commit_id,l=s.test_id,a=o=>{try{e.onAgentEvent?.(o)}catch{}};try{let o=await(e.syncFn??ee)({sourcePath:t,testId:l,sessionId:e.sessionId,commitId:i,controller:new R(e.controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})});return o.ok?(e.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:i,path:t,bytes:o.bytes}),a({type:"test_md_bundle_sync",status:"ok",commit_id:i,path:t,bytes:o.bytes})):(e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:i,path:t,stage:o.stage,error:o.error}),a({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:o.stage})),o}catch(o){let d=g(o);return e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{commit_id:i,path:t,error:d}),a({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:"upload"}),{ok:!1,stage:"upload",error:d}}}export{j as a,W as b,X as c,ee as d,ge as e,te as f,ye as g};
@@ -0,0 +1,34 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as C,d as P}from"./chunk-OCVDMZWB.js";import{d as I}from"./chunk-F2F257PU.js";import{e as x}from"./chunk-5D7ENQTQ.js";import{b,e as R}from"./chunk-KL7XFNSD.js";import{f as D,h as S,l as E}from"./chunk-KQ4XKTIZ.js";import{b as _,c as N,g as k,h as A}from"./chunk-WLEWXE6L.js";import{b as h}from"./chunk-LPJKNX6D.js";import{a as v}from"./chunk-ZCBOHWN3.js";import{h as w}from"./chunk-A7RJQJNT.js";import{mkdirSync as q,writeFileSync as z}from"fs";import{join as J}from"path";function $(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||v(e).mobileAppBaseUrl}var G="device-config.json",T=new WeakMap;function X(e,t){let r=T.get(e)??new Map;T.set(e,r);let n=JSON.stringify([t.path,t.type,t.env,t.orgId]),o=r.get(n);if(o)return o;let i=e(t).finally(()=>r.delete(n));return r.set(n,i),i}function U(e){return e.startsWith("lt://")?e:`lt://${e}`}async function Y(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 Q(e,t){let r=e.selection.app.value.trim();if(h(r))return U(r);let n=e.credentials;if(!n?.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 o=await X(t,{path:r,type:e.platform,env:e.env,orgId:n.orgId,userId:n.userId??"",auth:{username:n.username,accessKey:n.accessKey,orgId:n.orgId},baseUrl:$(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if(b(o))throw new Error(`could not upload ${r} for this real-device run: ${o.reason}`);return U(o.appUrl??o.appId)}async function V(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 Y(e,t.fetchCatalog??S);let r=await Q(e,t.upload??R),{deviceName:n,osVersion:o}=e.selection,i={platform_name:e.platform,device_name:n?.value??D,...o?{platform_version:o.value}:{},app:r,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},a=J(e.outDir,G);return q(e.outDir,{recursive:!0}),z(a,`${JSON.stringify(i,null,2)}
3
+ `),{device:{platform:e.platform,target:e.platform,device_config_path:a},...n?{deviceName:n.value}:{},...o?{osVersion:o.value}:{},app:r}}import{createServer as Z}from"http";import{randomBytes as ee}from"crypto";import{spawn as re}from"child_process";import{mkdtempSync as te,readdirSync as ne,readFileSync as oe,rmSync as ie,writeFileSync as se}from"fs";import{tmpdir as M}from"os";import{join as y}from"path";function O(e,t,r,n){let o=Buffer.from(`${n.username}:${n.accessKey}`).toString("base64"),i=new URLSearchParams({session:r,auth:o});return t==="ios"&&i.set("mode","webrtc"),`${e.replace(/\/+$/,"")}/?${i.toString()}`}function W(e){return e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}function ae(e){return`<!doctype html>
4
+ <html lang="en">
5
+ <head>
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <title>${W(e.title)}</title>
9
+ <style>
10
+ html, body { margin: 0; height: 100%; background: #111; font-family: system-ui, sans-serif; }
11
+ iframe { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; }
12
+ #guard { position: fixed; inset: 0; cursor: not-allowed; background: transparent; }
13
+ #badge, #ended { position: fixed; left: 50%; transform: translateX(-50%); padding: 6px 12px;
14
+ border-radius: 999px; font-size: 13px; color: #fff; background: rgba(0, 0, 0, 0.7); }
15
+ #badge { bottom: 16px; }
16
+ #ended { top: 16px; display: none; background: #b42318; }
17
+ </style>
18
+ </head>
19
+ <body>
20
+ <iframe src="${W(e.streamUrl)}" allow="autoplay; fullscreen"></iframe>
21
+ ${e.viewOnly?'<div id="guard"></div>':""}
22
+ <div id="badge">View only \u2014 the test is driving this device</div>
23
+ <div id="ended">The session ended</div>
24
+ <script>
25
+ // kane-cli answers while the run lives; once it stops, say so.
26
+ setInterval(() => {
27
+ fetch(location.pathname + "/alive", { cache: "no-store" })
28
+ .then((r) => { if (!r.ok) throw new Error(); })
29
+ .catch(() => { document.getElementById("ended").style.display = "block"; });
30
+ }, 3000);
31
+ </script>
32
+ </body>
33
+ </html>
34
+ `}async function B(e){let t=`/${ee(16).toString("hex")}`,r=ae(e),n=Z((a,s)=>{if(a.url===t){s.writeHead(200,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),s.end(r);return}if(a.url===`${t}/alive`){s.writeHead(204),s.end();return}s.writeHead(404),s.end()});await new Promise((a,s)=>{n.once("error",s),n.listen(0,"127.0.0.1",()=>a())}),n.unref();let o=n.address();return{url:`http://127.0.0.1:${typeof o=="object"&&o?o.port:0}${t}`,close:()=>n.close()}}function j(e){let r=e?.width,n=e?.height;return!r||!n?{width:400,height:820}:{width:Math.min(1200,Math.max(320,Math.round(820*r/n))),height:820}}function ce(e,t,r){return[`--app=${e}`,`--user-data-dir=${t}`,`--window-size=${r.width},${r.height}`,"--no-first-run","--no-default-browser-check","--autoplay-policy=no-user-gesture-required"]}var le=3e3;async function L(e,t,r=le){if(!P())throw new Error("Google Chrome is not installed (or set KANE_CLI_CHROME_PATH).");me();let n=te(y(M(),K));se(y(n,F),String(process.pid));let o=re(C(),ce(e,n,t),{stdio:"ignore",detached:process.platform!=="win32"});o.unref();let i=()=>H(n);await new Promise((u,g)=>{let c=setTimeout(()=>{o.off("error",l),o.off("exit",p),u()},r);c.unref();function l(d){clearTimeout(c),i(),g(new Error(`Chrome did not start: ${d.message}`))}function p(d,m){clearTimeout(c),i(),g(new Error(`Chrome quit as it opened (${m??`exit code ${d}`}).`))}o.once("error",l),o.once("exit",p)}),o.on("error",()=>{}),o.once("exit",i);let a=()=>f();process.once("exit",a);let s=!1;function f(){if(!s){s=!0,process.off("exit",a);try{o.pid&&process.platform!=="win32"?process.kill(-o.pid):o.kill()}catch{}i()}}return f}var K="kane-device-view-",F="kane-cli.pid";function H(e){try{ie(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch{}}function de(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function me(e=M()){let t;try{t=ne(e).filter(r=>r.startsWith(K))}catch{return}for(let r of t){let n=y(e,r),o=NaN;try{o=Number(oe(y(n,F),"utf8"))}catch{}Number.isInteger(o)&&o>0&&de(o)||H(n)}}function Oe(e){return e.flag===!1||e.mobile?.device_stream===!1?"off":e.interactive?"open":"off"}function fe(e){let t=e.basicAuth;if(!t)return;let r=e.resolvedCreds;return{username:t.username,accessKey:t.access_key,...r?.org_id?{orgId:String(r.org_id)}:{},...r?.user_id?{userId:String(r.user_id)}:{}}}async function Be(e){let t=fe(e.auth),r=e.selection?await V({platform:e.target,selection:e.selection,env:e.env,outDir:e.sessionDir,...t?{credentials:t}:{},testName:e.testName,...e.tcId?{tcId:e.tcId}:{},capabilities:{...x(e.mobile,e.target),...I(e.tunnel)},onProgress:e.write,onWarning:c=>e.write(`warning: ${c}`)}):_({platform:e.target,hasCredentials:!!t});!e.selection&&e.tunnel&&e.write("warning: --tunnel is ignored: this run's device config names its own tunnel"),e.write(N(e.target,e.selection?e.tunnel:null));let n=r.app?.replace(/^lt:\/\//,""),o=A(e.target,r.app,e.write),i,a,s=!1,f=!1,u=()=>{f=!0,a?.(),i?.close()},g=c=>{let l=c.type==="run_start"&&!c.child_id?c.environment?.device:void 0,p=l?.session_id;if(s||!p||!t||(e.stream??"off")==="off")return;s=!0;let d=k(l);B({streamUrl:O(v(e.env).deviceStreamUrl,w(e.target),p,t),title:d?`${d} \u2014 live`:"Real device \u2014 live",viewOnly:e.target==="android"}).then(async m=>{i=m,a=await(e.openWindow??L)(m.url,j(l)),f?u():e.write("Showing the device in its own window.")}).catch(m=>{i?.close(),e.write(`note: no live view of the device \u2014 ${m.message}`)})};return{device:r.device,...r.deviceName?{deviceName:r.deviceName}:{},...r.osVersion?{osVersion:r.osVersion}:{},...r.app?{app:r.app}:{},...h(n)?{appId:n}:{},announce:c=>{o(c),g(c)},stopStream:u}}var pe="infra_error.device_lost";function je(e){return e?.reason_code===pe}export{$ as a,Oe as b,fe as c,Be as d,je as e};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-M7Y5GGVJ.js";import{e as d}from"./chunk-6K5BEEAJ.js";import{r as a}from"./chunk-UJLULWSR.js";import{a as y}from"./chunk-FI2DVNRT.js";import{a as h}from"./chunk-K75WIRI5.js";var $=10,u=200,C=1e4,N=1e6;function k(t,e,r="streaming"){let n=r==="full-fetch"?N:C,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function S(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function b(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as j}from"./chunk-X45RZIAJ.js";import{e as d}from"./chunk-SB26HQO7.js";import{r as a}from"./chunk-UJLULWSR.js";import{a as y}from"./chunk-ZCBOHWN3.js";import{a as h}from"./chunk-TM45NPWL.js";var $=10,u=200,C=1e4,N=1e6;function k(t,e,r="streaming"){let n=r==="full-fetch"?N:C,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function S(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function b(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function T(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:m}=await import("./token-refresh-K6PVBBFE.js"),w=await m({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(m){return{ok:!1,reason:"refresh_failed",detail:m instanceof Error?m.message:String(m)}}let c=y(e),f=await new j(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:m}=await import("./token-refresh-E4FTJVHY.js"),w=await m({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(m){return{ok:!1,reason:"refresh_failed",detail:m instanceof Error?m.message:String(m)}}let c=y(e),f=await new j(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function M(t){return{id:t.project_id,name:t.name}}function O(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function x(t,e=r=>process.stdout.write(`${r}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-PVN64537.js";import{e as y}from"./chunk-ZAQGIC33.js";import{b as d}from"./chunk-FI2DVNRT.js";function g(t={}){let a=t.readStore??C,s=t.readLis??w;return{async controller(){let e=await a();return{token:e.token,...e.basic?{basic:e.basic}:{}}},async lis(){return s()}}}var A=()=>C(!0),_=g(),P=8e3;function f(){return y("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function h(t,a,s=!1){try{let[{getEnvironment:e},{ControllerClient:r}]=await Promise.all([import("./config-YMHI3H3Y.js"),import("./controller-client-PB3AZAGG.js")]),o=new r(e(t).controllerBaseUrl,a),i;try{let n=await Promise.race([o.getTmsCredentials().catch(()=>null),new Promise(c=>{i=setTimeout(()=>c(null),P)})]);if(typeof n?.username!="string"||!n.username||typeof n.access_key!="string"||!n.access_key)return s?null:f();try{let[{refreshIdentitySnapshot:c},{telemetryEnvName:u}]=await Promise.all([import("./identity-HL5CJJXR.js"),import("./bootstrap-JEVSVPQ2.js")]);await c(u(),n)}catch{}return{username:n.username,accessKey:n.access_key}}finally{clearTimeout(i)}}catch{return s?null:f()}}var l=null;function E(t){l=t===null?null:{username:t.username,accessKey:t.accessKey}}async function C(t=!1){if(l!==null)return{token:null,basic:{...l}};let[{CredentialsManager:a},{refreshOAuthToken:s}]=await Promise.all([import("./credentials-BCR73VGS.js"),import("./token-refresh-K6PVBBFE.js")]),e=new a,r=d(),o=e.getActiveProfile()??"default",i=e.loadBasicAuth(o,r);if(i)return{token:null,basic:{username:i.username,accessKey:i.access_key}};let n=e.loadCredentials(o,r);if(!n)throw new m("Not authenticated \u2014 no credentials found","not_authenticated");try{await s({creds:e,profile:o,env:r,credentials:n})}catch{}let c=e.loadCredentials(o,r)??n;if(typeof c.access_token!="string")throw new m("Not authenticated \u2014 no credentials found","not_authenticated");let u=c.access_token,p=await h(r,u,t);return{token:u,...p?{basic:p}:{}}}async function w(){if(l!==null)return{basic:Buffer.from(`${l.username}:${l.accessKey}`,"utf8").toString("base64")};let{CredentialsManager:t}=await import("./credentials-BCR73VGS.js"),a=new t,s=d(),e=a.loadCredentials(a.getActiveProfile()??"default",s);if(typeof e?.access_token!="string")return{};let r=await h(s,e.access_token,!0);return r?{basic:Buffer.from(`${r.username}:${r.accessKey}`,"utf8").toString("base64")}:{}}export{A as a,_ as b,E as c};
2
+ import{a as m}from"./chunk-PVN64537.js";import{e as y}from"./chunk-ZAQGIC33.js";import{b as d}from"./chunk-ZCBOHWN3.js";function g(t={}){let a=t.readStore??C,s=t.readLis??w;return{async controller(){let e=await a();return{token:e.token,...e.basic?{basic:e.basic}:{}}},async lis(){return s()}}}var A=()=>C(!0),_=g(),P=8e3;function f(){return y("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function h(t,a,s=!1){try{let[{getEnvironment:e},{ControllerClient:r}]=await Promise.all([import("./config-7WTZPMAH.js"),import("./controller-client-PB3AZAGG.js")]),o=new r(e(t).controllerBaseUrl,a),i;try{let n=await Promise.race([o.getTmsCredentials().catch(()=>null),new Promise(c=>{i=setTimeout(()=>c(null),P)})]);if(typeof n?.username!="string"||!n.username||typeof n.access_key!="string"||!n.access_key)return s?null:f();try{let[{refreshIdentitySnapshot:c},{telemetryEnvName:u}]=await Promise.all([import("./identity-HL5CJJXR.js"),import("./bootstrap-XGKU4WXB.js")]);await c(u(),n)}catch{}return{username:n.username,accessKey:n.access_key}}finally{clearTimeout(i)}}catch{return s?null:f()}}var l=null;function E(t){l=t===null?null:{username:t.username,accessKey:t.accessKey}}async function C(t=!1){if(l!==null)return{token:null,basic:{...l}};let[{CredentialsManager:a},{refreshOAuthToken:s}]=await Promise.all([import("./credentials-5WIFF5DG.js"),import("./token-refresh-E4FTJVHY.js")]),e=new a,r=d(),o=e.getActiveProfile()??"default",i=e.loadBasicAuth(o,r);if(i)return{token:null,basic:{username:i.username,accessKey:i.access_key}};let n=e.loadCredentials(o,r);if(!n)throw new m("Not authenticated \u2014 no credentials found","not_authenticated");try{await s({creds:e,profile:o,env:r,credentials:n})}catch{}let c=e.loadCredentials(o,r)??n;if(typeof c.access_token!="string")throw new m("Not authenticated \u2014 no credentials found","not_authenticated");let u=c.access_token,p=await h(r,u,t);return{token:u,...p?{basic:p}:{}}}async function w(){if(l!==null)return{basic:Buffer.from(`${l.username}:${l.accessKey}`,"utf8").toString("base64")};let{CredentialsManager:t}=await import("./credentials-5WIFF5DG.js"),a=new t,s=d(),e=a.loadCredentials(a.getActiveProfile()??"default",s);if(typeof e?.access_token!="string")return{};let r=await h(s,e.access_token,!0);return r?{basic:Buffer.from(`${r.username}:${r.accessKey}`,"utf8").toString("base64")}:{}}export{A as a,_ as b,E as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B}from"./chunk-5Y2G4NC7.js";import{a as T}from"./chunk-HCBYKLMW.js";import{a as S,b as l,k as w}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-FAMQ4DHU.js";import{e as k}from"./chunk-UR6MHSHU.js";var y=k(J(),1);var r=k(T(),1),v=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function H(e){let n=e.replace(/…$/,"");return n&&n.charAt(0).toLowerCase()+n.slice(1)}function j(e,n){if(e.length<=n)return e;if(n<=1)return"\u2026";let p=Math.ceil((n-1)/2),b=Math.floor((n-1)/2);return`${e.slice(0,p)}\u2026${b>0?e.slice(-b):""}`}function K({status:e,meta:n,tallies:p,keys:b,child:d,cols:C,remote:A=!1,gapAbove:M=!1,accent:u=o.assuranceAccent}){let{stdout:R}=w(),m=C??R?.columns??80,L=e.kind==="working"||e.kind==="child-working",[E,O]=(0,y.useState)(0);B(()=>O(a=>a+1),L?120:null);let $=v[E%v.length],i,s;switch(e.kind){case"working":i=`${$} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,s=u;break;case"waiting":i=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:e.label?` \u2014 ${e.label}`:""}`,s=o.amber;break;case"retrying":i=`\u25CF ${e.text}`,s=o.amber;break;case"idle":i="\u25CF idle",s=u;break;case"card":i=`\u25CF card ${e.n} of ${e.m}`,s=o.amber;break;case"child-working":i=`${$} child: ${e.step}`,s=u;break;case"child-waiting":i="\u25CF child waiting on you",s=o.amber;break}let f=d?`${n.verb} \u25B8 ${d.verb}`:n.verb,F=d?.sid?n.sid?`${j(n.sid,14)} \u25B8 ${d.sid}`:d.sid:n.sid,h=n.env==="prod"?"":n.env,t=" \xB7 ",P=16,x=a=>i.length+t.length+[f,a,h].filter(Boolean).join(t).length,c=F,I=m-x(c)-t.length;A&&c&&(n.subject?I<Math.min(n.subject.length,P):x(c)>m)&&(c="");let N=[f,c,h].filter(Boolean),q=i.length+t.length+N.join(t).length,g=n.subject;if(g){let a=m-q-t.length;g=a>=8?j(g,a):void 0}let D=[f,...g?[g]:[],c,h].filter(Boolean).join(t);return(0,r.jsxs)(S,{flexDirection:"column",marginTop:M?1:0,children:[(0,r.jsx)(l,{color:o.muted,children:"\u2500".repeat(Math.max(1,m))}),(0,r.jsxs)(l,{children:[(0,r.jsx)(l,{color:s,children:i}),(0,r.jsx)(l,{color:o.dim,children:`${t}${D}`})]}),(0,r.jsx)(l,{color:o.dim,children:p.items.length>0?p.items.join(t):" "}),(0,r.jsx)(l,{color:o.muted,children:b.join(t)})]})}export{H as a,K as b};
2
+ import{a as B}from"./chunk-5Y2G4NC7.js";import{a as T}from"./chunk-HCBYKLMW.js";import{a as S,b as l,k as w}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-J4FIESTB.js";import{e as k}from"./chunk-UR6MHSHU.js";var y=k(J(),1);var r=k(T(),1),v=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function H(e){let n=e.replace(/…$/,"");return n&&n.charAt(0).toLowerCase()+n.slice(1)}function j(e,n){if(e.length<=n)return e;if(n<=1)return"\u2026";let p=Math.ceil((n-1)/2),b=Math.floor((n-1)/2);return`${e.slice(0,p)}\u2026${b>0?e.slice(-b):""}`}function K({status:e,meta:n,tallies:p,keys:b,child:d,cols:C,remote:A=!1,gapAbove:M=!1,accent:u=o.assuranceAccent}){let{stdout:R}=w(),m=C??R?.columns??80,L=e.kind==="working"||e.kind==="child-working",[E,O]=(0,y.useState)(0);B(()=>O(a=>a+1),L?120:null);let $=v[E%v.length],i,s;switch(e.kind){case"working":i=`${$} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,s=u;break;case"waiting":i=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:e.label?` \u2014 ${e.label}`:""}`,s=o.amber;break;case"retrying":i=`\u25CF ${e.text}`,s=o.amber;break;case"idle":i="\u25CF idle",s=u;break;case"card":i=`\u25CF card ${e.n} of ${e.m}`,s=o.amber;break;case"child-working":i=`${$} child: ${e.step}`,s=u;break;case"child-waiting":i="\u25CF child waiting on you",s=o.amber;break}let f=d?`${n.verb} \u25B8 ${d.verb}`:n.verb,F=d?.sid?n.sid?`${j(n.sid,14)} \u25B8 ${d.sid}`:d.sid:n.sid,h=n.env==="prod"?"":n.env,t=" \xB7 ",P=16,x=a=>i.length+t.length+[f,a,h].filter(Boolean).join(t).length,c=F,I=m-x(c)-t.length;A&&c&&(n.subject?I<Math.min(n.subject.length,P):x(c)>m)&&(c="");let N=[f,c,h].filter(Boolean),q=i.length+t.length+N.join(t).length,g=n.subject;if(g){let a=m-q-t.length;g=a>=8?j(g,a):void 0}let D=[f,...g?[g]:[],c,h].filter(Boolean).join(t);return(0,r.jsxs)(S,{flexDirection:"column",marginTop:M?1:0,children:[(0,r.jsx)(l,{color:o.muted,children:"\u2500".repeat(Math.max(1,m))}),(0,r.jsxs)(l,{children:[(0,r.jsx)(l,{color:s,children:i}),(0,r.jsx)(l,{color:o.dim,children:`${t}${D}`})]}),(0,r.jsx)(l,{color:o.dim,children:p.items.length>0?p.items.join(t):" "}),(0,r.jsx)(l,{color:o.muted,children:b.join(t)})]})}export{H as a,K as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as D}from"./chunk-KGNE5CIM.js";import{a as ue,b as te,d as ce,e as R,k as de}from"./chunk-GQARXS6F.js";import{mkdirSync as Be,writeFileSync as Ae}from"fs";import{join as X}from"path";var ve="start LT with --env ht-stage|ht-prod --tunnelName <name>; see kane-cli explore run --help";function me(t){if(/either tunnel is not running or disconnected/i.test(t))return`remote browser: no running LT tunnel found for this run (HPS: either tunnel is not running or disconnected)
2
+ import{a as D}from"./chunk-KGNE5CIM.js";import{a as ue,b as te,d as ce,e as R,k as de}from"./chunk-NPAUSUNM.js";import{mkdirSync as Be,writeFileSync as Ae}from"fs";import{join as X}from"path";var ve="start LT with --env ht-stage|ht-prod --tunnelName <name>; see kane-cli explore run --help";function me(t){if(/either tunnel is not running or disconnected/i.test(t))return`remote browser: no running LT tunnel found for this run (HPS: either tunnel is not running or disconnected)
3
3
  next: ${ve}`;let e=/WebSocket error: \S*\/kane-cli\S* (5\d\d)\b/.exec(t)?.[1];if(e){let r=Ee(t);return`remote browser: HPS answered HTTP ${e} to the connect${r?` (HPS: ${r})`:""} (on a tunnel run: the tunnel service failed); run again, and report it to the platform team if it persists`}return null}function Ee(t){let e=t.split(`
4
4
  `).slice(1).find(i=>i.trim()&&!/^Call log:/.test(i.trim())&&!/^\s*-\s*</.test(i));if(!e)return null;let r=e.trim();try{let i=JSON.parse(r),s=i?.value?.message??i?.message;typeof s=="string"&&s.trim()&&(r=s.trim())}catch{}return r=r.replace(/\b(?:wss?|https?):\/\/\S+/g,"<url>"),r.length>300?r.slice(0,300)+"\u2026":r}var Se={baseMs:500,maxMs:3e4},W=class{o;backoff;sleep;nextSeq;draining=null;stopDeadline=null;wake=null;_state="open";_refusal=null;_fatal=null;_committedThisRun=0;constructor(e){this.o=e,this.backoff=e.backoff??Se,this.sleep=e.sleep??(r=>new Promise(i=>setTimeout(i,r))),this.nextSeq=Math.max(e.firstSeq,e.queue.lastParked+1)}get state(){return this._state}get refusal(){return this._refusal}get fatal(){return this._fatal}get pendingCount(){return this.o.queue.pendingCount}get committedThisRun(){return this._committedThisRun}get lastCommitted(){return this.o.queue.lastCommitted}enqueue(e){return e.run_id!==this.o.runId?{ok:!1,code:"RUN_MISMATCH",reason:`delta ${e.seq} names run ${e.run_id}, this run is ${this.o.runId}`}:!Number.isInteger(e.seq)||e.seq!==this.nextSeq?{ok:!1,code:"SEQUENCE_LOCAL",reason:`expected seq ${this.nextSeq} for run ${this.o.runId}, received ${String(e.seq)}`}:(this.o.queue.append(e),this.nextSeq=e.seq+1,this.kick(),{ok:!0})}kick(){this._state==="open"&&(this.draining||(this.draining=this.drainLoop().catch(e=>(this.markFatal(this.o.queue.pending()[0]?.seq??-1,"LOCAL_IO",e instanceof Error?e.message:String(e)),"stopped")).then(e=>{this.draining=null,e==="empty"&&this._state==="open"&&this.o.queue.pendingCount>0&&this.kick()})))}async flush(e){if(this.stopDeadline=Date.now()+e,this.kick(),this.wake){let r=this.wake;this.wake=null,r()}for(;this.draining;)await this.draining;return this.o.queue.pendingCount}async drainLoop(){let e=0;for(;this._state==="open";){let r=this.o.queue.pending()[0];if(!r)return"empty";let i=this.o.queue.refused(r.seq);if(i)return this.refuse(r.seq,i.code,`previously refused: ${i.reason}`,!1),"stopped";let s=await this.o.client.commitDelta(this.o.explorationId,this.o.runId,r);switch(s.kind){case"committed":e=0,this.o.queue.markCommitted(r.seq),this._committedThisRun++,this.o.onAck?.(r.seq);break;case"refused":return this.refuse(r.seq,s.code,s.reason,!0),"stopped";case"fatal":return this.markFatal(r.seq,s.code,s.reason),"stopped";case"transient":{e++;let a=Math.min(this.backoff.maxMs,this.backoff.baseMs*2**(e-1));if(this.stopDeadline!==null&&Date.now()+a>this.stopDeadline)return"deadline";this.o.onRetry?.(r.seq,e,s.reason,a),await this.interruptibleSleep(a);break}}}return"stopped"}markFatal(e,r,i){this._state="fatal",this._fatal={seq:e,code:r,reason:i},this.o.onFatal?.(e,r,i)}refuse(e,r,i,s){s&&this.o.queue.markRefused(e,r,i,{controller_wire:this.o.controllerWire,client_wire:ue}),this._state="refused",this._refusal={seq:e,code:r,reason:i},this.o.onRefused?.(e,r,i)}async interruptibleSleep(e){await Promise.race([this.sleep(e),new Promise(r=>{this.wake=r})]),this.wake=null}};import{appendFileSync as Ce,closeSync as $e,existsSync as Pe,fsyncSync as Te,mkdirSync as Ie,openSync as De,readFileSync as Me}from"fs";import{dirname as Oe,join as Le}from"path";var Fe="pending-deltas.ndjson",Q=class{path;deltas=new Map;committed=new Set;refusedBySeq=new Map;tornTail=!1;constructor(e){this.path=Le(e,Fe),this.load()}append(e){let r=this.deltas.get(e.seq);if(r){if(JSON.stringify(r)===JSON.stringify(e))return;throw new Error(`pending queue already holds a different delta for seq ${e.seq}`)}this.write({op:"delta",seq:e.seq,delta:e}),this.deltas.set(e.seq,e)}markCommitted(e){this.committed.has(e)||(this.write({op:"committed",seq:e}),this.committed.add(e))}markRefused(e,r,i,s={}){let a={...s.controller_wire?{controller_wire:s.controller_wire}:{},...s.client_wire?{client_wire:s.client_wire}:{}};this.write({op:"refused",seq:e,code:r,reason:i,...a}),this.refusedBySeq.set(e,{seq:e,code:r,reason:i,...a})}pending(){return[...this.deltas.entries()].filter(([e])=>!this.committed.has(e)).sort(([e],[r])=>e-r).map(([,e])=>e)}get pendingCount(){return this.pending().length}get lastCommitted(){let e=0;for(let r of this.committed)e=Math.max(e,r);return e}get lastParked(){let e=0;for(let r of this.deltas.keys())e=Math.max(e,r);return e}refused(e){return this.refusedBySeq.get(e)}load(){if(!Pe(this.path))return;let e=Me(this.path,"utf8");this.tornTail=e.length>0&&!e.endsWith(`
5
5
  `);let r=e.split(`