@testmuai/kane-cli 0.8.23 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/{ChatSurface-GBZX4LWL.js → ChatSurface-FJPK3XEJ.js} +1 -1
  2. package/dist/{ChromeProfilePicker-UONX2UVC.js → ChromeProfilePicker-7DUDJTE2.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6BJCNRNG.js → CliFeedbackPrompt-ZZPYC6OS.js} +1 -1
  4. package/dist/{CliUploadProgress-K4Z22DSY.js → CliUploadProgress-WQYKIBAR.js} +1 -1
  5. package/dist/ConfigView-KXNOODDW.js +2 -0
  6. package/dist/EvidenceViewOffer-BTBVPBZX.js +2 -0
  7. package/dist/FolderPicker-H4YEX5LV.js +2 -0
  8. package/dist/{InfoBox-OU5PLRIL.js → InfoBox-DTM7X24Z.js} +1 -1
  9. package/dist/{LinksBox-DH7TSUXW.js → LinksBox-KFG3FVOT.js} +1 -1
  10. package/dist/{ProfilesView-MGJKBOF5.js → ProfilesView-KBZHT4KL.js} +1 -1
  11. package/dist/{ProjectPicker-YFV6K77F.js → ProjectPicker-OARWULNN.js} +1 -1
  12. package/dist/{SaveSessionPrompt-64QKQB6B.js → SaveSessionPrompt-37SMU5MC.js} +1 -1
  13. package/dist/SingleShotApp-UYCAW65Y.js +2 -0
  14. package/dist/{SummaryBox-DGS3LVRF.js → SummaryBox-6RB5DSAH.js} +1 -1
  15. package/dist/TestMdRunView-ZMOII3PL.js +2 -0
  16. package/dist/{TestrunEvidenceTable-PHBAB4XQ.js → TestrunEvidenceTable-3UP2EYIV.js} +1 -1
  17. package/dist/{WhoamiView-6HWPYN6Y.js → WhoamiView-MC62GERR.js} +1 -1
  18. package/dist/app-client-PQFJAB63.js +2 -0
  19. package/dist/app-download-P6YXWSVQ.js +2 -0
  20. package/dist/{auth-NWBIFCB7.js → auth-LXW4OFKF.js} +1 -1
  21. package/dist/{binary-MOJTQGUV.js → binary-LVHXED3O.js} +1 -1
  22. package/dist/{bind-S3IQTPNN.js → bind-ZYESQSCJ.js} +2 -2
  23. package/dist/{bootstrap-RCV7PNMQ.js → bootstrap-DI4UGMH3.js} +1 -1
  24. package/dist/bridge-7J3JE3JS.js +2 -0
  25. package/dist/catalog-LLME3744.js +2 -0
  26. package/dist/{changelog-2N6HKKKQ.js → changelog-N5AZHXOS.js} +1 -1
  27. package/dist/{chunk-MZ7W4WLF.js → chunk-243ZJHT6.js} +1 -1
  28. package/dist/{chunk-LF42V6P6.js → chunk-2PKME4VT.js} +4 -4
  29. package/dist/{chunk-3OKX64UR.js → chunk-3MCPTVJX.js} +1 -1
  30. package/dist/{chunk-5UHY3PTQ.js → chunk-3YIZG7WZ.js} +1 -1
  31. package/dist/{chunk-TONFENRW.js → chunk-4BZOG6PE.js} +1 -1
  32. package/dist/{chunk-MBJHS653.js → chunk-4CYBXJIA.js} +1 -1
  33. package/dist/{chunk-BASTDR3M.js → chunk-4FHK4LKQ.js} +1 -1
  34. package/dist/{chunk-LNSBC32V.js → chunk-4Y2WH77W.js} +1 -1
  35. package/dist/{chunk-UQSVO7TY.js → chunk-5HMN74RZ.js} +1 -1
  36. package/dist/chunk-5RCS2LIQ.js +26 -0
  37. package/dist/chunk-5TQFOPJV.js +2 -0
  38. package/dist/{chunk-KJIDMW6N.js → chunk-6HU5M2DS.js} +1 -1
  39. package/dist/{chunk-JFZA4UON.js → chunk-6MD7SR7D.js} +1 -1
  40. package/dist/{chunk-J6TBTWW7.js → chunk-6VY62QC2.js} +1 -1
  41. package/dist/{chunk-GFNCGN5V.js → chunk-75MMTNPB.js} +2 -2
  42. package/dist/{chunk-OFRYEWZE.js → chunk-7GAHJZLH.js} +1 -1
  43. package/dist/chunk-7WXMV3O3.js +7 -0
  44. package/dist/{chunk-IIDBLJ5A.js → chunk-AHFIRHSP.js} +1 -1
  45. package/dist/chunk-AJT34ESA.js +38 -0
  46. package/dist/chunk-AKE2CTV6.js +2 -0
  47. package/dist/{chunk-VACHFCNC.js → chunk-AUMJ4RVA.js} +1 -1
  48. package/dist/chunk-BL3SJDCG.js +10 -0
  49. package/dist/chunk-BUPRL2TE.js +2 -0
  50. package/dist/chunk-C25M2J5Q.js +4 -0
  51. package/dist/{chunk-RAARDC2O.js → chunk-C6S2RPZA.js} +1 -1
  52. package/dist/{chunk-3C32LVLX.js → chunk-CNUCP6DK.js} +1 -1
  53. package/dist/chunk-CSNJPD2J.js +5 -0
  54. package/dist/{chunk-2FH4HJYB.js → chunk-CW3RHKLA.js} +1 -1
  55. package/dist/{chunk-J2FJ62K4.js → chunk-DOOI2JBD.js} +1 -1
  56. package/dist/{chunk-2A7OQRAD.js → chunk-DTRKTBCE.js} +4 -4
  57. package/dist/{chunk-QAG67DUT.js → chunk-DTRSYWZE.js} +1 -1
  58. package/dist/{chunk-5HOHXV2K.js → chunk-DWMESHFI.js} +1 -1
  59. package/dist/chunk-EBLXHOE3.js +2 -0
  60. package/dist/{chunk-PXHN7SFG.js → chunk-EOA6YPES.js} +1 -1
  61. package/dist/{chunk-FPFS6OSR.js → chunk-F7NSSQYZ.js} +1 -1
  62. package/dist/chunk-FMUV6UCX.js +2 -0
  63. package/dist/chunk-GCISXCDU.js +2 -0
  64. package/dist/chunk-GFBAK7WQ.js +8 -0
  65. package/dist/{chunk-RMVASIVL.js → chunk-GTVQYT3D.js} +2 -2
  66. package/dist/{chunk-CLQP3DHT.js → chunk-HAYV4D2I.js} +1 -1
  67. package/dist/{chunk-6YZ3VP3E.js → chunk-HG5LLZBU.js} +1 -1
  68. package/dist/chunk-HGFWIBVF.js +8 -0
  69. package/dist/{chunk-3UMVRJX3.js → chunk-ILDHE4P4.js} +2 -2
  70. package/dist/{chunk-QQCEP3QP.js → chunk-IPXKUYUK.js} +1 -1
  71. package/dist/{chunk-D4XR7EEQ.js → chunk-J3BGYSMD.js} +12 -10
  72. package/dist/{chunk-OYKRCDT4.js → chunk-JQY5HRZ4.js} +1 -1
  73. package/dist/{chunk-AGDPEZXT.js → chunk-JX6BFEDO.js} +1 -1
  74. package/dist/chunk-K3IQEL7R.js +7 -0
  75. package/dist/{chunk-5RHR4DMF.js → chunk-KWEOLPBJ.js} +1 -1
  76. package/dist/{chunk-SYJXTB4J.js → chunk-KXEE6VCA.js} +1 -1
  77. package/dist/{chunk-FORNRNHU.js → chunk-LH4IPANP.js} +1 -1
  78. package/dist/{chunk-WICJY6KL.js → chunk-LLG7NEGX.js} +1 -1
  79. package/dist/{chunk-UYI4WPNQ.js → chunk-M3UAZTDK.js} +1 -1
  80. package/dist/{chunk-DUYRCVI5.js → chunk-NMSZ7G6P.js} +1 -1
  81. package/dist/chunk-NOL7MNZH.js +2 -0
  82. package/dist/{chunk-C7NWWGLT.js → chunk-OC6H6BYI.js} +1 -1
  83. package/dist/{chunk-HBSYBL6J.js → chunk-OHOJSADN.js} +1 -1
  84. package/dist/chunk-OIUV3ISA.js +2 -0
  85. package/dist/{chunk-AIK7BAME.js → chunk-OJAXOOZ5.js} +2 -2
  86. package/dist/{chunk-RGRFL7XG.js → chunk-OMNLAGQC.js} +1 -1
  87. package/dist/{chunk-HPHETGRE.js → chunk-OOCCUUR2.js} +1 -1
  88. package/dist/{chunk-SB2SKN34.js → chunk-OXC6O5O7.js} +1 -1
  89. package/dist/chunk-OZQDD2EX.js +94 -0
  90. package/dist/{chunk-D6BULK7E.js → chunk-PCKIANML.js} +1 -1
  91. package/dist/{chunk-RD72POF2.js → chunk-PEDINHVU.js} +1 -1
  92. package/dist/{chunk-MKMJOMLX.js → chunk-PNUAP3RY.js} +2 -2
  93. package/dist/{chunk-2MEQTHNI.js → chunk-Q5CINJYL.js} +1 -1
  94. package/dist/{chunk-SY4T44VC.js → chunk-Q5RDCSYM.js} +1 -1
  95. package/dist/chunk-QAB3Y5FQ.js +4 -0
  96. package/dist/{chunk-WJR2FU7S.js → chunk-RTSBKCZY.js} +1 -1
  97. package/dist/{chunk-K6VDRR3H.js → chunk-RWSOZPJQ.js} +1 -1
  98. package/dist/{chunk-HJGVM6TS.js → chunk-SID4X77D.js} +1 -1
  99. package/dist/chunk-SOCHN2PY.js +2 -0
  100. package/dist/{chunk-NIFJJX6N.js → chunk-SRTKRHYI.js} +1 -1
  101. package/dist/chunk-TM7VRLWS.js +2 -0
  102. package/dist/{chunk-IEW7AW64.js → chunk-UA2QDAWT.js} +1 -1
  103. package/dist/{chunk-ZIHG6EKH.js → chunk-USOYXCZ4.js} +1 -1
  104. package/dist/{chunk-DWHF5HUD.js → chunk-USY7VAO6.js} +1 -1
  105. package/dist/{chunk-AT3RME5W.js → chunk-UWXDURAB.js} +1 -1
  106. package/dist/{chunk-D7WG7SRA.js → chunk-VBS33P2C.js} +1 -1
  107. package/dist/{chunk-YI3H2UIB.js → chunk-VHW7BMZQ.js} +1 -1
  108. package/dist/{chunk-SFFDVF3J.js → chunk-VORWZLS3.js} +2 -2
  109. package/dist/{chunk-DSKJ6J7Y.js → chunk-WDMUPK6I.js} +1 -1
  110. package/dist/{chunk-QGXVQIN5.js → chunk-WMI4P76K.js} +2 -2
  111. package/dist/{chunk-MKQ7ZRDW.js → chunk-WNOC6MQC.js} +1 -1
  112. package/dist/{chunk-XQQHSC7G.js → chunk-WRSIKZ2V.js} +1 -1
  113. package/dist/chunk-X2A6CC6B.js +2 -0
  114. package/dist/{chunk-LNFU4JZ7.js → chunk-XBX643ZD.js} +1 -1
  115. package/dist/{chunk-CAJZQQ3G.js → chunk-XKHWWKJZ.js} +1 -1
  116. package/dist/{chunk-HJX5PQRD.js → chunk-XT7XA4DN.js} +1 -1
  117. package/dist/{chunk-QU7P7B3W.js → chunk-Y3ZYN6AK.js} +3 -3
  118. package/dist/chunk-YBAVDT3G.js +2 -0
  119. package/dist/{chunk-5ESGUPSR.js → chunk-YWYORBY3.js} +1 -1
  120. package/dist/{chunk-IGHK2ENL.js → chunk-Z7IGTVJW.js} +1 -1
  121. package/dist/{chunk-CSVPZ33X.js → chunk-ZC2CKWLB.js} +1 -1
  122. package/dist/{chunk-UF4MU2AZ.js → chunk-ZER3FZSZ.js} +2 -2
  123. package/dist/chunk-ZJYT72BA.js +9 -0
  124. package/dist/{chunk-LHUW5QDT.js → chunk-ZXY4P76I.js} +1 -1
  125. package/dist/{config-7E4NS553.js → config-YGTHSGQN.js} +1 -1
  126. package/dist/cover-cmd-6RO366CC.js +3 -0
  127. package/dist/{credentials-PSQWWFGD.js → credentials-QD32Y7K7.js} +1 -1
  128. package/dist/{deps-bundle-PPOQHJTB.js → deps-bundle-OI7JJ22L.js} +1 -1
  129. package/dist/{deps-resolve-AX6ZAKLH.js → deps-resolve-ZOALDS6H.js} +1 -1
  130. package/dist/device-env-DXDJJMTL.js +2 -0
  131. package/dist/{dispatch-KMWEDMKE.js → dispatch-7EWWQRQ5.js} +1 -1
  132. package/dist/{doctor-XDF3MA4W.js → doctor-TPYPEEUL.js} +1 -1
  133. package/dist/evidence-NPFTBGDF.js +2 -0
  134. package/dist/evolve-cmd-VGVXV6XW.js +2 -0
  135. package/dist/explain-cmd-GOP5TE63.js +9 -0
  136. package/dist/{explain-cmd-JAOHSI4F.js → explain-cmd-M7IX2YNB.js} +1 -1
  137. package/dist/{extract-bind-PLMSZKLZ.js → extract-bind-CKIRLXAJ.js} +2 -2
  138. package/dist/{extract-cmd-RJBHPPF3.js → extract-cmd-3EWLSPGS.js} +1 -1
  139. package/dist/gaps-cmd-WVC5GXQC.js +3 -0
  140. package/dist/{generate-headless-TEDHS3F2.js → generate-headless-6WMJYNI6.js} +2 -2
  141. package/dist/index.js +175 -174
  142. package/dist/ingest-cmd-AECK5T4H.js +2 -0
  143. package/dist/install-ZV3KJZV4.js +2 -0
  144. package/dist/{interactive-bind-XUMKEGAN.js → interactive-bind-IYS6KDOH.js} +3 -3
  145. package/dist/lifecycle-cmd-XCSBELFQ.js +2 -0
  146. package/dist/list-cmd-S4DSN2ET.js +3 -0
  147. package/dist/{list-commands-OHIQFJGQ.js → list-commands-GLNGHPDU.js} +1 -1
  148. package/dist/login-flow-ASUUU7SO.js +2 -0
  149. package/dist/maintenance-cmd-K5KXRIFL.js +2 -0
  150. package/dist/mobile-prompts-ZUZTA3RV.js +2 -0
  151. package/dist/{objective-variable-gate-JALOH6SL.js → objective-variable-gate-CG2KK5UX.js} +1 -1
  152. package/dist/{open-provider-746LLSEO.js → open-provider-YIBB77FE.js} +1 -1
  153. package/dist/persist-recorded-session-EWV56TSZ.js +3 -0
  154. package/dist/pipeline-LAWACB2O.js +2 -0
  155. package/dist/prepare-target-WGPCZKLE.js +2 -0
  156. package/dist/real-device-run-MDLFKFVQ.js +2 -0
  157. package/dist/reconcile-cmd-XFM2ZXUJ.js +2 -0
  158. package/dist/reconcile-deps-V5VLDPYT.js +4 -0
  159. package/dist/reconcile-engine-VZBTMPUK.js +2 -0
  160. package/dist/{recording-banner-TCFFB6KE.js → recording-banner-CJHRPHHF.js} +1 -1
  161. package/dist/registry-3JXQFZEG.js +2 -0
  162. package/dist/{require-project-folder-2224ZMJ5.js → require-project-folder-SE5GVCYJ.js} +1 -1
  163. package/dist/resolve-run-intent-DD4MB6UD.js +2 -0
  164. package/dist/{resolver-GJR2Z7JY.js → resolver-TLO4SRWV.js} +1 -1
  165. package/dist/review-cmd-7EOYQMPE.js +5 -0
  166. package/dist/run-EHUNJPW6.js +2 -0
  167. package/dist/run-OTMPUQSH.js +2 -0
  168. package/dist/run-test-md-KBDEHGXJ.js +17 -0
  169. package/dist/session-target-UMNASXI7.js +2 -0
  170. package/dist/{sessions-cmd-IV25N2L7.js → sessions-cmd-M3SECFKQ.js} +1 -1
  171. package/dist/{skill-installer-T2IOCPET.js → skill-installer-32YYMM4N.js} +1 -1
  172. package/dist/{spawner-HQM2757J.js → spawner-DPT2RLAO.js} +1 -1
  173. package/dist/store-guard-U32JE6JJ.js +2 -0
  174. package/dist/structured-answers-ZI2B6JJE.js +1 -1
  175. package/dist/sync-cmd-3EP7LZGL.js +2 -0
  176. package/dist/sync-setup-SWTBVQEV.js +2 -0
  177. package/dist/tcg-generate-KXU7E2GF.js +2 -0
  178. package/dist/testmd-actions-PEWCPQ5R.js +2 -0
  179. package/dist/testmd-sync-ZWFQWZ2X.js +2 -0
  180. package/dist/token-refresh-QD3OCGJJ.js +2 -0
  181. package/dist/{validate-basic-V7R4RH5M.js → validate-basic-AAIXSAWH.js} +1 -1
  182. package/dist/{variable-receipt-F55CSW5Z.js → variable-receipt-YWNS24TH.js} +1 -1
  183. package/dist/{verdicts-7IUZFXB4.js → verdicts-LAB5BGCC.js} +1 -1
  184. package/dist/{version-check-PUUSB7AY.js → version-check-EHOLX3YH.js} +1 -1
  185. package/dist/{view-cmd-ELDKYRMZ.js → view-cmd-3WHG6MVB.js} +1 -1
  186. package/dist/walk-session-XP4KYFKO.js +2 -0
  187. package/dist/with-telemetry-FJMJQDCM.js +2 -0
  188. package/package.json +11 -11
  189. package/dist/ConfigView-BB22G7JO.js +0 -2
  190. package/dist/EvidenceViewOffer-25IQF3TX.js +0 -2
  191. package/dist/FolderPicker-65JFR2NW.js +0 -2
  192. package/dist/SingleShotApp-VYKUCRVW.js +0 -2
  193. package/dist/TestMdRunView-LKAITAA4.js +0 -2
  194. package/dist/app-client-ZCCNE3RV.js +0 -2
  195. package/dist/app-download-SQ2LYYL7.js +0 -2
  196. package/dist/bridge-O7ENTV4K.js +0 -2
  197. package/dist/chunk-7KRY26OF.js +0 -4
  198. package/dist/chunk-ATYXPCM6.js +0 -6
  199. package/dist/chunk-BL5QHONU.js +0 -2
  200. package/dist/chunk-CXF6AZWY.js +0 -2
  201. package/dist/chunk-DDHGEJJP.js +0 -2
  202. package/dist/chunk-EM3PU2YW.js +0 -2
  203. package/dist/chunk-EYOCNMUM.js +0 -2
  204. package/dist/chunk-FMBPUXWL.js +0 -8
  205. package/dist/chunk-FQJOWUEN.js +0 -2
  206. package/dist/chunk-MV3Q335C.js +0 -7
  207. package/dist/chunk-MWIE6LOZ.js +0 -4
  208. package/dist/chunk-ODU2JSMA.js +0 -8
  209. package/dist/chunk-RAPV3BTA.js +0 -98
  210. package/dist/chunk-TAOHYWEO.js +0 -2
  211. package/dist/chunk-URWWROLS.js +0 -9
  212. package/dist/chunk-VAN7ECN6.js +0 -2
  213. package/dist/chunk-VOYMN2WQ.js +0 -5
  214. package/dist/chunk-X4NUVVCJ.js +0 -26
  215. package/dist/chunk-YFQGOOF7.js +0 -2
  216. package/dist/cover-cmd-6KZX46S2.js +0 -3
  217. package/dist/device-env-TZQDB5T3.js +0 -2
  218. package/dist/evidence-EUIDOVOR.js +0 -2
  219. package/dist/evolve-cmd-QVTGTCJ5.js +0 -2
  220. package/dist/explain-cmd-36SVSHU7.js +0 -9
  221. package/dist/gaps-cmd-3WZPDDYS.js +0 -3
  222. package/dist/ingest-cmd-JDIOPJBN.js +0 -2
  223. package/dist/install-Y3VKFBK3.js +0 -2
  224. package/dist/lifecycle-cmd-FBDRFIOE.js +0 -2
  225. package/dist/list-cmd-TFUACRAM.js +0 -3
  226. package/dist/login-flow-OHNKSVYZ.js +0 -2
  227. package/dist/maintenance-cmd-7OSUIDL4.js +0 -2
  228. package/dist/mobile-prompts-DEVUZRG3.js +0 -2
  229. package/dist/persist-recorded-session-GPP6UKN6.js +0 -3
  230. package/dist/pipeline-QPTPZVUJ.js +0 -2
  231. package/dist/prepare-target-N7QRNYOS.js +0 -2
  232. package/dist/reconcile-cmd-SMGLHMLF.js +0 -2
  233. package/dist/reconcile-deps-DVIJK5UZ.js +0 -4
  234. package/dist/reconcile-engine-KL2J5SNQ.js +0 -2
  235. package/dist/registry-BFFA4YJK.js +0 -2
  236. package/dist/resolve-run-intent-HFXGEOYK.js +0 -2
  237. package/dist/review-cmd-CQE6SBZA.js +0 -5
  238. package/dist/run-BXKWDJFJ.js +0 -2
  239. package/dist/run-HSP2MZPU.js +0 -2
  240. package/dist/run-test-md-2ELPAASM.js +0 -17
  241. package/dist/session-target-UWROGOCY.js +0 -2
  242. package/dist/store-guard-NAW26EEQ.js +0 -2
  243. package/dist/sync-cmd-Q6ZYEVWI.js +0 -2
  244. package/dist/sync-setup-CA362C5S.js +0 -2
  245. package/dist/tcg-generate-CDB2N5LD.js +0 -2
  246. package/dist/testmd-actions-BDWDE2TG.js +0 -2
  247. package/dist/testmd-sync-EPTUVJYJ.js +0 -2
  248. package/dist/token-refresh-TKBOHXSD.js +0 -2
  249. package/dist/walk-session-EGIMA4VG.js +0 -2
  250. package/dist/with-telemetry-LRWWBISP.js +0 -2
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{homedir as s}from"os";import{join as t}from"path";var b="0.9.0";var a=t(s(),".testmuai","kaneai"),g=t(a,"profiles"),h=t(a,"tui-config.json"),u=t(a,"media"),U="https://registry.npmjs.org/@testmuai/kane-cli",_="https://api.github.com/repos/LambdaTest/kane-cli/releases",i="@testmuai/kane-cli-skill",A=`https://registry.npmjs.org/${i}`,r="kane-cli",x=[{dir:t(s(),".claude","skills",r),agent:"Claude Code"},{dir:t(s(),".agents","skills",r),agent:"Codex CLI"},{dir:t(s(),".gemini","skills",r),agent:"Gemini CLI"}],L="https://dd-proxy.lambdatest.com/intake/kane-cli",R="https://kaneai-playground.lambdatest.io",I=9222,E=9230,C=t(a,"chrome-profiles"),o=t(a,"hints"),f=t(o,"state.json");function S(e){return t(o,`catalog-${e}.json`)}var l=t(a,"mobile");function v(e,n="android"){return t(l,n==="ios"?`device-catalog-ios-${e}.json`:`device-catalog-${e}.json`)}var m="127.0.0.1",B=18392,T=18400,c="/callback";function N(e){return`http://${m}:${e}${c}`}var O="KANE CLI",P="*",k={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com",mobileHubUrl:"https://mobile-hub.lambdatest.com/wd/hub",lrmaaBaseUrl:"https://mobile-api.lambdatest.com/mobile-automation/api/v1",deviceStreamUrl:"https://stream-microfrontend.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com",mobileHubUrl:"https://stage-mobile-hub.lambdatestinternal.com/wd/hub",lrmaaBaseUrl:"https://stage-mobile-api.lambdatestinternal.com/mobile-automation/api/v1",deviceStreamUrl:"https://stage-stream-microfrontend.lambdatestinternal.com"}},D={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{b as a,a as b,h as c,u as d,U as e,_ as f,i as g,x as h,L as i,R as j,I as k,E as l,C as m,f as n,S as o,v as p,m as q,B as r,T as s,c as t,N as u,O as v,P as w,k as x,D as y};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f,d as l}from"./chunk-LHUW5QDT.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-PPOQHJTB.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
2
+ import{b as f,d as l}from"./chunk-ZXY4P76I.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-OI7JJ22L.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
3
3
  `))e.push(` fix: ${r}`)}}}return e.join(`
4
4
  `)}function w(t){return t.sections.length===0?!0:t.sections.every(e=>e.checks.some(o=>o.required&&o.status==="fail"&&!o.fixedByBundle))}function b(t){for(let e of t.sections)for(let o of e.checks)if(o.required&&o.status!=="pass")return 2;return 0}export{k as a,C as b,w as c,b as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as wr}from"./chunk-NJ4BXZBX.js";import{a as br}from"./chunk-Q4YYAN6E.js";import{a as mr,b as yr}from"./chunk-EVFFDODK.js";import{a as gr}from"./chunk-3VAU3PNU.js";import{a as hr}from"./chunk-WVHMPIDQ.js";import{a as lr,d as pr}from"./chunk-BB2W35TW.js";import{c as ur,d as fr}from"./chunk-V4B5QA3U.js";import{a as ir,g as xt,h as ar,n as dr,p as cr}from"./chunk-7N6OCHPC.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-VACHFCNC.js";import{A as tr,B as qt,C as te,D as it,E as fe,F as nr,G as ne,H as _e,I as at,J as rr,K as Y,L as Fe,M as dt,N as Re,O as sr,P as or,S as Be,a as Dn,b as Mn,c as Ae,d as Pe,e as le,f as st,g as Gn,h as Vn,i as pe,j as Kn,k as qe,l as je,m as Yn,n as ot,o as ue,p as zn,q as Qn,r as Zn,s as Xn,t as At,u as Pt,v as X,w as Te,x as er,y as Nt,z as xe}from"./chunk-RMVASIVL.js";import{b as Ln,d as Bn,g as Ct,h as K}from"./chunk-T2ONUKTL.js";import{a as R,b as Hn,d as ee,e as Ne,h as Jn,i as Wn,k as Un}from"./chunk-YLQHY4A7.js";import{a as Tn,b as xn,e as Fn}from"./chunk-WJR2FU7S.js";import{b as sn,f as on,h as an,k as dn,l as cn}from"./chunk-RGRFL7XG.js";import{b as Ot,d as ce}from"./chunk-VVOKM2VO.js";import{A as qn,n as Sn,o as En,p as On,q as Cn,r as An,s as Pn,t as Nn,x as tt,y as nt,z as rt}from"./chunk-IICT4VOU.js";import{a as jn}from"./chunk-CH273NAE.js";import{b as ve}from"./chunk-BKM2LWU2.js";import{B as oe,C as vn,D as $n,F as $e,G as Xe,J as kn,K as Ce,O as _n,P as et,U as Rn,W as In,X as ke,b as rn,c as de,f as Et,h as pn,l as un,m as fn,o as Oe,p as O,q as hn,t as gn,v as mn,x as yn,y as bn,z as wn}from"./chunk-RDHWNSDP.js";import{d as ln,f as Qe,g as Ze}from"./chunk-XLSOQLVT.js";import{existsSync as Ue,readdirSync as os,readFileSync as is,realpathSync as Mo,statSync as Ho,writeFileSync as Go}from"fs";import{basename as Rt,join as Ke,relative as Vo,resolve as tn}from"path";import{randomBytes as _s}from"crypto";var vr=8,De=()=>Un(_s(8).toString("hex")),$r=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Rs=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=De(),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(!$r(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=De(),r=(await Promise.all(Array.from({length:vr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${vr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=De(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?$r(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(De())?"a never-written key was reported present":null]];async function lt(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 Rs){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await kr(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await kr(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function kr(e){try{return!await e.head(De())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as Is,readFileSync as Ir}from"fs";import{join as Ss}from"path";async function Ft(e,t,n,r){let i=le(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 qe(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 d=s.storage,c=wn(e),a;try{mn(e),a=Es(e,d)}catch(F){throw F instanceof gn?new R("SYNC_REBASE_PENDING",`${F.message.split(";")[0]}; nothing was pushed`,F.remedy):F}finally{c()}let l=a.map(F=>Os(e,F)),g=0,p=0,f=0,u=0,y=d,b=null,h=null,m=t.beginTransaction?await t.beginTransaction():void 0,w=m?{...t,head:m.head,get:m.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=m?m.stageIfAbsent.bind(m):t.putIfAbsent.bind(t),x=[],ae=F=>m?x.push(F):r(F);try{let F=new Set;for(let A of l){for(let $ of A.blobs)if(await v($.key,$.bytes)!=="exists")p++,F.add($.key);else if(!F.has($.key)){let M=await w.get($.key);if(M===null||Ot(Buffer.from(M))!==$.fp){h=new R("SYNC_OBJECT_CORRUPT",`the blob ${$.fp} ${n} already holds does not hash to its name (named by record ${A.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}F.add($.key)}if(h)break;A.proposal&&await v(A.proposal.key,A.proposal.bytes)!=="exists"&&f++;let Q=Ne(A.seq);if(await v(Q,A.raw)!=="exists")g++;else if((await pe(w,A.seq)).hash===A.hash)ae(`position ${A.seq} is already on ${n}`),u++;else{b=A.seq;break}y={seq:A.seq,hash:A.hash}}if(m||await Rr(t,y,d,n),y&&!await w.head(ee)){let A=await pe(w,1),Q={layout:1,canonicalizer:"v1",genesis_hash:A.hash};await v(ee,Buffer.from(JSON.stringify(Q)+`
2
+ import{a as wr}from"./chunk-NJ4BXZBX.js";import{a as br}from"./chunk-Q4YYAN6E.js";import{a as mr,b as yr}from"./chunk-EVFFDODK.js";import{a as gr}from"./chunk-3VAU3PNU.js";import{a as hr}from"./chunk-WVHMPIDQ.js";import{a as lr,d as pr}from"./chunk-BB2W35TW.js";import{c as ur,d as fr}from"./chunk-V4B5QA3U.js";import{a as ir,g as xt,h as ar,n as dr,p as cr}from"./chunk-7N6OCHPC.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-AUMJ4RVA.js";import{A as tr,B as qt,C as te,D as it,E as fe,F as nr,G as ne,H as _e,I as at,J as rr,K as Y,L as Fe,M as dt,N as Re,O as sr,P as or,S as Be,a as Dn,b as Mn,c as Ae,d as Pe,e as le,f as st,g as Gn,h as Vn,i as pe,j as Kn,k as qe,l as je,m as Yn,n as ot,o as ue,p as zn,q as Qn,r as Zn,s as Xn,t as At,u as Pt,v as X,w as Te,x as er,y as Nt,z as xe}from"./chunk-GTVQYT3D.js";import{b as Ln,d as Bn,g as Ct,h as K}from"./chunk-T2ONUKTL.js";import{a as R,b as Hn,d as ee,e as Ne,h as Jn,i as Wn,k as Un}from"./chunk-YLQHY4A7.js";import{a as Tn,b as xn,e as Fn}from"./chunk-RTSBKCZY.js";import{b as sn,f as on,h as an,k as dn,l as cn}from"./chunk-OMNLAGQC.js";import{b as Ot,d as ce}from"./chunk-VVOKM2VO.js";import{A as qn,n as Sn,o as En,p as On,q as Cn,r as An,s as Pn,t as Nn,x as tt,y as nt,z as rt}from"./chunk-IICT4VOU.js";import{B as oe,C as vn,D as $n,F as $e,G as Xe,J as kn,K as Ce,O as _n,P as et,U as Rn,W as In,X as ke,b as rn,c as de,f as Et,h as pn,l as un,m as fn,o as Oe,p as O,q as hn,t as gn,v as mn,x as yn,y as bn,z as wn}from"./chunk-RDHWNSDP.js";import{d as ln,f as Qe,g as Ze}from"./chunk-XLSOQLVT.js";import{a as jn}from"./chunk-CH273NAE.js";import{b as ve}from"./chunk-BKM2LWU2.js";import{existsSync as Ue,readdirSync as os,readFileSync as is,realpathSync as Mo,statSync as Ho,writeFileSync as Go}from"fs";import{basename as Rt,join as Ke,relative as Vo,resolve as tn}from"path";import{randomBytes as _s}from"crypto";var vr=8,De=()=>Un(_s(8).toString("hex")),$r=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Rs=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=De(),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(!$r(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=De(),r=(await Promise.all(Array.from({length:vr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${vr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=De(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?$r(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(De())?"a never-written key was reported present":null]];async function lt(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 Rs){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await kr(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await kr(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function kr(e){try{return!await e.head(De())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as Is,readFileSync as Ir}from"fs";import{join as Ss}from"path";async function Ft(e,t,n,r){let i=le(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 qe(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 d=s.storage,c=wn(e),a;try{mn(e),a=Es(e,d)}catch(F){throw F instanceof gn?new R("SYNC_REBASE_PENDING",`${F.message.split(";")[0]}; nothing was pushed`,F.remedy):F}finally{c()}let l=a.map(F=>Os(e,F)),g=0,p=0,f=0,u=0,y=d,b=null,h=null,m=t.beginTransaction?await t.beginTransaction():void 0,w=m?{...t,head:m.head,get:m.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=m?m.stageIfAbsent.bind(m):t.putIfAbsent.bind(t),x=[],ae=F=>m?x.push(F):r(F);try{let F=new Set;for(let A of l){for(let $ of A.blobs)if(await v($.key,$.bytes)!=="exists")p++,F.add($.key);else if(!F.has($.key)){let M=await w.get($.key);if(M===null||Ot(Buffer.from(M))!==$.fp){h=new R("SYNC_OBJECT_CORRUPT",`the blob ${$.fp} ${n} already holds does not hash to its name (named by record ${A.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}F.add($.key)}if(h)break;A.proposal&&await v(A.proposal.key,A.proposal.bytes)!=="exists"&&f++;let Q=Ne(A.seq);if(await v(Q,A.raw)!=="exists")g++;else if((await pe(w,A.seq)).hash===A.hash)ae(`position ${A.seq} is already on ${n}`),u++;else{b=A.seq;break}y={seq:A.seq,hash:A.hash}}if(m||await Rr(t,y,d,n),y&&!await w.head(ee)){let A=await pe(w,1),Q={layout:1,canonicalizer:"v1",genesis_hash:A.hash};await v(ee,Buffer.from(JSON.stringify(Q)+`
3
3
  `,"utf8"))!=="exists"&&ae(`wrote ${ee} on ${n}`)}if(m){if(y){let M=await w.get(ee),T=await pe(w,1),be={};try{let Z=JSON.parse(Buffer.from(M??[]).toString("utf8"));Z&&typeof Z=="object"&&!Array.isArray(Z)&&(be=Z)}catch{}if(be.layout!==1||be.canonicalizer!=="v1"||be.genesis_hash!==T.hash)throw new R("SYNC_OBJECT_CORRUPT",`${ee} does not describe this context's verified genesis and format.`,"Ask the location owner to inspect the metadata before publishing.")}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer; this batch was not published`,_r(n,b));let A=await m.commit(),Q=new Set(A.created),$=l.filter(M=>Q.has(Ne(M.seq))).length;u+=g-$,g=$,p=new Set(l.flatMap(M=>M.blobs.map(T=>T.key)).filter(M=>Q.has(M))).size,f=new Set(l.flatMap(M=>M.proposal?[M.proposal.key]:[]).filter(M=>Q.has(M))).size}m&&await Rr(t,y,d,n);for(let A of x)r(A);let U="";if(y)try{Yn(e,n,y,{forwardOnly:!0})}catch(A){if(b===null||!(A instanceof O))throw A;U=" (the witness was not saved; the next pull records it)"}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer while this push ran; this store's history through position ${y?.seq??0} is confirmed on ${n}${U}`,_r(n,b))}finally{await m?.abort()}return{pushed:g,from:d?.seq??0,to:y?.seq??0,blobs:p,proposals:f,alreadyThere:u}}function _r(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 Rr(e,t,n,r){if(!t||t.seq<=(n?.seq??0))return;let o=await pe(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 Es(e,t){let{records:n,hashes:r}=Ce(e,t?.seq??0,t?.hash??null);return n.map((o,i)=>{let s=r[i],d=Ir(Ss(e,"commits",`${String(o.seq).padStart(6,"0")}-${s.slice(7,19)}.json`));if(oe(JSON.parse(d.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:d}})}function Os(e,{rec:t,hash:n,raw:r}){{let o=Dn(t),i=o.blobs.map(s=>{let d=ce(e,s);if(d===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(d)!==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:Jn(s),fp:s,bytes:d}});return{seq:t.seq,hash:n,raw:new Uint8Array(r),blobs:i,proposal:Cs(e,o.proposalId)}}}function Cs(e,t){if(t===null)return null;let n=pn(e,t);if(!Is(n))return null;let r=Ir(n);return{key:Wn(t,Mn(r.toString("utf8"))),bytes:r}}import{existsSync as As,readdirSync as Ps,readFileSync as Sr}from"fs";import{basename as Ns,join as Lt}from"path";var qs=/^\d{6}-[0-9a-f]{12}\.json$/;function Bt(e,t){let n=Lt(e,"commits"),r=As(n)?Ps(n).filter(s=>qs.test(s)).sort():[],o=t.hash,i=t.seq;return r.map(s=>{let d;try{d=JSON.parse(Sr(Lt(n,s),"utf8"))}catch(a){throw new O(`backup record ${s} is not JSON: ${String(a)}`)}if(i+=1,d.seq!==i||d.prev_hash!==o)throw new O(`backup record ${s} does not continue the chain at ${i} from ${String(o)}`);let c=oe(d);if(!c.slice(7).startsWith(s.slice(7,19)))throw new O(`backup record ${s} does not match its name`);return o=c,{seq:i,hash:c,body:d}})}function pt(e,t){let n=JSON.parse(Sr(Lt(t,"base-witness.json"),"utf8")),r=$e(e),o=r.records.slice(0,n.base.seq),i=Bt(t,n.base),s=[...o,...i.map(f=>f.body)],d=[...r.hashes.slice(0,n.base.seq),...i.map(f=>f.hash)],c=new Map;for(let f of s)for(let u of f.nodes)c.set(u.cid,{label:u.label,content:u.content});let a=Rn();In(e,a,s,d,{writeNodeFiles:!1});let l=qn(e,a,c),g=new Map(i.map(f=>[f.seq,f])),p=f=>l.displayNameOf(f)??f.slice(0,19);return{backupDir:t,backupId:Ns(t),from:n.from,base:n.base,index:a,graph:l,records:i,chain:s,recordAt:f=>g.get(f),resolveName:f=>l.resolve(f)?.cid,nameOf:f=>l.displayNameOf(f)??void 0,displayNameFor:f=>{let u=Dt(t,f),y=Object.keys(f.source_head_moves),b=u==="revert"?String(js(t,f)??""):u==="names"?(f.names??[]).map(h=>h.slug).join(", "):y.length>0?y.join(", "):f.nodes.length>0?[...new Set(f.nodes.map(h=>p(h.cid)))].join(", "):(f.executions?.length??0)>0?[...new Set(f.executions.map(h=>p(h.about)))].join(", "):f.review.length>0?[...new Set(f.review.map(h=>p(h.id)))].join(", "):f.supersessions.length>0?[...new Set(f.supersessions.map(h=>h.kind==="node"?p(h.old):h.ecid.slice(0,19)))].join(", "):y.join(", ");return b?`${u} ${b}`:u}}}function js(e,t){try{let r=Oe(e,oe(t))?.args?.seq;return typeof r=="number"?r:void 0}catch{return}}function Dt(e,t){let n=null;try{n=Oe(e,oe(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 Er,readdirSync as Ts,readFileSync as Mt}from"fs";import{isAbsolute as xs,join as ut,normalize as Fs,relative as Ls,sep as Bs}from"path";var Ds=e=>e===""||xs(e)||e.includes("\\")||Fs(e).split(Bs).some(t=>t==="..")||e.startsWith("./")||e.includes("\0");function He(e){let t=ut(e,"manifest.json");if(!Er(t))throw new O(`backup ${e} has no manifest.json \u2014 it was never completed; kane-cli context sync doctor`);let n;try{n=JSON.parse(Mt(t,"utf8"))}catch(s){throw new O(`backup manifest ${t} is not JSON: ${s instanceof Error?s.message:String(s)}`)}if(!Array.isArray(n))throw new O(`backup manifest ${t} is not a list`);let r=new Set,o=[];for(let s of n){let d=typeof s?.name=="string"?s.name:"";if(Ds(d))throw new O(`backup manifest names an unsafe path ${JSON.stringify(s?.name)} \u2014 the backup is not trusted`);let c=ut(e,d);if(!Er(c))throw new O(`backup file ${d} is missing from ${e}`);let a=Mt(c);if("sha256:"+rn(a)!==s.hash)throw new O(`backup file ${d} does not match its manifest hash \u2014 the backup was changed after it was written`);if(d.startsWith("commits/"))try{r.add(oe(JSON.parse(a.toString("utf8"))))}catch(l){throw new O(`backup record ${d} is not a record: ${l instanceof Error?l.message:String(l)}`)}d.startsWith("intents/")&&o.push(d)}let i=new Set(n.map(s=>s.name));for(let s of Or(e)){let d=Ls(e,s);if(d!=="manifest.json"&&!i.has(d))throw new O(`backup ${e} holds ${d}, which its manifest does not name \u2014 the backup was changed after it was written`)}for(let s of o){let d;try{d=JSON.parse(Mt(ut(e,s),"utf8"))}catch(a){throw new O(`backup envelope ${s} is not JSON: ${a instanceof Error?a.message:String(a)}`)}let c=un(d);if(c!==null)throw new O(`backup envelope ${s} is not a valid intent: ${c}`);if(typeof d.born?.hash!="string"||!r.has(d.born.hash))throw new O(`backup envelope ${s} was born from a record the backup does not hold`)}}function Or(e){let t=[];for(let n of Ts(e,{withFileTypes:!0})){let r=ut(e,n.name);n.isDirectory()?t.push(...Or(r)):t.push(r)}return t}import{basename as lo,join as po}from"path";import{existsSync as uo,readFileSync as fo}from"fs";var G=class extends Error{},B=(e,t)=>({kind:"apply",inputs:e,...t&&t.length>0?{aliases:t}:{}}),J=e=>({kind:"noop",reason:e}),Ht=e=>({kind:"dedupe",as:e}),k=(e,t,n,r,o={})=>({kind:"hold",hold:{kind:e,mine:t,theirs:n,answers:r,detail:o}}),Cr=(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)},re=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),Gt=(e,t)=>e.graph.superseded.has(e.graph.tipOf(t)),_=(e,t)=>e.fold.nameOf(t)??re(t),S=(e,t)=>e.graph.displayNameOf(t)??re(t);function Vt(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[a,l]of o.heads)if(l===t||l===s)return a;let d=o.getNode(t);if(d?.label==="source"&&typeof d.content.source_id=="string")return d.content.source_id;let c=d?.content.title??d?.content.text??d?.content.statement;return d&&typeof c=="string"&&c!==""?`${d.label} "${z(c,32)}"`:re(t)}var L=e=>e.created_by?.by?.id??e.review[0]?.by.id??e.supersessions[0]?.by.id??e.names?.[0]?.by.id??"someone",P=e=>e.ts;function z(e,t=48){let n=typeof e=="string"?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function he(e,t,n,r){return`${[...new Set([...Object.keys(e),...Object.keys(t)])].filter(s=>s!=="derived"&&JSON.stringify(e[s])!==JSON.stringify(t[s])).map(s=>`${s} "${z(e[s]??"")}" \u2192 "${z(t[s]??"")}"`).join(", ")||"no field changed"} by ${n} at ${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 Jt(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 Ms=new Set(Object.values(Ze).filter(e=>e!==Ze.DERIVES&&e!==Ze.ANNOTATES));function Wt(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))!Ms.has(s.type)||e.graph.superseded.has(s.src)||(!(s.src in e.fold.index.nodeLabel)&&!r.some(d=>d.cid===s.src)&&r.push({cid:s.src,label:e.graph.nodeLabel.get(s.src)??"node"}),o.push(s.src))}}return r}function Ut(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 Ie(e,t){let n=t.event_ids??[],r=n.filter(i=>i in e.index.eventDigests);return n.length===0||r.length===0?void 0:r.every(i=>{let s=n.indexOf(i),d=t.event_digests?.[s];return d!==void 0&&d!==""&&e.index.eventDigests[i]===d})&&r.length===n.length?J("already applied: every event id is in the chain with the same intent"):k("ambiguous",`committed ${n.length} event id${n.length===1?"":"s"}`,`${r.length} of them already in the shared chain under another intent`,["keep-theirs"],{event_ids:n})}function Hs(e){return String(e??"").toLowerCase().trim().replace(/\s+/g," ")}function ft(e,t){let n=t.question;return`${e}\0${Hs(t.title??t.text??t.statement??n?.header??t.source_id??"")}`}function Ar(e,t){let n=[],r=new Set;for(let o of e.nodes){let i=ft(o.label,o.content),s=t.nodes.find(d=>!r.has(d.cid)&&ft(d.label,d.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 Pr(e,t){let n=[],r=new Set;for(let o of t.names??[]){if(!tt.test(o.slug))continue;let i=t.nodes.find(d=>d.cid===o.cid);if(!i||e.graph.nameOf.has(H(e,o.cid)))continue;let s=nt(i.label,d=>r.has(d),e.graph.names.keys());s!==null&&(r.add(s),s!==o.slug&&n.push({from:o.slug,to:s}))}return n}function Nr(e,t,n){let r=[];for(let o of e.names??[]){let i=n.find(([d])=>d===o.cid)?.[1],s=t.names?.find(d=>d.cid===i);s&&s.slug!==o.slug&&r.push({from:o.slug,to:s.slug})}return r}function qr(e,t,n){let r=e===void 0?void 0:e.split(`
4
4
  `).map(s=>{let d=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(s);if(d)return`${d[1]} @verifies ${d[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 a=/^## Import: (\S+)\s*$/.exec(s);return a?`## Import: ${n(a[1])}`:s}).join(`
5
5
  `),o=!1,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 h}from"./chunk-CSVPZ33X.js";import{y as l}from"./chunk-CXF6AZWY.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
2
+ import{a as h}from"./chunk-ZC2CKWLB.js";import{y as l}from"./chunk-5TQFOPJV.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-CXF6AZWY.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-AX6ZAKLH.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 W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-5TQFOPJV.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-ZOALDS6H.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,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as t}from"./chunk-CXF6AZWY.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-5TQFOPJV.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};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as ne,b as te,c as re,d as ie,e as z}from"./chunk-K3IQEL7R.js";import{b as se,c as oe}from"./chunk-GCISXCDU.js";import{n as ee,p as j}from"./chunk-RSSOJ3L2.js";import{a as $e}from"./chunk-6YGTRKDT.js";import{e as Te}from"./chunk-UR6MHSHU.js";function Oe(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Le={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",De=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ae(r){return!r||!De.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
+ `)}function ue(r){return{command:"start",...r}}function de(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function le(r){return{command:"cancel",...r?{run_id:r}:{}}}function ce(r){return{command:"ask_user_response",answer:r}}function pe(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),J=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??te,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(ue(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new J,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(de(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(ce(e))}cancel(e){this.writeCommand(le(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(pe(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
4
+ `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let d of this.proc.events){if(d.type==="ready"){this.onReady();continue}if(d.type==="error"&&this.pendingReady){this.onStartError(d.message);continue}try{this.onEvent?.(d)}catch{}this.routeEvent(d)}}catch(d){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:d instanceof Error?d.message:String(d)})}let{code:e,signal:s}=await this.proc.exited;this.onExit(e,s)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}onStartError(e){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null;let d=ae(e);if(d){this.log?.("error","REAL_DEVICE_PLAN_REQUIRED","The mobile hub refused the session over the plan",{reason:e}),s(new L(d));return}s(new Error(`failed to start: ${e??"unknown error"}`))}routeEvent(e){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}s.queue.push(e)}onExit(e,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:s}),this.pendingReady){let{reject:d}=this.pendingReady;this.pendingReady=null,d(new Error(`v16-runner exited before ready (code=${e}, signal=${s??"none"})`))}if(this.activeRun){let{queue:d}=this.activeRun;if(this.activeRun=null,this.shuttingDown)d.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";d.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${s??"none"})${g?`
5
+ ${g}`:""}`))}}}}};var p=Te($e(),1);function he(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function N(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function T(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=T(_.children??[],v,s);g[d]={..._,children:E}}return g}var Ue=6e4;function fe(){return{steps:[],maxOrdinal:0}}function Me(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=oe(r.runnerEnvironment,se(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function H(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function nn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[me,$]=(0,p.useState)(null),[ve,B]=(0,p.useState)(null),[ge,C]=(0,p.useState)(null),[Re,X]=(0,p.useState)(null),[Se,Y]=(0,p.useState)([]),[ye,Z]=(0,p.useState)(null),[we,xe]=(0,p.useState)(void 0),[_e,A]=(0,p.useState)(0),x=(0,p.useRef)(null),D=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(fe()),M=(0,p.useRef)(null),Ee=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),$(null),B(null),C(null),X(null),Y([]),Z(null),xe(f.max_steps),v(!0),w.current=null,b.current=0,U.current=fe();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,A(n=>n+1),y=null}if(!y){let n=ne();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=ie({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await re(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=he(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,A(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let je=`run-${f.run_index}`,Ne=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(je,Ne,q)){if(V.current)break;switch(U.current=Me(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=N(t,c=>c.branchChildId===o)??N(t,c=>c.status==="running");return i?T(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?H(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?H(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?H(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=N(o,t=>t.status==="running");return a?T(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=N(o,t=>t.branchChildId===l);return a?T(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":$(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
6
+ `).includes(o)&&u.push(o),C(u.join(`
7
+ `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),j("runner","Runner died mid-run"),x.current=null,k.current=null,A(a=>a+1)});M.current=K,K.finally(()=>{M.current===K&&(M.current=null)})},[r,e,s,d,g]),be=(0,p.useCallback)(f=>{x.current?.sendUserResponse(f),$(null)},[]),ke=(0,p.useCallback)(()=>{let f=x.current;f&&(f.cancel(),v(!1),$(null))},[]),Ie=(0,p.useCallback)((f,S)=>{if(D.current)return D.current;let I=x.current;if(!I)return Promise.resolve();let y=Ce(I,f,S?.timeoutMs).finally(()=>{D.current=null});return D.current=y,y},[]),Ce=async(f,S,I)=>{try{await Promise.race([f.shutdown(S??{}),new Promise(y=>setTimeout(y,I??(S?Ue:5e3)))])}catch{}j("runner","Runner shut down"),x.current=null,k.current=null,A(y=>y+1)},Pe=(0,p.useCallback)(()=>{h([]),B(null),C(null)},[]);return(0,p.useEffect)(()=>()=>{V.current=!0,j("runner","Component unmounted"),x.current=null,k.current=null},[]),{isRunning:_,steps:E,askingUser:me,lastRunEnd:ve,runError:ge,bifurcationInfo:Re,cmInitCounts:Se,replayInfo:ye,maxSteps:we,sessionGen:_e,startRun:Ee,sendAnswer:be,cancelRun:ke,shutdownRunner:Ie,clearLastRun:Pe,getEvidenceState:()=>U.current}}export{Oe as a,Le as b,F as c,he as d,fe as e,Me as f,nn as g};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-TDPWFYTJ.js";import{a as y}from"./chunk-JQ64X2TO.js";import{c as b}from"./chunk-VZ7KXRXB.js";import{a as S}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-CXF6AZWY.js";import{randomUUID as V}from"crypto";import{mkdirSync as W,writeFileSync as _,appendFileSync as K,existsSync as f,readFileSync as B}from"fs";import{join as u}from"path";import{writeFileSync as j,mkdirSync as L,existsSync as D}from"fs";import{join as g,relative as $}from"path";function I(s){let t=Object.keys(s.frontmatter).length>0?b(s.frontmatter).trimEnd():"",r=["---"];return t&&r.push(t),r.push("---",""),r.push(`# ${s.heading}`,""),s.steps.forEach((o,n)=>{r.push(`## Step ${n+1}`,o,"")}),r.join(`
2
+ import{a as y}from"./chunk-JQ64X2TO.js";import{a as R}from"./chunk-TDPWFYTJ.js";import{c as b}from"./chunk-VZ7KXRXB.js";import{a as S}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-5TQFOPJV.js";import{randomUUID as V}from"crypto";import{mkdirSync as W,writeFileSync as _,appendFileSync as K,existsSync as f,readFileSync as B}from"fs";import{join as u}from"path";import{writeFileSync as j,mkdirSync as L,existsSync as D}from"fs";import{join as g,relative as $}from"path";function I(s){let t=Object.keys(s.frontmatter).length>0?b(s.frontmatter).trimEnd():"",r=["---"];return t&&r.push(t),r.push("---",""),r.push(`# ${s.heading}`,""),s.steps.forEach((o,n)=>{r.push(`## Step ${n+1}`,o,"")}),r.join(`
3
3
  `)}function A(s,e){let t=e.syntax?.trim()??"";return t.startsWith("${")&&t.endsWith("}")?t:"${"+s+"}"}function C(s,e,t){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return s.replace(new RegExp(`\\{\\{\\s*${r}(?=\\s*\\}\\}|[.\\[])`,"g"),`{{${t}.${e}`)}function q(s,e){let t={},r={},o=e;for(let[n,i]of Object.entries(s)){if(y(i)){t[n]={value:i.value,secret:!!i.secret,syntax:A(n,i),type:"parameter"},r[n]=n;continue}if(n.startsWith("global.")||n.startsWith("secrets.user.")||n.startsWith("environment.")){let a=n.startsWith("secrets.user.");t[n]={value:i.value,secret:a,syntax:`{{${n}}}`,type:a?"secret":n.startsWith("environment.")?"environment":"global"},r[n]=n;continue}if(i.secret){let a=`secrets.user.${n}`;t[a]={value:i.value,secret:!0,syntax:`{{secrets.user.${n}}}`,type:"secret"},r[n]=a,o=C(o,n,"secrets.user")}else{let a=`global.${n}`;t[a]={value:i.value,secret:!1,syntax:`{{global.${n}}}`,type:"global"},r[n]=a,o=C(o,n,"global")}}return{variables:t,objective:o,keyMap:r}}var T=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function m(s){return typeof s!="string"||!s.includes("{{")?s:s.replace(T,"{{$1}}")}function d(s){if(typeof s=="string")return m(s);if(Array.isArray(s))return s.map(e=>d(e));if(s&&typeof s=="object"){let e={};for(let[t,r]of Object.entries(s))e[t]=d(r);return e}return s}var k=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),F=new Set(["model","env"]),c=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=g(this.opts.cwd,".testmuai","tests");try{L(t,{recursive:!0})}catch(l){process.stderr.write(`
4
4
  \u26A0 Failed to create ${$(this.opts.cwd,t)}/
5
5
  ${l.message}
@@ -0,0 +1,38 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{e as H}from"./chunk-AKE2CTV6.js";import{b as G,c as W,f as K,g as B}from"./chunk-OIUV3ISA.js";import{b as $,e as O}from"./chunk-SOCHN2PY.js";import{f as L,h as M,l as U}from"./chunk-BL3SJDCG.js";import{l as A}from"./chunk-RSSOJ3L2.js";import{b as _}from"./chunk-XT7XA4DN.js";import{a as C}from"./chunk-NMSZ7G6P.js";import{a as N}from"./chunk-RZ4F3BHX.js";import{h as T}from"./chunk-NOL7MNZH.js";import{k as S,l as x}from"./chunk-5TQFOPJV.js";import{mkdirSync as ae,writeFileSync as ce}from"fs";import{join as le}from"path";function V(e,r=process.env){return r.KANE_MOBILE_APP_BASE_URL||C(e).mobileAppBaseUrl}var de="device-config.json",F=new WeakMap;function me(e,r){let t=F.get(e)??new Map;F.set(e,t);let o=JSON.stringify([r.path,r.type,r.env,r.orgId]),n=t.get(o);if(n)return n;let i=e(r).finally(()=>t.delete(o));return t.set(o,i),i}function j(e){return e.startsWith("lt://")?e:`lt://${e}`}async function pe(e,r){let t=await U(e.env,e.platform,{...e.selection.deviceName?{deviceName:e.selection.deviceName.value}:{},...e.selection.osVersion?{osVersion:e.selection.osVersion.value}:{}},r);if(t.kind==="unchecked"&&e.onWarning?.(`${t.reason} \u2014 the run continues, but the device and OS version are not checked before the session is requested.`),t.kind==="refused")throw new Error(t.detail)}async function ue(e,r){let t=e.selection.app.value.trim();if(_(t))return j(t);let o=e.credentials;if(!o?.orgId)throw new Error(`${t} 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 me(r,{path:t,type:e.platform,env:e.env,orgId:o.orgId,userId:o.userId??"",auth:{username:o.username,accessKey:o.accessKey,orgId:o.orgId},baseUrl:V(e.env),...e.onProgress?{onProgress:e.onProgress}:{}});if($(n))throw new Error(`could not upload ${t} for this real-device run: ${n.reason}`);return j(n.appUrl??n.appId)}async function q(e,r={}){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 pe(e,r.fetchCatalog??M);let t=await ue(e,r.upload??O),{deviceName:o,osVersion:n}=e.selection,i={platform_name:e.platform,device_name:o?.value??L,...n?{platform_version:n.value}:{},app:t,...e.testName?{test_name:e.testName}:{},...e.tcId?{"tms.tc_id":e.tcId}:{},...e.capabilities},c=le(e.outDir,de);return ae(e.outDir,{recursive:!0}),ce(c,`${JSON.stringify(i,null,2)}
3
+ `),{device:{platform:e.platform,target:e.platform,device_config_path:c},...o?{deviceName:o.value}:{},...n?{osVersion:n.value}:{},app:t}}import{createServer as Ee}from"http";import{randomBytes as Se}from"crypto";import{spawn as xe}from"child_process";import{mkdtempSync as Ae,readdirSync as Ie,readFileSync as Pe,rmSync as ke,writeFileSync as Te}from"fs";import{tmpdir as Z}from"os";import{join as E}from"path";import{spawn as X,spawnSync as fe}from"child_process";import{existsSync as I}from"fs";import{createConnection as ge}from"net";import{homedir as h,platform as y}from"os";import{join as v}from"path";var he=new Set(["1","true","yes"]),D=class extends Error{constructor(r){super(r),this.name="ChromeNotFoundError"}};function or(e){return e instanceof D?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var R={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",v(h(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",v(h(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",v(h(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",v(h(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",v(h(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe"),v(h(),"AppData\\Local\\kane-chrome\\chrome.exe")]};function Y(){let e=process.env.KANE_CLI_CHROME_PATH?.trim();return e||void 0}function P(){let e=Y();if(e)return e;let r=y(),t=R[r]??R.linux;for(let o of t)if(I(o))return o;return r==="win32"?"chrome.exe":"google-chrome"}function k(){let e=Y();if(e)return I(e);let r=y();if((R[r]??R.linux).some(i=>I(i)))return!0;let o=r==="win32"?"chrome.exe":"google-chrome",n=r==="win32"?"where":"which";try{return fe(n,[o],{stdio:"ignore"}).status===0}catch{return!1}}function ve(){let e=y();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
4
+ `):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
5
+ `):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
6
+ `):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
7
+ `)}function we(e){let r=y(),t=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return r==="linux"&&(t.push("--no-sandbox"),t.push("--disable-dev-shm-usage"),t.push("--password-store=basic")),r==="darwin"&&t.push("--use-mock-keychain"),e.headless&&t.push("--headless=new"),t}function be(e){return new Promise(r=>{let t=ge({port:e,host:"127.0.0.1"});t.setTimeout(1e3),t.on("connect",()=>{t.destroy(),r(!0)}),t.on("timeout",()=>{t.destroy(),r(!1)}),t.on("error",()=>{t.destroy(),r(!1)})})}async function ye(){for(let e=S;e<=x;e++)if(!await be(e))return e;throw new Error(`All CDP ports ${S}-${x} are in use. Close other Chrome instances.`)}var b=class extends Error{constructor(r){super(r),this.name="CdpReadinessError"}};async function Ce(e,r){let t=Date.now(),o=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-t<r;){try{if((await N(o)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(n=>setTimeout(n,200))}throw new b(`Chrome CDP not ready after ${r}ms on port ${e}`)}var _e=3e4,De=2;function z(e,r,t){let o=process.env[e];if(o==null||o.trim()==="")return r;let n=Number(o);return!Number.isInteger(n)||n<t?r:n}function Re(e){return Math.min(500*e,3e3)}function J(e,r){try{if(e.pid)if(r==="win32")X("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function nr(e){let r=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(r!=null&&he.has(r.toLowerCase()))&&!k())throw A()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new D(ve());let o=y(),n=P(),i=z("KANE_CLI_CDP_TIMEOUT_MS",_e,1),s=z("KANE_CLI_CDP_RETRIES",De,0)+1,g;for(let m=1;m<=s;m++){let f=await ye(),a=we({port:f,...e});e.startUrl&&a.push(e.startUrl);let l=X(n,a,{stdio:"ignore",detached:!0});l.unref();try{let d=await new Promise((p,u)=>{l.on("error",w=>{u(new Error(`Failed to launch Chrome: ${w.message}. Is Chrome installed at ${n}?`))}),l.on("close",w=>{w!==null&&w!==0&&u(new b(`Chrome exited during startup with code ${w}`))}),Ce(f,i).then(p,u)});return{process:l,port:f,cdpEndpoint:d,kill(){J(l,o)}}}catch(d){if(g=d,!(d instanceof b))throw d;J(l,o),A()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${m}/${s} failed`,{attempt:m,max_attempts:s,port:f,timeout_ms:i,headless:e.headless??!1,error:d.message}),m<s&&await new Promise(p=>setTimeout(p,Re(m)))}}throw g??new Error("Chrome launch failed after retries")}function ee(e,r,t,o){let n=Buffer.from(`${o.username}:${o.accessKey}`).toString("base64"),i=new URLSearchParams({session:t,auth:n});return r==="ios"&&i.set("mode","webrtc"),`${e.replace(/\/+$/,"")}/?${i.toString()}`}function Q(e){return e.replace(/[&<>"']/g,r=>`&#${r.charCodeAt(0)};`)}function Ne(e){return`<!doctype html>
8
+ <html lang="en">
9
+ <head>
10
+ <meta charset="utf-8">
11
+ <meta name="viewport" content="width=device-width, initial-scale=1">
12
+ <title>${Q(e.title)}</title>
13
+ <style>
14
+ html, body { margin: 0; height: 100%; background: #111; font-family: system-ui, sans-serif; }
15
+ iframe { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; }
16
+ #guard { position: fixed; inset: 0; cursor: not-allowed; background: transparent; }
17
+ #badge, #ended { position: fixed; left: 50%; transform: translateX(-50%); padding: 6px 12px;
18
+ border-radius: 999px; font-size: 13px; color: #fff; background: rgba(0, 0, 0, 0.7); }
19
+ #badge { bottom: 16px; }
20
+ #ended { top: 16px; display: none; background: #b42318; }
21
+ </style>
22
+ </head>
23
+ <body>
24
+ <iframe src="${Q(e.streamUrl)}" allow="autoplay; fullscreen"></iframe>
25
+ ${e.viewOnly?'<div id="guard"></div>':""}
26
+ <div id="badge">View only \u2014 the test is driving this device</div>
27
+ <div id="ended">The session ended</div>
28
+ <script>
29
+ // kane-cli answers while the run lives; once it stops, say so.
30
+ setInterval(() => {
31
+ fetch(location.pathname + "/alive", { cache: "no-store" })
32
+ .then((r) => { if (!r.ok) throw new Error(); })
33
+ .catch(() => { document.getElementById("ended").style.display = "block"; });
34
+ }, 3000);
35
+ </script>
36
+ </body>
37
+ </html>
38
+ `}async function re(e){let r=`/${Se(16).toString("hex")}`,t=Ne(e),o=Ee((c,s)=>{if(c.url===r){s.writeHead(200,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),s.end(t);return}if(c.url===`${r}/alive`){s.writeHead(204),s.end();return}s.writeHead(404),s.end()});await new Promise((c,s)=>{o.once("error",s),o.listen(0,"127.0.0.1",()=>c())}),o.unref();let n=o.address();return{url:`http://127.0.0.1:${typeof n=="object"&&n?n.port:0}${r}`,close:()=>o.close()}}function te(e){let t=e?.width,o=e?.height;return!t||!o?{width:400,height:820}:{width:Math.min(1200,Math.max(320,Math.round(820*t/o))),height:820}}function $e(e,r,t){return[`--app=${e}`,`--user-data-dir=${r}`,`--window-size=${t.width},${t.height}`,"--no-first-run","--no-default-browser-check","--autoplay-policy=no-user-gesture-required"]}var Oe=3e3;async function oe(e,r,t=Oe){if(!k())throw new Error("Google Chrome is not installed (or set KANE_CLI_CHROME_PATH).");Me();let o=Ae(E(Z(),ne));Te(E(o,ie),String(process.pid));let n=xe(P(),$e(e,o,r),{stdio:"ignore",detached:process.platform!=="win32"});n.unref();let i=()=>se(o);await new Promise((m,f)=>{let a=setTimeout(()=>{n.off("error",l),n.off("exit",d),m()},t);a.unref();function l(p){clearTimeout(a),i(),f(new Error(`Chrome did not start: ${p.message}`))}function d(p,u){clearTimeout(a),i(),f(new Error(`Chrome quit as it opened (${u??`exit code ${p}`}).`))}n.once("error",l),n.once("exit",d)}),n.on("error",()=>{}),n.once("exit",i);let c=()=>g();process.once("exit",c);let s=!1;function g(){if(!s){s=!0,process.off("exit",c);try{n.pid&&process.platform!=="win32"?process.kill(-n.pid):n.kill()}catch{}i()}}return g}var ne="kane-device-view-",ie="kane-cli.pid";function se(e){try{ke(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch{}}function Le(e){try{return process.kill(e,0),!0}catch(r){return r.code==="EPERM"}}function Me(e=Z()){let r;try{r=Ie(e).filter(t=>t.startsWith(ne))}catch{return}for(let t of r){let o=E(e,t),n=NaN;try{n=Number(Pe(E(o,ie),"utf8"))}catch{}Number.isInteger(n)&&n>0&&Le(n)||se(o)}}function Cr(e){return e.flag===!1||e.mobile?.device_stream===!1?"off":e.interactive?"open":"off"}function Ue(e){let r=e.basicAuth;if(!r)return;let t=e.resolvedCreds;return{username:r.username,accessKey:r.access_key,...t?.org_id?{orgId:String(t.org_id)}:{},...t?.user_id?{userId:String(t.user_id)}:{}}}async function _r(e){let r=Ue(e.auth),t=e.selection?await q({platform:e.target,selection:e.selection,env:e.env,outDir:e.sessionDir,...r?{credentials:r}:{},testName:e.testName,...e.tcId?{tcId:e.tcId}:{},capabilities:H(e.mobile,e.target),onProgress:e.write,onWarning:a=>e.write(`warning: ${a}`)}):G({platform:e.target,hasCredentials:!!r});e.write(W(e.target));let o=t.app?.replace(/^lt:\/\//,""),n=B(e.target,t.app,e.write),i,c,s=!1,g=!1,m=()=>{g=!0,c?.(),i?.close()},f=a=>{let l=a.type==="run_start"&&!a.child_id?a.environment?.device:void 0,d=l?.session_id;if(s||!d||!r||(e.stream??"off")==="off")return;s=!0;let p=K(l);re({streamUrl:ee(C(e.env).deviceStreamUrl,T(e.target),d,r),title:p?`${p} \u2014 live`:"Real device \u2014 live",viewOnly:e.target==="android"}).then(async u=>{i=u,c=await(e.openWindow??oe)(u.url,te(l)),g?m():e.write("Showing the device in its own window.")}).catch(u=>{i?.close(),e.write(`note: no live view of the device \u2014 ${u.message}`)})};return{device:t.device,...t.deviceName?{deviceName:t.deviceName}:{},...t.osVersion?{osVersion:t.osVersion}:{},...t.app?{app:t.app}:{},..._(o)?{appId:o}:{},announce:a=>{n(a),f(a)},stopStream:m}}var He="infra_error.device_lost";function Dr(e){return e?.reason_code===He}export{V as a,D as b,or as c,nr as d,Cr as e,Ue as f,_r as g,Dr as h};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{j as n}from"./chunk-NOL7MNZH.js";var o={command:"set-auto-grant-permissions",capability:"auto_grant_permissions",label:"Auto Grant Permissions",onHint:"grant Android runtime permissions at session start (default)",offHint:"leave permission dialogs on screen"},r={command:"set-auto-accept-alerts",capability:"auto_accept_alerts",label:"Auto Accept Alerts",onHint:"accept iOS alerts, incl. permission prompts (default)",offHint:"leave alerts on screen"},s=[{target:"emulator",key:"auto_grant_permissions",...o},{target:"simulator",key:"auto_accept_alerts",...r},{target:"android",key:"android_auto_grant_permissions",...o},{target:"ios",key:"ios_auto_accept_alerts",...r}],g=s.map(e=>e.key);function i(e){return s.find(t=>t.target===e)}function c(e,t){return e?.[i(t).key]!==!1}function u(e,t){return{[i(t).capability]:c(e,t)}}function l(e){return e.label.charAt(0)+e.label.slice(1).toLowerCase()}function d(e){return`${l(e)} (${n(e.target)})`}function m(e,t){let a=c(e,t);return i(t).capability==="auto_grant_permissions"?{autoGrantPermissions:a}:{autoAcceptAlerts:a}}export{s as a,g as b,i as c,c as d,u as e,l as f,d as g,m as h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as d,g as B,k as ee}from"./chunk-YLQHY4A7.js";import{P as Z}from"./chunk-RDHWNSDP.js";import{b as A}from"./chunk-CXF6AZWY.js";import{createHash as Ie,randomBytes as F}from"crypto";import{mkdirSync as xe,mkdtempSync as P,rmSync as $,existsSync as ve,renameSync as ke}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as ce}from"path";import{spawn as te}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function be(n,e){if(n.GIT_SSH_COMMAND)return re(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?re(e):"ssh -o BatchMode=yes"}function re(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var _e=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,ie=new Map;function Ae(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=ie.get(t);return r===void 0&&(r=se(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),ie.set(t,r)),r}var ne=new Set(["fetch","push","clone","ls-remote"]);function Ce(n,e,t){if(t!==void 0)return t;if(!n.some(i=>ne.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ne(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ne(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>ne.has(h))&&n.some(h=>_e.test(h))?await Ae({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=be(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",se(n,t,e.cwd,Ce(n,t,e.timeout),e.input)};function se(n,e,t,r,i){return new Promise((s,o)=>{let a=te("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)te("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function oe(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function ae(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function gt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=ae(e),s=N(n).trim().split(`
2
+ import{a as d,g as B,k as ee}from"./chunk-YLQHY4A7.js";import{P as Z}from"./chunk-RDHWNSDP.js";import{b as A}from"./chunk-5TQFOPJV.js";import{createHash as Ie,randomBytes as F}from"crypto";import{mkdirSync as xe,mkdtempSync as P,rmSync as $,existsSync as ve,renameSync as ke}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as ce}from"path";import{spawn as te}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function be(n,e){if(n.GIT_SSH_COMMAND)return re(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?re(e):"ssh -o BatchMode=yes"}function re(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var _e=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,ie=new Map;function Ae(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=ie.get(t);return r===void 0&&(r=se(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),ie.set(t,r)),r}var ne=new Set(["fetch","push","clone","ls-remote"]);function Ce(n,e,t){if(t!==void 0)return t;if(!n.some(i=>ne.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ne(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ne(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>ne.has(h))&&n.some(h=>_e.test(h))?await Ae({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=be(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",se(n,t,e.cwd,Ce(n,t,e.timeout),e.input)};function se(n,e,t,r,i){return new Promise((s,o)=>{let a=te("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)te("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function oe(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function ae(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function gt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=ae(e),s=N(n).trim().split(`
3
3
  `).slice(-2).join(" ").trim();return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`this computer has not accepted ${t}'s SSH host key yet`,remedy:`in a terminal run: ssh -T ${i?`-p ${i} `:""}${r}@${t} and answer yes, then run the command again`,diagnostic:s}:/Permission denied \(publickey/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`${t} did not accept your SSH key`,remedy:"load it with ssh-add, or ask the repository owner to grant your account access",diagnostic:s}:/could not read Username|Authentication failed|Access denied|Invalid username or (password|token)|returned error: 401|returned error: 403/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`sign in is needed, or your account has no access to this repository on ${t}`,remedy:"sign in through Git, or ask the owner to grant your account access",diagnostic:s}:/Could not resolve host|Connection refused|Connection timed out|timed out|Network is unreachable|Failed to connect/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:`${t} could not be reached`,remedy:"check the address and your network, then run the command again",diagnostic:s}:/not found|does not appear to be a git repository|Repository not found/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:"no repository answered at that address, or your account cannot see it; a private repository looks missing until access is granted",remedy:"check the address, then run the command again",diagnostic:s}:{code:"SYNC_LOCATION_UNREACHABLE",message:`git could not read the repository on ${t}`,remedy:"check the address and your access, then run the command again",...s?{diagnostic:s}:{}}}function M(n,e){return(n.startsWith(e)?n:n.charAt(0).toUpperCase()+n.slice(1))+"."}function yt(n,e){let t=Y(n,e),{host:r}=ae(e),i=t.remedy.replace(/,? ?(and )?then run the command again$/,"");return i?`${M(t.message,r)} ${M(i,r)}`:M(t.message,r)}var Oe=Buffer.from(`* -text -filter -ident -working-tree-encoding
4
4
  `),Re="refs/kane/tip",Pe=/unexpected disconnect|hung up unexpectedly|Connection reset|Connection timed out|timed out|Could not resolve host|Failed to connect|RPC failed|Broken pipe|early EOF/i,$e={GIT_AUTHOR_NAME:"kane-cli context",GIT_AUTHOR_EMAIL:"context@kane-cli.invalid",GIT_COMMITTER_NAME:"kane-cli context",GIT_COMMITTER_EMAIL:"context@kane-cli.invalid"},G=class n{constructor(e){this.options=e;this.exec=e.exec??H,this.prefix=e.prefix?`${e.prefix}/`:"";let t=Ie("sha256").update(JSON.stringify([e.url,e.branch,this.prefix])).digest("hex");if(this.repo=_(e.cacheDir??_(A,"context-sync","mirrors"),`${t}.git`),this.ref=e.ref??`refs/heads/${e.branch}`,!/^refs\/(heads|kane\/probe)\/[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(this.ref)||this.ref.includes(".."))throw new Error("Invalid Git location ref")}kind="git";contractVersion=1;ceilingTier=1;exec;repo;ref;prefix;ready;tip=null;tree=new Map;async run(e,t={}){let r=await this.exec(["--git-dir",this.repo,...e],t);if(r.code)throw new Error(`Git ${e[0]} failed: ${r.stderr||"unable to read the location"}`);return r.stdout}async transfer(e){let t=await this.exec(["--git-dir",this.repo,...e]);if(t.code){let r=Y(t.stderr||"",this.options.url);throw new d(r.code,r.message,r.remedy,r.diagnostic)}return t.stdout}get name(){return this.options.name??"<name>"}takenRemedy(e){return e===1?`${this.name} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${this.name}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${this.name} --rebase`}init(){return this.ready??=(async()=>{if(await oe(this.exec),xe(ce(this.repo),{recursive:!0}),!ve(this.repo)){let e=P(_(ce(this.repo),".init-"));try{let t=await this.exec(["init","--bare",e]);if(t.code)throw new Error(`Cannot open Git cache: ${t.stderr}`);try{ke(e,this.repo)}catch(r){if(!["EEXIST","ENOTEMPTY"].includes(r.code??""))throw r}}finally{$(e,{recursive:!0,force:!0})}}if((await this.run(["rev-parse","--is-bare-repository"])).toString().trim()!=="true")throw new Error("The Git cache must be a bare repository");await this.refresh()})()}async refresh(){let t=(await this.transfer(["ls-remote",this.options.url,this.ref])).toString().trim();if(!t){this.tip=null,this.tree=new Map;return}let r=t.split(/\s+/)[0];if(!/^[0-9a-f]{40,64}$/.test(r))throw new Error("Git returned an invalid ref");if(r===this.tip)return;let i=`refs/kane/snapshots/${F(16).toString("hex")}`;await this.transfer(["fetch","--no-tags","--no-write-fetch-head",this.options.url,`${this.ref}:${i}`]);let s=(await this.run(["rev-parse",i])).toString().trim();await this.run(["update-ref",Re,s]),await this.run(["update-ref","-d",i]);let o=await this.readTree(s);this.tip=s,this.tree=o}contextKeys(e){let t=new Map;for(let[r,i]of e)r.startsWith(`${this.prefix}kane-context/`)&&t.set(r,i);return t}async readTree(e){let t=await this.run(["ls-tree","-rz","--full-tree",e]),r=new Map;for(let i of t.toString().split("\0").filter(Boolean)){let s=/^(\d+) (\w+) ([0-9a-f]+)\t([\s\S]+)$/.exec(i);if(!s)throw new Error("Git returned an invalid tree entry");if(s[4].startsWith(`${this.prefix}kane-context/`)&&(s[1]!=="100644"||s[2]!=="blob"))throw new d("SYNC_OBJECT_CORRUPT","Context storage contains a link or non-file object.","Ask the repository owner to restore the original context files.");r.set(s[4],s[3])}return r}key(e){if(!/^[a-zA-Z0-9_~./-]+$/.test(e)||e.split("/").some(t=>!t||t==="."||t===".."||t.toLowerCase()===".git"))throw new Error("Invalid context storage key");return this.prefix+e}async head(e){return await this.init(),this.tree.has(this.key(e))}async get(e){await this.init();let t=this.tree.get(this.key(e));return t?this.run(["cat-file","blob",t]):null}async list(e){return await this.init(),e&&e.replace(/\/$/,"")&&this.key(e.replace(/\/$/,"")),[...this.tree.keys()].filter(t=>t.startsWith(this.prefix+e)).map(t=>t.slice(this.prefix.length)).sort()}async beginTransaction(){await this.init();let e=new Map(this.tree),t=this.tip,r=new Map,i=!1,s=()=>{if(i)throw new Error("Git transaction is closed")},o=async a=>{s();let c=this.key(a),h=r.get(c),u=e.get(c);return h?Buffer.from(h):u?this.run(["cat-file","blob",u]):null};return{get:o,head:async a=>await o(a)!==null,stageIfAbsent:async(a,c)=>{s();let h=this.key(a);if(e.has(h)||r.has(h))return"exists";if(c.length>1e8)throw new d("SYNC_LOCATION_REFUSED_WRITE","A context object is too large for this Git location.","Use an S3 location for this context.");return r.set(h,Buffer.from(c)),"staged"},abort:async()=>{i=!0,r.clear()},commit:async()=>{s();try{if(!r.size)return{created:[]};let a=this.prefix+"kane-context/.gitattributes";e.has(a)||r.set(a,Oe);let c=new Map;for(let[l,m]of r)c.set(l,(await this.run(["hash-object","-w","--no-filters","--stdin"],{input:m})).toString().trim());let h=this.contextKeys(e),u=()=>{this.assertUnchanged(h);for(let[l,m]of this.contextKeys(this.tree))h.set(l,m)},g=!1,w="",S=0;for(let l=0;l<4;l++){u();for(let f of this.tree.keys())if(!(!f.startsWith(this.prefix)||e.has(f)||c.has(f))&&B(f.slice(this.prefix.length))!==null)throw new d("SYNC_BEHIND","the location gained records after this batch was prepared; nothing was published","run kane-cli context pull, then push again");let m=new Map;for(let[f,T]of c){let C=this.tree.get(f);if(C&&C!==T){let R=B(f.slice(this.prefix.length));throw R?new d("SYNC_POSITION_TAKEN",g?`position ${R} on ${this.name} now holds different work; an earlier publication could not be confirmed`:`position ${R} on ${this.name} was published by another writer; this batch was not published`,this.takenRemedy(R)):new d("SYNC_OBJECT_CORRUPT",`existing context object ${f} differs from the intended bytes`,"the object needs a person to look; nothing was published")}C||m.set(f,T)}if(!m.size)return await this.verifyPublication(c),{created:[]};t=this.tip;let I=await this.build(t,m);await this.checkAttributes(I,[...r.keys()]),S++;let E=await this.exec(["--git-dir",this.repo,"push","--porcelain",this.options.url,`${I}:${this.ref}`]),y=N(E.stdout.toString()+`
5
5
  `+E.stderr);w=y.trim();let O=E.code!==0&&/\[rejected\]|\[remote rejected\]/.test(y),p=E.code!==0&&(E.code===124||Pe.test(y));g||=p;try{await this.refresh()}catch{throw new d("SYNC_PUBLICATION_UNKNOWN","we could not confirm whether your context was uploaded; your local work is safe","check the connection and retry; kane-cli compares the published data before writing again")}if(u(),[...c].every(([f,T])=>this.tree.get(f)===T)){await this.verifyPublication(c);let f=E.code===0&&!E.stdout.toString().split(`
@@ -0,0 +1,10 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as h}from"./chunk-NMSZ7G6P.js";import{a as p}from"./chunk-RZ4F3BHX.js";function f(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=new Array(t.length+1),o=new Array(t.length+1);for(let r=0;r<=t.length;r++)n[r]=r;for(let r=1;r<=e.length;r++){o[0]=r;for(let i=1;i<=t.length;i++){let s=e[r-1]===t[i-1]?0:1;o[i]=Math.min(n[i]+1,o[i-1]+1,n[i-1]+s)}[n,o]=[o,n]}return n[t.length]}function C(e){let t=e.indexOf(".");return t>=0?e.slice(0,t):e}function l(e){return e.toLowerCase().replace(/\+/g,"plus").replace(/[^a-z0-9]/g,"")}function u(e){return e==="ios"?{os:"iOS",device:"simulator",target:"simulator"}:{os:"Android",device:"emulator",target:"emulator"}}var x=.4,y=3;function _(e,t,n){let o=l(t);if(o==="")return[];let r=Math.max(1,Math.round(o.length*x)),i=[];for(let s of e.devices){if(n&&!s.osVersions.includes(n))continue;let a=Math.min(f(o,l(s.name)),s.configName?f(o,l(s.configName)):1/0);a<=r&&i.push({device:s,score:a})}return i.sort((s,a)=>s.score-a.score||s.device.name.localeCompare(a.device.name)),i.slice(0,y).map(s=>s.device)}function w(e,t){let n=Number.parseFloat(t);if(!Number.isFinite(n))return e.osVersions[e.osVersions.length-1];let o,r=1/0;for(let i of e.osVersions){let s=Math.abs(Number.parseFloat(i)-n);Number.isFinite(s)&&s<r&&(r=s,o=i)}return o??e.osVersions[e.osVersions.length-1]}function D(e){return` See all devices: kane-cli devices list --target ${u(e).target} --remote`}function N(e,t){let n=l(t);return e.devices.find(o=>l(o.name)===n||o.configName!==void 0&&l(o.configName)===n)}function k(e,t){return e.runson?.[C(t)]}function G(e,t,n){let o=u(e.platform),r=N(e,t);if(!r){let i=_(e,t,n),s=i.length?` Did you mean: ${i.map(a=>`${a.name} (${a.osVersions.join(", ")})`).join(`
3
+ `)}
4
+ `:"";return{ok:!1,code:"device_not_found",detail:`no ${o.device} device named "${t}"`+(n&&i.length?` running ${o.os} ${n}`:"")+`.
5
+ ${s}${D(e.platform)}`}}if(!r.osVersions.includes(n)){let i=w(r,n);return{ok:!1,code:"device_os_version_unsupported",detail:`${r.name} does not run ${o.os} ${n}.
6
+ Supported: ${r.osVersions.join(", ")}`+(i?` \u2014 nearest is ${i}.`:".")+`
7
+ ${D(e.platform)}`}}return e.platform==="ios"?{ok:!0,resolved:{device:r,osVersion:n,slug:`${r.name}-${n}`,...k(e,n)?{pool:k(e,n)}:{}}}:{ok:!0,resolved:{device:r,osVersion:n,slug:`${r.configName}-${n}`,avdId:r.avdIds?.[n]}}}var A=15e3,b="/capability/generator",M=".*";function R(e){let t=e?.brands;if(!t||typeof t!="object")return[];let n=[];for(let[o,r]of Object.entries(t))if(Array.isArray(r))for(let i of r){let s=i;if(typeof s.name!="string"||!s.name.trim())continue;let a=Array.isArray(s.osVersion)?s.osVersion.map(String).filter(g=>g.trim()!==""):[];n.push({name:s.name.trim(),brand:o,osVersions:a})}return n}function P(e){let t=e??{};return{android:R(t.android),ios:R(t.ios)}}async function E(e,t={}){let n=t.url??`${h(e).lrmaaBaseUrl}${b}`;try{let o=await(t.request??p)(n,{method:"GET",signal:AbortSignal.timeout(A)});if(!o.ok)return{ok:!1,reason:`the real-device list answered HTTP ${o.status}`};let r=P(await o.json());return r.android.length===0&&r.ios.length===0?{ok:!1,reason:"the real-device list came back empty"}:{ok:!0,catalog:r}}catch(o){return{ok:!1,reason:`could not read the real-device list: ${o.message}`}}}function S(e){return e.trim().split(".")[0]??e.trim()}function j(e){try{let t=new RegExp(e,"i");return n=>t.test(n)}catch{let t=e.toLowerCase();return n=>n.toLowerCase().includes(t)}}function $(e){let t=e?.trim();return!t||t===M}function d(e){return u(e).os}function m(e){return` See the supported devices: kane-cli devices list --target ${e} --remote`}function O(e,t,n){let o=e[t];if(o.length===0)return{ok:!1,code:"device_not_found",detail:`no real ${d(t)} devices are listed right now \u2014 try again later.
8
+ ${m(t)}`};let r=n.deviceName?.trim()??"",i=o.filter(c=>c.name.toLowerCase()===r.toLowerCase()),s=$(n.deviceName)?o:i.length?i:o.filter(c=>j(r)(c.name));if(s.length===0)return{ok:!1,code:"device_not_found",detail:`"${n.deviceName.trim()}" is not available as a real ${d(t)} device.
9
+ ${m(t)}`};let a=n.osVersion?.trim();if(!a)return{ok:!0,models:s};let g=S(a),v=s.filter(c=>c.osVersions.includes(g));return v.length===0?{ok:!1,code:"device_os_version_unsupported",detail:`${$(n.deviceName)?`no real ${d(t)} device`:`no real device matching "${n.deviceName.trim()}"`} runs ${d(t)} ${a}.
10
+ ${m(t)}`}:{ok:!0,models:v}}async function W(e,t,n,o=E){let r=await o(e);if(!r.ok)return{kind:"unchecked",reason:r.reason};let i=O(r.catalog,t,n);return i.ok?{kind:"ok"}:{kind:"refused",detail:i.detail}}export{f as a,C as b,u as c,N as d,G as e,M as f,P as g,E as h,S as i,$ as j,O as k,W as l};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as J,c as Y,d as Z,e as ce,f as ue}from"./chunk-HAYV4D2I.js";import{a as fe}from"./chunk-X2A6CC6B.js";import{e as ie}from"./chunk-AHFIRHSP.js";import{a as se}from"./chunk-QAB3Y5FQ.js";import{a as ae}from"./chunk-4BZOG6PE.js";import{d as ne}from"./chunk-OIUV3ISA.js";import{a as O}from"./chunk-HG5LLZBU.js";import{b as oe}from"./chunk-USOYXCZ4.js";import{b as re}from"./chunk-PEDINHVU.js";import{a as M}from"./chunk-2KVECC36.js";import{a as T,b as j,d as le}from"./chunk-VE3SUJMA.js";import{b as te}from"./chunk-TZXXJWHA.js";import{r as y}from"./chunk-RSSOJ3L2.js";import{i as ee}from"./chunk-Z7S3IWUX.js";import{a as B}from"./chunk-NMSZ7G6P.js";import{a as D,c as H,e as I}from"./chunk-FMUV6UCX.js";import{f as q,g as z}from"./chunk-NOL7MNZH.js";import{a as Q}from"./chunk-YWYORBY3.js";import{a as W}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as F,j as V}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var s=L(we(),1);var r=L(W(),1);function ze({resultRef:x,mode:g="singleshot",loginCompleteRef:d}){let{exit:m}=V(),A=(0,s.useRef)(new Q),k=(0,s.useRef)(new se),v=(0,s.useRef)(new ie),n=A.current,l=k.current,N=v.current,de=J(),[h,f]=(0,s.useState)(g==="login"?"login":"gate"),[X,ge]=(0,s.useState)(null),[be,R]=(0,s.useState)(null),[ye,$]=(0,s.useState)(null),[U,pe]=(0,s.useState)(null),[G,E]=(0,s.useState)([]),P=(0,s.useCallback)((e,t,i,o)=>N.log(e,t,i,o),[N]),je=(0,s.useCallback)((e,t)=>{e?T(n,l,e,t):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[n,l]),b=(0,s.useCallback)(()=>{if(g==="login")d&&(d.current=!0),m();else{let e=l.load().mobile,t=D(e?.tui_target,e?.default_target?.kind),i=t.kind==="unset"||t.kind==="choose-mobile"&&te();f(i?"target":"input")}},[g,m,d,l]),S=(0,s.useCallback)((e,t)=>{let i=T(n,l,e,t);if(g==="login"){f("ensure-project");return}le(i)?b():i.projectId?f("ensure-folder"):f("ensure-project")},[n,l,b,g]);F((e,t)=>{t.ctrl&&e==="c"&&y(0,"Ctrl+C exit")});let K=(0,s.useRef)(!1);s.default.useEffect(()=>{K.current||(K.current=!0,g!=="login"&&ue(n,P).then(e=>{ge(e),e.status==="authenticated"?S(e.result.profile,e.result.env):e.status==="needs_pick"?f("pick"):(R(e.profile??null),$(e.env??null),f("login"))}).catch(e=>{pe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[n,P]);let me=(0,s.useCallback)(e=>{x.current={objective:e},m()},[x,m]),ve=(0,s.useCallback)(async(e,t)=>{n.setActiveProfile(e),n.setDefaultEnv(t),(await ce(n,e,t,P)).status==="authenticated"?S(e,t):(R(e),$(t),f("login"))},[n,P,S]),w=(0,s.useCallback)(()=>{let e=n.getActiveProfile(),t=n.getDefaultEnv();if(!e)return null;let i=B(t),o=n.loadBasicAuth(e,t);return new ae(i.controllerBaseUrl,async()=>n.loadCredentials(e,t)?.access_token??null,o,P)},[n,P]),he=(0,s.useCallback)(async()=>{let e=w();if(!e)return null;let t=e.cached??await e.resolve();if(!t)return null;let i=B(n.getDefaultEnv()),o=new M(i.tmsBaseUrl,t.username,t.access_key);try{let p=(await o.listProjects()).find(_=>_.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let C=await o.createProject("KaneAI Generated");return{id:C.id,name:C.name}}catch{return null}},[w,n]),xe=(0,s.useCallback)(async e=>{let t=w();if(!t)return null;let i=t.cached??await t.resolve();if(!i)return null;let o=B(n.getDefaultEnv()),a=new M(o.tmsBaseUrl,i.username,i.access_key);try{let C=(await a.listFolders(e)).find(Pe=>Pe.name==="Untitled");if(C)return{id:C.id,name:C.name};let _=await a.createFolder(e,"Untitled");return{id:_.id,name:_.name}}catch{return null}},[w,n]);if(h==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(U)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:U}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(h==="pick"&&X?.status==="needs_pick")return(0,r.jsx)(Ce,{profiles:X.profiles,onSelect:ve});if(h==="login")return(0,r.jsx)(Z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:n.listProfiles(),onBasicLogin:async(e,t,i,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-AAIXSAWH.js");await a(t,i,o),n.saveBasicAuth(e,t,{username:i,access_key:o}),n.setActiveProfile(e),n.setDefaultEnv(t)},onOAuthLogin:async(e,t)=>{let{LoginFlow:i}=await import("./login-flow-ASUUU7SO.js");n.setDefaultEnv(t),n.setActiveProfile(e),await new i(e,t,n).login()},onComplete:(e,t)=>{R(e),$(t),n.setActiveProfile(e),n.setDefaultEnv(t),S(e,t)},onCancel:()=>{y(0,"Login cancelled")}});if(h==="ensure-project"){let e=n.getActiveProfile()??"default",t=n.getDefaultEnv(),i=()=>{if(g==="login"){f("ensure-folder");return}T(n,l,e,t).folderId?b():f("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(oe,{resolver:w(),currentProjectId:l.load().project_id,env:t,onSelect:(o,a)=>{j(n,l,e,t,{projectId:o,projectName:a}),E(p=>[...p,`\u2713 Project: ${a} (${o})`]),i()},onCancel:async()=>{let o=await he();o&&(j(n,l,e,t,{projectId:o.id,projectName:o.name}),E(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),i())}})]})}if(h==="ensure-folder"){let e=n.getActiveProfile()??"default",t=n.getDefaultEnv(),i=n.loadProfileConfig(e,t);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(re,{resolver:w(),projectId:i?.project_id??"",currentFolderId:l.load().folder_id,env:t,onSelect:(o,a)=>{j(n,l,e,t,{folderId:o,folderName:a}),E(p=>[...p,`\u2713 Folder: ${a} (${o})`]),b()},onCancel:async()=>{if(!i?.project_id)return;let o=await xe(i.project_id);o&&(j(n,l,e,t,{folderId:o.id,folderName:o.name}),E(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),b())}})]})}if(h==="target"){let e=D(l.load().mobile?.tui_target,l.load().mobile?.default_target?.kind).kind==="choose-mobile";return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(fe,{mode:e?"legacy-mobile":"all",onSelect:t=>{l.setMobile({tui_target:t}),f("input")},onCancel:()=>f("input")})})}if(h==="input"){let e=l.load().mobile,t=D(e?.tui_target,e?.default_target?.kind),i=(()=>{if(z(t.kind)){let o=ee(e?.default_target)??"(no device)",a=O(e?.default_app)??"(no app)";return`Config: ${I(t.kind)} \xB7 ${o} \xB7 ${a}`}if(q(t.kind)){let o=H(e,t.kind),a=O(o.app)??"(no app)";return`Config: ${I(t.kind)} \xB7 ${ne(o)} \xB7 ${a}`}return"Config: Desktop \xB7 Chrome"})();return(0,r.jsxs)(c,{flexDirection:"column",children:[G.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:G.map((o,a)=>(0,r.jsx)(u,{color:"green",children:o},a))}),(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"gray",children:i})}),(0,r.jsx)(Y,{onSubmit:me,onEscape:()=>y(0,"User pressed Escape"),history:de,placeholder:"Type an objective..."})]})}return(0,r.jsx)(r.Fragment,{})}function Ce({profiles:x,onSelect:g}){let[d,m]=(0,s.useState)(0),[A,k]=(0,s.useState)(!1);return F((v,n)=>{if(!A){if(n.escape){y(0,"Profile picker cancelled");return}if(n.upArrow&&d>0&&m(l=>l-1),n.downArrow&&d<x.length-1&&m(l=>l+1),n.return){k(!0);let l=x[d];g(l.profile,l.env).catch(()=>k(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:x.map((v,n)=>(0,r.jsxs)(u,{children:[n===d?"\u276F ":" ",(0,r.jsx)(u,{color:n===d?"#ff9500":"white",bold:n===d,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),A&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{ze as a};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as $e,b as we,g as Ee}from"./chunk-7WXMV3O3.js";import{a as te}from"./chunk-DWMESHFI.js";import{a as G}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-CNUCP6DK.js";import{a as Te}from"./chunk-Z7IGTVJW.js";import{y as i}from"./chunk-5TQFOPJV.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as E}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as ve,k as ee}from"./chunk-C44QQJR4.js";import{a as z}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var M=R(z(),1);var I=R(z(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function ke(e){let t=Ee(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,I.useState)(0),[a,u]=(0,I.useState)("idle"),c=(0,I.useRef)("idle"),B=(0,I.useRef)(0),S=(0,I.useRef)(!1),v=(0,I.useRef)(null),d=(0,I.useRef)(null),O=(0,I.useCallback)(m=>{c.current=m,u(m)},[]),P=(0,I.useCallback)(async m=>{e.reportVerdictOnComplete&&await t.shutdownRunner($e(e.runVerdict?.()??(m?"failed":"passed"))),e.onAllComplete?.()},[t,e]),T=(0,I.useCallback)(async m=>{let b=await e.getNextConfig(m);if(!b){O("done"),await P(!1);return}let C=m?B.current+1:0;B.current=C,l(C),e.onStepStart?.(b,C),v.current=null,d.current=null,O("running"),await t.startRun(b,e.spawnOpts)},[t,e,O]);(0,I.useEffect)(()=>{S.current||(S.current=!0,T(null))},[]),(0,I.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===v.current||c.current!=="running")return;v.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let m=t.lastRunEnd,b=de(t.steps),C=t.bifurcationInfo,A={status:m.status==="passed"?"passed":"failed",duration_s:m.duration??0,reason:m.reason,runEnd:m,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:C&&!C.isSingleFlow?C.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(A,B.current)??!0)){O("done"),P(A.status==="failed");return}T(A)},[t.lastRunEnd]),(0,I.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let m=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:m.passed,stepsFailed:m.failed,stepsTotal:m.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,B.current)??!0)){O("done"),P(!0);return}T(b)},[t.runError,t.lastRunEnd]);let k=(0,I.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:k}}var pe=R(z(),1);var ne=R(E(),1),Ce=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Le({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);G(()=>{l(B=>(B+1)%Ce.length)},80),G(()=>{u(B=>(B+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ce[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Oe(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var L=R(z(),1);var Pe=R(z(),1);var re=R(E(),1),Ue="#ffc580",We="#ffd9a8",Ie="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Pe.useState)(0),a=4;if(G(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Ie,children:e});let u=e.split("").map((c,B)=>{let S=n-a,v=Math.abs(B-S-a/2),d;return v<=a/2?d=Ue:v<=a?d=We:d=Ie,(0,re.jsx)(o,{color:d,children:c},B)});return(0,re.jsx)(o,{children:u})}var _=R(E(),1),ze={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=ze[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Xe={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function De(e){return Xe[e]??"\u25CF"}var q=R(E(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let B=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return B?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(v=>(0,q.jsx)(s,{marginLeft:2,children:l(v,`${S}-${v.childId??"p"}-${v.index}`)},`${S}-${v.childId??"p"}-${v.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var K=R(E(),1);function je({label:e,shimmer:t=!1}){return(0,K.jsxs)(s,{marginLeft:6,children:[(0,K.jsx)(te,{}),(0,K.jsx)(o,{children:" "}),t?(0,K.jsx)(oe,{text:e,active:!0}):(0,K.jsx)(o,{color:i.dim,children:e})]})}var Fe=R(z(),1);var me=R(E(),1);function Ye(e,t){let n=[];for(let l of e.split(`
3
+ `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function _e({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,Fe.useState)(!0);G(()=>c(v=>!v),500);let B=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=Ye(B,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((v,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:v.length?v:" "},d))})}var H=R(E(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,H.jsxs)(H.Fragment,{children:[e?(0,H.jsx)(je,{label:e.label,shimmer:e.shimmer}):null,n?(0,H.jsx)(_e,{text:t??""}):null]})}var r=R(E(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function X(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Ae(e){let t=[];for(let n of e)X(n)||(n.children&&n.children.length>0?t.push({...n,children:Ae(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function D({step:e,indent:t=2}){let n=e.actionType?De(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:B}=ee(),S=B?.columns??80,v=Math.max(20,S-t-21),d=e.objective??"",O=d.length>v?d.slice(0,v-1)+"\u2026":d,P=(e.duration??0)*1e3,T=e.duration!=null?P<1e3?`${Math.round(P)}ms`:`${(P/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:O,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:O}):c?(0,r.jsx)(o,{color:i.dim,children:O}):(0,r.jsx)(o,{color:i.dim,children:O})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:T})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((k,m)=>(0,r.jsx)(D,{step:k,indent:t+2},`child-${m}`))})]})}function Je(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(D,{step:e.step})})}function Me({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:B,describeVisible:S,describeRevealing:v}){let d=(0,L.useRef)(new Set),O=(0,L.useRef)(!1),P=(0,L.useRef)(new Set),T=(0,L.useRef)(!1),k=(0,L.useRef)(new Set),m=(0,L.useRef)(0);(0,L.useEffect)(()=>{e.length===0&&m.current>0&&(d.current.clear(),O.current=!1,P.current.clear(),T.current=!1,k.current.clear()),m.current=e.length},[e.length]);let b=e.flatMap(p=>[p,...p.children??[]]),C=b.some(p=>p.status==="running"),A=b.some(p=>p.status==="failed"),W=b.length===0||b.every(p=>p.status==="pending"),Y=b.filter(p=>p.status==="passed"||p.status==="failed").length,N;W?N="starting":C?N="running":A?N="failed":N="passed";let J=(0,L.useRef)(null),[ce,he]=(0,L.useState)(0);(0,L.useEffect)(()=>{b.length===0||W?(J.current=null,he(0)):C&&J.current==null&&(J.current=Date.now())},[C,W,b.length]),(0,L.useEffect)(()=>{if(!C)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[C]);let ae=(0,L.useRef)(new Set),[,xe]=(0,L.useState)(0),be=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let h of e)(h.status==="passed"||h.status==="failed")&&!ae.current.has(h.index)&&(ae.current.add(h.index),p.push({key:`step_${h.index}`,type:"step",step:{...h,children:h.children?[...h.children]:void 0}}));if(p.length>0){for(let h of p)c(Je(h));xe(h=>h+1)}},[e,t,l,u,c]),(0,L.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!T.current&&l&&l[0]!=null&&(T.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!O.current&&(O.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let h=e.flatMap((x,f)=>{let g=x.children??[];return!P.current.has(f)&&g.length>0&&(P.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!k.current.has(f)&&(k.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&P.current.has(f)&&!k.current.has(f)&&(k.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),g});for(let x of h){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...x,children:void 0}})})));for(let y of x.children??[]){let $=`child-${x.childId??"p"}-${x.index}-${y.childId??"p"}-${y.index}-${y.objective}`;d.current.has($)||(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(D,{step:y})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:x})})))}}else for(let h of e){let x=`${h.index}-${h.objective}`,f=!!h.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...h,children:void 0}})})));for(let g of h.children??[]){let y=`child-${h.index}-${g.childId??"p"}-${g.index}-${g.objective}`;d.current.has(y)||(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(y),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(D,{step:g})})))}!f&&!d.current.has(x)&&(h.status==="passed"||h.status==="failed"||h.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:{...h,children:void 0}})})))}d.current.size>p&&xe(h=>h+1)},[e,c,t,n,l]);let V=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||V.push(p);else if(c&&!u)if(t)for(let p of e){let h=p.children??[],x=[];for(let f of h){let g=`${f.childId??"p"}-${f.index}-${f.objective}`,y=d.current.has(g);if(f.branchObjective){let $=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!y||$.length>0)&&x.push({...f,children:$})}else y||x.push(f)}x.length>0&&V.push({...p,children:x})}else for(let p of e){let h=`${p.index}-${p.objective}`,x=d.current.has(h),f=(p.children??[]).filter(g=>{let y=`child-${p.index}-${g.childId??"p"}-${g.index}-${g.objective}`;return!d.current.has(y)});x?f.length>0&&V.push({...p,children:f}):V.push({...p,children:f})}if(!u){let p=c?V:e,h=le(p),x=ge(h,v);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((g,y)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:y>0?1:0,children:g.children&&g.children.length>0?g.children.map($=>{if(X($))return null;let Q=!!$.branchObjective,ue=`${$.childId??"p"}-${$.index}-${$.objective}`,He=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!He&&(0,r.jsx)(D,{step:{...$,children:void 0}}),($.children??[]).filter(Z=>!X(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:Z})},`f${y}-${$.index}-${Z.childId??"p"}-${Z.index}`))]},`f${y}-host-${$.childId??"p"}-${$.index}`):(0,r.jsx)(D,{step:$},`f${y}-${$.childId??"p"}-${$.index}`)}):g.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},y))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(g,y)=>X(g)?null:(0,r.jsx)(D,{step:g},y)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(g=>!(g.status==="running"&&(!g.children||g.children.length===0))).map(g=>{let y=`${g.index}-${g.objective}`;return c&&d.current.has(y)?(0,r.jsx)(s,{flexDirection:"column",children:(g.children??[]).filter($=>!X($)).map($=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(D,{step:$})},`${$.childId??"p"}-${$.index}`))},`branch-children-${g.index}`):(0,r.jsx)(D,{step:g},g.index)})]}),(0,r.jsx)(se,{activity:x,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),h=ge(p,v);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>X(x)?null:(0,r.jsx)(D,{step:x},f)}),(0,r.jsx)(se,{activity:h,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ge=le(V),Ke=ge(Ge,v),Re=Ae(V);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(D,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ke,describe:B,describeVisible:S}),b.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var U=R(E(),1);function qe({runner:e,runKey:t,onStepCommit:n}){let l=Oe({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,U.jsxs)(U.Fragment,{children:[l&&(0,U.jsx)(Le,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,U.jsx)(Me,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var j=R(E(),1),Qe=64;function Ze(e){return e.split(`
4
+ `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function Ne({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:B}){let S=e==="passed",v=S?i.green:i.red,d=S?"\u2713":"\u2717",O=e.toUpperCase(),P=a??(S?l:Math.max(0,l-1)),T=u??(S?0:1),k=T>0?`${l} steps (${P} passed, ${T} failed)`:`${l} steps`,m=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,b=Ze(t);return(0,j.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,j.jsxs)(s,{borderStyle:"round",borderColor:v,flexDirection:"column",paddingX:2,paddingY:1,width:Qe+6,children:[(0,j.jsxs)(s,{flexDirection:"column",children:[(0,j.jsxs)(o,{bold:!0,color:v,children:[d," ",O]}),(0,j.jsxs)(o,{color:i.dim,wrap:"wrap",children:[k," \xB7 ",m,typeof B=="number"&&B>0?` \xB7 ${parseFloat(B.toFixed(4))} credits`:""]})]}),b.length>0&&(0,j.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:b.map((C,A)=>(0,j.jsxs)(s,{marginBottom:A<b.length-1?1:0,children:[(0,j.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,j.jsx)(s,{flexShrink:1,children:(0,j.jsx)(o,{wrap:"wrap",children:C})})]},A))}),c&&!S&&(0,j.jsx)(s,{marginTop:1,children:(0,j.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var F=R(E(),1);function Ve({message:e,code:t,remediation:n,docsUrl:l}){return(0,F.jsx)(Te,{title:"Error",variant:"error",children:(0,F.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,F.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,F.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,F.jsx)(o,{color:i.muted,children:"Code: "}),(0,F.jsx)(o,{color:i.dim,children:t})]}),n&&(0,F.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,F.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,F.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,F.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,F.jsx)(o,{color:i.muted,children:"Docs: "}),(0,F.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var w=R(E(),1),et=1e4;function gn(e){let{exit:t}=ve(),{append:n}=ye(),l=(0,M.useRef)(!1);(0,M.useEffect)(()=>{l.current||(l.current=!0,n((0,w.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,w.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,w.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,w.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,w.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,w.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,w.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,w.jsx)(tt,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,w.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,M.useRef)(null),u=(0,M.useCallback)(async T=>{let k=await e.getNextStep(T);return k?(a.current=k,k.config):(a.current=null,null)},[e]),c=(0,M.useCallback)((T,k)=>{let m=a.current;if(!m)return;let b=m.mode==="replay"?"cyan":"#dc4e08",C=m.modeReason?` (${m.modeReason})`:"",A=m.perStepOverrides?Object.entries(m.perStepOverrides):[];n((0,w.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,w.jsxs)(o,{children:[(0,w.jsxs)(o,{color:i.dim,children:[m.banner.stepLabel," "]}),(0,w.jsxs)(o,{color:b,children:["[",m.mode,"]"]}),(0,w.jsx)(o,{color:i.dim,children:C})]}),(0,w.jsx)(o,{color:i.dim,children:m.banner.objective}),A.length>0&&(0,w.jsxs)(o,{color:i.dim,children:["overrides: ",A.map(([W,Y])=>`${W}=${Y}`).join(", ")]})]}))},[n]),B=(0,M.useRef)(0),S=(0,M.useRef)(!1),v=(0,M.useCallback)((T,k)=>(T.hadError?n((0,w.jsx)(Ve,{message:T.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,w.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,w.jsx)(Ne,{status:T.status,summary:T.runEnd?.summary??"",duration:T.runEnd?.duration??0,steps:T.stepsTotal,stepsPassed:T.stepsPassed,stepsFailed:T.stepsFailed,reason:T.runEnd?.reason,creditsConsumed:T.runEnd?.credits_consumed})})),e.onStepEnd?.(T,k)??!0),[n,e]),d=ke({getNextConfig:u,onStepStart:c,onStepEnd:v,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts,...e.reportVerdictOnComplete?{reportVerdictOnComplete:!0}:{},...e.runVerdict?{runVerdict:e.runVerdict}:{}}),O=250,P=5e3;return Se((T,k)=>{if(k.ctrl&&T==="c"){let m=Date.now(),b=m-B.current;if(b<O)return;if(S.current&&b<P){d.cancel(),e.onCancel?.();let C=e.reportVerdictOnComplete?d.runner.shutdownRunner(we,{timeoutMs:et}):Promise.resolve();e.exitOnComplete!==!1&&C.then(()=>setImmediate(()=>t()))}else S.current=!0,n((0,w.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}));B.current=m}}),(0,w.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,w.jsx)(qe,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function tt({data:e}){return(0,w.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{Me as a,Le as b,Oe as c,de as d,Ne as e,Ve as f,gn as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-DUYRCVI5.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-CXF6AZWY.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-NMSZ7G6P.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-5TQFOPJV.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as u,b as x}from"./chunk-IGHK2ENL.js";import{y as m}from"./chunk-CXF6AZWY.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
2
+ import{a as u,b as x}from"./chunk-Z7IGTVJW.js";import{y as m}from"./chunk-5TQFOPJV.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};