@testmuai/kane-cli 0.10.4 → 0.10.5

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 (235) hide show
  1. package/dist/{ChatSurface-DN7VVN3Y.js → ChatSurface-WKYH5MYP.js} +1 -1
  2. package/dist/{ChromeProfilePicker-TVGWXTUU.js → ChromeProfilePicker-ROQIRMWR.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-L5ILK66U.js → CliFeedbackPrompt-55OKAT4W.js} +1 -1
  4. package/dist/{CliUploadProgress-IU6BQLMV.js → CliUploadProgress-NK2U3CKQ.js} +1 -1
  5. package/dist/{ConfigView-LU5IRRQU.js → ConfigView-7A5JTKLF.js} +1 -1
  6. package/dist/{EvidenceViewOffer-DNTARDEL.js → EvidenceViewOffer-U7J5ZRVK.js} +1 -1
  7. package/dist/{FolderPicker-6E5GE2K2.js → FolderPicker-R4QDIFTW.js} +1 -1
  8. package/dist/{InfoBox-SFFPLWCV.js → InfoBox-SRQ4TSUT.js} +1 -1
  9. package/dist/{LinksBox-6YDTIO6I.js → LinksBox-7BWLLQVR.js} +1 -1
  10. package/dist/{ProfilesView-6C5HJQ3Y.js → ProfilesView-TQTJR4WQ.js} +1 -1
  11. package/dist/{ProjectPicker-YIQIVXGK.js → ProjectPicker-A5SXNDUL.js} +1 -1
  12. package/dist/{SaveSessionPrompt-X3N6OGYB.js → SaveSessionPrompt-IECYZMXW.js} +1 -1
  13. package/dist/SingleShotApp-MN5IE6EU.js +2 -0
  14. package/dist/{SummaryBox-T7PDXDKS.js → SummaryBox-WFOS6GON.js} +1 -1
  15. package/dist/{TestMdRunView-HRJSBP2C.js → TestMdRunView-URNSXIVC.js} +1 -1
  16. package/dist/TestrunEvidenceTable-SZPZMW3J.js +2 -0
  17. package/dist/{WhoamiView-WGCWD7GP.js → WhoamiView-G6QP4SID.js} +1 -1
  18. package/dist/{app-download-ZS6ZMX2Z.js → app-download-UGLDWWTX.js} +1 -1
  19. package/dist/{assurance-job-QO4VJJCL.js → assurance-job-V5QB36WJ.js} +1 -1
  20. package/dist/{binary-CCCTW3QQ.js → binary-32FXH6PQ.js} +1 -1
  21. package/dist/{bind-JU4XPDN3.js → bind-3PB77PWJ.js} +1 -1
  22. package/dist/{bootstrap-BV7HAARR.js → bootstrap-A2O4UZUJ.js} +1 -1
  23. package/dist/{catalog-ZAROGOJA.js → catalog-P5IOIVYP.js} +1 -1
  24. package/dist/{catalog-client-QLHCEPPZ.js → catalog-client-LR2KPSU7.js} +1 -1
  25. package/dist/{changelog-6L7W76ZH.js → changelog-GKIKDJ32.js} +1 -1
  26. package/dist/{chunk-FTP2K6RS.js → chunk-2AHQ3D3D.js} +1 -1
  27. package/dist/{chunk-SZQNYDST.js → chunk-2G7UYQOW.js} +1 -1
  28. package/dist/{chunk-3O2RPYPM.js → chunk-2MBNAW2G.js} +1 -1
  29. package/dist/{chunk-SO3IXFAJ.js → chunk-2NP3THOE.js} +1 -1
  30. package/dist/{chunk-YZP4F23B.js → chunk-37KFCYHG.js} +1 -1
  31. package/dist/{chunk-Z4O5HOFX.js → chunk-3RJRCAUX.js} +3 -3
  32. package/dist/{chunk-PBVNX43X.js → chunk-4DM5EWEV.js} +1 -1
  33. package/dist/{chunk-QYWWL7M7.js → chunk-5K7PCSTP.js} +1 -1
  34. package/dist/{chunk-LCBDNZL3.js → chunk-5LKDOE3P.js} +1 -1
  35. package/dist/{chunk-ZVSZ6DIQ.js → chunk-5OFHMBZC.js} +2 -2
  36. package/dist/{chunk-SMSQVGLH.js → chunk-63BFLTJI.js} +1 -1
  37. package/dist/{chunk-PMYN3XMN.js → chunk-642GD7E6.js} +1 -1
  38. package/dist/{chunk-HMGM4KO6.js → chunk-66C5A2F5.js} +1 -1
  39. package/dist/{chunk-3HGKFRFL.js → chunk-6OL5EVRC.js} +1 -1
  40. package/dist/{chunk-LLDEAV3W.js → chunk-6PZ3SVWE.js} +1 -1
  41. package/dist/{chunk-7V6JPZBM.js → chunk-6VG2FG67.js} +1 -1
  42. package/dist/{chunk-Q5B54TR5.js → chunk-6WN4WSXR.js} +1 -1
  43. package/dist/{chunk-TO2ROHIJ.js → chunk-76MKY7FG.js} +2 -2
  44. package/dist/{chunk-2CJ75THZ.js → chunk-77BZTEHJ.js} +1 -1
  45. package/dist/chunk-7TSM2FCL.js +5 -0
  46. package/dist/{chunk-ECPSBI2Z.js → chunk-A5C7HIAH.js} +1 -1
  47. package/dist/{chunk-BV7NUIRT.js → chunk-AXOSLGQ4.js} +1 -1
  48. package/dist/{chunk-DJ76NDW6.js → chunk-BDZWRJAL.js} +1 -1
  49. package/dist/{chunk-6PURZLKM.js → chunk-BFRWZPIK.js} +1 -1
  50. package/dist/{chunk-MWLRLQ27.js → chunk-BLHFNL5K.js} +1 -1
  51. package/dist/chunk-BRWCWZE3.js +2 -0
  52. package/dist/{chunk-IQMJJN52.js → chunk-BZEW7CSM.js} +1 -1
  53. package/dist/{chunk-TXRWH6HL.js → chunk-C466XER3.js} +2 -2
  54. package/dist/{chunk-55W3WAAL.js → chunk-C4UME2PA.js} +1 -1
  55. package/dist/{chunk-ZHENGHYZ.js → chunk-CBPACEYQ.js} +1 -1
  56. package/dist/{chunk-IDWAG6L4.js → chunk-CJGQFKLJ.js} +1 -1
  57. package/dist/{chunk-4G2T54FE.js → chunk-CQBLJTDU.js} +1 -1
  58. package/dist/{chunk-BPTWMV5L.js → chunk-CVVUBCB7.js} +1 -1
  59. package/dist/{chunk-4WFN23DE.js → chunk-EIQSXD7B.js} +1 -1
  60. package/dist/{chunk-AFOP7DVG.js → chunk-EP4WGGMY.js} +1 -1
  61. package/dist/{chunk-S5PIVHPC.js → chunk-F4GWIX66.js} +1 -1
  62. package/dist/{chunk-GMSWZIAS.js → chunk-FHULYIG3.js} +1 -1
  63. package/dist/{chunk-JE5M5QIK.js → chunk-FKA5SWWF.js} +1 -1
  64. package/dist/{chunk-WHMCVH3T.js → chunk-FLGOQ6Q6.js} +1 -1
  65. package/dist/{chunk-ABNQL3PQ.js → chunk-FNBHP75S.js} +1 -1
  66. package/dist/{chunk-GJYMR4RT.js → chunk-FOURJ24E.js} +1 -1
  67. package/dist/{chunk-UZKVV3LW.js → chunk-FOUUD3LI.js} +1 -1
  68. package/dist/{chunk-CVVZ6NWR.js → chunk-FP6JCXOS.js} +1 -1
  69. package/dist/{chunk-WMIR4UXG.js → chunk-H23ZMHHC.js} +1 -1
  70. package/dist/{chunk-ZFKR5I3J.js → chunk-HHF7AM3D.js} +1 -1
  71. package/dist/{chunk-6CMBA5SG.js → chunk-HTJDMLZS.js} +1 -1
  72. package/dist/{chunk-DRWHVVW6.js → chunk-HY5BBSYX.js} +1 -1
  73. package/dist/{chunk-RG3FNO37.js → chunk-IPXITNFD.js} +1 -1
  74. package/dist/{chunk-EWSNJ3IX.js → chunk-IT6M7OMG.js} +1 -1
  75. package/dist/{chunk-5OGYXLOR.js → chunk-ITG5WMQG.js} +1 -1
  76. package/dist/{chunk-MZ4GTIO2.js → chunk-J3YID4A5.js} +1 -1
  77. package/dist/{chunk-TELSHQ3W.js → chunk-J44FV6CH.js} +1 -1
  78. package/dist/{chunk-JYSIPTX3.js → chunk-J5D4IGAM.js} +1 -1
  79. package/dist/{chunk-WB4JZ67W.js → chunk-J5QFO7LW.js} +1 -1
  80. package/dist/{chunk-EOLMWSLX.js → chunk-JGQ3VB44.js} +1 -1
  81. package/dist/{chunk-MOAZZKIZ.js → chunk-JVXEAO62.js} +1 -1
  82. package/dist/{chunk-YWQNZRJG.js → chunk-JYH7CTF7.js} +1 -1
  83. package/dist/{chunk-FH4FWIET.js → chunk-JZ7GFPKZ.js} +1 -1
  84. package/dist/{chunk-I3G3IUKY.js → chunk-KUSHV5SR.js} +1 -1
  85. package/dist/{chunk-NMCE7VR2.js → chunk-LMOW4NM5.js} +1 -1
  86. package/dist/{chunk-UVBPUZC4.js → chunk-LPJX5L3F.js} +1 -1
  87. package/dist/{chunk-4FA44D6S.js → chunk-LWP7E5FU.js} +1 -1
  88. package/dist/{chunk-MQU6EA44.js → chunk-LXYXCANZ.js} +1 -1
  89. package/dist/{chunk-5HJRYEOT.js → chunk-MAQVRBUQ.js} +1 -1
  90. package/dist/{chunk-4WKFM72U.js → chunk-MBNSCXVK.js} +1 -1
  91. package/dist/{chunk-P7V24ZXP.js → chunk-MIQ6J5YG.js} +1 -1
  92. package/dist/{chunk-454IWKHT.js → chunk-MUL2QFG2.js} +1 -1
  93. package/dist/{chunk-DBMDAWTA.js → chunk-N4XUGIAK.js} +1 -1
  94. package/dist/{chunk-ACBNVGVJ.js → chunk-NAUIJF72.js} +1 -1
  95. package/dist/{chunk-QFA6JPVE.js → chunk-NFDVDEOH.js} +2 -2
  96. package/dist/{chunk-BIXABKSK.js → chunk-NGBXXBHP.js} +1 -1
  97. package/dist/{chunk-RNKJXVG2.js → chunk-NIBNVPAE.js} +1 -1
  98. package/dist/{chunk-DAV4ONGS.js → chunk-NNVHWFLI.js} +1 -1
  99. package/dist/{chunk-QOXUGYEA.js → chunk-NZ7UCAN6.js} +1 -1
  100. package/dist/{chunk-HGKAUG7L.js → chunk-OPR5XIPT.js} +1 -1
  101. package/dist/{chunk-QXZGBYGQ.js → chunk-PCL2FYPE.js} +1 -1
  102. package/dist/{chunk-KJZD2ADR.js → chunk-PE3CEG6E.js} +1 -1
  103. package/dist/{chunk-3VSAAB2W.js → chunk-PKXWYYVK.js} +1 -1
  104. package/dist/{chunk-56NUPYFG.js → chunk-PSBR2LVL.js} +1 -1
  105. package/dist/{chunk-H6QHG62O.js → chunk-PZOQ2IQK.js} +1 -1
  106. package/dist/{chunk-2VLM4L3S.js → chunk-Q4QCSO6Y.js} +1 -1
  107. package/dist/{chunk-MNELOQ4J.js → chunk-QJ5XHVS5.js} +1 -1
  108. package/dist/{chunk-JJDD4HPX.js → chunk-QRUAI2ST.js} +1 -1
  109. package/dist/{chunk-2KPJ62RZ.js → chunk-QWEQ742S.js} +1 -1
  110. package/dist/{chunk-DXXHCLFC.js → chunk-R6S4EJ5R.js} +1 -1
  111. package/dist/{chunk-7WWCIS2B.js → chunk-RHQLDNZL.js} +1 -1
  112. package/dist/{chunk-X3O4VGTM.js → chunk-RM5ZVDVR.js} +1 -1
  113. package/dist/{chunk-4KFSSETE.js → chunk-RU3SWHRE.js} +1 -1
  114. package/dist/{chunk-662MCICY.js → chunk-S5UITUBB.js} +1 -1
  115. package/dist/{chunk-T5FQRUI2.js → chunk-SACFQNUH.js} +7 -7
  116. package/dist/{chunk-EG3B52WU.js → chunk-SDIHDYWT.js} +1 -1
  117. package/dist/{chunk-GPIVYCHQ.js → chunk-SFHDRKUX.js} +1 -1
  118. package/dist/{chunk-EWK3UPEN.js → chunk-SLISNOG6.js} +1 -1
  119. package/dist/{chunk-OSEXVHEN.js → chunk-TC2PHBPH.js} +1 -1
  120. package/dist/{chunk-FQ2AMM3E.js → chunk-TPCW5OU5.js} +1 -1
  121. package/dist/{chunk-P43YHCF3.js → chunk-UJYC2XDD.js} +1 -1
  122. package/dist/chunk-UV7FPIBL.js +2 -0
  123. package/dist/{chunk-A74JRNNX.js → chunk-UWEBI76C.js} +1 -1
  124. package/dist/{chunk-LV7OWLJK.js → chunk-UWQ4KXLB.js} +1 -1
  125. package/dist/{chunk-73EHVDL5.js → chunk-V24LUINK.js} +1 -1
  126. package/dist/{chunk-OX3ZAGCH.js → chunk-V3IWCGZT.js} +1 -1
  127. package/dist/{chunk-4QV2RL6P.js → chunk-VEE2O524.js} +1 -1
  128. package/dist/{chunk-3JATEWA5.js → chunk-VJRXJJML.js} +2 -2
  129. package/dist/{chunk-JM45SLKV.js → chunk-VKIUHHNT.js} +2 -2
  130. package/dist/{chunk-7KASYSFM.js → chunk-W3PQMIXE.js} +1 -1
  131. package/dist/{chunk-S74NLCFZ.js → chunk-WAC5WISH.js} +1 -1
  132. package/dist/{chunk-KLY6IQD5.js → chunk-XJV5SF3X.js} +3 -3
  133. package/dist/{chunk-ATCJ7EHL.js → chunk-XRJH4UF3.js} +1 -1
  134. package/dist/{chunk-SBW3QVHN.js → chunk-Y3RDLUH5.js} +5 -5
  135. package/dist/{chunk-BXAPTB2H.js → chunk-YF22VTR5.js} +3 -3
  136. package/dist/{chunk-TLYFHPNM.js → chunk-YLI7DQMJ.js} +2 -2
  137. package/dist/{chunk-BK3LWNKB.js → chunk-YQXOD7SV.js} +3 -3
  138. package/dist/{chunk-PHKJIJ7D.js → chunk-YTWBNACA.js} +1 -1
  139. package/dist/{chunk-QEBVYQNC.js → chunk-YUFXE6WU.js} +1 -1
  140. package/dist/{commands-X5T6YANK.js → commands-TRAUFCRZ.js} +1 -1
  141. package/dist/{config-F5Q6QX27.js → config-O3BWQUP4.js} +1 -1
  142. package/dist/{cover-cmd-PWUZU4HK.js → cover-cmd-SAWVP7TL.js} +1 -1
  143. package/dist/{credentials-D5KQMHCK.js → credentials-NNNODDXF.js} +1 -1
  144. package/dist/{deps-bundle-R7FNIV4M.js → deps-bundle-CXKBCA7W.js} +1 -1
  145. package/dist/{deps-resolve-IF6P6NWI.js → deps-resolve-K7XNTRZX.js} +1 -1
  146. package/dist/{design-chat-HYK3HNIM.js → design-chat-S4KYE6PP.js} +1 -1
  147. package/dist/{design-headless-DR7WB37W.js → design-headless-DDAFAJNR.js} +1 -1
  148. package/dist/{design-remote-TGUNEWEM.js → design-remote-UITWJ72Q.js} +2 -2
  149. package/dist/device-env-SBTHFSVK.js +2 -0
  150. package/dist/doctor-SRMLENYN.js +2 -0
  151. package/dist/{evidence-SRWISQMQ.js → evidence-FOWW3MOS.js} +1 -1
  152. package/dist/{evolve-cmd-2BALEYZU.js → evolve-cmd-MDK2H4JY.js} +1 -1
  153. package/dist/{evolve-remote-OHOUWO65.js → evolve-remote-4G7YFC5H.js} +1 -1
  154. package/dist/{explain-cmd-VTDAMXAW.js → explain-cmd-Q4NLNJFB.js} +1 -1
  155. package/dist/{explore-UZWQRJ7H.js → explore-MWUMVGRM.js} +1 -1
  156. package/dist/{explore-context-tty-PAKJVDJU.js → explore-context-tty-QLMZGYBX.js} +1 -1
  157. package/dist/{explore-entry-ZOPO7DBZ.js → explore-entry-QMCVGRP4.js} +4 -4
  158. package/dist/{explore-live-RUAAZGX4.js → explore-live-QIET6WO4.js} +1 -1
  159. package/dist/{explore-run-tty-DYLMHI7F.js → explore-run-tty-6UTBRCEF.js} +2 -2
  160. package/dist/{extract-bind-WPICR4IC.js → extract-bind-UTERWZMW.js} +3 -3
  161. package/dist/{extract-chat-KVUB5HPM.js → extract-chat-4WBNRVPG.js} +1 -1
  162. package/dist/{extract-cmd-OJ7LXSKL.js → extract-cmd-SYZX6CML.js} +2 -2
  163. package/dist/{extract-headless-OQJSUSG4.js → extract-headless-QBF77JWP.js} +1 -1
  164. package/dist/{folder-flags-MEZUAXTT.js → folder-flags-IJ556UET.js} +1 -1
  165. package/dist/{gaps-cmd-2R4RMWN6.js → gaps-cmd-E55OGZ7P.js} +1 -1
  166. package/dist/{gate-SM4HPJLA.js → gate-5UIJVMHL.js} +1 -1
  167. package/dist/{generate-headless-XR3RVULC.js → generate-headless-VYD2QIUO.js} +2 -2
  168. package/dist/{impact-cmd-EL3QSOAF.js → impact-cmd-3P6SKFJC.js} +2 -2
  169. package/dist/index.js +20 -20
  170. package/dist/{ingest-cmd-N3USC7TW.js → ingest-cmd-HMTLO5MB.js} +3 -3
  171. package/dist/{ingest-remote-2VKWAFJZ.js → ingest-remote-NIW5VAGW.js} +1 -1
  172. package/dist/install-KJDAGU2R.js +2 -0
  173. package/dist/{interactive-bind-F7QTQOKC.js → interactive-bind-K3ZQFHLH.js} +2 -2
  174. package/dist/{interactive-remote-A33J4KMP.js → interactive-remote-SGM76D6M.js} +1 -1
  175. package/dist/{lattice-auth-IJT542IF.js → lattice-auth-DCAVEQKY.js} +1 -1
  176. package/dist/{lifecycle-cmd-OKUFZKEX.js → lifecycle-cmd-Y5DH2PL5.js} +1 -1
  177. package/dist/{list-cmd-7OTI66MQ.js → list-cmd-RYHICCUV.js} +1 -1
  178. package/dist/{list-commands-FZPVH76I.js → list-commands-QFTIQE6Q.js} +1 -1
  179. package/dist/{list-remote-BQ4NILCA.js → list-remote-PWAQBF57.js} +1 -1
  180. package/dist/login-flow-W7RAVXSD.js +2 -0
  181. package/dist/{maintenance-cmd-BLV7K4RK.js → maintenance-cmd-JNP2KCSI.js} +1 -1
  182. package/dist/{mobile-prompts-5TGLJUBV.js → mobile-prompts-SP2RULD7.js} +1 -1
  183. package/dist/{onboarding-F4EIJ4GD.js → onboarding-YPIKXNYA.js} +1 -1
  184. package/dist/{persist-recorded-session-WYMOHDTB.js → persist-recorded-session-BWGA7WXR.js} +1 -1
  185. package/dist/{pipeline-XYM6HIDZ.js → pipeline-YE4IRKQX.js} +1 -1
  186. package/dist/{policy-commands-AOLVAZZD.js → policy-commands-MSJIPHDB.js} +1 -1
  187. package/dist/{prepare-target-P4AZWC37.js → prepare-target-G7LU4LYX.js} +1 -1
  188. package/dist/{pull-cmd-C4HMYD4I.js → pull-cmd-G3PVSSFP.js} +1 -1
  189. package/dist/{pull-route-MHW5PWDW.js → pull-route-5JQUUSU7.js} +1 -1
  190. package/dist/real-device-run-425XK527.js +2 -0
  191. package/dist/{reconcile-cmd-VXY737OT.js → reconcile-cmd-QJBYZVUB.js} +4 -4
  192. package/dist/{reconcile-remote-UGW2433E.js → reconcile-remote-JMV26DLX.js} +2 -2
  193. package/dist/{recording-banner-EPOTSMYF.js → recording-banner-VZ67EWWQ.js} +1 -1
  194. package/dist/{registry-WTWTFRXD.js → registry-3YMKU5GC.js} +1 -1
  195. package/dist/{remote-entry-SPA4CSJJ.js → remote-entry-6LQRYR5F.js} +1 -1
  196. package/dist/{remote-mode-QO6BDGXM.js → remote-mode-35BQUMEL.js} +1 -1
  197. package/dist/{remote-words-TAZT4YBT.js → remote-words-QXVFVHOB.js} +1 -1
  198. package/dist/{require-project-folder-WBCAVVMB.js → require-project-folder-O2XCXDRE.js} +1 -1
  199. package/dist/{resolve-run-intent-RBOCIYEA.js → resolve-run-intent-QCRZPYXM.js} +1 -1
  200. package/dist/{resolver-3BGIXYYJ.js → resolver-LWXOB7PH.js} +1 -1
  201. package/dist/{review-cmd-WE6I5XTY.js → review-cmd-PYU7YCAC.js} +1 -1
  202. package/dist/{run-remote-6Y62RWMJ.js → run-remote-PS45MTHW.js} +1 -1
  203. package/dist/{run-startup-gate-Q7FP2IRE.js → run-startup-gate-YBQB2JLF.js} +1 -1
  204. package/dist/{run-test-md-24MBKBC6.js → run-test-md-XYOCVA6F.js} +2 -2
  205. package/dist/session-worker.js +2 -2
  206. package/dist/{sessions-cmd-5NS5P4CP.js → sessions-cmd-WUWZYZJW.js} +1 -1
  207. package/dist/{sessions-remote-75PDRPOY.js → sessions-remote-4J7ITZB4.js} +1 -1
  208. package/dist/{skill-installer-7PK64TZE.js → skill-installer-54ZAFNOB.js} +1 -1
  209. package/dist/{store-AVYBL5HB.js → store-2F26FIUS.js} +1 -1
  210. package/dist/{store-choice-ZWU3PDNL.js → store-choice-ZE7AZMRC.js} +1 -1
  211. package/dist/{store-guard-ETUXXG7X.js → store-guard-X5FIEZWZ.js} +1 -1
  212. package/dist/{sync-cmd-CSTMT6E6.js → sync-cmd-TAVE44DU.js} +1 -1
  213. package/dist/{sync-setup-Y53K6TJ6.js → sync-setup-M65RX34Y.js} +1 -1
  214. package/dist/tcg-generate-OXZF7TNQ.js +2 -0
  215. package/dist/{testmd-actions-BE4YJ6ZZ.js → testmd-actions-4OHRME2Z.js} +1 -1
  216. package/dist/{testmd-sync-QZWVWTZZ.js → testmd-sync-HM24JCS7.js} +1 -1
  217. package/dist/token-refresh-3SEDPIXO.js +2 -0
  218. package/dist/{validate-basic-QWPESO74.js → validate-basic-HWDR665U.js} +1 -1
  219. package/dist/{version-check-EOYWTY3Z.js → version-check-DRE5KT7F.js} +1 -1
  220. package/dist/{view-cmd-KG4HI334.js → view-cmd-3UKV3YEX.js} +1 -1
  221. package/dist/{walk-session-WM4S2JMV.js → walk-session-W6OLG5NT.js} +1 -1
  222. package/dist/{with-telemetry-RJM3JKL6.js → with-telemetry-BF4BGK5S.js} +1 -1
  223. package/package.json +11 -11
  224. package/dist/SingleShotApp-MXNJPU6A.js +0 -2
  225. package/dist/TestrunEvidenceTable-OGMWTJQF.js +0 -2
  226. package/dist/chunk-APXJRWIJ.js +0 -2
  227. package/dist/chunk-V57R4X3O.js +0 -5
  228. package/dist/chunk-YKOZBFR3.js +0 -2
  229. package/dist/device-env-LZB3PKMA.js +0 -2
  230. package/dist/doctor-PLFEA2HM.js +0 -2
  231. package/dist/install-3IEM3I3X.js +0 -2
  232. package/dist/login-flow-BYQ7SYGB.js +0 -2
  233. package/dist/real-device-run-WAOWKEFJ.js +0 -2
  234. package/dist/tcg-generate-VQLI6NGK.js +0 -2
  235. package/dist/token-refresh-PZ3TOKAL.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as kr,c as Rr,d as Er,e as Sr,f as Ir}from"./chunk-4WFN23DE.js";import{a as _r,b as Lr,c as jr,d as Tr,e as Cr}from"./chunk-MOAZZKIZ.js";import{c as Vr}from"./chunk-4KFSSETE.js";import{c as z,d as Pe,f as Pr,g as $r,k as Mr,l as me,m as fe,q as Y,v as Hr}from"./chunk-EWK3UPEN.js";import{b as Te,d as le}from"./chunk-ZUZ6QJRA.js";import{a as de,b as L}from"./chunk-KGNE5CIM.js";import{a as mr,b as fr}from"./chunk-6PURZLKM.js";import{b as Ce,c as gr,d as hr,e as xr,f as ue,g as ce,h as wr,i as br,j as yr,k as vr,m as w,n as Q,o as Br,p as Ae,q as Oe,r as Ue,s as Ne}from"./chunk-P7V24ZXP.js";import{e as J,l as pe,n as $e,q as Ar,r as Or,s as Ur,t as Nr}from"./chunk-4WKFM72U.js";import{d as je,f as D}from"./chunk-OSEXVHEN.js";import{a as cr,b as dr}from"./chunk-FQ2AMM3E.js";import{a as lr}from"./chunk-HMGM4KO6.js";import{l as pr}from"./chunk-BV7NUIRT.js";import{a as ur}from"./chunk-UTM7D4PI.js";import{a as sr,b as Le,d as ir}from"./chunk-SBW3QVHN.js";import{b as or}from"./chunk-QXZGBYGQ.js";import{e as tr}from"./chunk-WHMCVH3T.js";import{b as rr}from"./chunk-F2F257PU.js";import{e as nr}from"./chunk-SB26HQO7.js";import{a as er}from"./chunk-FCD3NYOM.js";import{a as ar}from"./chunk-PVN64537.js";import{b as Se}from"./chunk-IQMJJN52.js";import{g as Ie}from"./chunk-CBEMXSWF.js";import{a as X}from"./chunk-4QTH7VYE.js";import{a as ae}from"./chunk-73EHVDL5.js";import{a as ie}from"./chunk-YWQNZRJG.js";import{a as V,b as se,z as ze}from"./chunk-YKOZBFR3.js";import{m as Qe,n as Ye}from"./chunk-WMXBRC4B.js";import{a as q}from"./chunk-RZ4F3BHX.js";import{a as Ze}from"./chunk-FOJHSG5M.js";import{join as De}from"path";function Dr(e){let r=e.now??Date.now,n=r(),t=!1,o=null,i=null,u=e.hxJobId,h=0,a=null,c=l=>({exploration_id:l?.explorationId??o,run_id:l?.runId??i});return{observe:l=>{switch(l.type){case"explore_run_started":typeof l.exploration_id=="string"&&(o=l.exploration_id),typeof l.run_id=="string"&&(i=l.run_id);return;case"explore_remote_started":typeof l.run_id=="string"&&(i=l.run_id),typeof l.hx_job_id=="string"&&(u=l.hx_job_id);return;case"lease_end":h++;return;case"explore_end":l.totals&&typeof l.totals=="object"&&(a=l.totals);return;default:return}},started:()=>t,markStarted:()=>{t=!0},startFields:()=>({...c(),remote:e.remote,on_vm:e.onVm,hx_job_id:u,policy:e.policy,max_parallel:e.maxParallel,max_leases:e.maxLeases}),endFields:l=>({...c(l),remote:e.remote,on_vm:e.onVm,hx_job_id:u,outcome:l.state==="queued"?"queued":l.remark?.code??(l.exitCode===0?"completed":"error"),stop_reason:l.stopReason??null,exit_code:l.exitCode,duration_ms:r()-n,leases:typeof a?.leases=="number"?a.leases:h,findings:typeof a?.findings=="number"?a.findings:null,committed:l.committed??0,pending:l.pending??0,complete:l.complete??!1,credits_total:l.credits?.total??null,peak_parallel:l.peakParallel??null}),errorFields:l=>{if(l.exitCode===0||l.exitCode===3&&!l.error)return null;let f=l.remark?.code?.startsWith("failed:")?l.remark.code:l.exitCode===2?"usage":l.stopReason??"explore_error";return{...c(l),error_code:f,exit_code:l.exitCode,stage:t?"run":"setup",...l.error?{error:l.error}:{}}}}}import{appendFileSync as dt,mkdirSync as pt}from"fs";import{dirname as mt}from"path";function Fr(e,r,n){if(r)try{pt(mt(r),{recursive:!0})}catch{}let t="",o=u=>{if(!(!r||!u))try{dt(r,n(u))}catch{}};e.child.stderr?.on("data",u=>{t+=u.toString();let h=t.lastIndexOf(`
2
+ import{b as kr,c as Rr,d as Er,e as Sr,f as Ir}from"./chunk-EIQSXD7B.js";import{a as _r,b as Lr,c as jr,d as Tr,e as Cr}from"./chunk-JVXEAO62.js";import{c as Vr}from"./chunk-RU3SWHRE.js";import{c as z,d as Pe,f as Pr,g as $r,k as Mr,l as me,m as fe,q as Y,v as Hr}from"./chunk-SLISNOG6.js";import{b as Te,d as le}from"./chunk-ZUZ6QJRA.js";import{a as de,b as L}from"./chunk-KGNE5CIM.js";import{a as mr,b as fr}from"./chunk-BFRWZPIK.js";import{b as Ce,c as gr,d as hr,e as xr,f as ue,g as ce,h as wr,i as br,j as yr,k as vr,m as w,n as Q,o as Br,p as Ae,q as Oe,r as Ue,s as Ne}from"./chunk-MIQ6J5YG.js";import{e as J,l as pe,n as $e,q as Ar,r as Or,s as Ur,t as Nr}from"./chunk-MBNSCXVK.js";import{d as je,f as D}from"./chunk-TC2PHBPH.js";import{a as cr,b as dr}from"./chunk-TPCW5OU5.js";import{a as lr}from"./chunk-66C5A2F5.js";import{l as pr}from"./chunk-AXOSLGQ4.js";import{a as ur}from"./chunk-UTM7D4PI.js";import{a as sr,b as Le,d as ir}from"./chunk-Y3RDLUH5.js";import{b as or}from"./chunk-PCL2FYPE.js";import{e as tr}from"./chunk-FLGOQ6Q6.js";import{b as rr}from"./chunk-F2F257PU.js";import{e as nr}from"./chunk-SB26HQO7.js";import{a as er}from"./chunk-FCD3NYOM.js";import{a as ar}from"./chunk-PVN64537.js";import{b as Se}from"./chunk-BZEW7CSM.js";import{g as Ie}from"./chunk-CBEMXSWF.js";import{a as X}from"./chunk-4QTH7VYE.js";import{a as ae}from"./chunk-V24LUINK.js";import{a as ie}from"./chunk-JYH7CTF7.js";import{A as ze,a as V,b as se}from"./chunk-BRWCWZE3.js";import{m as Qe,n as Ye}from"./chunk-WMXBRC4B.js";import{a as q}from"./chunk-RZ4F3BHX.js";import{a as Ze}from"./chunk-FOJHSG5M.js";import{join as De}from"path";function Dr(e){let r=e.now??Date.now,n=r(),t=!1,o=null,i=null,u=e.hxJobId,h=0,a=null,c=l=>({exploration_id:l?.explorationId??o,run_id:l?.runId??i});return{observe:l=>{switch(l.type){case"explore_run_started":typeof l.exploration_id=="string"&&(o=l.exploration_id),typeof l.run_id=="string"&&(i=l.run_id);return;case"explore_remote_started":typeof l.run_id=="string"&&(i=l.run_id),typeof l.hx_job_id=="string"&&(u=l.hx_job_id);return;case"lease_end":h++;return;case"explore_end":l.totals&&typeof l.totals=="object"&&(a=l.totals);return;default:return}},started:()=>t,markStarted:()=>{t=!0},startFields:()=>({...c(),remote:e.remote,on_vm:e.onVm,hx_job_id:u,policy:e.policy,max_parallel:e.maxParallel,max_leases:e.maxLeases}),endFields:l=>({...c(l),remote:e.remote,on_vm:e.onVm,hx_job_id:u,outcome:l.state==="queued"?"queued":l.remark?.code??(l.exitCode===0?"completed":"error"),stop_reason:l.stopReason??null,exit_code:l.exitCode,duration_ms:r()-n,leases:typeof a?.leases=="number"?a.leases:h,findings:typeof a?.findings=="number"?a.findings:null,committed:l.committed??0,pending:l.pending??0,complete:l.complete??!1,credits_total:l.credits?.total??null,peak_parallel:l.peakParallel??null}),errorFields:l=>{if(l.exitCode===0||l.exitCode===3&&!l.error)return null;let f=l.remark?.code?.startsWith("failed:")?l.remark.code:l.exitCode===2?"usage":l.stopReason??"explore_error";return{...c(l),error_code:f,exit_code:l.exitCode,stage:t?"run":"setup",...l.error?{error:l.error}:{}}}}}import{appendFileSync as dt,mkdirSync as pt}from"fs";import{dirname as mt}from"path";function Fr(e,r,n){if(r)try{pt(mt(r),{recursive:!0})}catch{}let t="",o=u=>{if(!(!r||!u))try{dt(r,n(u))}catch{}};e.child.stderr?.on("data",u=>{t+=u.toString();let h=t.lastIndexOf(`
3
3
  `);h<0||(o(t.slice(0,h+1)),t=t.slice(h+1))}),e.child.stderr?.on("end",()=>{o(t),t=""});let i=e.getStderr.bind(e);return Object.assign(e,{getStderr:()=>n(i())})}var ft={seeding:"seeding",replay:"replaying",walking:"walking",settling:"settling",verifying:"verifying"},gt=8,ht=6,S=e=>typeof e=="string"&&e?e:null,F=e=>typeof e=="number"&&Number.isFinite(e)?e:null,ge=class{s={run_id:null,exploration_id:null,status:"running",stop_reason:null,progress:null,browsers:[],version:0,updated_at:0};subs=new Set;now;constructor(r={}){this.now=r.now??Date.now}snapshot(){return structuredClone(this.s)}subscribe(r){return this.subs.add(r),()=>{this.subs.delete(r)}}end(r){this.s.status!=="ended"&&(this.s.status="ended",this.s.stop_reason=r,this.s.browsers=[],this.changed())}apply(r){this.reduce(r)&&this.changed()}changed(){if(this.s.version+=1,this.s.updated_at=this.now(),!this.subs.size)return;let r=this.snapshot();for(let n of this.subs)try{n(r)}catch{}}browser(r,n){let t=this.s.browsers.find(o=>o.worker===r)??null;return!t&&n&&(t={worker:r,state:"opening",since:this.now(),lease:null,step:null,steps:[],trail:[],held:null},this.s.browsers.push(t),this.s.browsers.sort((o,i)=>o.worker-i.worker)),t}setState(r,n){r.state!==n&&(r.state=n,r.since=this.now())}reduce(r){let n=F(r.worker_index);switch(r.type){case"explore_start":return this.s.run_id=S(r.run_id),this.s.exploration_id=S(r.exploration_id),this.s.status="running",!0;case"browser_request":return n===null?!1:(this.browser(n,!0),!0);case"browser_release":{if(n===null)return!1;let t=this.s.browsers.length;return this.s.browsers=this.s.browsers.filter(o=>o.worker!==n),this.s.browsers.length!==t}case"lease_start":{if(n===null||!S(r.lease_id))return!1;let t=this.browser(n,!0),o=r.reach&&typeof r.reach=="object"&&!Array.isArray(r.reach)?r.reach:null;return t.lease={id:String(r.lease_id),kind:String(r.kind??""),target:S(r.target),reach:o,started_at:this.now()},t.step=null,t.steps=[],this.setState(t,"starting"),!0}case"lease_step":{if(n===null)return!1;let t=this.browser(n,!1);if(!t||!t.lease||t.lease.id!==r.lease_id)return!1;let o={ordinal:F(r.ordinal)??t.steps.length,phase:String(r.phase??""),intent:S(r.intent),junction_id:S(r.junction_id),known:r.known===!0,url_pattern:S(r.url_pattern),flow_id:S(r.flow_id),navigated:r.navigated===!0,at:this.now()};return t.step=o,t.steps=[...t.steps,o].slice(-gt),o.junction_id&&t.trail[t.trail.length-1]!==o.junction_id&&(t.trail=[...t.trail,o.junction_id].slice(-ht)),this.setState(t,ft[o.phase]??"walking"),!0}case"lease_end":{let t=this.s.browsers.find(o=>o.lease?.id===r.lease_id);return t?(t.lease=null,t.step=null,t.steps=[],this.setState(t,t.held?"holding":"idle"),!0):!1}case"session_held":{if(n===null)return!1;let t=this.browser(n,!0);return t.held={kind:String(r.kind??""),start_flow:S(r.start_flow),junction_id:S(r.junction_id),url_pattern:S(r.url_pattern)},t.lease||this.setState(t,"holding"),!0}case"session_released":{if(n===null)return!1;let t=this.browser(n,!1);return!t||!t.held?!1:(t.held=null,t.lease||this.setState(t,"idle"),!0)}case"progress":return this.s.progress={frontier:F(r.frontier)??0,visited:F(r.visited)??0,active_workers:F(r.active_workers)??0,elapsed_s:F(r.elapsed_s)??0},!0;case"explore_control":return r.control!=="stop"||this.s.status!=="running"?!1:(this.s.status="paused",!0);case"explore_end":return this.s.status="ended",this.s.stop_reason=S(r.stop_reason),this.s.browsers=[],!0;default:return!1}}};var he=class{link=null;wanted=new Map;source=async(r,n)=>(this.wanted.set(r,n),this.link?.start(r),{stop:async()=>{this.wanted.get(r)===n&&(this.wanted.delete(r),this.link?.stop(r))}});attach(r){if(this.link=r,r)for(let n of this.wanted.keys())r.start(n)}frame(r,n){this.wanted.get(r)?.(n)}};var xt=500,wt=1e4,Gr=5e3,bt=async(e,r)=>{let n=new AbortController,t=()=>n.abort(),o=setTimeout(t,r.timeoutMs);r.signal.addEventListener("abort",t,{once:!0});try{let i=await q(e,{method:"POST",headers:r.headers,body:r.body,signal:n.signal}),u=null;try{u=await i.json()}catch{}return{status:i.status,body:u}}finally{clearTimeout(o),r.signal.removeEventListener("abort",t)}},xe=class{constructor(r){this.opts=r;this.post=r.post??bt,this.unsubscribeModel=r.model.subscribe(()=>this.stateChanged())}post;target=null;off=!1;framesOff=!1;abort=new AbortController;unsubscribeModel;stateInFlight=!1;stateDirty=!1;lastStateAt=0;stateTimer=null;heartbeat=null;watched=new Map;stopAsked=!1;waiting=new Map;sending=new Set;arm(r){this.off||(this.letAllGo(),this.abort.abort(),this.abort=new AbortController,this.stateInFlight=!1,this.target=r,this.framesOff=!1,this.stateDirty=!0,this.sendState())}async close(){this.off=!0,this.unsubscribeModel(),this.clearTimers(),this.letAllGo(),this.abort.abort()}url(r,n=""){let t=this.target;return`${t.baseUrl.replace(/\/+$/,"")}${n}/exploration/${encodeURIComponent(t.explorationId)}/runs/${encodeURIComponent(t.runId)}/live/${r}`}stateChanged(){if(this.off||!this.target||(this.stateDirty=!0,this.stateInFlight||this.stateTimer))return;let r=xt-(Date.now()-this.lastStateAt);r<=0?this.sendState():this.stateTimer=setTimeout(()=>{this.stateTimer=null,this.sendState()},r)}sendState(){if(this.off||!this.target||this.stateInFlight)return;let r=this.target;this.stateDirty=!1,this.stateInFlight=!0,this.lastStateAt=Date.now(),this.heartbeat&&clearTimeout(this.heartbeat),this.heartbeat=null;let n;try{n=JSON.stringify(this.opts.model.snapshot())}catch{this.stateInFlight=!1;return}this.post(this.url("state"),{headers:{Authorization:r.authHeader,"Content-Type":"application/json"},body:n,timeoutMs:Gr,signal:this.abort.signal}).then(t=>{if(this.target===r){if(t.status===404||t.status===403||t.status===401)return this.turnOff(t.status);t.status>=200&&t.status<300&&(this.stopIfAsked(t.body),this.follow(t.body))}},()=>{}).finally(()=>{this.target!==r||this.off||(this.stateInFlight=!1,this.heartbeat=setTimeout(()=>{this.heartbeat=null,this.stateDirty=!0,this.sendState()},wt),this.stateDirty&&this.stateChanged())})}turnOff(r){this.off||(this.off=!0,this.clearTimers(),this.letAllGo(),this.abort.abort(),this.opts.onWarn?.(`live view is off for this run: the controller has no live routes (HTTP ${r})`))}stopIfAsked(r){this.stopAsked||!r||typeof r!="object"||r.stop!==!0||(this.stopAsked=!0,this.opts.onStop?.())}follow(r){let n=r&&typeof r=="object"?r.watched:void 0;if(!Array.isArray(n)||this.framesOff)return;let t=new Set(n.filter(o=>Number.isInteger(o)&&o>=0));for(let o of[...this.watched.keys()])t.has(o)||this.letGo(o);for(let o of t)this.watched.has(o)||this.watched.set(o,this.opts.frames.subscribe(new Map([[o,jr]]),i=>this.frame(i)))}frame(r){r.kind!=="frame"||this.off||!this.watched.has(r.worker)||(this.waiting.set(r.worker,{data:r.data,at:r.at}),this.sendFrame(r.worker))}sendFrame(r){if(this.sending.has(r)||!this.target)return;let n=this.waiting.get(r);if(n===void 0)return;this.waiting.delete(r);let t=this.target;this.sending.add(r);let o=Number.isFinite(n.at)?`&at=${Math.round(n.at)}`:"";this.post(`${this.url("frames","/public")}?worker=${r}${o}`,{headers:{"X-Live-Token":t.liveToken,"Content-Type":"image/jpeg"},body:Buffer.from(n.data,"base64"),timeoutMs:Gr,signal:this.abort.signal}).then(i=>{this.target===t&&(i.status===410?this.letGo(r):i.status===401&&!this.framesOff&&(this.framesOff=!0,this.letAllGo(),this.opts.onWarn?.("live frames are off for this run: the controller refused its live token (HTTP 401)")))},()=>{}).finally(()=>{this.target===t&&(this.sending.delete(r),!this.off&&this.watched.has(r)&&this.sendFrame(r))})}letGo(r){let n=this.watched.get(r);this.watched.delete(r),this.waiting.delete(r),n?.()}letAllGo(){for(let r of[...this.watched.keys()])this.letGo(r);this.sending.clear()}clearTimers(){this.stateTimer&&clearTimeout(this.stateTimer),this.heartbeat&&clearTimeout(this.heartbeat),this.stateTimer=this.heartbeat=null}};function we(e,r){return`watch live: kane-cli explore view --exploration-id ${e}${r?` --env ${r}`:""}`}async function Kr(e){let r=new ge,n=new he,t=new Lr({start:e.startSource??n.source}),o=new xe({model:r,frames:t,post:e.post,onWarn:e.onWarn,onStop:e.onStop}),i=!1,u=!1,h=!1;return{model:r,frames:t,onBrowser(a){u||t.addBrowser(a)},offBrowser(a){t.removeBrowser(a)},attachRunner(a){n.attach(u?null:a)},runnerFrame(a,c){u||n.frame(a,c)},onEvent(a){r.apply(a),a.type==="explore_start"&&!i&&typeof a.exploration_id=="string"&&a.exploration_id&&(i=!0,e.onExploration?.(a.exploration_id))},armRun(a){if(!u){if(!a.liveToken){h||e.onWarn?.("live view is off for this run: the controller handed out no live token"),h=!0;return}o.arm({...e.controller,explorationId:a.explorationId,runId:a.runId,liveToken:a.liveToken})}},async close(a){u||(u=!0,await o.close(),n.attach(null),r.end(a),await t.close())}}}import{readFileSync as vt}from"fs";import{basename as _t}from"path";import{randomUUID as Qr}from"crypto";function Be(e){let r=[];for(let[n,t]of Object.entries(e)){if(t.type==="parameter")continue;let o=n.replace(/^(secrets\.user\.|global\.|environment\.)/,"");r.push({name:o,secret:!!t.secret,value:String(t.value??"")})}return r}async function Wr(e,r){if(r.activeRun){let c=null;try{c=await r.activeRun()}catch{c=null}if(c)return{ok:!1,error:`RUN_ACTIVE: run ${c.runId} is ${c.state} on exploration ${c.explorationId}; stop it or wait for it to end`}}let n=e.variables.filter(c=>c.secret),t=e.variables.filter(c=>!c.secret),o=[["LT_USERNAME",e.login.username],["LT_ACCESS_KEY",e.login.accessKey],...n.map(c=>[c.name,c.value])];for(let[c,l]of o){if(e.dev?.skipPush===c){e.onNote?.(`dev: not pushing secret ${c} (KANE_EXPLORE_DEV_SKIP_SECRET_PUSH)`);continue}try{await r.pushSecret(c,l)}catch(f){return{ok:!1,error:`could not push secret ${c} to HyperExecute Secrets: ${Z(f)}`}}}for(let c of t)try{await r.upsertGlobal(c.name,c.value)}catch(l){return{ok:!1,error:`could not push variable ${c.name} to Test Manager: ${Z(l)}`}}let i=o.map(([c])=>c);if(e.dev?.skipCheck)return e.onNote?.("dev: not checking the HyperExecute secrets list (KANE_EXPLORE_DEV_SKIP_SECRET_CHECK); the VM's check must refuse a missing secret"),a();let u;try{u=await r.hxSecretNames(i)}catch(c){return{ok:!1,error:`could not read your HyperExecute secrets to check them: ${Z(c)}`}}let h=i.filter(c=>!u.includes(c));if(h.length)return{ok:!1,error:`HyperExecute Secrets does not list ${h.join(", ")} after the push; the VM would run without ${h.length===1?"it":"them"}`};return a();async function a(){let c=e.body;if(e.devBundle)try{let{kane_version:l,...f}=e.body;c={...f,dev:await e.devBundle()}}catch(l){return{ok:!1,error:`--dev-bundle: could not upload the bundle: ${Z(l)}`}}try{return{ok:!0,reply:await r.remoteRun({...c,variables:e.variables.map(f=>({name:f.name,secret:f.secret}))})}}catch(l){if(l instanceof de&&l.code==="SECRETS_MISSING"){let f=l.body??{};return{ok:!1,secretsMissing:!0,error:typeof f.error=="string"&&f.error?f.error:"HyperExecute refused the job: a secret it names is missing",explorationId:typeof f.exploration_id=="string"?f.exploration_id:null,runId:typeof f.run_id=="string"?f.run_id:null}}return{ok:!1,error:`could not launch the remote run: ${Z(l)}`}}}}async function qr(e,r,n){let t={Authorization:X(r.username,r.accessKey),Accept:"application/json"},o=new URLSearchParams({username:r.username});for(let a of n)o.append("secretKey",a);let i=await q(`${e}/logistics/v1.0/all-secrets/list?${o}`,{method:"GET",headers:t});if(i.status===404&&(i=await q(`${e}/logistics/v1.0/secrets/list/${encodeURIComponent(r.username)}`,{method:"GET",headers:t})),!i.ok)throw new Error(`HTTP ${i.status}`);let u=null;try{u=await i.json()}catch{u=null}let h=yt(u);return n.filter(a=>h.has(a))}function yt(e){let r=new Set,n=e&&typeof e=="object"?e:{},t=Array.isArray(n.Data)?n.Data:Array.isArray(n.data)?n.data:Array.isArray(e)?e:[];for(let o of t)if(typeof o=="string")r.add(o);else if(o&&typeof o=="object"){let i=o,u=i.key??i.secretKey??i.Key??i.name;typeof u=="string"&&r.add(u)}return r}var Xr=["allowDomain","deny","allowPost","depthCaps","slowBudget","recheck","focus","hpsRegion","tunnel","tunnelName"];function Me(e,r){let n={};r&&(n.deps=r);for(let t of Xr){let o=e[t];o===void 0||Array.isArray(o)&&!o.length||(n[t]=o)}return n}function Jr(e){let r=e.args&&typeof e.args=="object"?e.args:{},n={url:e.url,prompt:e.prompt,browser:"remote",headless:!0};typeof e.max_parallel=="number"&&e.max_parallel>0&&(n.maxParallel=e.max_parallel),typeof e.max_leases=="number"&&e.max_leases>0&&(n.maxLeases=e.max_leases),Array.isArray(e.allowed_domains)&&(n.allowDomain=e.allowed_domains),typeof e.policy=="string"&&e.policy&&(n.policy=e.policy);for(let t of Xr)r[t]!==void 0&&(n[t]=r[t]);return typeof r.deps=="string"&&r.deps&&(n.depsText=r.deps),n}function zr(e,r){let n={},t=[];for(let o of e){if(!o.secret){n[o.name]={value:"",secret:!1};continue}let i=r[o.name];if(!i||i.includes("${{.secrets.")){t.push(o.name);continue}n[o.name]={value:i,secret:!0}}return t.length?{ok:!1,missing:t}:{ok:!0,variables:n}}function Z(e){return e instanceof Error?e.message:String(e)}function Yr(e){let r=Be(e.variables).map(n=>({name:n.name,secret:n.secret}));return{url:e.url,prompt:e.prompt,policy:e.policy??pe,...r.length?{variables:r}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Me({...e.opts,allowDomain:e.allowedDomains},e.depsText)}}function kt(e){let r={},n=(e.KANE_EXPLORE_DEV_SKIP_SECRET_PUSH??"").trim();return n&&(r.skipPush=n),(e.KANE_EXPLORE_DEV_SKIP_SECRET_CHECK??"").trim()==="1"&&(r.skipCheck=!0),r}async function Rt(e,r){let n=vt(r),t=new er(e.controllerBaseUrl,{username:e.basic.username,accessKey:e.basic.access_key}),o=`${Qr()}-${_t(r)}`,u=(await t.getPresignedUrls("explore-dev",Qr(),[{key:"bundle",content_type:"application/gzip",filename:o}])).urls.bundle;if(!u)throw new Error("the presign reply named no URL for the bundle");return await ur(u.upload_url,n,"application/gzip"),u.blob_url}function Et(e){return{project_id:e.projectId,url:e.url,prompt:e.prompt,policy:e.policy??pe,...e.allowedDomains.length?{allowed_domains:e.allowedDomains}:{},...e.contextEnabled===!1?{context_enabled:!1}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Me(e.opts,e.depsText),kane_version:e.kaneVersion}}async function Zr(e,r){let n=new L({baseUrl:e.controllerBaseUrl,auth:e.basic}),t=new cr(e.secretsBaseUrl),o=new dr(e.tmsBaseUrl,e.basic.username,e.basic.access_key),i={username:e.basic.username,accessKey:e.basic.access_key},u=Et(r),h=r.dev,a=await Wr({variables:Be(r.variables),login:i,body:u,...h?{dev:kt(process.env),onNote:c=>e.emit({type:"warning",message:c}),devBundle:async()=>({bundle_url:await Rt(e,h.bundlePath),controller_url:h.controllerUrl})}:{}},{pushSecret:(c,l)=>t.pushSecret({secretKey:c,secretValue:l,username:i.username,accessKey:i.accessKey,orgId:e.orgId}),upsertGlobal:async(c,l)=>{await o.upsertVariable({name:c,value:l})},hxSecretNames:c=>qr(e.secretsBaseUrl,i,c),remoteRun:c=>n.remoteRun(c),activeRun:async()=>{if(!r.projectId)return null;let l=(await n.listExplorations({state:"running",project:r.projectId,limit:1})).explorations.find(f=>f.project_id===r.projectId&&f.current_session);return l&&l.current_session?{explorationId:l.exploration_id,runId:l.current_session.run_id,state:l.current_session.state}:null}});if(!a.ok&&a.secretsMissing)return{ok:!1,error:a.error,exitCode:2,stopped:{explorationId:a.explorationId,runId:a.runId}};if(!a.ok){if(r.contextEnabled===!1&&Sr(a.error))return{ok:!1,error:Er,exitCode:2};let c=/could not launch/.test(a.error)||a.error.startsWith("RUN_ACTIVE:");return{ok:!1,error:a.error,exitCode:c?1:2}}return e.emit({type:"explore_remote_started",exploration_id:a.reply.exploration_id,run_id:a.reply.run_id,state:a.reply.state,hx_job_id:a.reply.hx_job_id,job_link:a.reply.job_link,created:a.reply.created,policy:u.policy??pe}),r.contextEnabled===!1&&!a.reply.created&&e.emit({type:"warning",message:`exploration ${a.reply.exploration_id} already exists; its assurance context is unchanged \u2014 use \`kane-cli explore context off ${a.reply.exploration_id}\``}),e.terminal||(process.stderr.write(`exploration ${a.reply.exploration_id}, run ${a.reply.run_id}: queued on HyperExecute
4
4
  `),a.reply.job_link&&process.stderr.write(`job: ${a.reply.job_link}
5
5
  `),process.stderr.write(we(a.reply.exploration_id,e.env)+`
@@ -25,23 +25,23 @@ On a terminal, plain \`kane-cli explore\` opens the project picker, then the
25
25
  exploration's card (run again, watch, stop, map, sessions, context, delete);
26
26
  with --agent or a pipe it prints this help. Each command's --help lists its
27
27
  options, grouped, with their values, defaults and examples.
28
- `).action(async(n,t)=>{if(t.args.length>0&&t.error(`error: unknown command '${t.args[0]}'`,{exitCode:2}),me(n,Mr()))return t.help();let{runExploreEntryAction:o}=await import("./explore-entry-ZOPO7DBZ.js");process.exitCode=await o(n)});r.command("run").description("Run one exploration of an app into its project's map: on HyperExecute by default (exits once the run is queued; stop it with explore stop), or on this machine with --local-orchestration. A terminal opens a setup form and a review first; --agent or a pipe gets NDJSON on stdout, done last").option("--url <url>",w("url")).option("--project <id>",w("project")).option("--exploration-id <id>",w("explorationId")).option("--prompt <text>",w("prompt"),"Explore the app").option("--max-leases <n>",w("maxLeases"),tt).option("--max-parallel <n>",w("maxParallel"),tt).option("--depth-caps <depth:cap,\u2026>",w("depthCaps")).option("--slow-budget <spec>",w("slowBudget")).option("--no-recheck",w("recheck")).option("--policy <policy>",w("policy")).option("--allow-domain <host>",w("allowDomain"),ye,[]).option("--deny <name>",w("deny"),ye,[]).option("--allow-post <host/path>",w("allowPost"),ye,[]).option("--focus <screen>",w("focus")).option("--local-orchestration",w("localOrchestration")).option("--browser <where>",w("browser"),"local").option("--headless",w("headless")).option("--tunnel",w("tunnel")).option("--tunnel-name <name>",w("tunnelName")).option("--deps <text>",w("deps"),ye,[]).option("--variables <json>",w("variables")).option("--variables-file <path>",w("variablesFile")).option("--no-context",w("context")).option("--agent",w("agent")).option("--env <name>",w("env")).option("--username <user>",w("username")).option("--access-key <key>",w("accessKey")).addOption(new le("--claim-run <run-id>","On a HyperExecute VM: take over this queued run (the job's own command; needs --exploration-id)").hideHelp()).addOption(new le("--dev-bundle <tgz>","Dev only: the VM installs this kane-cli bundle and talks to EXPLORE_DEV_CONTROLLER_URL").hideHelp()).addOption(new le("--hps-region <region>",`With remote browsers on prod: the regional host (${ce.join(", ")})`).hideHelp()).configureHelp(fe(Br())).addHelpText("after",Pt).configureOutput({outputError:(n,t)=>t(/\'--setup(?:-check)?(?:=|\')/.test(n)?Ct:n)}).action(async n=>{process.exitCode=await Vt(n)}),r.command("view").description("Serve a live graph of an exploration's map on 127.0.0.1 (polls the service; Ctrl-C to stop)").option("--exploration-id <id>",Q({purpose:"The exploration to view",values:"an id from kane-cli explore list --all"})).option("--project <id>",Q({purpose:"View this project's exploration instead (a project has one)",values:"a project id"})).option("--port <n>",Q({purpose:"The port on 127.0.0.1",values:"1-65535",dflt:"the first free of 7420-7429"}),$t).option("--agent",Ae).option("--env <name>",Oe).option("--username <user>",Ue).option("--access-key <key>",Ne).configureHelp(fe([{title:"Target",flags:["--exploration-id","--project"]},{title:"Server",flags:["--port"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])).addHelpText("after",`
28
+ `).action(async(n,t)=>{if(t.args.length>0&&t.error(`error: unknown command '${t.args[0]}'`,{exitCode:2}),me(n,Mr()))return t.help();let{runExploreEntryAction:o}=await import("./explore-entry-QMCVGRP4.js");process.exitCode=await o(n)});r.command("run").description("Run one exploration of an app into its project's map: on HyperExecute by default (exits once the run is queued; stop it with explore stop), or on this machine with --local-orchestration. A terminal opens a setup form and a review first; --agent or a pipe gets NDJSON on stdout, done last").option("--url <url>",w("url")).option("--project <id>",w("project")).option("--exploration-id <id>",w("explorationId")).option("--prompt <text>",w("prompt"),"Explore the app").option("--max-leases <n>",w("maxLeases"),tt).option("--max-parallel <n>",w("maxParallel"),tt).option("--depth-caps <depth:cap,\u2026>",w("depthCaps")).option("--slow-budget <spec>",w("slowBudget")).option("--no-recheck",w("recheck")).option("--policy <policy>",w("policy")).option("--allow-domain <host>",w("allowDomain"),ye,[]).option("--deny <name>",w("deny"),ye,[]).option("--allow-post <host/path>",w("allowPost"),ye,[]).option("--focus <screen>",w("focus")).option("--local-orchestration",w("localOrchestration")).option("--browser <where>",w("browser"),"local").option("--headless",w("headless")).option("--tunnel",w("tunnel")).option("--tunnel-name <name>",w("tunnelName")).option("--deps <text>",w("deps"),ye,[]).option("--variables <json>",w("variables")).option("--variables-file <path>",w("variablesFile")).option("--no-context",w("context")).option("--agent",w("agent")).option("--env <name>",w("env")).option("--username <user>",w("username")).option("--access-key <key>",w("accessKey")).addOption(new le("--claim-run <run-id>","On a HyperExecute VM: take over this queued run (the job's own command; needs --exploration-id)").hideHelp()).addOption(new le("--dev-bundle <tgz>","Dev only: the VM installs this kane-cli bundle and talks to EXPLORE_DEV_CONTROLLER_URL").hideHelp()).addOption(new le("--hps-region <region>",`With remote browsers on prod: the regional host (${ce.join(", ")})`).hideHelp()).configureHelp(fe(Br())).addHelpText("after",Pt).configureOutput({outputError:(n,t)=>t(/\'--setup(?:-check)?(?:=|\')/.test(n)?Ct:n)}).action(async n=>{process.exitCode=await Vt(n)}),r.command("view").description("Serve a live graph of an exploration's map on 127.0.0.1 (polls the service; Ctrl-C to stop)").option("--exploration-id <id>",Q({purpose:"The exploration to view",values:"an id from kane-cli explore list --all"})).option("--project <id>",Q({purpose:"View this project's exploration instead (a project has one)",values:"a project id"})).option("--port <n>",Q({purpose:"The port on 127.0.0.1",values:"1-65535",dflt:"the first free of 7420-7429"}),$t).option("--agent",Ae).option("--env <name>",Oe).option("--username <user>",Ue).option("--access-key <key>",Ne).configureHelp(fe([{title:"Target",flags:["--exploration-id","--project"]},{title:"Server",flags:["--port"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])).addHelpText("after",`
29
29
  Name the exploration with --exploration-id or --project, not both.
30
30
 
31
31
  Examples:
32
32
  $ kane-cli explore view --project <id>
33
33
  $ kane-cli explore view --exploration-id <id> --port 7430
34
- `).action(async n=>{process.exitCode=await Ft(n)}),Hr(r),Vr(r),r.command("assurance-job",{hidden:!0}).description("One cut of an exploration into its project's assurance (the controller's job; input from the environment)").action(async()=>{let{runAssuranceJob:n}=await import("./assurance-job-QO4VJJCL.js");process.exitCode=await n()})}function $t(e){let r=Number(e);if(!Number.isInteger(r)||r<1||r>65535)throw new Te("must be an integer 1-65535");return r}function ye(e,r){return[...r,e]}function nt(e){let r=new Set;for(let n of e){let t=n.trim().toLowerCase();if(t){try{t.includes("://")&&(t=new URL(t).hostname)}catch{}t=t.replace(/\/.*$/,"").replace(/^www\./,"").replace(/\.$/,""),t&&r.add(t)}}return[...r]}function At(e,r){if(e.some(t=>t.trim()==="*"))return{posts:["*"]};let n=new Set;for(let t of e){let o=t.trim();if(!o)continue;let i=y=>({error:`--allow-post ${JSON.stringify(o)}: ${y}; write it as host/path, e.g. api.example.com/v1/flags`});if(o.includes("://"))return i("no scheme");if(/[?#]/.test(o))return i("no query or fragment (the match is on host and path only)");if(o.includes("*"))return i("no partial wildcards (name the endpoint exactly, or pass a bare * for every POST)");if(/\s/.test(o))return i("no whitespace");let u=o.indexOf("/");if(u<=0)return i("a host followed by a path starting with /");let h=o.slice(0,u).toLowerCase(),a=o.slice(u),c=/^([^:]+?)\.?(?::(\d+))?$/.exec(h);if(!c)return i("an invalid host");let l=c[1],f=c[2]&&c[2]!=="80"&&c[2]!=="443"?`:${c[2]}`:"";if(h=l+f,!r.some(y=>l===y||l.endsWith(`.${y}`)))return i(`host ${l} is outside the run's domains (${r.join(", ")||"none"}); add it with --allow-domain first`);n.add(h+a)}return{posts:[...n]}}function Ot(e){if(e===void 0)return{caps:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(\d+):(\d+)$/.exec(n);if(!t)return{error:`--depth-caps "${e}": each entry is depth:cap with whole numbers, e.g. 0:0,1:3,2:1`};r[String(Number(t[1]))]=Number(t[2])}return Object.keys(r).length?{caps:r}:{error:`--depth-caps "${e}": give at least one depth:cap pair`}}var Ut={response:"response_ms",page:"page_ready_ms",step:"step_ms"};function Nt(e){if(e===void 0)return{budgets:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(response|page|step)=(\d+(?:\.\d+)?)(s|ms)$/.exec(n);if(!t)return{error:`--slow-budget "${e}": each entry is response|page|step=<number>s or ms, e.g. response=3s,page=4s,step=2.5s`};let o=Math.round(Number(t[2])*(t[3]==="s"?1e3:1));if(o<1)return{error:`--slow-budget "${e}": a budget is more than 0`};r[Ut[t[1]]]=o}return Object.keys(r).length?{budgets:r}:{error:`--slow-budget "${e}": give at least one budget`}}function ot(e){return e.context===!1?{contextEnabled:!1}:{}}var Bt="--tunnel on a remote run: the remote browsers reach your apps through the LT tunnel on this machine; keep it (and this machine) up until the run ends, or its pages fail to load";function Fe(e){return async r=>{let n=await Y(e,"explore run");return n.ok?He(new L({baseUrl:n.controllerBaseUrl,auth:n.basic,timeoutMs:5e3}),r):null}}async function at(e){let r=typeof e.project=="string"?e.project:"";if(!r)return null;try{let n=await Y(e,"explore run");if(!n.ok)return null;let t=ae(e.env??new ie().getDefaultEnv()??"prod"),o=new nr(t.tmsBaseUrl,n.basic.username,n.basic.access_key);return await _r((async()=>{try{let u=await o.getProject(r);if(u?.name)return u.name}catch{}return(await o.listProjects()).find(u=>String(u.project_id)===r)?.name??null})(),4e3,()=>null)}catch{return null}}var Mt=async(e,r=Fe(e))=>{let n=null,t=typeof e.project=="string"?e.project:"",o=be(e,!!e.localOrchestration,t||null),i=null;if(o)try{i=await r(o)}catch{i=null}if(i){let h=Ve(i,typeof e.url=="string"?e.url:"");if(h){for(let a of Pe(h.error,h.next))process.stderr.write(a+`
35
- `);return 2}n=i.target_url??null}let u=await(await import("./explore-run-tty-DYLMHI7F.js")).setupRunOpts(e,n,await at(e));return"opts"in u?u.opts:u.code};function Ht(e){if(e.startsWith("RUN_ACTIVE:"))return"watch it (kane-cli explore view) or stop it (kane-cli explore stop) first \u2014 one run per exploration";if(/HyperExecute Secrets does not list/.test(e))return"check the secret's name in HyperExecute Secrets and your variables files, then launch again; or run it here with --local-orchestration";if(/a secret it names is missing|SECRETS_MISSING/.test(e))return"add the missing secret to your variables files (secret: true) and launch again";if(/REMOTE_UNAVAILABLE|503|could not launch the remote run|could not read your HyperExecute secrets|could not push/.test(e))return"try again in a minute, or run it on this machine with --local-orchestration"}async function Vt(e,r,n={}){let t=me(e,r),o=t?je("explore"):null,i=s=>s,u=null,h=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null,a=Dr({remote:!e.localOrchestration&&!h,onVm:!!h,hxJobId:Se().jobId??null,policy:typeof e.policy=="string"?e.policy:null,maxParallel:typeof e.maxParallel=="number"?e.maxParallel:null,maxLeases:typeof e.maxLeases=="number"?e.maxLeases:null}),c=()=>{if(!a.started()){a.markStarted();try{Ie()?.event("EXPLORE_START",a.startFields())}catch{}}},l=s=>{try{a.observe(s),s.type==="explore_run_started"&&c()}catch{}},f=s=>{l(s),o?o.emit(i(s)):u?.(i(s))},y=s=>{o?D(i(s)):process.stderr.write(`${s.type}: ${i(s).message}
34
+ `).action(async n=>{process.exitCode=await Ft(n)}),Hr(r),Vr(r),r.command("assurance-job",{hidden:!0}).description("One cut of an exploration into its project's assurance (the controller's job; input from the environment)").action(async()=>{let{runAssuranceJob:n}=await import("./assurance-job-V5QB36WJ.js");process.exitCode=await n()})}function $t(e){let r=Number(e);if(!Number.isInteger(r)||r<1||r>65535)throw new Te("must be an integer 1-65535");return r}function ye(e,r){return[...r,e]}function nt(e){let r=new Set;for(let n of e){let t=n.trim().toLowerCase();if(t){try{t.includes("://")&&(t=new URL(t).hostname)}catch{}t=t.replace(/\/.*$/,"").replace(/^www\./,"").replace(/\.$/,""),t&&r.add(t)}}return[...r]}function At(e,r){if(e.some(t=>t.trim()==="*"))return{posts:["*"]};let n=new Set;for(let t of e){let o=t.trim();if(!o)continue;let i=y=>({error:`--allow-post ${JSON.stringify(o)}: ${y}; write it as host/path, e.g. api.example.com/v1/flags`});if(o.includes("://"))return i("no scheme");if(/[?#]/.test(o))return i("no query or fragment (the match is on host and path only)");if(o.includes("*"))return i("no partial wildcards (name the endpoint exactly, or pass a bare * for every POST)");if(/\s/.test(o))return i("no whitespace");let u=o.indexOf("/");if(u<=0)return i("a host followed by a path starting with /");let h=o.slice(0,u).toLowerCase(),a=o.slice(u),c=/^([^:]+?)\.?(?::(\d+))?$/.exec(h);if(!c)return i("an invalid host");let l=c[1],f=c[2]&&c[2]!=="80"&&c[2]!=="443"?`:${c[2]}`:"";if(h=l+f,!r.some(y=>l===y||l.endsWith(`.${y}`)))return i(`host ${l} is outside the run's domains (${r.join(", ")||"none"}); add it with --allow-domain first`);n.add(h+a)}return{posts:[...n]}}function Ot(e){if(e===void 0)return{caps:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(\d+):(\d+)$/.exec(n);if(!t)return{error:`--depth-caps "${e}": each entry is depth:cap with whole numbers, e.g. 0:0,1:3,2:1`};r[String(Number(t[1]))]=Number(t[2])}return Object.keys(r).length?{caps:r}:{error:`--depth-caps "${e}": give at least one depth:cap pair`}}var Ut={response:"response_ms",page:"page_ready_ms",step:"step_ms"};function Nt(e){if(e===void 0)return{budgets:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(response|page|step)=(\d+(?:\.\d+)?)(s|ms)$/.exec(n);if(!t)return{error:`--slow-budget "${e}": each entry is response|page|step=<number>s or ms, e.g. response=3s,page=4s,step=2.5s`};let o=Math.round(Number(t[2])*(t[3]==="s"?1e3:1));if(o<1)return{error:`--slow-budget "${e}": a budget is more than 0`};r[Ut[t[1]]]=o}return Object.keys(r).length?{budgets:r}:{error:`--slow-budget "${e}": give at least one budget`}}function ot(e){return e.context===!1?{contextEnabled:!1}:{}}var Bt="--tunnel on a remote run: the remote browsers reach your apps through the LT tunnel on this machine; keep it (and this machine) up until the run ends, or its pages fail to load";function Fe(e){return async r=>{let n=await Y(e,"explore run");return n.ok?He(new L({baseUrl:n.controllerBaseUrl,auth:n.basic,timeoutMs:5e3}),r):null}}async function at(e){let r=typeof e.project=="string"?e.project:"";if(!r)return null;try{let n=await Y(e,"explore run");if(!n.ok)return null;let t=ae(e.env??new ie().getDefaultEnv()??"prod"),o=new nr(t.tmsBaseUrl,n.basic.username,n.basic.access_key);return await _r((async()=>{try{let u=await o.getProject(r);if(u?.name)return u.name}catch{}return(await o.listProjects()).find(u=>String(u.project_id)===r)?.name??null})(),4e3,()=>null)}catch{return null}}var Mt=async(e,r=Fe(e))=>{let n=null,t=typeof e.project=="string"?e.project:"",o=be(e,!!e.localOrchestration,t||null),i=null;if(o)try{i=await r(o)}catch{i=null}if(i){let h=Ve(i,typeof e.url=="string"?e.url:"");if(h){for(let a of Pe(h.error,h.next))process.stderr.write(a+`
35
+ `);return 2}n=i.target_url??null}let u=await(await import("./explore-run-tty-6UTBRCEF.js")).setupRunOpts(e,n,await at(e));return"opts"in u?u.opts:u.code};function Ht(e){if(e.startsWith("RUN_ACTIVE:"))return"watch it (kane-cli explore view) or stop it (kane-cli explore stop) first \u2014 one run per exploration";if(/HyperExecute Secrets does not list/.test(e))return"check the secret's name in HyperExecute Secrets and your variables files, then launch again; or run it here with --local-orchestration";if(/a secret it names is missing|SECRETS_MISSING/.test(e))return"add the missing secret to your variables files (secret: true) and launch again";if(/REMOTE_UNAVAILABLE|503|could not launch the remote run|could not read your HyperExecute secrets|could not push/.test(e))return"try again in a minute, or run it on this machine with --local-orchestration"}async function Vt(e,r,n={}){let t=me(e,r),o=t?je("explore"):null,i=s=>s,u=null,h=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null,a=Dr({remote:!e.localOrchestration&&!h,onVm:!!h,hxJobId:Se().jobId??null,policy:typeof e.policy=="string"?e.policy:null,maxParallel:typeof e.maxParallel=="number"?e.maxParallel:null,maxLeases:typeof e.maxLeases=="number"?e.maxLeases:null}),c=()=>{if(!a.started()){a.markStarted();try{Ie()?.event("EXPLORE_START",a.startFields())}catch{}}},l=s=>{try{a.observe(s),s.type==="explore_run_started"&&c()}catch{}},f=s=>{l(s),o?o.emit(i(s)):u?.(i(s))},y=s=>{o?D(i(s)):process.stderr.write(`${s.type}: ${i(s).message}
36
36
  `)},_=s=>{try{let d=Ie(),m={...s,error:s.error?i({message:s.error}).message:void 0};a.started()&&d?.event("EXPLORE_END",a.endFields(m));let p=a.errorFields(m);p&&d?.event("EXPLORE_ERROR",p)}catch{}return f({...Rr({state:s.state??null,remark:s.remark??null,exitCode:s.exitCode,explorationId:s.explorationId??null,runId:s.runId??null,committed:s.committed??0,pending:s.pending??0,lastSeq:s.lastSeq??0,stopReason:s.stopReason??null,complete:s.complete??!1,runDir:s.runDir??null,error:s.error}),...s.teardown?{teardown:s.teardown}:{},...s.credits?{credits:s.credits}:{},...typeof s.creditsConsumed=="number"?{credits_consumed:s.creditsConsumed}:{},...s.focus?{focus:s.focus}:{},...s.refused?{refused:s.refused}:{},...s.parallelism?{parallelism:s.parallelism}:typeof s.peakParallel=="number"?{peak_parallel:s.peakParallel}:{}}),s.exitCode},g=(s,d)=>(y({type:"error",message:s}),d&&!o&&process.stderr.write(`next: ${d}
37
37
  `),_({exitCode:2,error:s})),b=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null;if(b&&!t)return g("--claim-run is the HyperExecute VM's own mode; it never runs on a terminal");let G=$e(e);if("error"in G)return g(G.error,G.next);if(!t){let s=await(n.setup??(d=>Mt(d,n.lookupExploration??Fe(d))))(e);if(s===null)return 0;if(typeof s=="number")return s;e=s}if(!b&&!(typeof e.url=="string"&&e.url.trim())){let s=be(e,!!e.localOrchestration,typeof e.project=="string"&&e.project?e.project:null),d=null;if(s)try{d=await(n.lookupExploration??Fe(e))(s)}catch{d=null}d?.target_url&&(e={...e,url:d.target_url})}if(!b&&!(typeof e.url=="string"&&e.url.trim()))return g("required option '--url <url>' not specified");let E=!!e.localOrchestration||!!b;if(b&&e.localOrchestration)return g("--claim-run is the VM's own mode; it takes no --local-orchestration");if(e.devBundle&&E)return g("--dev-bundle is for a remote run (the default), not --local-orchestration or --claim-run");if(b){let s=String(e.explorationId??"").trim();if(!s)return g("--claim-run needs --exploration-id");let d=await Y(e,"explore run --claim-run");if(!d.ok)return g(d.error);let m=String(e.env??new ie().getDefaultEnv()??"prod"),p=await et(it(m,d.basic,"",A=>f(A)),s,b,process.env);if(!p.ok)return D(i({type:"error",message:p.error})),p.stopped?_({exitCode:p.exitCode,error:p.error,state:"stopped",remark:J("secrets_missing",p.error),explorationId:s,runId:b}):_({exitCode:p.exitCode,error:p.error,explorationId:s,runId:b});e={...e,...p.opts,env:e.env,username:e.username,accessKey:e.accessKey}}let O=$e(e);if("error"in O)return g(O.error,O.next);let x=O.policy,k={prompt:"",deps:""},R={},U="";try{let s=typeof e.depsText=="string"?e.depsText:mr(e.deps??[]);U=s;let d=fr({prompt:e.prompt??"Explore the app",deps:s},{globalDir:De(se,"variables"),localDir:De(process.cwd(),".testmuai","variables"),file:e.variablesFile,inline:e.variables,onLoadError:m=>y({type:"warning",message:m})});if("error"in d)return g(d.error);k={prompt:d.prompt,deps:d.deps},R=d.variables}catch(s){return g(`variables: ${s.message}`)}let C=nt(e.allowDomain??[]);if(k.deps&&C.length===0)return g("--deps needs --allow-domain for every host the app signs in or writes on (e.g. --allow-domain testmuai.com --allow-domain lambdatest.com)");let lt=[...new Set([...C,...nt([String(e.url??"")])])],P=E?String(e.browser??"local"):"remote";if(!E&&e.browser!==void 0&&e.browser!=="local")return g("--browser applies to --local-orchestration; a remote run always uses remote browsers");if(P!=="local"&&P!=="remote")return g(`--browser ${P}: local or remote`);let M=e.hpsRegion;if(M!==void 0&&P!=="remote")return g("--hps-region needs --browser remote");if(M!==void 0&&!ce.includes(M))return g(`--hps-region ${M}: one of ${ce.join(", ")}`);let N=rr(e);if("error"in N)return g(N.error);if(N.tunnel&&P!=="remote")return g("--tunnel needs remote browsers (a remote run, or --browser remote): a local Chrome already reaches this machine");let K=e.maxParallel??1;if(P==="local"&&K>Ce)return g(`--max-parallel ${K}: at most ${Ce} browsers run on this machine at once (--browser remote runs up to ${ue})`);if(P==="remote"&&K>ue)return g(`--max-parallel ${K}: at most ${ue} remote browsers at once`);let ve=Ot(e.depthCaps);if("error"in ve)return g(ve.error);let _e=Nt(e.slowBudget);if("error"in _e)return g(_e.error);let ee=At(e.allowPost??[],lt);if("error"in ee)return g(ee.error);x==="mutating"&&ee.posts.length&&y({type:"warning",code:"allow_post_ignored",message:Ar});let re=new ie,I=e.env??re.getDefaultEnv()??"prod",B=ae(I),W=new or().load(),ut=re.loadProfileConfig(re.getActiveProfile()??"default",I)?.project_id??null,j=e.project??W.project_id??ut??null;if(x==="mutating"){let s=Or(String(e.url??"")),d=Ur(String(e.url??""));o?D(i({type:"warning",code:"policy_mutating",policy:x,host:s,message:d})):process.stderr.write((process.stderr.columns?pr(d,process.stderr.columns):d)+`
38
- `);let m=n.mutatingMemory??Nr();if(!t&&!(j&&m.confirmed(j))){let A=await(n.confirmMutating??(async H=>(await import("./explore-run-tty-DYLMHI7F.js")).confirmMutatingRun({...H,projectName:H.projectName??(H.projectId?await at({...e,project:H.projectId}):null)})))({host:s,projectId:j,projectName:j===W.project_id?W.project_name??null:null});if(A!==!0)return process.stderr.write(`setup discarded; nothing launched
38
+ `);let m=n.mutatingMemory??Nr();if(!t&&!(j&&m.confirmed(j))){let A=await(n.confirmMutating??(async H=>(await import("./explore-run-tty-6UTBRCEF.js")).confirmMutatingRun({...H,projectName:H.projectName??(H.projectId?await at({...e,project:H.projectId}):null)})))({host:s,projectId:j,projectName:j===W.project_id?W.project_name??null:null});if(A!==!0)return process.stderr.write(`setup discarded; nothing launched
39
39
  `),A===null?130:0;j&&m.remember(j)}}if(!t&&n.afterChecks)return n.afterChecks();let Ge=new Set;t||(u=s=>{s.type==="explore_remote_started"?process.stderr.write(z("queued on HyperExecute",` \xB7 run ${String(s.run_id).slice(0,8)}${s.job_link?` \xB7 ${String(s.job_link)}`:""}`,"done")+`
40
40
  `):(s.type==="warning"||s.type==="error")&&process.stderr.write(`${String(s.type)}: ${String(s.message)}
41
41
  `);for(let d of Ge)d(s)});let Ke=(s,d)=>{if(o)D(i({type:"error",message:s}));else for(let m of Pe(i({message:s}).message,d??Ht(s)))process.stderr.write(m+`
42
42
  `)},v,We="";try{let s=await lr({creds:re,env:I,usernameFlag:e.username,accessKeyFlag:e.accessKey,log:()=>{}});v=s.basicAuth,We=String(s.resolvedCreds?.org_id??"")}catch(s){return s instanceof ar&&s.code==="not_authenticated"?g("not authenticated: pass --username/--access-key or run 'kane-cli login'"):g(`auth resolution failed: ${s.message}`)}if(!v)return g("explore needs Basic credentials (username + access key); none resolved");if(!b){let s=be(e,E,j),d=null,m=v;if(s)try{d=await(n.lookupExploration??(A=>He(new L({baseUrl:B.controllerBaseUrl,auth:m,timeoutMs:5e3}),A)))(s)}catch{d=null}let p=d?Ve(d,String(e.url??"")):null;if(p)return Ke(p.error,p.next),_({exitCode:2,error:p.error})}if(n.afterUrlCheck)return n.afterUrlCheck();if(!E){N.tunnel&&f({type:"warning",message:Bt});let s={...it(I,v,We,oe=>f(oe)),terminal:!t},d;if(typeof e.devBundle=="string"&&e.devBundle){let oe=(process.env.EXPLORE_DEV_CONTROLLER_URL??"").trim();if(!oe)return g("--dev-bundle needs EXPLORE_DEV_CONTROLLER_URL (the controller the VM talks to: the tunnel URL)");if(!Tt(e.devBundle))return g(`--dev-bundle ${e.devBundle}: no such file`);d={bundlePath:e.devBundle,controllerUrl:oe}}let m=j;if(!m)return g("a remote run needs a project: pass --project <id> or set one (kane-cli config set-project); one project has one exploration");t||process.stderr.write(z("launching on HyperExecute")+`
43
- `),c();let p=await Zr(s,{opts:e,variables:R,depsText:U,prompt:e.prompt??"Explore the app",url:String(e.url),projectId:m,allowedDomains:C,policy:x,...ot(e),maxParallel:e.maxParallel,maxLeases:e.maxLeases,kaneVersion:V,...d?{dev:d}:{}});if(!p.ok)return Ke(p.error,p.stopped?"add the missing secret to your variables files (secret: true) or HyperExecute Secrets, then launch again":void 0),p.stopped?_({exitCode:p.exitCode,error:p.error,state:"stopped",remark:J("secrets_missing",p.error),explorationId:p.stopped.explorationId,runId:p.stopped.runId}):_({exitCode:p.exitCode,error:p.error});let A=_({exitCode:0,state:"queued",explorationId:p.explorationId,runId:p.runId});if(t)return A;let{runLiveView:H}=await import("./explore-live-RUAAZGX4.js");return(await H({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:p.explorationId,runId:p.runId,mode:"remote",env:I,policy:x})).exitCode}let ke=sr();if(!ke)return g("v16-runner not found");let qe=W.window_size?.width??1280,Xe=W.window_size?.height??800,Je=j,$,te={explorationId:null,runId:null};if(P==="remote"){if(I!=="stage"&&I!=="prod")return g(`--browser remote: no remote browsers for env ${I}`);let s;try{s=wr(I,M??null)}catch(m){return g(m.message)}let d=v;i=xr([d.access_key]),$=vr({hpsBase:s,auth:d,forge:br(B.tmsBaseUrl,d,()=>({exploration_id:te.explorationId,run_id:te.runId,project_id:Je,hx_job_id:Se().jobId??null,kane_version:V,region:M??null,tunnel:!!N.tunnel,tunnel_name:N.tunnel?.name??null})),tunnel:N.tunnel,releaseSync:m=>yr(B.tmsBaseUrl,d,m),onEvent:m=>f({type:"remote_browser",...m})})}else $=gr({launch:tr,width:qe,height:Xe,headless:!!e.headless});Qe("explore-browsers",()=>$.releaseAllSync());let T=null,Re=null;try{T=await Kr({controller:{baseUrl:B.controllerBaseUrl,authHeader:X(v.username,v.access_key)},onWarn:s=>f({type:"warning",message:s}),onExploration:s=>{process.stderr.write(we(s,e.env)+`
44
- `)},onStop:()=>{f({type:"warning",message:"explore stop: the run is stopping cleanly"}),Re?.()}})}catch(s){f({type:"warning",message:`live mode is off for this run: ${s.message}`})}let Ee=()=>{},ct=new Promise(s=>{Ee=s}),ne=null;t||Ge.add(s=>{s.type!=="explore_run_started"||ne||(ne=import("./explore-live-RUAAZGX4.js").then(({runLiveView:d})=>d({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:String(s.exploration_id),runId:String(s.run_id),mode:"local",env:I,policy:x,ended:ct})))});try{let s=await Ir({url:e.url,prompt:k.prompt,maxLeases:e.maxLeases,explorationId:e.explorationId,...typeof e.claimRunId=="string"?{claimRunId:e.claimRunId}:{requested:Yr({opts:e,url:String(e.url),prompt:e.prompt??"Explore the app",depsText:U,variables:R,allowedDomains:C,policy:x,maxParallel:e.maxParallel,maxLeases:e.maxLeases})},projectId:Je,policy:x,context:k,variables:R,allowedDomains:C,...ot(e),allowPosts:x==="read_only"?ee.posts:[],depthCaps:ve.caps,slowBudgets:_e.budgets,recheck:e.recheck!==!1,maxParallel:K,...typeof e.focus=="string"?{focus:e.focus}:{},denyNames:(e.deny??[]).map(m=>m.trim()).filter(Boolean),headless:!!e.headless,width:qe,height:Xe,auth:v,clientRelease:V},{client:new L({baseUrl:B.controllerBaseUrl,auth:v}),spawnRunner:m=>{let p=ir({environment:I,username:v.username,accessKey:v.access_key,sessionId:m});return $.kind==="local"?Le({env:p,runner:ke,sessionId:m}):Fr(Le({env:p,runner:ke}),De(se,"sessions",m,"runner-stderr.log"),hr([v.access_key]))},acquireBrowser:async m=>{let p=await $.acquire(m);return T?.onBrowser(m),{cdpEndpoint:p.cdpEndpoint,release:()=>{T?.offBrowser(m),p.release()}}},releaseBrowsersOnInterrupt:$.kind==="remote",frameLink:m=>T?.attachRunner(m),onFrame:(m,p)=>T?.runnerFrame(m,p),onLiveRun:m=>{te.explorationId=m.explorationId,te.runId=m.runId,T?.armRun(m)},emit:m=>{l(m);let p=i(m);o?o.emit(p):u?.(p),T?.onEvent(p)},baseDir:se,onInterrupt:m=>{Re=m;let p=Kt(m);return()=>{Re=null,p()}}});await $.releaseAll(),await T?.close(s.stopReason??s.remark?.code??"stopped");let d=_(b?{...s,exitCode:kr(s)}:s);return Ee(d),ne&&await ne,d}finally{Ee(1),await T?.close("stopped"),await $.releaseAll(),Ye("explore-browsers")}}var Dt=3e3;async function Ft(e,r={}){let n=r.tty??!me(e),t=r.out??(x=>{process.stdout.write(x+`
43
+ `),c();let p=await Zr(s,{opts:e,variables:R,depsText:U,prompt:e.prompt??"Explore the app",url:String(e.url),projectId:m,allowedDomains:C,policy:x,...ot(e),maxParallel:e.maxParallel,maxLeases:e.maxLeases,kaneVersion:V,...d?{dev:d}:{}});if(!p.ok)return Ke(p.error,p.stopped?"add the missing secret to your variables files (secret: true) or HyperExecute Secrets, then launch again":void 0),p.stopped?_({exitCode:p.exitCode,error:p.error,state:"stopped",remark:J("secrets_missing",p.error),explorationId:p.stopped.explorationId,runId:p.stopped.runId}):_({exitCode:p.exitCode,error:p.error});let A=_({exitCode:0,state:"queued",explorationId:p.explorationId,runId:p.runId});if(t)return A;let{runLiveView:H}=await import("./explore-live-QIET6WO4.js");return(await H({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:p.explorationId,runId:p.runId,mode:"remote",env:I,policy:x})).exitCode}let ke=sr();if(!ke)return g("v16-runner not found");let qe=W.window_size?.width??1280,Xe=W.window_size?.height??800,Je=j,$,te={explorationId:null,runId:null};if(P==="remote"){if(I!=="stage"&&I!=="prod")return g(`--browser remote: no remote browsers for env ${I}`);let s;try{s=wr(I,M??null)}catch(m){return g(m.message)}let d=v;i=xr([d.access_key]),$=vr({hpsBase:s,auth:d,forge:br(B.tmsBaseUrl,d,()=>({exploration_id:te.explorationId,run_id:te.runId,project_id:Je,hx_job_id:Se().jobId??null,kane_version:V,region:M??null,tunnel:!!N.tunnel,tunnel_name:N.tunnel?.name??null})),tunnel:N.tunnel,releaseSync:m=>yr(B.tmsBaseUrl,d,m),onEvent:m=>f({type:"remote_browser",...m})})}else $=gr({launch:tr,width:qe,height:Xe,headless:!!e.headless});Qe("explore-browsers",()=>$.releaseAllSync());let T=null,Re=null;try{T=await Kr({controller:{baseUrl:B.controllerBaseUrl,authHeader:X(v.username,v.access_key)},onWarn:s=>f({type:"warning",message:s}),onExploration:s=>{process.stderr.write(we(s,e.env)+`
44
+ `)},onStop:()=>{f({type:"warning",message:"explore stop: the run is stopping cleanly"}),Re?.()}})}catch(s){f({type:"warning",message:`live mode is off for this run: ${s.message}`})}let Ee=()=>{},ct=new Promise(s=>{Ee=s}),ne=null;t||Ge.add(s=>{s.type!=="explore_run_started"||ne||(ne=import("./explore-live-QIET6WO4.js").then(({runLiveView:d})=>d({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:String(s.exploration_id),runId:String(s.run_id),mode:"local",env:I,policy:x,ended:ct})))});try{let s=await Ir({url:e.url,prompt:k.prompt,maxLeases:e.maxLeases,explorationId:e.explorationId,...typeof e.claimRunId=="string"?{claimRunId:e.claimRunId}:{requested:Yr({opts:e,url:String(e.url),prompt:e.prompt??"Explore the app",depsText:U,variables:R,allowedDomains:C,policy:x,maxParallel:e.maxParallel,maxLeases:e.maxLeases})},projectId:Je,policy:x,context:k,variables:R,allowedDomains:C,...ot(e),allowPosts:x==="read_only"?ee.posts:[],depthCaps:ve.caps,slowBudgets:_e.budgets,recheck:e.recheck!==!1,maxParallel:K,...typeof e.focus=="string"?{focus:e.focus}:{},denyNames:(e.deny??[]).map(m=>m.trim()).filter(Boolean),headless:!!e.headless,width:qe,height:Xe,auth:v,clientRelease:V},{client:new L({baseUrl:B.controllerBaseUrl,auth:v}),spawnRunner:m=>{let p=ir({environment:I,username:v.username,accessKey:v.access_key,sessionId:m});return $.kind==="local"?Le({env:p,runner:ke,sessionId:m}):Fr(Le({env:p,runner:ke}),De(se,"sessions",m,"runner-stderr.log"),hr([v.access_key]))},acquireBrowser:async m=>{let p=await $.acquire(m);return T?.onBrowser(m),{cdpEndpoint:p.cdpEndpoint,release:()=>{T?.offBrowser(m),p.release()}}},releaseBrowsersOnInterrupt:$.kind==="remote",frameLink:m=>T?.attachRunner(m),onFrame:(m,p)=>T?.runnerFrame(m,p),onLiveRun:m=>{te.explorationId=m.explorationId,te.runId=m.runId,T?.armRun(m)},emit:m=>{l(m);let p=i(m);o?o.emit(p):u?.(p),T?.onEvent(p)},baseDir:se,onInterrupt:m=>{Re=m;let p=Kt(m);return()=>{Re=null,p()}}});await $.releaseAll(),await T?.close(s.stopReason??s.remark?.code??"stopped");let d=_(b?{...s,exitCode:kr(s)}:s);return Ee(d),ne&&await ne,d}finally{Ee(1),await T?.close("stopped"),await $.releaseAll(),Ye("explore-browsers")}}var Dt=3e3;async function Ft(e,r={}){let n=r.tty??!me(e),t=r.out??(x=>{process.stdout.write(x+`
45
45
  `)}),o=n?null:je("explore"),i=String(e.explorationId??"").trim(),u=String(e.project??"").trim(),h=(x,k,R)=>(o?.emit({type:"done",status:k,exit_code:x,exploration_id:i||null,...R?{error:R}:{}}),x),a=(x,k)=>{if(o)D({type:"error",message:x});else{let R=r.err??(U=>{process.stderr.write(U+`
46
46
  `)});R(`error: ${x}`),k&&R(`next: ${k}`)}return h(2,"error",x)};if(i&&u)return a("--exploration-id or --project, not both","kane-cli explore view --exploration-id <id>");if(!i&&!u)return a("name the exploration: --exploration-id or --project","kane-cli explore list --all names them (or plain kane-cli explore to pick one)");let c=await Y(e,"explore view");if(!c.ok)return a(c.error,"kane-cli login");let l=c.basic,f={controllerBaseUrl:c.controllerBaseUrl};if(u){try{i=(await new L({baseUrl:f.controllerBaseUrl,auth:l}).listExplorations({state:"all",project:u})).explorations.find(k=>k.project_id===u)?.exploration_id??""}catch(x){return a(`could not find project ${u}'s exploration: ${x.message}`)}if(!i)return a(`project ${u} has no exploration`,`start one: kane-cli explore run --project ${u} --url <app>`)}let y=X(l.username,l.access_key),_={controllerBaseUrl:f.controllerBaseUrl,authHeader:y,explorationId:i,port:e.port,live:{controller:{baseUrl:f.controllerBaseUrl,authHeader:y}}},g=await Tr(_);if(g.kind==="not_found")return a(`exploration ${i} not found`,"kane-cli explore list --all");if(g.kind==="error")return a(`could not read the map: ${g.message}`);let b;try{b=await Cr(_)}catch(x){return a(`could not bind 127.0.0.1${_.port?`:${_.port}`:""}: ${x.message}`,"pass another --port, or leave it out for the first free one")}let G=r.hold?null:Wt(),E=null;try{E=await new L({baseUrl:f.controllerBaseUrl,auth:l,timeoutMs:Dt}).getContext(i)}catch{}o&&o.emit({type:"explore_view_started",url:b.url,exploration_id:i,context:E});let O=null;if(!o){let x=!r.out&&!!process.stdin.isTTY&&!!process.stdout.isTTY;x&&st(b.url),t(z("map viewer ready",` \xB7 ${b.url}`)),t(jt(` ${x?"opened in your browser \xB7 ":""}live when a run is going`)),t("");let k=g.kind==="ok"&&g.body.counts&&typeof g.body.counts=="object"?g.body.counts:null,R=E?`context ${E.enabled?"on":"off"}${E.last_job?` \xB7 ${E.last_job.status}`:""}`:"";for(let U of Pr({status:z("serving"),meta:["explore",i.slice(0,8),c.environment??""],tallies:[...$r(k).filter(C=>!C.endsWith("findings")&&!C.endsWith("finding")),...R?[R]:[]],keys:[...x?["o open again"]:[],"ctrl+c stop serving"]}))t(U);x&&!r.hold&&(O=Gt(()=>{st(b.url)}))}r.onStarted?.(b);try{await(G??r.hold())}finally{O?.()}return await b.close(),h(0,"stopped")}async function st(e){try{let{default:r}=await import("./open-MQLQKFAW.js");await r(e)}catch{process.stderr.write(`could not open a browser: open ${e}
47
47
  `)}}function Gt(e){let r=process.stdin;if(!r.isTTY)return()=>{};let n=t=>{let o=t.toString("utf8");o===""?process.kill(process.pid,"SIGINT"):(o==="o"||o==="O")&&e()};return r.setRawMode(!0),r.resume(),r.on("data",n),()=>{r.off("data",n);try{r.setRawMode(!1)}catch{}r.pause()}}function Kt(e){let r=process.listeners("SIGINT");for(let n of r)process.removeListener("SIGINT",n);return process.on("SIGINT",e),()=>{process.removeListener("SIGINT",e);for(let n of r)process.on("SIGINT",n)}}function Wt(){return new Promise(e=>{let r=process.listeners("SIGINT"),n=process.listeners("SIGTERM");process.removeAllListeners("SIGINT"),process.removeAllListeners("SIGTERM");let t=()=>{process.removeListener("SIGINT",t),process.removeListener("SIGTERM",t);for(let o of r)process.on("SIGINT",o);for(let o of n)process.on("SIGTERM",o);e()};process.once("SIGINT",t),process.once("SIGTERM",t)})}function it(e,r,n,t){let o=ae(e);return{env:e,controllerBaseUrl:o.controllerBaseUrl,secretsBaseUrl:o.secretsBaseUrl,tmsBaseUrl:o.tmsBaseUrl,basic:r,orgId:n,emit:t}}export{Ct as a,Pt as b,yo as c,nt as d,At as e,Ot as f,Nt as g,ot as h,Bt as i,Vt as j,Dt as k,Ft as l,Kt as m};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-FCD3NYOM.js";import{a as c}from"./chunk-4QTH7VYE.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-66TGWITQ.js"),import("./bootstrap-BV7HAARR.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
2
+ import{a as l}from"./chunk-FCD3NYOM.js";import{a as c}from"./chunk-4QTH7VYE.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-66TGWITQ.js"),import("./bootstrap-A2O4UZUJ.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-6CMBA5SG.js";import{a as C}from"./chunk-YWQNZRJG.js";import{r as m,s as u,t as f,u as x,v as y}from"./chunk-YKOZBFR3.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
2
+ import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-HTJDMLZS.js";import{a as C}from"./chunk-JYH7CTF7.js";import{s as m,t as u,u as f,v as x,w as y}from"./chunk-BRWCWZE3.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
3
3
  Please open this URL manually: ${e}
4
4
  `)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
5
5
  <html lang="en">
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ae}from"./chunk-AFOP7DVG.js";import{b as ue}from"./chunk-ZUZ6QJRA.js";import{a as w,b as q}from"./chunk-KGNE5CIM.js";import{n as k,p as ce,q as de,r as pe,s as fe}from"./chunk-P7V24ZXP.js";import{a as ge}from"./chunk-YDPTSDIJ.js";import{d as le}from"./chunk-3AGP2BVN.js";import{d as oe,f as se}from"./chunk-OSEXVHEN.js";import{a as re}from"./chunk-HMGM4KO6.js";import{b as ie}from"./chunk-H6QHG62O.js";import{a as te}from"./chunk-2VLM4L3S.js";import{a as I}from"./chunk-HCBYKLMW.js";import{a as ne}from"./chunk-PVN64537.js";import{a as G}from"./chunk-73EHVDL5.js";import{a as ee}from"./chunk-YWQNZRJG.js";import{z as m}from"./chunk-YKOZBFR3.js";import{a as M,b as E}from"./chunk-33DWJV67.js";import{a as h}from"./chunk-FOJHSG5M.js";import{e as Z}from"./chunk-UR6MHSHU.js";function j(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}function W(e){return e?e.code||e.message:""}function Y(e,t=Date.now()){if(!e)return"";let n=new Date(e).getTime();if(Number.isNaN(n))return e;let r=Math.floor(Math.max(0,t-n)/6e4);if(r<1)return"just now";if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function v(e,t=Date.now()){let n=Y(e,t);return!n||n==="just now"||!/^\d/.test(n)?n:`${n} ago`}function R(e){return e?e.slice(0,8):""}function me(e){if(!e)return"";try{return new URL(e).host||e}catch{return e}}function P(e){return e?e.replace(/_/g," "):""}var Ue={user_off:"turned off",project_not_shared:"project not shared: share it in Test Manager",project_unknown:"the project's sharing could not be checked",not_configured:"assurance jobs are not set up on this service",mark_refused:"the first assurance job could not share the project: ask a Test Manager admin for permission to create test cases, then turn context off and on"};function A(e){return e==null?"":e==="end"?"run end":`cut ${e}`}function xe(e){return e?e.enabled?e.running?"on \xB7 job running":e.last_job_status?`on \xB7 last job ${e.last_job_status}`:"on":"off":""}function K(e){let t=e.off_reason?Ue[e.off_reason]??e.off_reason:"";return e.enabled&&t?`on, blocked: ${t}`:e.enabled?"on":t?`off (${t})`:"off"}var f=e=>h.hex(m.dim)(e);var _e=e=>h.hex(m.orange)(e),J=e=>h.hex(m.green)(e),be=e=>h.hex(m.amber)(e),D=e=>h.hex(m.red)(e);function Be(e=process.stdout.columns){return Math.max(60,(e&&e>0?e:140)-2)}function Fe(e,t,n,r){let i=e.map((s,l)=>Math.max(s.length,...t.map(d=>(d[l]??"").length),1)),o=e.length*3+1,a=i.reduce((s,l)=>s+l,0)+o-n;if(a<=0)return t;let u=Math.min(a,Math.max(0,i[r]-7));for(i[r]-=u,a-=u;a>0;){let s=-1;if(i.forEach((l,d)=>{l>Math.max(7,e[d].length)&&(s<0||l>i[s])&&(s=d)}),s<0)break;i[s]-=1,a-=1}let c=(s,l)=>s.length<=l?s:`${s.slice(0,Math.max(0,l-1))}\u2026`;return t.map(s=>s.map((l,d)=>c(l,i[d])))}function ye(e,t,n,r){let i=Be(r);return le(e,Fe(e,t,i,n),i,n).map((o,a)=>a===1?h.bold(o):o)}function b(e,t="",n="open"){return`${(n==="done"?J:n==="failed"?D:_e)(`\u25CF ${e}`)}${t?f(t):""}`}function we(e,t){return[D(`error: ${e}`),...t?[`next: ${t}`]:[]]}function Ve(e){return e.current_session?`\u25CF ${e.current_session.state}`:"idle"}function Ge(e,t){if(e.current_session)return`run ${R(e.current_session.run_id)} \xB7 ${Y(e.current_session.started_at,t)}`;let n=e.last_session;return n?[W(n.remark)||"stopped",v(n.ended_at??n.started_at,t)].filter(Boolean).join(" \xB7 "):"never run"}function qe(e,t={}){return(e.project_id?t[e.project_id]:void 0)||(e.name?e.name:"")||R(e.project_id??e.exploration_id)}function $e(e,t){if(!e.length)return[f(t.all?"no explorations":"no running explorations (--all lists every one)")];let n=t.now??Date.now(),r=e.some(a=>a.context),i=["project","app","state","last run",...r?["context"]:[]],o=e.map(a=>[qe(a,t.projects),me(a.target_url),Ve(a),Ge(a,n),...r?[xe(a.context)]:[]]);return[...ye(i,o,1,t.cols),f(`${e.length} exploration${e.length===1?"":"s"} \xB7 newest first${t.nextCursor?` \xB7 more: --cursor ${t.nextCursor}`:""} \xB7 kane-cli explore to open one`)]}function ke(e){return e.credits&&typeof e.credits.total=="number"?Math.round(e.credits.total).toLocaleString("en-US"):""}function je(e,t,n){if(!t.length)return[f(`exploration ${e} has no sessions yet`)];let r=n.now??Date.now(),i=t.map(o=>[R(o.run_id),o.state==="stopped"?"stopped":`\u25CF ${o.state}`,W(o.remark)||"\u2014",o.mode,o.leases===void 0?"":String(o.leases),o.findings===void 0?"":String(o.findings),ke(o),v(o.started_at,r)]);return[...ye(["run","state","remark","mode","leases","findings","credits","started"],i,2,n.cols),f(`${t.length} session${t.length===1?"":"s"} \xB7 --run <run-id> for one in full${n.nextCursor?` \xB7 more: --cursor ${n.nextCursor}`:""}`)]}function X(e,t=18){let n=e.filter(([,i])=>i),r=Math.max(t,...n.map(([i])=>i.length+2));return n.map(([i,o,a])=>` ${f(i.padEnd(r))}${a?a(o):o}`)}function Ee(e){return[h.bold(`run ${e.run_id}`),...X([["exploration",e.exploration_id],["session",`#${e.version}`],["state",e.state,e.state==="stopped"?void 0:_e],["remark",e.remark?`${e.remark.code}: ${e.remark.message}`:""],["stop reason",e.stop_reason??""],["mode",e.mode],["started",j(e.started_at)],["started by",e.started_by_user_id?`user ${e.started_by_user_id}`:""],["claimed",j(e.claimed_at)],["stop asked",j(e.stop_requested_at)],["stopped by",e.stopped_by_user_id?`user ${e.stopped_by_user_id}`:""],["ended",j(e.ended_at)],["leases",e.leases===void 0?"":String(e.leases)],["findings",e.findings===void 0?"":String(e.findings)],["credits",ke(e)],["job",e.hx_job_link??e.hx_job_id??""]])]}function Ce(e){let t=K(e);return e.enabled?e.off_reason?be(t):J(t):f(t)}function We(e,t){return e?t!=null&&e===t?" by you":` by user ${e}`:""}function he(e,t){let n=P(e),r=A(t);return n?!r||r===n?n:`${n} \xB7 ${r}`:r}function at(e){let t=Math.max(20,e.cols??process.stdout.columns??100);return[f("\u2500".repeat(t)),`${e.status}${e.meta.filter(Boolean).length?f(` \xB7 ${e.meta.filter(Boolean).join(" \xB7 ")}`):""}`,...e.tallies?.length?[f(e.tallies.join(" \xB7 "))]:[],f(e.keys.join(" \xB7 "))]}function Te(e){if(!e)return[];let t=(n,r,i)=>typeof n=="number"?`${n} ${n===1?r:i}`:"";return[t(e.junctions,"screen","screens"),t(e.flows,"flow","flows"),t(e.findings,"finding","findings")].filter(Boolean)}function ut(e,t={}){let n=e.last_job,r=e.running_job,i=[h.bold(`Assurance context${t.project?` \xB7 "${t.project}"`:""}`),...X([["state",K(e),()=>Ce(e)],["changed",e.changed_at?`${v(e.changed_at)}${We(e.changed_by_user_id,t.me)}`:""],["pending cut",e.pending_cut?`${A(e.pending_cut.cut)} (${P(e.pending_cut.trigger)})`:"none"],["running job",r?`${R(r.job_id)} \xB7 ${he(r.trigger,r.cut)}${r.status==="launching"?" \xB7 launching (HyperExecute has not answered yet)":""}${r.hx_job_link?` \xB7 ${r.hx_job_link}`:""}`:"none"]]),""],o=["",f(`sync now: kane-cli explore context sync ${e.exploration_id}`)];if(!n)return[...i,f("no assurance job has run yet"),...o];let a=n.use_cases?.added?.length??0,u=n.use_cases?.modified?.length??0,c=n.tests?.failed??[],s=n.status==="ok"||n.status==="noop"?J:n.status==="partial"?be:D;return[...i,h.bold("Last job"),...X([["status",n.status,s],["trigger \xB7 cut",he(n.trigger,n.cut)],["use cases",a||u?`${a} added \xB7 ${u} modified`:""],["tests",n.tests?`${n.tests.designed??0} designed \xB7 ${n.tests.saved??0} saved${c.length?` \xB7 failed: ${c.join(", ")}`:""}`:""],["held",n.held?.length?n.held.map(l=>`${l.ref} (${l.why})`).join("; "):""],["error",n.error?`${n.error.code}${n.error.message?`: ${n.error.message}`:""}`:"",D],["ended",v(n.ended_at)],["credits",typeof n.credits=="number"?String(n.credits):""],["job",n.hx_job_link??n.hx_job_id??n.job_id]]),...(n.attempt??1)>1?[f(" retry of a failed attempt; counts cover this attempt only")]:[],...o]}function lt(e,t){let n=A(t.cut)||"the newest cut",r=f(` status: kane-cli explore context status ${e}`);return t.state==="launched"?[b("assurance job launched",` \xB7 ${P(t.trigger)||"manual"} \xB7 ${n}`),...t.hx_job_link?[f(` job: ${t.hx_job_link}`)]:[],r]:t.state==="launching"?[b("assurance job launching",` \xB7 ${n} \xB7 HyperExecute has not answered yet`),r]:t.state==="pending"&&t.trigger==="run_end"?[b("the run-end job is waiting",` \xB7 a job is running${t.running_job_id?` (${t.running_job_id})`:""}`),f(" this sync was folded into it: the run-end job reads the whole run, so nothing else is queued"),r]:t.state==="pending"?[b(`assurance ${n} pending`,` \xB7 a job is running${t.running_job_id?` (${t.running_job_id})`:""}; this cut runs after it (a newer one replaces it)`),r]:t.state==="running"?[b(`a job is already running on ${n}`,t.job_id?` (${t.job_id})`:""),r]:t.state==="up_to_date"?[b("assurance context up to date",` \xB7 ${t.cut!==void 0&&t.cut!==null?`${A(t.cut)} already read`:"nothing new"}`,"done")]:[b(`assurance sync: ${t.state}`)]}function ct(e,t,n,r){return[b(`assurance context ${n}`,r?` \xB7 "${r}"`:` \xB7 exploration ${e}`,"done"),` ${f("now")} ${Ce(t)}`,...n==="off"?[f(" the next cut is skipped; nothing already saved is deleted"),f(` turn on: kane-cli explore context on ${e}`)]:[f(" the controller catches up from the newest ended run")]]}function z(){return{stdin:!!process.stdin.isTTY,stdout:!!process.stdout.isTTY}}function Se(e,t=z()){return!!e.agent||!t.stdin||!t.stdout}var Ye=ce;function ve(e){return e.option("--agent",Ye)}function Re(e){return{formatHelp(t,n){let r=n.padWidth(t,n),i=n.helpWidth||80,o=2,a=2,u=(p,y)=>{if(!y)return p;let _=r+a;return y.split(`
2
+ import{a as ae}from"./chunk-EP4WGGMY.js";import{b as ue}from"./chunk-ZUZ6QJRA.js";import{a as w,b as q}from"./chunk-KGNE5CIM.js";import{n as k,p as ce,q as de,r as pe,s as fe}from"./chunk-MIQ6J5YG.js";import{a as ge}from"./chunk-YDPTSDIJ.js";import{d as le}from"./chunk-3AGP2BVN.js";import{d as oe,f as se}from"./chunk-TC2PHBPH.js";import{a as re}from"./chunk-66C5A2F5.js";import{b as ie}from"./chunk-PZOQ2IQK.js";import{a as te}from"./chunk-Q4QCSO6Y.js";import{a as I}from"./chunk-HCBYKLMW.js";import{a as ne}from"./chunk-PVN64537.js";import{a as G}from"./chunk-V24LUINK.js";import{a as ee}from"./chunk-JYH7CTF7.js";import{A as m}from"./chunk-BRWCWZE3.js";import{a as M,b as E}from"./chunk-33DWJV67.js";import{a as h}from"./chunk-FOJHSG5M.js";import{e as Z}from"./chunk-UR6MHSHU.js";function j(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}function W(e){return e?e.code||e.message:""}function Y(e,t=Date.now()){if(!e)return"";let n=new Date(e).getTime();if(Number.isNaN(n))return e;let r=Math.floor(Math.max(0,t-n)/6e4);if(r<1)return"just now";if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function v(e,t=Date.now()){let n=Y(e,t);return!n||n==="just now"||!/^\d/.test(n)?n:`${n} ago`}function R(e){return e?e.slice(0,8):""}function me(e){if(!e)return"";try{return new URL(e).host||e}catch{return e}}function P(e){return e?e.replace(/_/g," "):""}var Ue={user_off:"turned off",project_not_shared:"project not shared: share it in Test Manager",project_unknown:"the project's sharing could not be checked",not_configured:"assurance jobs are not set up on this service",mark_refused:"the first assurance job could not share the project: ask a Test Manager admin for permission to create test cases, then turn context off and on"};function A(e){return e==null?"":e==="end"?"run end":`cut ${e}`}function xe(e){return e?e.enabled?e.running?"on \xB7 job running":e.last_job_status?`on \xB7 last job ${e.last_job_status}`:"on":"off":""}function K(e){let t=e.off_reason?Ue[e.off_reason]??e.off_reason:"";return e.enabled&&t?`on, blocked: ${t}`:e.enabled?"on":t?`off (${t})`:"off"}var f=e=>h.hex(m.dim)(e);var _e=e=>h.hex(m.orange)(e),J=e=>h.hex(m.green)(e),be=e=>h.hex(m.amber)(e),D=e=>h.hex(m.red)(e);function Be(e=process.stdout.columns){return Math.max(60,(e&&e>0?e:140)-2)}function Fe(e,t,n,r){let i=e.map((s,l)=>Math.max(s.length,...t.map(d=>(d[l]??"").length),1)),o=e.length*3+1,a=i.reduce((s,l)=>s+l,0)+o-n;if(a<=0)return t;let u=Math.min(a,Math.max(0,i[r]-7));for(i[r]-=u,a-=u;a>0;){let s=-1;if(i.forEach((l,d)=>{l>Math.max(7,e[d].length)&&(s<0||l>i[s])&&(s=d)}),s<0)break;i[s]-=1,a-=1}let c=(s,l)=>s.length<=l?s:`${s.slice(0,Math.max(0,l-1))}\u2026`;return t.map(s=>s.map((l,d)=>c(l,i[d])))}function ye(e,t,n,r){let i=Be(r);return le(e,Fe(e,t,i,n),i,n).map((o,a)=>a===1?h.bold(o):o)}function b(e,t="",n="open"){return`${(n==="done"?J:n==="failed"?D:_e)(`\u25CF ${e}`)}${t?f(t):""}`}function we(e,t){return[D(`error: ${e}`),...t?[`next: ${t}`]:[]]}function Ve(e){return e.current_session?`\u25CF ${e.current_session.state}`:"idle"}function Ge(e,t){if(e.current_session)return`run ${R(e.current_session.run_id)} \xB7 ${Y(e.current_session.started_at,t)}`;let n=e.last_session;return n?[W(n.remark)||"stopped",v(n.ended_at??n.started_at,t)].filter(Boolean).join(" \xB7 "):"never run"}function qe(e,t={}){return(e.project_id?t[e.project_id]:void 0)||(e.name?e.name:"")||R(e.project_id??e.exploration_id)}function $e(e,t){if(!e.length)return[f(t.all?"no explorations":"no running explorations (--all lists every one)")];let n=t.now??Date.now(),r=e.some(a=>a.context),i=["project","app","state","last run",...r?["context"]:[]],o=e.map(a=>[qe(a,t.projects),me(a.target_url),Ve(a),Ge(a,n),...r?[xe(a.context)]:[]]);return[...ye(i,o,1,t.cols),f(`${e.length} exploration${e.length===1?"":"s"} \xB7 newest first${t.nextCursor?` \xB7 more: --cursor ${t.nextCursor}`:""} \xB7 kane-cli explore to open one`)]}function ke(e){return e.credits&&typeof e.credits.total=="number"?Math.round(e.credits.total).toLocaleString("en-US"):""}function je(e,t,n){if(!t.length)return[f(`exploration ${e} has no sessions yet`)];let r=n.now??Date.now(),i=t.map(o=>[R(o.run_id),o.state==="stopped"?"stopped":`\u25CF ${o.state}`,W(o.remark)||"\u2014",o.mode,o.leases===void 0?"":String(o.leases),o.findings===void 0?"":String(o.findings),ke(o),v(o.started_at,r)]);return[...ye(["run","state","remark","mode","leases","findings","credits","started"],i,2,n.cols),f(`${t.length} session${t.length===1?"":"s"} \xB7 --run <run-id> for one in full${n.nextCursor?` \xB7 more: --cursor ${n.nextCursor}`:""}`)]}function X(e,t=18){let n=e.filter(([,i])=>i),r=Math.max(t,...n.map(([i])=>i.length+2));return n.map(([i,o,a])=>` ${f(i.padEnd(r))}${a?a(o):o}`)}function Ee(e){return[h.bold(`run ${e.run_id}`),...X([["exploration",e.exploration_id],["session",`#${e.version}`],["state",e.state,e.state==="stopped"?void 0:_e],["remark",e.remark?`${e.remark.code}: ${e.remark.message}`:""],["stop reason",e.stop_reason??""],["mode",e.mode],["started",j(e.started_at)],["started by",e.started_by_user_id?`user ${e.started_by_user_id}`:""],["claimed",j(e.claimed_at)],["stop asked",j(e.stop_requested_at)],["stopped by",e.stopped_by_user_id?`user ${e.stopped_by_user_id}`:""],["ended",j(e.ended_at)],["leases",e.leases===void 0?"":String(e.leases)],["findings",e.findings===void 0?"":String(e.findings)],["credits",ke(e)],["job",e.hx_job_link??e.hx_job_id??""]])]}function Ce(e){let t=K(e);return e.enabled?e.off_reason?be(t):J(t):f(t)}function We(e,t){return e?t!=null&&e===t?" by you":` by user ${e}`:""}function he(e,t){let n=P(e),r=A(t);return n?!r||r===n?n:`${n} \xB7 ${r}`:r}function at(e){let t=Math.max(20,e.cols??process.stdout.columns??100);return[f("\u2500".repeat(t)),`${e.status}${e.meta.filter(Boolean).length?f(` \xB7 ${e.meta.filter(Boolean).join(" \xB7 ")}`):""}`,...e.tallies?.length?[f(e.tallies.join(" \xB7 "))]:[],f(e.keys.join(" \xB7 "))]}function Te(e){if(!e)return[];let t=(n,r,i)=>typeof n=="number"?`${n} ${n===1?r:i}`:"";return[t(e.junctions,"screen","screens"),t(e.flows,"flow","flows"),t(e.findings,"finding","findings")].filter(Boolean)}function ut(e,t={}){let n=e.last_job,r=e.running_job,i=[h.bold(`Assurance context${t.project?` \xB7 "${t.project}"`:""}`),...X([["state",K(e),()=>Ce(e)],["changed",e.changed_at?`${v(e.changed_at)}${We(e.changed_by_user_id,t.me)}`:""],["pending cut",e.pending_cut?`${A(e.pending_cut.cut)} (${P(e.pending_cut.trigger)})`:"none"],["running job",r?`${R(r.job_id)} \xB7 ${he(r.trigger,r.cut)}${r.status==="launching"?" \xB7 launching (HyperExecute has not answered yet)":""}${r.hx_job_link?` \xB7 ${r.hx_job_link}`:""}`:"none"]]),""],o=["",f(`sync now: kane-cli explore context sync ${e.exploration_id}`)];if(!n)return[...i,f("no assurance job has run yet"),...o];let a=n.use_cases?.added?.length??0,u=n.use_cases?.modified?.length??0,c=n.tests?.failed??[],s=n.status==="ok"||n.status==="noop"?J:n.status==="partial"?be:D;return[...i,h.bold("Last job"),...X([["status",n.status,s],["trigger \xB7 cut",he(n.trigger,n.cut)],["use cases",a||u?`${a} added \xB7 ${u} modified`:""],["tests",n.tests?`${n.tests.designed??0} designed \xB7 ${n.tests.saved??0} saved${c.length?` \xB7 failed: ${c.join(", ")}`:""}`:""],["held",n.held?.length?n.held.map(l=>`${l.ref} (${l.why})`).join("; "):""],["error",n.error?`${n.error.code}${n.error.message?`: ${n.error.message}`:""}`:"",D],["ended",v(n.ended_at)],["credits",typeof n.credits=="number"?String(n.credits):""],["job",n.hx_job_link??n.hx_job_id??n.job_id]]),...(n.attempt??1)>1?[f(" retry of a failed attempt; counts cover this attempt only")]:[],...o]}function lt(e,t){let n=A(t.cut)||"the newest cut",r=f(` status: kane-cli explore context status ${e}`);return t.state==="launched"?[b("assurance job launched",` \xB7 ${P(t.trigger)||"manual"} \xB7 ${n}`),...t.hx_job_link?[f(` job: ${t.hx_job_link}`)]:[],r]:t.state==="launching"?[b("assurance job launching",` \xB7 ${n} \xB7 HyperExecute has not answered yet`),r]:t.state==="pending"&&t.trigger==="run_end"?[b("the run-end job is waiting",` \xB7 a job is running${t.running_job_id?` (${t.running_job_id})`:""}`),f(" this sync was folded into it: the run-end job reads the whole run, so nothing else is queued"),r]:t.state==="pending"?[b(`assurance ${n} pending`,` \xB7 a job is running${t.running_job_id?` (${t.running_job_id})`:""}; this cut runs after it (a newer one replaces it)`),r]:t.state==="running"?[b(`a job is already running on ${n}`,t.job_id?` (${t.job_id})`:""),r]:t.state==="up_to_date"?[b("assurance context up to date",` \xB7 ${t.cut!==void 0&&t.cut!==null?`${A(t.cut)} already read`:"nothing new"}`,"done")]:[b(`assurance sync: ${t.state}`)]}function ct(e,t,n,r){return[b(`assurance context ${n}`,r?` \xB7 "${r}"`:` \xB7 exploration ${e}`,"done"),` ${f("now")} ${Ce(t)}`,...n==="off"?[f(" the next cut is skipped; nothing already saved is deleted"),f(` turn on: kane-cli explore context on ${e}`)]:[f(" the controller catches up from the newest ended run")]]}function z(){return{stdin:!!process.stdin.isTTY,stdout:!!process.stdout.isTTY}}function Se(e,t=z()){return!!e.agent||!t.stdin||!t.stdout}var Ye=ce;function ve(e){return e.option("--agent",Ye)}function Re(e){return{formatHelp(t,n){let r=n.padWidth(t,n),i=n.helpWidth||80,o=2,a=2,u=(p,y)=>{if(!y)return p;let _=r+a;return y.split(`
3
3
  `).map((V,Oe)=>n.wrap(`${(Oe===0?p:"").padEnd(_)}${V}`,i-o,_)).join(`
4
4
  `)},c=p=>p.join(`
5
5
  `).replace(/^/gm," ".repeat(o)),s=[`Usage: ${n.commandUsage(t)}`,""],l=n.commandDescription(t);l&&(s=s.concat([n.wrap(l,i,0),""]));let d=n.visibleArguments(t).map(p=>u(n.argumentTerm(p),n.argumentDescription(p)));d.length&&(s=s.concat(["Arguments:",c(d),""]));let g=n.visibleOptions(t),$=new Set;for(let p of e){let y=p.flags.map(_=>g.find(V=>V.long===_)).filter(_=>!!_&&!$.has(_));if(y.length){for(let _ of y)$.add(_);s=s.concat([`${p.title}:`,c(y.map(_=>u(n.optionTerm(_),_.description))),""])}}let T=g.filter(p=>!$.has(p));T.length&&(s=s.concat(["Other options:",c(T.map(p=>u(n.optionTerm(p),p.description))),""]));let S=n.visibleCommands(t).map(p=>u(n.subcommandTerm(p),n.subcommandDescription(p)));return S.length&&(s=s.concat(["Commands:",c(S),""])),s.join(`
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as v}from"./chunk-CCOD4GQJ.js";import{a as S}from"./chunk-QSCXXNC2.js";import{a as u,b as d}from"./chunk-YKOZBFR3.js";import{m as g}from"./chunk-WMXBRC4B.js";import{existsSync as P}from"fs";import{join as T}from"path";import{mkdirSync as b,rmSync as h,writeFileSync as k}from"fs";import{join as E,resolve as A}from"path";import{join as w}from"path";function m(){return process.env.KANE_CLI_WIRE_BASE_DIR||d}function J(e){return w(m(),"sessions",`testrun-${e}`)}function y(e=m()){return E(e,"sessions","active")}function _(e,r){return E(y(r),`${e}.json`)}function x(e){let r=e.pid??process.pid,n=_(r,e.baseDir);try{b(y(e.baseDir),{recursive:!0}),k(n,JSON.stringify({pid:r,cwd:process.cwd(),surface:e.surface,session_dir:A(e.sessionDir),started:new Date().toISOString(),cli_version:u,host_agent:S()},null,2)+`
2
+ import{b as v}from"./chunk-CCOD4GQJ.js";import{a as S}from"./chunk-QSCXXNC2.js";import{a as u,b as d}from"./chunk-BRWCWZE3.js";import{m as g}from"./chunk-WMXBRC4B.js";import{existsSync as P}from"fs";import{join as T}from"path";import{mkdirSync as b,rmSync as h,writeFileSync as k}from"fs";import{join as E,resolve as A}from"path";import{join as w}from"path";function m(){return process.env.KANE_CLI_WIRE_BASE_DIR||d}function J(e){return w(m(),"sessions",`testrun-${e}`)}function y(e=m()){return E(e,"sessions","active")}function _(e,r){return E(y(r),`${e}.json`)}function x(e){let r=e.pid??process.pid,n=_(r,e.baseDir);try{b(y(e.baseDir),{recursive:!0}),k(n,JSON.stringify({pid:r,cwd:process.cwd(),surface:e.surface,session_dir:A(e.sessionDir),started:new Date().toISOString(),cli_version:u,host_agent:S()},null,2)+`
3
3
  `)}catch{}return n}function f(e=process.pid,r){try{h(_(e,r),{force:!0})}catch{}}var R={run:"run_end",testmd:"test_md_done",testrun:"testrun_done",explore:"done"};import{appendFileSync as I,mkdirSync as N}from"fs";import{dirname as O}from"path";function D(e){let r=!1;return{path:e,append(n){try{r||(N(O(e),{recursive:!0}),r=!0),I(e,n+`
4
4
  `)}catch{}}}}function W(e,r=()=>new Date){let{v:n,ts:c,...i}=e;return{...i,v:1,ts:typeof c=="string"?c:r().toISOString()}}function V(e){let r=e.stdout??(t=>{process.stdout.write(t)}),n=R[e.surface],c=!1,i=null,o=null,p=[],l=()=>{if(!(o||!i||!P(i))){o=D(T(i,"events.ndjson"));for(let t of p)o.append(t);p=[];try{e.onAttach?.(i)}catch{}}};return{emit(t){if(c)return;let a=v(JSON.stringify(W(t,e.now)));r(a+`
5
5
  `),l(),o?o.append(a):p.push(a),t.type===n&&(c=!0,p=[])},attachSessionDir(t){i=t,l()},setTerminal(t){n=t},get logPath(){return o?o.path:null}}}var s=null;function j(e){return r=>{x({surface:e,sessionDir:r}),g("wire-active-run",()=>f()),process.once("exit",()=>f())}}function se(e,r){return s=V({surface:e,cliVersion:u,onAttach:r??j(e)}),s.emit({type:"stream_start",cli_version:u,surface:e,pid:process.pid}),s}function ce(){return s}function ue(e){if(s){s.emit(e);return}process.stdout.write(JSON.stringify(W(e))+`
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as v}from"./chunk-72KYMWQ5.js";import{a as h}from"./chunk-CCOD4GQJ.js";import{a as b}from"./chunk-JQ64X2TO.js";import{a as m}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as p}from"./chunk-4QTH7VYE.js";import{a as g}from"./chunk-73EHVDL5.js";import{a as u}from"./chunk-RZ4F3BHX.js";var f=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=p(e.username,e.accessKey),n=await u(`${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 d=class extends m{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await u(`${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 c=await n.json().catch(()=>({}));if(c.type==="Success"&&c.id!=null)return{id:Number(c.id)||0}}let t=await u(`${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 u(`${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 A,readFileSync as S,existsSync as R}from"fs";import{join as I}from"path";function y(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 E(r,e){if(!R(r))return{};let s={},n;try{n=A(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=S(I(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[o,c]of Object.entries(i))c&&typeof c=="object"&&"value"in c&&(s[o]=y(o,c))}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 v}from"./chunk-72KYMWQ5.js";import{a as h}from"./chunk-CCOD4GQJ.js";import{a as b}from"./chunk-JQ64X2TO.js";import{a as m}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as p}from"./chunk-4QTH7VYE.js";import{a as g}from"./chunk-V24LUINK.js";import{a as u}from"./chunk-RZ4F3BHX.js";var f=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=p(e.username,e.accessKey),n=await u(`${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 d=class extends m{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await u(`${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 c=await n.json().catch(()=>({}));if(c.type==="Success"&&c.id!=null)return{id:Number(c.id)||0}}let t=await u(`${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 u(`${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 A,readFileSync as S,existsSync as R}from"fs";import{join as I}from"path";function y(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 E(r,e){if(!R(r))return{};let s={},n;try{n=A(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=S(I(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[o,c]of Object.entries(i))c&&typeof c=="object"&&"value"in c&&(s[o]=y(o,c))}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 w(r){if(!R(r))throw new Error(`Variables file not found: ${r}`);let e=S(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]=y(t,a));return n}function j(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]=y(n,t));return s}function P(r,e,s){let n=E(r,s),t=E(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}}}`;_(e,a)&&(s[n]=t)}return s}function k(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 _(r,e){if(!e||!r)return!1;if(r.includes(e))return!0;let s=k(e);if(!s)return!1;let n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${n}(?=\\s*\\}|[.\\[])`).test(r)}function Y(r){let e=P(r.globalDir,r.localDir,r.onLoadError),s=r.file?w(r.file):{},n=r.inline?j(r.inline):{},t={...e,...s,...n,...r.parameters??{}},a=Object.keys(t).length>0,{variables:i,objective:o}=a?v(t,r.objective):{variables:{},objective:r.objective},c=$(t);return h(c.secretEntries.map(([,l])=>l.value)),{raw:t,auteur:i,auteurObjective:o,...c}}function $(r){let e=Object.entries(r),s=e.filter(([,t])=>b(t)),n=e.filter(([,t])=>!b(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=g(r.env),s=[];if(r.variables.secretEntries.length>0){let i=new f(e.secretsBaseUrl);for(let[o,c]of r.variables.secretEntries){let l=i.pushSecret({secretKey:o,secretValue:c.value,username:r.auth.username,accessKey:r.auth.access_key,orgId:r.orgId}).then(()=>!0).catch(x=>(r.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:o,error:String(x)}),!1));s.push(l)}}let n={},t=0,a=0;if(r.variables.nonSecretEntries.length>0){let i=new d(e.tmsBaseUrl,r.auth.username,r.auth.access_key);for(let[o,c]of r.variables.nonSecretEntries)try{let l=await i.upsertVariable({name:o,value:c.value});n[o]=l.id,t++}catch(l){a++,r.log("error","VAR_PUSH_FAILED","Variable push failed",{name:o,error:String(l)})}}return(s.length>0||t+a>0)&&Promise.all(s).then(i=>{let o=i.filter(Boolean).length;r.log("info","VAR_SUMMARY","Variables pushed",{vars_pushed:t,vars_failed:a,secrets_pushed:o,secrets_failed:i.length-o})}),n}export{f as a,d as b,G as c,Y as d,$ as e,Q as f};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as P}from"./chunk-RNKJXVG2.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{z as i}from"./chunk-YKOZBFR3.js";import{a as c,b as l,i as X}from"./chunk-33DWJV67.js";import{a as Z}from"./chunk-6YGTRKDT.js";import{e as O}from"./chunk-UR6MHSHU.js";var u=O(Z(),1);var e=O(Y(),1),d=5;function _(t,I){if(!I)return t;let a=I.toLowerCase();return t.filter(L=>L.label.toLowerCase().includes(a))}function U(t){let{title:I,items:a,loading:L=!1,loadingText:$,error:A=null,itemNoun:B="items",onSelect:k,onCancel:R,defaultActiveId:D,onTab:T,extraHint:w}=t,[b,s]=(0,u.useState)(0),[v,g]=(0,u.useState)(0),[f,M]=(0,u.useState)(""),[y,x]=(0,u.useState)(null),H=(0,u.useRef)(!1),N=!t.onSearch&&f!=="";(0,u.useEffect)(()=>{if(a.length===0||N)return;let n=D?a.findIndex(o=>o.id===D):a.findIndex(o=>o.isActive);if(t.preserveSelectionById&&!H.current&&n>=0&&a[n].id!==y){g(Math.floor(n/d)),s(n%d),x(a[n].id);return}if(t.preserveSelectionById&&y!==null){let o=a.findIndex(r=>r.id===y);if(o>=0){g(Math.floor(o/d)),s(o%d);return}}n>=0?(g(Math.floor(n/d)),s(n%d),t.preserveSelectionById&&x(a[n].id)):t.preserveSelectionById&&(g(0),s(0),x(a[0]?.id??null))},[a,D,t.preserveSelectionById,y,N]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let n=setTimeout(()=>t.onSearch(f),t.searchDebounceMs??250);return()=>clearTimeout(n)},[f,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?a:_(a,f),C=v*d,F=Math.min(C+d,m.length),E=Math.ceil(m.length/d),G=F-C,h=m.slice(C,F);return X((n,o)=>{if(H.current=!0,A){o.escape?R():o.tab&&T&&t.tabOnError&&T();return}if(o.escape){f?(M(""),s(0),g(0)):R();return}if(o.tab&&T){T();return}if(o.upArrow){if(b>0){let r=b-1;s(r),t.preserveSelectionById&&x(h[r]?.id??null)}else if(v>0){let r=v-1,S=d-1;g(r),s(S),t.preserveSelectionById&&x(m[r*d+S]?.id??null)}return}if(o.downArrow){if(b<G-1){let r=b+1;s(r),t.preserveSelectionById&&x(h[r]?.id??null)}else if(v<E-1){let r=v+1,S=0;g(r),s(S),t.preserveSelectionById&&x(m[r*d+S]?.id??null)}return}if(o.return&&h[b]){if(h[b].disabled)return;k(h[b]);return}if(o.backspace||o.delete){M(r=>r.slice(0,-1)),s(0),g(0);return}n&&!o.ctrl&&!o.meta&&(M(r=>r+n),s(0),g(0))},{isActive:!L}),L?(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(c,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:$??`Loading ${B}\u2026`})})]}):A?(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(c,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:A})}),(0,e.jsx)(P,{bindings:t.tabOnError&&T&&w?[{keys:"tab",label:w}]:[],escBackLabel:t.escLabel??"back to chat"})]}):(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(c,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",m.length,!t.onSearch&&f?`/${a.length}`:""," ",B,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(c,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:f?"filter: ":""}),f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:f}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",B,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(c,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",B,"\u2026"]}):m.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",B,' match "',f,'"']}):h.map((n,o)=>{let r=o===b,S=r?"\u276F ":" ",K=n.disabled?i.muted:n.isActive?i.green:r?i.orange:void 0;return(0,e.jsxs)(c,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:K,children:[S,n.label,n.isActive&&!n.disabled?" \u25CF selected":""]}),r&&n.disabled&&n.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",n.disabledHint]})]},n.id)})}),!t.searching&&E>1&&(0,e.jsx)(c,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",v+1,"/",E]})}),t.footer&&(0,e.jsx)(c,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(P,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},...t.hideSelectOnDisabled&&h[b]?.disabled?[]:[{keys:"\u21B5",label:"select"}],...T&&w?[{keys:"tab",label:w}]:[]],escBackLabel:f?"clear":t.escLabel??"back to chat"})]})}export{U as a};
2
+ import{a as P}from"./chunk-NIBNVPAE.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{A as i}from"./chunk-BRWCWZE3.js";import{a as c,b as l,i as X}from"./chunk-33DWJV67.js";import{a as Z}from"./chunk-6YGTRKDT.js";import{e as O}from"./chunk-UR6MHSHU.js";var u=O(Z(),1);var e=O(Y(),1),d=5;function _(t,I){if(!I)return t;let a=I.toLowerCase();return t.filter(L=>L.label.toLowerCase().includes(a))}function U(t){let{title:I,items:a,loading:L=!1,loadingText:$,error:A=null,itemNoun:B="items",onSelect:k,onCancel:R,defaultActiveId:D,onTab:T,extraHint:w}=t,[b,s]=(0,u.useState)(0),[v,g]=(0,u.useState)(0),[f,M]=(0,u.useState)(""),[y,x]=(0,u.useState)(null),H=(0,u.useRef)(!1),N=!t.onSearch&&f!=="";(0,u.useEffect)(()=>{if(a.length===0||N)return;let n=D?a.findIndex(o=>o.id===D):a.findIndex(o=>o.isActive);if(t.preserveSelectionById&&!H.current&&n>=0&&a[n].id!==y){g(Math.floor(n/d)),s(n%d),x(a[n].id);return}if(t.preserveSelectionById&&y!==null){let o=a.findIndex(r=>r.id===y);if(o>=0){g(Math.floor(o/d)),s(o%d);return}}n>=0?(g(Math.floor(n/d)),s(n%d),t.preserveSelectionById&&x(a[n].id)):t.preserveSelectionById&&(g(0),s(0),x(a[0]?.id??null))},[a,D,t.preserveSelectionById,y,N]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let n=setTimeout(()=>t.onSearch(f),t.searchDebounceMs??250);return()=>clearTimeout(n)},[f,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?a:_(a,f),C=v*d,F=Math.min(C+d,m.length),E=Math.ceil(m.length/d),G=F-C,h=m.slice(C,F);return X((n,o)=>{if(H.current=!0,A){o.escape?R():o.tab&&T&&t.tabOnError&&T();return}if(o.escape){f?(M(""),s(0),g(0)):R();return}if(o.tab&&T){T();return}if(o.upArrow){if(b>0){let r=b-1;s(r),t.preserveSelectionById&&x(h[r]?.id??null)}else if(v>0){let r=v-1,S=d-1;g(r),s(S),t.preserveSelectionById&&x(m[r*d+S]?.id??null)}return}if(o.downArrow){if(b<G-1){let r=b+1;s(r),t.preserveSelectionById&&x(h[r]?.id??null)}else if(v<E-1){let r=v+1,S=0;g(r),s(S),t.preserveSelectionById&&x(m[r*d+S]?.id??null)}return}if(o.return&&h[b]){if(h[b].disabled)return;k(h[b]);return}if(o.backspace||o.delete){M(r=>r.slice(0,-1)),s(0),g(0);return}n&&!o.ctrl&&!o.meta&&(M(r=>r+n),s(0),g(0))},{isActive:!L}),L?(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(c,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:$??`Loading ${B}\u2026`})})]}):A?(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(c,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:A})}),(0,e.jsx)(P,{bindings:t.tabOnError&&T&&w?[{keys:"tab",label:w}]:[],escBackLabel:t.escLabel??"back to chat"})]}):(0,e.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(c,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",m.length,!t.onSearch&&f?`/${a.length}`:""," ",B,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(c,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:f?"filter: ":""}),f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:f}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",B,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(c,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",B,"\u2026"]}):m.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",B,' match "',f,'"']}):h.map((n,o)=>{let r=o===b,S=r?"\u276F ":" ",K=n.disabled?i.muted:n.isActive?i.green:r?i.orange:void 0;return(0,e.jsxs)(c,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:K,children:[S,n.label,n.isActive&&!n.disabled?" \u25CF selected":""]}),r&&n.disabled&&n.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",n.disabledHint]})]},n.id)})}),!t.searching&&E>1&&(0,e.jsx)(c,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",v+1,"/",E]})}),t.footer&&(0,e.jsx)(c,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(P,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},...t.hideSelectOnDisabled&&h[b]?.disabled?[]:[{keys:"\u21B5",label:"select"}],...T&&w?[{keys:"tab",label:w}]:[]],escBackLabel:f?"clear":t.escLabel??"back to chat"})]})}export{U as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{i as e,j as r}from"./chunk-BRWCWZE3.js";var t=()=>process.env.KANE_TELEMETRY_URL||e,o=()=>process.env.KANE_TELEMETRY_URL||r;export{t as a,o as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-4G2T54FE.js";import{a as w}from"./chunk-HCBYKLMW.js";import{z as s}from"./chunk-YKOZBFR3.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-33DWJV67.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-CQBLJTDU.js";import{a as w}from"./chunk-HCBYKLMW.js";import{A as s}from"./chunk-BRWCWZE3.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-33DWJV67.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as t}from"./chunk-YKOZBFR3.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
2
+ import{b as t}from"./chunk-BRWCWZE3.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as n}from"./chunk-YWQNZRJG.js";import{y as s}from"./chunk-YKOZBFR3.js";function E(t="prod",r=process.env){let e=s[t];return t!=="stage"?e:{authBaseUrl:r.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:r.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:r.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:r.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:r.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:r.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:r.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:r.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:r.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:r.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl,mediaArtefactsHost:r.KANE_STAGE_MEDIA_ARTEFACTS_HOST??e.mediaArtefactsHost,mobileAppBaseUrl:r.KANE_STAGE_MOBILE_APP_URL??e.mobileAppBaseUrl,mobileHubUrl:r.KANE_STAGE_MOBILE_HUB_URL??e.mobileHubUrl,lrmaaBaseUrl:r.KANE_STAGE_LRMAA_URL??e.lrmaaBaseUrl,latticeBaseUrl:r.KANE_LATTICE_URL??e.latticeBaseUrl,deviceStreamUrl:r.KANE_STAGE_DEVICE_STREAM_URL??e.deviceStreamUrl}}function U(){let t=process.env.TESTMUAI_ENV;return t!==void 0&&t!==""?t==="stage"?"stage":"prod":new n().getDefaultEnv()==="stage"?"stage":"prod"}function a(){let t=process.env.KANE_LATTICE_URL;return t!==void 0&&t.trim()===""?"":E(U()).latticeBaseUrl.trim()}export{E as a,U as b,a as c};
2
+ import{a as n}from"./chunk-JYH7CTF7.js";import{z as s}from"./chunk-BRWCWZE3.js";function E(t="prod",r=process.env){let e=s[t];return t!=="stage"?e:{authBaseUrl:r.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:r.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:r.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:r.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:r.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:r.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:r.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:r.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:r.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:r.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl,mediaArtefactsHost:r.KANE_STAGE_MEDIA_ARTEFACTS_HOST??e.mediaArtefactsHost,mobileAppBaseUrl:r.KANE_STAGE_MOBILE_APP_URL??e.mobileAppBaseUrl,mobileHubUrl:r.KANE_STAGE_MOBILE_HUB_URL??e.mobileHubUrl,lrmaaBaseUrl:r.KANE_STAGE_LRMAA_URL??e.lrmaaBaseUrl,latticeBaseUrl:r.KANE_LATTICE_URL??e.latticeBaseUrl,deviceStreamUrl:r.KANE_STAGE_DEVICE_STREAM_URL??e.deviceStreamUrl}}function U(){let t=process.env.TESTMUAI_ENV;return t!==void 0&&t!==""?t==="stage"?"stage":"prod":new n().getDefaultEnv()==="stage"?"stage":"prod"}function a(){let t=process.env.KANE_LATTICE_URL;return t!==void 0&&t.trim()===""?"":E(U()).latticeBaseUrl.trim()}export{E as a,U as b,a as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-HCBYKLMW.js";import{z as e}from"./chunk-YKOZBFR3.js";import{a as o,b as i}from"./chunk-33DWJV67.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:e.muted,error:e.red,success:e.green,info:e.orange,warning:e.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?e.orange:s[n]);return(0,r.jsxs)(o,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(o,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(o,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=e.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(o,{children:[(0,r.jsx)(o,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(o,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(o,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{a as m}from"./chunk-HCBYKLMW.js";import{A as e}from"./chunk-BRWCWZE3.js";import{a as o,b as i}from"./chunk-33DWJV67.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:e.muted,error:e.red,success:e.green,info:e.orange,warning:e.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?e.orange:s[n]);return(0,r.jsxs)(o,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(o,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(o,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=e.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(o,{children:[(0,r.jsx)(o,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(o,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(o,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as P,d as T}from"./chunk-WHMCVH3T.js";import{d as A}from"./chunk-F2F257PU.js";import{e as x}from"./chunk-5D7ENQTQ.js";import{b as D,e as S}from"./chunk-SZQNYDST.js";import{f as E,h as _,l as I}from"./chunk-ECPSBI2Z.js";import{b as C,c as N,g as b,h as k}from"./chunk-WLEWXE6L.js";import{b as y}from"./chunk-NMCE7VR2.js";import{a as h}from"./chunk-73EHVDL5.js";import{h as R}from"./chunk-A7RJQJNT.js";import{mkdirSync as z,writeFileSync as J}from"fs";import{join as G}from"path";function $(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||h(e).mobileAppBaseUrl}var X="device-config.json",U=new WeakMap;function Y(e,t){let r=U.get(e)??new Map;U.set(e,r);let o=JSON.stringify([t.path,t.type,t.env,t.orgId]),n=r.get(o);if(n)return n;let i=e(t).finally(()=>r.delete(o));return r.set(o,i),i}function V(e){return e.startsWith("lt://")?e:`lt://${e}`}async function Q(e,t){let r=await I(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 Z(e,t){let r=e.selection.app.value.trim();if(y(r))return V(r);let o=e.credentials;if(!o?.orgId)throw new Error(`${r} has to be uploaded before it can run on a real device, but your account's org id was not found. Run kane-cli login, or set app: to an app ID from \`kane-cli apps list --target ${e.platform}\`.`);let n=await Y(t,{path:r,type:e.platform,env:e.env,orgId:o.orgId,userId:o.userId??"",auth:{username:o.username,accessKey:o.accessKey,orgId:o.orgId},baseUrl:$(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if(D(n))throw new Error(`could not upload ${r} for this real-device run: ${n.reason}`);return V(n.appUrl??n.appId)}async function M(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 Q(e,t.fetchCatalog??_);let r=await Z(e,t.upload??S),{deviceName:o,osVersion:n}=e.selection,i={platform_name:e.platform,device_name:o?.value??E,...n?{platform_version:n.value}:{},app:r,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},a=G(e.outDir,X);return z(e.outDir,{recursive:!0}),J(a,`${JSON.stringify(i,null,2)}
2
+ import{c as P,d as T}from"./chunk-FLGOQ6Q6.js";import{d as A}from"./chunk-F2F257PU.js";import{e as x}from"./chunk-5D7ENQTQ.js";import{b as D,e as S}from"./chunk-2G7UYQOW.js";import{f as E,h as _,l as I}from"./chunk-A5C7HIAH.js";import{b as C,c as N,g as b,h as k}from"./chunk-WLEWXE6L.js";import{b as y}from"./chunk-LMOW4NM5.js";import{a as h}from"./chunk-V24LUINK.js";import{h as R}from"./chunk-A7RJQJNT.js";import{mkdirSync as z,writeFileSync as J}from"fs";import{join as G}from"path";function $(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||h(e).mobileAppBaseUrl}var X="device-config.json",U=new WeakMap;function Y(e,t){let r=U.get(e)??new Map;U.set(e,r);let o=JSON.stringify([t.path,t.type,t.env,t.orgId]),n=r.get(o);if(n)return n;let i=e(t).finally(()=>r.delete(o));return r.set(o,i),i}function V(e){return e.startsWith("lt://")?e:`lt://${e}`}async function Q(e,t){let r=await I(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 Z(e,t){let r=e.selection.app.value.trim();if(y(r))return V(r);let o=e.credentials;if(!o?.orgId)throw new Error(`${r} has to be uploaded before it can run on a real device, but your account's org id was not found. Run kane-cli login, or set app: to an app ID from \`kane-cli apps list --target ${e.platform}\`.`);let n=await Y(t,{path:r,type:e.platform,env:e.env,orgId:o.orgId,userId:o.userId??"",auth:{username:o.username,accessKey:o.accessKey,orgId:o.orgId},baseUrl:$(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if(D(n))throw new Error(`could not upload ${r} for this real-device run: ${n.reason}`);return V(n.appUrl??n.appId)}async function M(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 Q(e,t.fetchCatalog??_);let r=await Z(e,t.upload??S),{deviceName:o,osVersion:n}=e.selection,i={platform_name:e.platform,device_name:o?.value??E,...n?{platform_version:n.value}:{},app:r,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},a=G(e.outDir,X);return z(e.outDir,{recursive:!0}),J(a,`${JSON.stringify(i,null,2)}
3
3
  `),{device:{platform:e.platform,target:e.platform,device_config_path:a},...o?{deviceName:o.value}:{},...n?{osVersion:n.value}:{},app:r}}import{createServer as ee}from"http";import{randomBytes as re}from"crypto";import{spawn as te}from"child_process";import{mkdtempSync as oe,readdirSync as ne,readFileSync as ie,rmSync as se,writeFileSync as ae}from"fs";import{tmpdir as O}from"os";import{join as w}from"path";function W(e,t,r,o){let n=Buffer.from(`${o.username}:${o.accessKey}`).toString("base64"),i=new URLSearchParams({session:r,auth:n});return t==="ios"&&i.set("mode","webrtc"),`${e.replace(/\/+$/,"")}/?${i.toString()}`}function L(e){return e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}function ce(e){return`<!doctype html>
4
4
  <html lang="en">
5
5
  <head>
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{f as c}from"./chunk-OSEXVHEN.js";function m(o){if(o==null)return{ok:!0,url:void 0};if(typeof o!="string")return{ok:!1,message:`error: --override-start-url needs a URL (http:// or https://)
2
+ import{f as c}from"./chunk-TC2PHBPH.js";function m(o){if(o==null)return{ok:!0,url:void 0};if(typeof o!="string")return{ok:!1,message:`error: --override-start-url needs a URL (http:// or https://)
3
3
  `};let t=o.trim(),i=a=>({ok:!1,message:`error: --override-start-url ${a}: ${JSON.stringify(o)} (expected an http:// or https:// URL, e.g. http://localhost:3000)
4
- `});if(!t)return i("is empty");let n;try{n=new URL(t)}catch{return i("is not a URL")}return n.protocol!=="http:"&&n.protocol!=="https:"?i("must be http or https"):n.hostname?{ok:!0,url:t}:i("has no host")}function f(o){let t;try{t=new URL(o).hostname.toLowerCase()}catch{return!1}return t=t.replace(/^\[|\]$/g,""),t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\./.test(t)||t==="0.0.0.0"||t.endsWith(".local")}function y(o){let{isAgent:t,log:i}=o,n=o.stdout??process.stderr,a=o.stdin??process.stdin,d=e=>{t&&c(e)};return{async runSteps(e){let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{TestMdRunView:l}=await import("./TestMdRunView-HRJSBP2C.js"),{ScrollbackProvider:p}=await import("./scrollback-GGNBDFQV.js"),{waitUntilExit:u}=s(r.createElement(p,null,r.createElement(l,e)),{stdout:n,stdin:a,exitOnCtrlC:!1});await u()},async runUpload(e,r){let{renderUploadProgress:s}=await import("./CliUploadProgress-IU6BQLMV.js");return await s(e,r)},async onSummary(e){try{let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{AutoExitSummaryBox:l}=await import("./SummaryBox-T7PDXDKS.js"),{waitUntilExit:p}=s(r.createElement(l,{data:e}),{stdout:n,stdin:a});await p()}catch(r){i("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(r)})}},async onLinks(e){try{let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{LinksBox:l}=await import("./LinksBox-6YDTIO6I.js"),{waitUntilExit:p}=s(r.createElement(l,e),{stdout:n,stdin:a});await p()}catch(r){i("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(r)})}},onLockState(e){d({type:"test_md_lock_state",...e})},onAdaptiveHeal(e){d({type:"test_md_adaptive_heal",...e})},onAgentEvent(e){d(e)}}}export{m as a,f as b,y as c};
4
+ `});if(!t)return i("is empty");let n;try{n=new URL(t)}catch{return i("is not a URL")}return n.protocol!=="http:"&&n.protocol!=="https:"?i("must be http or https"):n.hostname?{ok:!0,url:t}:i("has no host")}function f(o){let t;try{t=new URL(o).hostname.toLowerCase()}catch{return!1}return t=t.replace(/^\[|\]$/g,""),t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\./.test(t)||t==="0.0.0.0"||t.endsWith(".local")}function y(o){let{isAgent:t,log:i}=o,n=o.stdout??process.stderr,a=o.stdin??process.stdin,d=e=>{t&&c(e)};return{async runSteps(e){let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{TestMdRunView:l}=await import("./TestMdRunView-URNSXIVC.js"),{ScrollbackProvider:p}=await import("./scrollback-GGNBDFQV.js"),{waitUntilExit:u}=s(r.createElement(p,null,r.createElement(l,e)),{stdout:n,stdin:a,exitOnCtrlC:!1});await u()},async runUpload(e,r){let{renderUploadProgress:s}=await import("./CliUploadProgress-NK2U3CKQ.js");return await s(e,r)},async onSummary(e){try{let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{AutoExitSummaryBox:l}=await import("./SummaryBox-WFOS6GON.js"),{waitUntilExit:p}=s(r.createElement(l,{data:e}),{stdout:n,stdin:a});await p()}catch(r){i("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(r)})}},async onLinks(e){try{let{default:r}=await import("./react-QWOAB3TB.js"),{render:s}=await import("./build-5ZN47FAT.js"),{LinksBox:l}=await import("./LinksBox-7BWLLQVR.js"),{waitUntilExit:p}=s(r.createElement(l,e),{stdout:n,stdin:a});await p()}catch(r){i("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(r)})}},onLockState(e){d({type:"test_md_lock_state",...e})},onAdaptiveHeal(e){d({type:"test_md_adaptive_heal",...e})},onAgentEvent(e){d(e)}}}export{m as a,f as b,y as c};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as U,e as F}from"./chunk-4JOD47QI.js";import{d as W}from"./chunk-GMTHZUZ3.js";import{a as H}from"./chunk-YKOZBFR3.js";import{createHash as Y}from"crypto";import{access as Q,mkdir as S,mkdtemp as Z,readdir as O,readFile as y,rename as N,rm as v,writeFile as x}from"fs/promises";import{homedir as tt}from"os";import{arch as et,platform as st}from"process";import{dirname as C,isAbsolute as nt,join as l,relative as X,resolve as rt,sep as it}from"path";var q=1,ot={emulator:"emulator",simulator:"simulator"};function Pt(i){return ot[i.kind]??null}var j=class extends Error{constructor(s,e,n){super([`Managed mobile dependencies for ${s} are not installed.`,`- kaneai-mobile-deps ${s} ${e.bundleVersion}: ${e.url} (${_(e.bytes)})`,`Destination: ${n}`,`Run \`kane-cli doctor --target ${s} --install\` to download it.`].join(`
3
- `));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-IF6P6NWI.js")).controllerResolveBundle()(i),exec:U,now:()=>new Date,wait:F,processAlive:i=>{try{return process.kill(i,0),!0}catch{return!1}}}}var B=class extends Error{constructor(s,e,n){super(`No managed mobile dependencies are published for ${s} (kane-cli ${e}).
2
+ import{d as U,e as F}from"./chunk-4JOD47QI.js";import{d as W}from"./chunk-GMTHZUZ3.js";import{a as H}from"./chunk-BRWCWZE3.js";import{createHash as Y}from"crypto";import{access as Q,mkdir as S,mkdtemp as Z,readdir as O,readFile as y,rename as N,rm as v,writeFile as x}from"fs/promises";import{homedir as tt}from"os";import{arch as et,platform as st}from"process";import{dirname as C,isAbsolute as nt,join as l,relative as X,resolve as rt,sep as it}from"path";var q=1,ot={emulator:"emulator",simulator:"simulator"};function Pt(i){return ot[i.kind]??null}var j=class extends Error{constructor(s,e,n){super([`Managed mobile dependencies for ${s} are not installed.`,`- kaneai-mobile-deps ${s} ${e.bundleVersion}: ${e.url} (${_(e.bytes)})`,`Destination: ${n}`,`Run \`kane-cli doctor --target ${s} --install\` to download it.`].join(`
3
+ `));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-K7XNTRZX.js")).controllerResolveBundle()(i),exec:U,now:()=>new Date,wait:F,processAlive:i=>{try{return process.kill(i,0),!0}catch{return!1}}}}var B=class extends Error{constructor(s,e,n){super(`No managed mobile dependencies are published for ${s} (kane-cli ${e}).
4
4
  This is a packaging gap, not something to install locally \u2014 report it, or pass --appium-url to use an Appium server you manage yourself.`);this.coordinate=s;this.cause=n;this.name="NoPublishedBundleError"}},J=class i{deps;constructor(t={}){this.deps={...wt(),...t}}mobileRoot(){return l(this.deps.home,".testmuai","kaneai","mobile")}depsRoot(){return l(this.mobileRoot(),"deps")}classRoot(t,s){return l(this.depsRoot(),s,t)}resolveCacheFile(){return l(this.depsRoot(),"resolve-cache.json")}resolveCacheKey(t){return`${this.deps.cliVersion}|${this.deps.os}-${this.deps.arch}-${t}`}static RESOLVE_CACHE_TTL_MS=1440*60*1e3;async readCachedWantedVersion(t){try{let e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))[this.resolveCacheKey(t)];if(!e?.bundleVersion||!e.fetchedAt)return null;let n=this.deps.now().getTime()-new Date(e.fetchedAt).getTime();return n>=0&&n<i.RESOLVE_CACHE_TTL_MS?e.bundleVersion:null}catch{return null}}async writeResolveCache(t,s){try{let e={};try{e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))}catch{}e[this.resolveCacheKey(t)]={bundleVersion:s,fetchedAt:this.deps.now().toISOString()},await S(this.depsRoot(),{recursive:!0}),await x(this.resolveCacheFile(),`${JSON.stringify(e,null,2)}
5
5
  `)}catch{}}async warmResolveCache(t){if(await this.readCachedWantedVersion(t)===null)try{await this.resolveOrExplain(t)}catch{}}paths(t,s){let e=this.classRoot(t,s);return{root:e,appium:l(e,"appium"),appiumHome:l(e,"appium-home"),platformTools:l(e,"platform-tools"),wdaDir:l(e,"wda","Build","Products","Debug-iphonesimulator"),iwdpBinDir:l(e,"bin"),installManifest:l(e,"install-manifest.json")}}async status(t,s){s||(s=await this.readCachedWantedVersion(t)??void 0);let e=[];try{e=await O(this.depsRoot())}catch{}s&&(e=e.filter(c=>c===s));let n=null;for(let c of e){let h=this.classRoot(t,c),b=null;try{b=JSON.parse(await y(l(h,"install-manifest.json"),"utf8"))}catch{continue}b.schemaVersion===q&&(!s&&b.cliVersion!==this.deps.cliVersion||(!n||b.installedAt>n.manifest.installedAt)&&(n={manifest:b,root:h}))}if(!n)return{class:t,installed:!1};let r=this.paths(t,n.manifest.bundleVersion),o=[l(r.appium,"node_modules","appium","index.js")];t==="emulator"&&o.push(l(r.platformTools,this.deps.os==="win32"?"adb.exe":"adb")),t==="simulator"&&o.push(l(r.wdaDir,"WebDriverAgentRunner-Runner.app"));for(let c of o)if(!await A(c))return{class:t,installed:!1,version:n.manifest.bundleVersion,root:n.root,corrupt:`a bundle component is missing from disk (${X(n.root,c)})`};let a=await this.postInstallDrifted(r);return{class:t,installed:!0,version:n.manifest.bundleVersion,root:n.root,...a?{needsRepair:a}:{}}}async postInstallDrifted(t){let s=l(t.appiumHome,"node_modules",".cache","appium","extensions.yaml");if(!await A(s))return!1;let e=await y(s,"utf8");for(let n of e.split(`
6
6
  `)){let r=/^\s*installPath:\s*(.+?)\s*$/.exec(n);if(r&&!r[1].startsWith(t.appiumHome))return!0}return!1}async environment(t){let s=await this.status(t);if(!s.installed||!s.version)return{dirs:[]};let e=this.paths(t,s.version),n=[],r={dirs:n,appiumHome:e.appiumHome};return t!=="simulator"&&(n.push(e.platformTools),r.platformToolsDir=e.platformTools),n.push(l(e.appium,"node_modules",".bin")),t==="simulator"&&(n.push(e.iwdpBinDir),r.wdaDir=e.wdaDir,r.wdaRoot=l(e.root,"wda"),r.iwdpBinDir=e.iwdpBinDir),r}async ensure(t,s){let e,n;try{e=await this.resolveOrExplain(t)}catch(a){n=a}let r=await this.status(t,e?.bundleVersion);if(r.installed&&!r.needsRepair)return e&&r.version&&await this.adoptInstall(t,r.version),r;if(!e)throw n;if(r.installed&&r.needsRepair&&r.version){let a=this.paths(t,r.version);return await this.withInstallLock(async()=>{await this.postInstall(a.root,a,s.onProgress)}),await this.adoptInstall(t,r.version),this.status(t,e.bundleVersion)}let o=e;if(!s.automatic&&!s.approved)throw new j(t,o,this.classRoot(t,o.bundleVersion));return await this.withInstallLock(async()=>{(await this.status(t,o.bundleVersion)).installed||await this.install(t,o,s.onProgress)}),this.status(t,o.bundleVersion)}async adoptInstall(t,s){try{let e=this.paths(t,s).installManifest,n=JSON.parse(await y(e,"utf8"));if(n.cliVersion===this.deps.cliVersion)return;n.cliVersion=this.deps.cliVersion;let r=l(C(e),`install-manifest-${process.pid}.json`);await x(r,`${JSON.stringify(n,null,2)}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as qr}from"./chunk-F4XCCOWC.js";import{a as Pr}from"./chunk-ABAUIIPD.js";import{e as dt,f as jt,g as Bt,h as qe}from"./chunk-6FVGPKVX.js";import{A as st,B as ve,C as yr,D as oe,E as $e,F as ot,G as br,H as K,I as it,J as Tt,K as at,L as ke,M as wr,N as vr,Q as Te,a as tr,b as nr,c as Se,d as Ee,e as de,f as tt,g as sr,h as or,i as ce,j as cr,k as Ce,l as Ae,m as lr,n as fr,o as hr,p as At,q as Nt,r as Q,s as Ne,t as gr,u as Pt,v as Pe,w as mr,x as qt,y as te,z as rt}from"./chunk-DAV4ONGS.js";import{a as R,b as rr,d as X,e as Oe,h as ir,i as ar,k as dr}from"./chunk-CB4ARIHR.js";import{a as Un,b as Vn,e as Wn}from"./chunk-ZIRSTOEV.js";import{a as Zn}from"./chunk-TCK7WR3M.js";import{a as Yn,b as zn}from"./chunk-WMGKUERB.js";import{a as Qn}from"./chunk-2EKLTUY2.js";import{a as Jn}from"./chunk-73Y6T2UK.js";import{b as Xn,e as er,h as Ct,i as J}from"./chunk-XMPTFXPW.js";import{e as Ar,f as Nr}from"./chunk-HBGYEA3O.js";import{a as Er}from"./chunk-BIGOLVK6.js";import{a as Ir,d as Sr}from"./chunk-JSSM2TWY.js";import{a as Or,b as Lt,c as Cr}from"./chunk-H6IPGZTP.js";import{h as _r,i as Rr}from"./chunk-3A4KK22B.js";import{g as Ft,h as $r,q as kr}from"./chunk-C3DMMAFP.js";import{a as nt,b as le,c as pr,d as ur}from"./chunk-UVL6XQHU.js";import{b as Ot,d as Kn}from"./chunk-5ORBAYTU.js";import{Ea as C,Fa as On,Ia as Cn,Ka as An,M as wn,Na as Nn,Oa as Pn,Pa as qn,Qa as ee,Ra as Tn,Sa as jn,Ua as Bn,Va as Qe,Ya as Fn,Za as Ln,a as ae,d as Et,da as vn,ea as $n,eb as xn,fa as kn,fb as Ze,ga as _n,ha as Rn,ia as In,ja as Sn,kb as Mn,mb as Hn,na as Ye,oa as En,ob as Xe,pa as ze,q as mn,r as yn,t as bn,vb as Dn,wb as Gn}from"./chunk-5EAJO372.js";import{c as hn,n as gn}from"./chunk-DBMW3VUN.js";import{d as fn,f as Je,g as Ke}from"./chunk-KU3YHPWZ.js";import{b as dn,f as cn,h as ln,k as pn,l as un,q as et}from"./chunk-OKCVG7AG.js";import{b as an}from"./chunk-7V4BQSSV.js";import{b as we}from"./chunk-6PIIUAZF.js";import{g as We}from"./chunk-ZCRZFAOT.js";import{existsSync as De,readdirSync as ws,readFileSync as vs,realpathSync as oi,statSync as ii,writeFileSync as ai}from"fs";import{basename as Rt,join as Ge,relative as di,resolve as sn}from"path";import{randomBytes as Fs}from"crypto";var Tr=8,je=()=>dr(Fs(8).toString("hex")),jr=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Ls=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=je(),r=Buffer.from(`probe ${t} first`);if(await e.putIfAbsent(n,r)!=="created")return"a fresh key was reported as existing";if(await e.putIfAbsent(n,Buffer.from(`probe ${t} second`))!=="exists")return"the second write to one key was not refused";if(!jr(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=je(),r=(await Promise.all(Array.from({length:Tr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${Tr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=je(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?jr(await e.get(t),n)?(await e.list(t)).includes(t)?null:"list does not show a key just created":"get does not return the bytes just created":"head does not see a key just created"}],["P4 definitive absence",async e=>await e.head(je())?"a never-written key was reported present":null]];async function ct(e){if(e.probe){let r=await e.probe();return{tier:Math.max(r.tier,e.ceilingTier),detail:r.detail}}let t=1,n="all probes passed";for(let[r,o]of Ls){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await Br(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await Br(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function Br(e){try{return!await e.head(je())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as xs,readFileSync as xr}from"fs";import{join as Ms}from"path";async function xt(e,t,n,r){let i=de(e).entries[n];if(!i)throw new Error(`no sync state for ${n} \u2014 run kane-cli context sync add ${n} <descriptor> first`);if(i.tier!==1)throw new R("SYNC_READ_ONLY",`${n} is a tier ${i.tier} location: it can be cloned and pulled, never pushed`,"push to a location whose probe reached tier 1, or pull from this one");let s=await Ce(e,t,i.witness);switch(s.kind){case"empty-storage":case"ahead":case"up-to-date":break;case"behind":case"empty-local":throw new R("SYNC_BEHIND",`${n} holds ${s.storage.seq} records, this store ${s.local?.seq??0}: it has records this store has not seen`,`kane-cli context pull ${n}`);case"diverged":throw new R("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pushed`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new R("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`)}let a=s.storage,c=qn(e),d;try{An(e),d=Hs(e,a)}catch(M){throw M instanceof Cn?new R("SYNC_REBASE_PENDING",`${M.message.split(";")[0]}; nothing was pushed`,M.remedy):M}finally{c()}let l=d.map(M=>Ds(e,M)),f=0,p=0,g=0,u=0,m=a,y=null,w=null,h=t.beginTransaction?await t.beginTransaction():void 0,b=h?{...t,head:h.head,get:h.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=h?h.stageIfAbsent.bind(h):t.putIfAbsent.bind(t),q=[],re=M=>h?q.push(M):r(M);try{let M=new Set;for(let S of l){for(let D of S.blobs)if(await v(D.key,D.bytes)!=="exists")p++,M.add(D.key);else if(!M.has(D.key)){let $=await b.get(D.key);if($===null||Ot(Buffer.from($))!==D.fp){w=new R("SYNC_OBJECT_CORRUPT",`the blob ${D.fp} ${n} already holds does not hash to its name (named by record ${S.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}M.add(D.key)}if(w)break;S.proposal&&await v(S.proposal.key,S.proposal.bytes)!=="exists"&&g++;let Z=Oe(S.seq);if(await v(Z,S.raw)!=="exists")f++;else if((await ce(b,S.seq)).hash===S.hash)re(`position ${S.seq} is already on ${n}`),u++;else{y=S.seq;break}m={seq:S.seq,hash:S.hash}}if(h||await Lr(t,m,a,n),m&&!await b.head(X)){let S=await ce(b,1),Z={layout:1,canonicalizer:"v1",genesis_hash:S.hash};await v(X,Buffer.from(JSON.stringify(Z)+`
2
+ import{a as qr}from"./chunk-F4XCCOWC.js";import{a as Pr}from"./chunk-ABAUIIPD.js";import{e as dt,f as jt,g as Bt,h as qe}from"./chunk-6FVGPKVX.js";import{A as st,B as ve,C as yr,D as oe,E as $e,F as ot,G as br,H as K,I as it,J as Tt,K as at,L as ke,M as wr,N as vr,Q as Te,a as tr,b as nr,c as Se,d as Ee,e as de,f as tt,g as sr,h as or,i as ce,j as cr,k as Ce,l as Ae,m as lr,n as fr,o as hr,p as At,q as Nt,r as Q,s as Ne,t as gr,u as Pt,v as Pe,w as mr,x as qt,y as te,z as rt}from"./chunk-NNVHWFLI.js";import{a as R,b as rr,d as X,e as Oe,h as ir,i as ar,k as dr}from"./chunk-CB4ARIHR.js";import{a as Un,b as Vn,e as Wn}from"./chunk-ZIRSTOEV.js";import{a as Zn}from"./chunk-TCK7WR3M.js";import{a as Yn,b as zn}from"./chunk-WMGKUERB.js";import{a as Qn}from"./chunk-2EKLTUY2.js";import{a as Jn}from"./chunk-73Y6T2UK.js";import{b as Xn,e as er,h as Ct,i as J}from"./chunk-XMPTFXPW.js";import{e as Ar,f as Nr}from"./chunk-HBGYEA3O.js";import{a as Er}from"./chunk-BIGOLVK6.js";import{a as Ir,d as Sr}from"./chunk-JSSM2TWY.js";import{a as Or,b as Lt,c as Cr}from"./chunk-H6IPGZTP.js";import{h as _r,i as Rr}from"./chunk-3A4KK22B.js";import{g as Ft,h as $r,q as kr}from"./chunk-C3DMMAFP.js";import{a as nt,b as le,c as pr,d as ur}from"./chunk-UVL6XQHU.js";import{b as Ot,d as Kn}from"./chunk-5ORBAYTU.js";import{Ea as C,Fa as On,Ia as Cn,Ka as An,M as wn,Na as Nn,Oa as Pn,Pa as qn,Qa as ee,Ra as Tn,Sa as jn,Ua as Bn,Va as Qe,Ya as Fn,Za as Ln,a as ae,d as Et,da as vn,ea as $n,eb as xn,fa as kn,fb as Ze,ga as _n,ha as Rn,ia as In,ja as Sn,kb as Mn,mb as Hn,na as Ye,oa as En,ob as Xe,pa as ze,q as mn,r as yn,t as bn,vb as Dn,wb as Gn}from"./chunk-5EAJO372.js";import{c as hn,n as gn}from"./chunk-DBMW3VUN.js";import{d as fn,f as Je,g as Ke}from"./chunk-KU3YHPWZ.js";import{b as dn,f as cn,h as ln,k as pn,l as un,q as et}from"./chunk-OKCVG7AG.js";import{b as an}from"./chunk-7V4BQSSV.js";import{b as we}from"./chunk-6PIIUAZF.js";import{g as We}from"./chunk-ZCRZFAOT.js";import{existsSync as De,readdirSync as ws,readFileSync as vs,realpathSync as oi,statSync as ii,writeFileSync as ai}from"fs";import{basename as Rt,join as Ge,relative as di,resolve as sn}from"path";import{randomBytes as Fs}from"crypto";var Tr=8,je=()=>dr(Fs(8).toString("hex")),jr=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Ls=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=je(),r=Buffer.from(`probe ${t} first`);if(await e.putIfAbsent(n,r)!=="created")return"a fresh key was reported as existing";if(await e.putIfAbsent(n,Buffer.from(`probe ${t} second`))!=="exists")return"the second write to one key was not refused";if(!jr(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=je(),r=(await Promise.all(Array.from({length:Tr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${Tr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=je(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?jr(await e.get(t),n)?(await e.list(t)).includes(t)?null:"list does not show a key just created":"get does not return the bytes just created":"head does not see a key just created"}],["P4 definitive absence",async e=>await e.head(je())?"a never-written key was reported present":null]];async function ct(e){if(e.probe){let r=await e.probe();return{tier:Math.max(r.tier,e.ceilingTier),detail:r.detail}}let t=1,n="all probes passed";for(let[r,o]of Ls){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await Br(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await Br(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function Br(e){try{return!await e.head(je())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as xs,readFileSync as xr}from"fs";import{join as Ms}from"path";async function xt(e,t,n,r){let i=de(e).entries[n];if(!i)throw new Error(`no sync state for ${n} \u2014 run kane-cli context sync add ${n} <descriptor> first`);if(i.tier!==1)throw new R("SYNC_READ_ONLY",`${n} is a tier ${i.tier} location: it can be cloned and pulled, never pushed`,"push to a location whose probe reached tier 1, or pull from this one");let s=await Ce(e,t,i.witness);switch(s.kind){case"empty-storage":case"ahead":case"up-to-date":break;case"behind":case"empty-local":throw new R("SYNC_BEHIND",`${n} holds ${s.storage.seq} records, this store ${s.local?.seq??0}: it has records this store has not seen`,`kane-cli context pull ${n}`);case"diverged":throw new R("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pushed`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new R("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`)}let a=s.storage,c=qn(e),d;try{An(e),d=Hs(e,a)}catch(M){throw M instanceof Cn?new R("SYNC_REBASE_PENDING",`${M.message.split(";")[0]}; nothing was pushed`,M.remedy):M}finally{c()}let l=d.map(M=>Ds(e,M)),f=0,p=0,g=0,u=0,m=a,y=null,w=null,h=t.beginTransaction?await t.beginTransaction():void 0,b=h?{...t,head:h.head,get:h.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=h?h.stageIfAbsent.bind(h):t.putIfAbsent.bind(t),q=[],re=M=>h?q.push(M):r(M);try{let M=new Set;for(let S of l){for(let D of S.blobs)if(await v(D.key,D.bytes)!=="exists")p++,M.add(D.key);else if(!M.has(D.key)){let $=await b.get(D.key);if($===null||Ot(Buffer.from($))!==D.fp){w=new R("SYNC_OBJECT_CORRUPT",`the blob ${D.fp} ${n} already holds does not hash to its name (named by record ${S.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}M.add(D.key)}if(w)break;S.proposal&&await v(S.proposal.key,S.proposal.bytes)!=="exists"&&g++;let Z=Oe(S.seq);if(await v(Z,S.raw)!=="exists")f++;else if((await ce(b,S.seq)).hash===S.hash)re(`position ${S.seq} is already on ${n}`),u++;else{y=S.seq;break}m={seq:S.seq,hash:S.hash}}if(h||await Lr(t,m,a,n),m&&!await b.head(X)){let S=await ce(b,1),Z={layout:1,canonicalizer:"v1",genesis_hash:S.hash};await v(X,Buffer.from(JSON.stringify(Z)+`
3
3
  `,"utf8"))!=="exists"&&re(`wrote ${X} on ${n}`)}if(h){if(m){let $=await b.get(X),ge=await ce(b,1),T={};try{let me=JSON.parse(Buffer.from($??[]).toString("utf8"));me&&typeof me=="object"&&!Array.isArray(me)&&(T=me)}catch{}if(T.layout!==1||T.canonicalizer!=="v1"||T.genesis_hash!==ge.hash)throw new R("SYNC_OBJECT_CORRUPT",`${X} does not describe this context's verified genesis and format.`,"Ask the location owner to inspect the metadata before publishing.")}if(w)throw w;if(y!==null)throw new R("SYNC_POSITION_TAKEN",`position ${y} on ${n} was taken by another writer; this batch was not published`,Fr(n,y));let S=await h.commit(),Z=new Set(S.created),D=l.filter($=>Z.has(Oe($.seq))).length;u+=f-D,f=D,p=new Set(l.flatMap($=>$.blobs.map(ge=>ge.key)).filter($=>Z.has($))).size,g=new Set(l.flatMap($=>$.proposal?[$.proposal.key]:[]).filter($=>Z.has($))).size}h&&await Lr(t,m,a,n);for(let S of q)r(S);let se="";if(m)try{lr(e,n,m,{forwardOnly:!0})}catch(S){if(y===null||!(S instanceof C))throw S;se=" (the witness was not saved; the next pull records it)"}if(w)throw w;if(y!==null)throw new R("SYNC_POSITION_TAKEN",`position ${y} on ${n} was taken by another writer while this push ran; this store's history through position ${m?.seq??0} is confirmed on ${n}${se}`,Fr(n,y))}finally{await h?.abort()}return{pushed:f,from:a?.seq??0,to:m?.seq??0,blobs:p,proposals:g,alreadyThere:u}}function Fr(e,t){return t===1?`${e} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${e}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${e} --rebase`}async function Lr(e,t,n,r){if(!t||t.seq<=(n?.seq??0))return;let o=await ce(e,t.seq);if(o.hash!==t.hash)throw new R("SYNC_OBJECT_CORRUPT",`${r} answered "created" for position ${t.seq} but serves a record hashing ${o.hash}, not ${t.hash}`,"The location needs inspection before publishing more context.")}function Hs(e,t){let{records:n,hashes:r}=Ln(e,t?.seq??0,t?.hash??null);return n.map((o,i)=>{let s=r[i],a=xr(Ms(e,"commits",`${String(o.seq).padStart(6,"0")}-${s.slice(7,19)}.json`));if(ee(JSON.parse(a.toString("utf8")))!==s)throw new Error(`record ${o.seq} changed on disk while it was being read \u2014 run kane-cli context fsck`);return{rec:o,hash:s,raw:a}})}function Ds(e,{rec:t,hash:n,raw:r}){{let o=tr(t),i=o.blobs.map(s=>{let a=Kn(e,s);if(a===null)throw new R("SYNC_CLOSURE_MISSING",`record ${t.seq} names blob ${s}, which this store does not hold`,"restore the blob from a copy of this store, or run kane-cli context fsck");if(Ot(a)!==s)throw new R("SYNC_LOCAL_BLOB_CORRUPT",`record ${t.seq} names blob ${s}, but the local file does not hash to that: it is torn`,"restore the blob from a copy of this store, or run kane-cli context fsck");return{key:ir(s),fp:s,bytes:a}});return{seq:t.seq,hash:n,raw:new Uint8Array(r),blobs:i,proposal:Gs(e,o.proposalId)}}}function Gs(e,t){if(t===null)return null;let n=Qn(e,t);if(!xs(n))return null;let r=xr(n);return{key:ar(t,nr(r.toString("utf8"))),bytes:r}}import{existsSync as Us,readdirSync as Vs,readFileSync as Mr}from"fs";import{basename as Ws,join as Mt}from"path";function lt(e){return{id:Ws(e),witness:()=>JSON.parse(Mr(Mt(e,"base-witness.json"),"utf8")),records:t=>Ht(e,t),readIntent:t=>bn(e,t)}}var Js=/^\d{6}-[0-9a-f]{12}\.json$/;function Ht(e,t){let n=Mt(e,"commits"),r=Us(n)?Vs(n).filter(s=>Js.test(s)).sort():[],o=t.hash,i=t.seq;return r.map(s=>{let a;try{a=JSON.parse(Mr(Mt(n,s),"utf8"))}catch(d){throw new C(`backup record ${s} is not JSON: ${String(d)}`)}if(i+=1,a.seq!==i||a.prev_hash!==o)throw new C(`backup record ${s} does not continue the chain at ${i} from ${String(o)}`);let c=ee(a);if(!c.slice(7).startsWith(s.slice(7,19)))throw new C(`backup record ${s} does not match its name`);return o=c,{seq:i,hash:c,body:a}})}function pt(e,t){let n=t.witness(),r=e.recordsSince(null).slice(0,n.base.seq),o=t.records(n.base),i=[...r,...o.map(p=>p.body)],s=[...r.map(ee),...o.map(p=>p.hash)],a=new Map;for(let p of i)for(let g of p.nodes)a.set(g.cid,{label:g.label,content:g.content});let c=Mn();Hn(null,c,i,s,{writeNodeFiles:!1});let d=Gn(null,c,a),l=new Map(o.map(p=>[p.seq,p])),f=p=>d.displayNameOf(p)??p.slice(0,19);return{backup:t,backupId:t.id,from:n.from,base:n.base,index:c,graph:d,records:o,chain:i,recordAt:p=>l.get(p),resolveName:p=>d.resolve(p)?.cid,nameOf:p=>d.displayNameOf(p)??void 0,displayNameFor:p=>{let g=Dt(t,p),u=Object.keys(p.source_head_moves),m=g==="revert"?String(Ks(t,p)??""):g==="names"?(p.names??[]).map(y=>y.slug).join(", "):u.length>0?u.join(", "):p.nodes.length>0?[...new Set(p.nodes.map(y=>f(y.cid)))].join(", "):(p.executions?.length??0)>0?[...new Set(p.executions.map(y=>f(y.about)))].join(", "):p.review.length>0?[...new Set(p.review.map(y=>f(y.id)))].join(", "):p.supersessions.length>0?[...new Set(p.supersessions.map(y=>y.kind==="node"?f(y.old):y.ecid.slice(0,19)))].join(", "):u.join(", ");return m?`${g} ${m}`:g}}}function Ks(e,t){try{let r=e.readIntent(ee(t))?.args?.seq;return typeof r=="number"?r:void 0}catch{return}}function Dt(e,t){let n=null;try{n=e.readIntent(ee(t))}catch{n=null}if(n)return n.verb;if(t.intent_verb)return t.intent_verb;let r=Object.entries(t.source_head_moves);return(t.executions?.length??0)>0?"execution":t.design_of?"design":t.proposal_id!=null?"extract":t.conv?t.conv.turn===0?"conv-mint":"conv-turn":r.length===1&&r[0][1]===null&&t.supersessions.some(o=>o.kind==="node"&&o.new===null)?"retire":r.length===1&&typeof r[0][1]=="string"&&t.nodes.some(o=>o.label==="source")?"ingest":t.review.some(o=>o.resolution==="reset")||t.supersessions.some(o=>o.kind==="node"&&o.new===o.old||o.kind==="edge"&&o.revoke)?"revert":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===1&&t.supersessions[0].kind==="node"&&t.supersessions[0].new===null?"archive":t.nodes.length===0&&t.edges.length===0&&t.review.length===0&&(t.names?.length??0)>0?"names":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===0&&t.review.length>0?"review":"unknown"}import{existsSync as Hr,readdirSync as Ys,readFileSync as Gt}from"fs";import{isAbsolute as zs,join as ut,normalize as Qs,relative as Zs,sep as Xs}from"path";var eo=e=>e===""||zs(e)||e.includes("\\")||Qs(e).split(Xs).some(t=>t==="..")||e.startsWith("./")||e.includes("\0");function Fe(e){let t=ut(e,"manifest.json");if(!Hr(t))throw new C(`backup ${e} has no manifest.json \u2014 it was never completed; kane-cli context sync doctor`);let n;try{n=JSON.parse(Gt(t,"utf8"))}catch(s){throw new C(`backup manifest ${t} is not JSON: ${s instanceof Error?s.message:String(s)}`)}if(!Array.isArray(n))throw new C(`backup manifest ${t} is not a list`);let r=new Set,o=[];for(let s of n){let a=typeof s?.name=="string"?s.name:"";if(eo(a))throw new C(`backup manifest names an unsafe path ${JSON.stringify(s?.name)} \u2014 the backup is not trusted`);let c=ut(e,a);if(!Hr(c))throw new C(`backup file ${a} is missing from ${e}`);let d=Gt(c);if("sha256:"+an(d)!==s.hash)throw new C(`backup file ${a} does not match its manifest hash \u2014 the backup was changed after it was written`);if(a.startsWith("commits/"))try{r.add(ee(JSON.parse(d.toString("utf8"))))}catch(l){throw new C(`backup record ${a} is not a record: ${l instanceof Error?l.message:String(l)}`)}a.startsWith("intents/")&&o.push(a)}let i=new Set(n.map(s=>s.name));for(let s of Dr(e)){let a=Zs(e,s);if(a!=="manifest.json"&&!i.has(a))throw new C(`backup ${e} holds ${a}, which its manifest does not name \u2014 the backup was changed after it was written`)}for(let s of o){let a;try{a=JSON.parse(Gt(ut(e,s),"utf8"))}catch(d){throw new C(`backup envelope ${s} is not JSON: ${d instanceof Error?d.message:String(d)}`)}let c=mn(a);if(c!==null)throw new C(`backup envelope ${s} is not a valid intent: ${c}`);if(typeof a.born?.hash!="string"||!r.has(a.born.hash))throw new C(`backup envelope ${s} was born from a record the backup does not hold`)}}function Dr(e){let t=[];for(let n of Ys(e,{withFileTypes:!0})){let r=ut(e,n.name);n.isDirectory()?t.push(...Dr(r)):t.push(r)}return t}import{basename as Oo,join as Co}from"path";import{existsSync as Ao,readFileSync as No}from"fs";var G=class extends Error{},L=(e,t)=>({kind:"apply",inputs:e,...t&&t.length>0?{aliases:t}:{}}),V=e=>({kind:"noop",reason:e}),Vt=e=>({kind:"dedupe",as:e}),k=(e,t,n,r,o={})=>({kind:"hold",hold:{kind:e,mine:t,theirs:n,answers:r,detail:o}}),Gr=(e,t)=>{let n=ft(t.label,t.content);return e.graph.byLabel(t.label).filter(r=>!e.graph.superseded.has(r.cid)&&ft(t.label,r.content)===n).map(r=>r.cid)},z=e=>e?e.slice(0,19):"none",H=(e,t)=>e.maps.cid.rewrite(t);function I(e,t,n){if(typeof t!="string")throw new G(`${n} was not pinned`);let r=H(e,t);if(!e.graph.hasNode(r))throw new G(`${n} ${_(e,t)} has no counterpart on ${e.location}`);return r}var j=(e,t)=>e.graph.tipOf(t),Wt=(e,t)=>e.graph.superseded.has(e.graph.tipOf(t)),_=(e,t)=>e.fold.nameOf(t)??z(t),E=(e,t)=>e.graph.displayNameOf(t)??z(t);function Jt(e,t,n,r){let o=r==="fold"?e.fold.graph:e.graph,i=o.displayNameOf(t);if(i!==null&&i!==n)return i;let s=o.tipOf(t);for(let[d,l]of o.heads)if(l===t||l===s)return d;let a=o.getNode(t);if(a?.label==="source"&&typeof a.content.source_id=="string")return a.content.source_id;let c=a?.content.title??a?.content.text??a?.content.statement;return a&&typeof c=="string"&&c!==""?`${a.label} "${Y(c,32)}"`:z(t)}var F=e=>e.created_by?.by?.id??e.review[0]?.by.id??e.supersessions[0]?.by.id??e.names?.[0]?.by.id??"someone",N=e=>e.ts;function Y(e,t=48){let n=typeof e=="string"?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}var Ut={test_md_blob:"steps",objectives_blob:"checks"},to=/^sha256:[0-9a-f]{64}$/,no=(e,t)=>e==="derived"||Or.includes(e)||/_blob$/.test(e)||/(^|_)id$|Id$/.test(e)||t.some(n=>typeof n=="string"&&to.test(n));function pe(e,t,n,r){let o=[...new Set([...Object.keys(e),...Object.keys(t)])].filter(c=>JSON.stringify(e[c])!==JSON.stringify(t[c])),i=o.filter(c=>Ut[c]===void 0&&!no(c,[e[c],t[c]])).map(c=>`${c} "${Y(e[c]??"")}" \u2192 "${Y(t[c]??"")}"`),s=Object.keys(Ut).filter(c=>o.includes(c)).map(c=>Ut[c]);return`${[...i,...s.length>0?[`${s.join(" and ")} changed`]:[]].join(", ")||"no field changed"} by ${n} ${r===null?"since your last pull":`at ${r}`}`}var ro={usecase:"use case",scenario:"scenario",test:"test",ac:"acceptance criterion",source:"document"};function Ur(e,t){let n=e.graph.getNode(t),r=n?ro[n.label]??n.label:"item",o=n?.label!=="ac"?n?.content.title:void 0;if(typeof o=="string"&&o.trim()!=="")return`the ${r} "${o}"`;let i=e.fold.nameOf(t)??e.graph.displayNameOf(t);return i?`the ${r} ${En(i)}`:`the ${r}`}function ie(e,t){for(let n of e.theirs)for(let r of n.supersessions)if(r.kind==="node"&&r.old===t)return{rec:n,next:r.new}}function Kt(e,t){let n=new Set([t]);for(let o=!0;o;){o=!1;for(let[i,s]of e.graph.superseded)typeof s=="string"&&n.has(s)&&!n.has(i)&&(n.add(i),o=!0)}let r=[];for(let o of e.theirs)for(let i of o.review)n.has(i.id)&&i.resolution!=="pending"&&r.push({rec:o,resolution:i.resolution});return r}var so=new Set(Object.values(Ke).filter(e=>e!==Ke.DERIVES&&e!==Ke.ANNOTATES));function Yt(e,t){let n=new Set,r=[],o=[t,e.graph.tipOf(t)];for(;o.length>0;){let i=o.pop();if(!n.has(i)){n.add(i);for(let s of e.graph.edgesInto(i))!so.has(s.type)||e.graph.superseded.has(s.src)||(!(s.src in e.fold.index.nodeLabel)&&!r.some(a=>a.cid===s.src)&&r.push({cid:s.src,label:e.graph.nodeLabel.get(s.src)??"node"}),o.push(s.src))}}return r}function zt(e){let t=new Map;for(let n of e)t.set(n.label,(t.get(n.label)??0)+1);return[...t].map(([n,r])=>`${r} ${n}${r===1?"":"s"}`).join(", ")}function ht(e,t,n){if(!e.theirs.some(o=>o.edges.some(i=>i.type===t&&i.src===n)))return;let r=e.graph.edgesFrom(n).find(o=>o.type===t);return r?{live:r.dst}:void 0}function _e(e,t){let n=t.event_ids??[],r={token:e.store.parse(e.graph.latestHash)},o=new Map(n.map(a=>[a,e.store.appliedEvent(a,r)?.digest])),i=n.filter(a=>o.get(a)!==void 0);return n.length===0||i.length===0?void 0:i.every(a=>{let c=n.indexOf(a),d=t.event_digests?.[c];return d!==void 0&&d!==""&&o.get(a)===d})&&i.length===n.length?V("already applied: every event id is in the chain with the same intent"):k("ambiguous",`committed ${n.length} event id${n.length===1?"":"s"}`,`${i.length} of them already in the shared chain under another intent`,["keep-theirs"],{event_ids:n})}function oo(e){return String(e??"").toLowerCase().trim().replace(/\s+/g," ")}function ft(e,t){let n=t.question;return`${e}\0${oo(t.title??t.text??t.statement??n?.header??t.source_id??"")}`}function Vr(e,t){let n=[],r=new Set;for(let o of e.nodes){let i=ft(o.label,o.content),s=t.nodes.find(a=>!r.has(a.cid)&&ft(a.label,a.content)===i);s&&(r.add(s.cid),n.push([o.cid,s.cid]))}for(let o of e.nodes){if(n.some(([s])=>s===o.cid))continue;let i=t.nodes.find(s=>!r.has(s.cid)&&s.label===o.label);i&&(r.add(i.cid),n.push([o.cid,i.cid]))}return n}function Wr(e,t){let n=[],r=new Set;for(let o of t.names??[]){if(!Ye.test(o.slug))continue;let i=t.nodes.find(a=>a.cid===o.cid);if(!i||e.graph.nameOf.has(H(e,o.cid)))continue;let s=ze(i.label,a=>r.has(a),e.graph.names.keys());s!==null&&(r.add(s),s!==o.slug&&n.push({from:o.slug,to:s}))}return n}function Jr(e,t,n){let r=[];for(let o of e.names??[]){let i=n.find(([a])=>a===o.cid)?.[1],s=t.names?.find(a=>a.cid===i);s&&s.slug!==o.slug&&r.push({from:o.slug,to:s.slug})}return r}function Kr(e,t,n){let r=e===void 0?void 0:e.split(`
4
4
  `).map(s=>{let a=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(s);if(a)return`${a[1]} @verifies ${a[2].split(",").map(l=>l.trim()).filter(Boolean).map(n).join(", ")}`;let c=/^(\s*)@import\s+(\S+)\s*$/.exec(s);if(c)return`${c[1]}@import ${n(c[2])}`;let d=/^## Import: (\S+)\s*$/.exec(s);return d?`## Import: ${n(d[1])}`:s}).join(`
5
5
  `),o=null,i=t===void 0?void 0:t.split(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-LZPYIFHZ.js";import{f as e}from"./chunk-HYJVYYAZ.js";import{a as t,b as i,y as n}from"./chunk-YKOZBFR3.js";import{a as p}from"./chunk-WTMCDYR3.js";import{dirname as d}from"path";import{fileURLToPath as l}from"url";import{existsSync as a}from"fs";import{join as c,resolve as f}from"path";function g(r){for(let o of[f(r,".."),f(r,"../..")])if(a(c(o,"package.json")))return o;return null}function u(r=m,o,s=p){e({version:t,baseDir:i,authEnvironments:n,packageRoot:g(d(l(import.meta.url))),wording:r,...o?{warn:o}:{},userSessionId:s})}u();export{g as a,u as b};
2
+ import{a as m}from"./chunk-LZPYIFHZ.js";import{f as e}from"./chunk-HYJVYYAZ.js";import{a as t,b as i,z as n}from"./chunk-BRWCWZE3.js";import{a as p}from"./chunk-WTMCDYR3.js";import{dirname as d}from"path";import{fileURLToPath as l}from"url";import{existsSync as a}from"fs";import{join as c,resolve as f}from"path";function g(r){for(let o of[f(r,".."),f(r,"../..")])if(a(c(o,"package.json")))return o;return null}function u(r=m,o,s=p){e({version:t,baseDir:i,authEnvironments:n,packageRoot:g(d(l(import.meta.url))),wording:r,...o?{warn:o}:{},userSessionId:s})}u();export{g as a,u as b};