@testmuai/kane-cli 0.10.0 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/dist/ChatSurface-Z26BOE5U.js +2 -0
  2. package/dist/{ChromeProfilePicker-FWPUDKD6.js → ChromeProfilePicker-ODRIAXL3.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-D5L2DO6A.js → CliFeedbackPrompt-JWCTMIGI.js} +1 -1
  4. package/dist/{CliUploadProgress-HQX57WE6.js → CliUploadProgress-XFRRFRL4.js} +1 -1
  5. package/dist/{ConfigView-DGQXKEON.js → ConfigView-6JF4DOJN.js} +1 -1
  6. package/dist/EvidenceViewOffer-6344EX74.js +2 -0
  7. package/dist/FolderPicker-4PCYHE75.js +2 -0
  8. package/dist/InfoBox-NJ2DL7YC.js +2 -0
  9. package/dist/{LinksBox-WZ4RAMSH.js → LinksBox-HNDNFVUT.js} +1 -1
  10. package/dist/{ProfilesView-AGRNPGSW.js → ProfilesView-DEJKJOHY.js} +1 -1
  11. package/dist/ProjectPicker-DTWMWOH7.js +2 -0
  12. package/dist/SaveSessionPrompt-3GCLB3ZT.js +2 -0
  13. package/dist/SingleShotApp-HMOXO5DW.js +2 -0
  14. package/dist/{SummaryBox-XQJUZBAN.js → SummaryBox-7PPDMSSM.js} +1 -1
  15. package/dist/TestMdRunView-QLKRUU4V.js +2 -0
  16. package/dist/TestrunEvidenceTable-T2JUB4TE.js +2 -0
  17. package/dist/{WhoamiView-JQCURK2M.js → WhoamiView-H7JNLLCY.js} +1 -1
  18. package/dist/{app-download-OU6AGH2X.js → app-download-GKRF2EIM.js} +1 -1
  19. package/dist/{assurance-job-ZI3L6I4F.js → assurance-job-F4L3T4VJ.js} +1 -1
  20. package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
  21. package/dist/{binary-S5YL5GJD.js → binary-K3XMILST.js} +1 -1
  22. package/dist/{bind-LIV72SEZ.js → bind-SSHAZAB3.js} +1 -1
  23. package/dist/{bootstrap-3V6TOO6I.js → bootstrap-XGKU4WXB.js} +1 -1
  24. package/dist/bridge-2UHJOVLX.js +2 -0
  25. package/dist/{catalog-I3PC6LT6.js → catalog-YCU6OHNV.js} +1 -1
  26. package/dist/{catalog-client-WKYG3JN6.js → catalog-client-MVEEHTG2.js} +1 -1
  27. package/dist/{changelog-IHNWFYWY.js → changelog-5UB3AQT6.js} +1 -1
  28. package/dist/chat-committer-ZKEKJA2R.js +2 -0
  29. package/dist/chat-controller-FXRJXUG3.js +2 -0
  30. package/dist/child-JHYENXE7.js +2 -0
  31. package/dist/{chunk-ZTAZ2R5Z.js → chunk-23DKB2MT.js} +1 -1
  32. package/dist/{chunk-UX2CDUPE.js → chunk-2JFRN62I.js} +2 -2
  33. package/dist/chunk-2RBMQTYS.js +26 -0
  34. package/dist/{chunk-VVCZRCRD.js → chunk-2TK4MDF2.js} +1 -1
  35. package/dist/{chunk-G3J4XY3Z.js → chunk-32HED7X2.js} +1 -1
  36. package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
  37. package/dist/{chunk-N3KTLWJL.js → chunk-35BG2EMW.js} +1 -1
  38. package/dist/{chunk-4523YDTG.js → chunk-35WUYKGO.js} +1 -1
  39. package/dist/{chunk-KDR662D2.js → chunk-3KY7HHQU.js} +1 -1
  40. package/dist/{chunk-UNWPBMVM.js → chunk-3MD2XLE7.js} +2 -2
  41. package/dist/{chunk-YKL5H4K6.js → chunk-3NWUXRSI.js} +1 -1
  42. package/dist/{chunk-QQI6N3FO.js → chunk-3RO2YGKH.js} +1 -1
  43. package/dist/{chunk-AGXAJ2II.js → chunk-3ZC7GSMM.js} +1 -1
  44. package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
  45. package/dist/{chunk-VQZOKTJ2.js → chunk-4CJQ7XZP.js} +1 -1
  46. package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
  47. package/dist/{chunk-AUBSLPJZ.js → chunk-4KL3TSTT.js} +5 -5
  48. package/dist/{chunk-AG5XJWEV.js → chunk-4UX5N7YI.js} +1 -1
  49. package/dist/{chunk-WERIGVOH.js → chunk-5F5IVART.js} +1 -1
  50. package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
  51. package/dist/{chunk-FBQ7PQJV.js → chunk-5YYCCM6K.js} +1 -1
  52. package/dist/{chunk-SBR6D6GS.js → chunk-6FFX4S7N.js} +1 -1
  53. package/dist/{chunk-DHYGCHKB.js → chunk-6HRNG4CK.js} +1 -1
  54. package/dist/{chunk-HBVHIEPB.js → chunk-6QCCTZO3.js} +1 -1
  55. package/dist/{chunk-GI2JPIX5.js → chunk-6QH75BPJ.js} +1 -1
  56. package/dist/{chunk-5R3ODQHH.js → chunk-6SD4XTYC.js} +1 -1
  57. package/dist/{chunk-J4LQAT5P.js → chunk-7LYLJ75Z.js} +1 -1
  58. package/dist/{chunk-Y3YULFCK.js → chunk-7RELCXRW.js} +1 -1
  59. package/dist/{chunk-GXMD23XB.js → chunk-7SU53QGU.js} +1 -1
  60. package/dist/{chunk-DTYT6KBO.js → chunk-7Y55CO42.js} +1 -1
  61. package/dist/{chunk-2L3A5NKZ.js → chunk-7YV2FCN4.js} +1 -1
  62. package/dist/{chunk-ULGBK4NS.js → chunk-A2DODRHG.js} +1 -1
  63. package/dist/{chunk-EVZLINBN.js → chunk-AHT2ORJT.js} +1 -1
  64. package/dist/{chunk-RDH3E25Q.js → chunk-AT7AT3AR.js} +2 -2
  65. package/dist/{chunk-ZI3X7DI2.js → chunk-AVLYSNEG.js} +1 -1
  66. package/dist/{chunk-GET4DINR.js → chunk-BBJAKSA7.js} +1 -1
  67. package/dist/{chunk-CBVHP7JB.js → chunk-BJO6J5X2.js} +1 -1
  68. package/dist/{chunk-G3CYFCSR.js → chunk-BLVDV3QQ.js} +1 -1
  69. package/dist/{chunk-2N75WO7Y.js → chunk-C4KAPGBS.js} +1 -1
  70. package/dist/{chunk-XLQ4F6BI.js → chunk-CB2BWDHG.js} +2 -2
  71. package/dist/chunk-CB344EDO.js +2 -0
  72. package/dist/chunk-CCOD4GQJ.js +2 -0
  73. package/dist/{chunk-JSLKCCD2.js → chunk-CNHKZE4F.js} +1 -1
  74. package/dist/{chunk-CJE7PKRV.js → chunk-CQDCNP7V.js} +1 -1
  75. package/dist/{chunk-3OVFKUXV.js → chunk-CTHUX7O4.js} +1 -1
  76. package/dist/{chunk-4JWJH6TB.js → chunk-DC5F2ADJ.js} +1 -1
  77. package/dist/chunk-DIOK3SER.js +34 -0
  78. package/dist/{chunk-EQWMOGLO.js → chunk-DQXQJJOP.js} +2 -2
  79. package/dist/{chunk-EH43VWVR.js → chunk-DXIQVBMI.js} +1 -1
  80. package/dist/{chunk-WZLDFEWR.js → chunk-E4GIGM5V.js} +1 -1
  81. package/dist/{chunk-K3OSK6PB.js → chunk-EBJW6POT.js} +1 -1
  82. package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
  83. package/dist/{chunk-RARD6TC6.js → chunk-EJGCIGQY.js} +1 -1
  84. package/dist/{chunk-OR2B6T3B.js → chunk-ENRFXGID.js} +1 -1
  85. package/dist/{chunk-3ZPEQDXZ.js → chunk-ERRIDBE7.js} +1 -1
  86. package/dist/{chunk-HGVM2OZU.js → chunk-EZMRWXRT.js} +1 -1
  87. package/dist/chunk-F2F257PU.js +6 -0
  88. package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
  89. package/dist/{chunk-MPEIMWQI.js → chunk-FOLUB336.js} +1 -1
  90. package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
  91. package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
  92. package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
  93. package/dist/{chunk-PCDIEYV6.js → chunk-GEZVC4S3.js} +1 -1
  94. package/dist/{chunk-PL3SG3M2.js → chunk-GJXO6FF7.js} +1 -1
  95. package/dist/{chunk-252GEI3H.js → chunk-GLM5UGTF.js} +1 -1
  96. package/dist/{chunk-JOCEZK2M.js → chunk-GQAWZEA4.js} +1 -1
  97. package/dist/{chunk-45URQUAK.js → chunk-GXQYFOBD.js} +1 -1
  98. package/dist/{chunk-PBWYQR5I.js → chunk-HBLHKQR7.js} +1 -1
  99. package/dist/chunk-HC6VLPUB.js +5 -0
  100. package/dist/{chunk-K2PLULJD.js → chunk-HRIDAK6Y.js} +1 -1
  101. package/dist/{chunk-D6CS62O7.js → chunk-HV2CDY4K.js} +1 -1
  102. package/dist/{chunk-P2LDAW3C.js → chunk-HVOXMCKE.js} +1 -1
  103. package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
  104. package/dist/{chunk-GYDJO32R.js → chunk-IEHJG6J4.js} +1 -1
  105. package/dist/{chunk-GGS3ATPB.js → chunk-IZ66FKPC.js} +1 -1
  106. package/dist/{chunk-QMOGBKJM.js → chunk-J4FIESTB.js} +1 -1
  107. package/dist/{chunk-436FZ4KG.js → chunk-JBKHX5ES.js} +1 -1
  108. package/dist/{chunk-EX6ORR7P.js → chunk-JNPFEBUR.js} +1 -1
  109. package/dist/{chunk-AU26ZZTX.js → chunk-JTNEF5ZP.js} +1 -1
  110. package/dist/{chunk-5IO5ZC4S.js → chunk-KBGMQYMD.js} +1 -1
  111. package/dist/{chunk-WX4VGH5Q.js → chunk-KCXLRR3Q.js} +1 -1
  112. package/dist/{chunk-4R4YUOVY.js → chunk-KKLCXRW6.js} +1 -1
  113. package/dist/{chunk-YGMQXS2J.js → chunk-KL7XFNSD.js} +1 -1
  114. package/dist/{chunk-MJKRJGER.js → chunk-KQ4XKTIZ.js} +1 -1
  115. package/dist/{chunk-I2VU2DTS.js → chunk-L3BUPFAQ.js} +4 -4
  116. package/dist/{chunk-ZZNQIFFI.js → chunk-LHJSIHLC.js} +1 -1
  117. package/dist/{chunk-2GE5X2A5.js → chunk-LLQWEGXD.js} +1 -1
  118. package/dist/{chunk-PQXYHI5W.js → chunk-LPJKNX6D.js} +1 -1
  119. package/dist/{chunk-ZGQM6KWN.js → chunk-LRNUGKYH.js} +1 -1
  120. package/dist/chunk-LTPOMMAB.js +2 -0
  121. package/dist/{chunk-MHB6DMKZ.js → chunk-LUA25RYS.js} +1 -1
  122. package/dist/{chunk-2PZKMT3I.js → chunk-LV7224DG.js} +1 -1
  123. package/dist/{chunk-X3J4CC27.js → chunk-LXK4B2FE.js} +1 -1
  124. package/dist/{chunk-YH4VZVHJ.js → chunk-LZGAFKYH.js} +1 -1
  125. package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
  126. package/dist/{chunk-4BUEOKFV.js → chunk-M2E5CPPV.js} +1 -1
  127. package/dist/{chunk-65BG6GAE.js → chunk-M7A66MSK.js} +1 -1
  128. package/dist/{chunk-JX5NVKTV.js → chunk-MD3RABID.js} +1 -1
  129. package/dist/{chunk-QECTIQAC.js → chunk-MEBEVHGP.js} +1 -1
  130. package/dist/{chunk-52VCA4K2.js → chunk-MEMXFTLD.js} +1 -1
  131. package/dist/{chunk-U7NRZBB5.js → chunk-MINDIQET.js} +1 -1
  132. package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
  133. package/dist/{chunk-YKOEABP2.js → chunk-N7IWR45S.js} +1 -1
  134. package/dist/{chunk-WQR2GYP7.js → chunk-ND6OP3O2.js} +1 -1
  135. package/dist/{chunk-URAYFJGM.js → chunk-NHGPMYM3.js} +1 -1
  136. package/dist/{chunk-ZKPY3AXW.js → chunk-NI3TIAD7.js} +1 -1
  137. package/dist/{chunk-JCSVBD4F.js → chunk-NPAUSUNM.js} +1 -1
  138. package/dist/{chunk-XMALVGH7.js → chunk-NRAPCFI2.js} +2 -2
  139. package/dist/{chunk-567D5ZTO.js → chunk-NZJSGINB.js} +16 -16
  140. package/dist/{chunk-A4BB6GLN.js → chunk-OBNVGD5H.js} +1 -1
  141. package/dist/{chunk-BRVIK3BU.js → chunk-OCMPWCKQ.js} +1 -1
  142. package/dist/{chunk-4SJAOAYY.js → chunk-OCVDMZWB.js} +1 -1
  143. package/dist/{chunk-JRSEAXFE.js → chunk-OHGL4GEJ.js} +1 -1
  144. package/dist/{chunk-YYVBE6W2.js → chunk-OOGKX4Y6.js} +1 -1
  145. package/dist/{chunk-QWZJ5QDO.js → chunk-OTMHCHH6.js} +2 -2
  146. package/dist/{chunk-Z5BFCTHI.js → chunk-OZNYQONA.js} +2 -2
  147. package/dist/{chunk-EPJ5SJL2.js → chunk-PB6RXDWQ.js} +2 -2
  148. package/dist/{chunk-TZVPDGJD.js → chunk-PCQK62MP.js} +1 -1
  149. package/dist/{chunk-Z777GGHB.js → chunk-PI7OXS62.js} +1 -1
  150. package/dist/{chunk-MW2WNYJO.js → chunk-PRBWZXFA.js} +2 -2
  151. package/dist/{chunk-2SY2NCOP.js → chunk-PTLOOVV4.js} +1 -1
  152. package/dist/{chunk-EC5IP5HZ.js → chunk-Q4ALB7SH.js} +1 -1
  153. package/dist/{chunk-FYCD765R.js → chunk-Q4JV4U65.js} +58 -58
  154. package/dist/{chunk-CJQUVHHS.js → chunk-Q4SMITTV.js} +1 -1
  155. package/dist/{chunk-NJCN6LP5.js → chunk-QE4AWNOV.js} +6 -6
  156. package/dist/{chunk-BY2B4YJN.js → chunk-QEM5ZRDN.js} +1 -1
  157. package/dist/{chunk-VA3BSIUQ.js → chunk-QHH42RH5.js} +1 -1
  158. package/dist/{chunk-FPPVNF53.js → chunk-R6TFRAMZ.js} +1 -1
  159. package/dist/{chunk-3T2TYDPT.js → chunk-RNHSULQM.js} +1 -1
  160. package/dist/{chunk-32Y6QVFG.js → chunk-SALZ6WSF.js} +1 -1
  161. package/dist/chunk-SB26HQO7.js +2 -0
  162. package/dist/{chunk-4NUSW4A2.js → chunk-SIHX5FW5.js} +1 -1
  163. package/dist/{chunk-LHQUCRCH.js → chunk-SJQTTEXQ.js} +1 -1
  164. package/dist/{chunk-W3NWHWK2.js → chunk-SMGRXKXX.js} +1 -1
  165. package/dist/{chunk-USJ3LUAL.js → chunk-SSOUYKVG.js} +1 -1
  166. package/dist/{chunk-2B75UL7Y.js → chunk-SVIIUKJ2.js} +1 -1
  167. package/dist/{chunk-7ZJWUWSN.js → chunk-SXBPUUQ5.js} +1 -1
  168. package/dist/{chunk-QVP4FSKT.js → chunk-T77LTLAD.js} +1 -1
  169. package/dist/{chunk-KRRZCY7U.js → chunk-TAY7J5VS.js} +1 -1
  170. package/dist/chunk-TD6GCEIK.js +2 -0
  171. package/dist/{chunk-VZA7BPCK.js → chunk-TM45NPWL.js} +1 -1
  172. package/dist/{chunk-ZY65IZJR.js → chunk-TM6VLC6V.js} +1 -1
  173. package/dist/{chunk-COJINPOK.js → chunk-TU2KPOW2.js} +2 -2
  174. package/dist/{chunk-JTJ7IPNI.js → chunk-TUSG7DIL.js} +1 -1
  175. package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
  176. package/dist/{chunk-JQ7ZZQXC.js → chunk-UJ37XGSP.js} +3 -3
  177. package/dist/chunk-ULIIYKZB.js +7 -0
  178. package/dist/{chunk-LNHBZEDC.js → chunk-UWPG5MWM.js} +1 -1
  179. package/dist/{chunk-UUWSULIM.js → chunk-UXGMKRS4.js} +61 -60
  180. package/dist/{chunk-6DZ7LVOG.js → chunk-VCVEZEVS.js} +1 -1
  181. package/dist/{chunk-ZRDX2ARO.js → chunk-VKVYT6KZ.js} +2 -2
  182. package/dist/{chunk-B2WFW74J.js → chunk-VO2NNXKR.js} +1 -1
  183. package/dist/{chunk-B7JLM3IX.js → chunk-W54BX6HC.js} +1 -1
  184. package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
  185. package/dist/{chunk-TLOYTGVT.js → chunk-WE7HRAGO.js} +1 -1
  186. package/dist/{chunk-GRO6DLN3.js → chunk-WEJR2V7R.js} +1 -1
  187. package/dist/{chunk-YI4ESDAX.js → chunk-WIVKLNIO.js} +1 -1
  188. package/dist/chunk-WLEWXE6L.js +2 -0
  189. package/dist/{chunk-DBTMKBHU.js → chunk-X2MDL6S4.js} +1 -1
  190. package/dist/{chunk-MKPDF26Q.js → chunk-X45RZIAJ.js} +1 -1
  191. package/dist/{chunk-G2KTWFMU.js → chunk-X52YIWGG.js} +1 -1
  192. package/dist/{chunk-UEPJ26X2.js → chunk-X6FCXBXU.js} +1 -1
  193. package/dist/{chunk-LXM7VHYN.js → chunk-X7S7IGCV.js} +1 -1
  194. package/dist/{chunk-FVYIV36L.js → chunk-XKOVEMVZ.js} +1 -1
  195. package/dist/{chunk-3UHPVQLU.js → chunk-Y2HQMJGS.js} +1 -1
  196. package/dist/{chunk-4MNSP4EO.js → chunk-Y3RJHWNK.js} +1 -1
  197. package/dist/{chunk-A3TCFSCK.js → chunk-YCVEI7BT.js} +1 -1
  198. package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
  199. package/dist/{chunk-7C4IEL5V.js → chunk-YILRYMMG.js} +1 -1
  200. package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
  201. package/dist/{chunk-JGLADDRH.js → chunk-YNDELIXL.js} +1 -1
  202. package/dist/{chunk-WKZLK57W.js → chunk-YPGZ5E4I.js} +1 -1
  203. package/dist/{chunk-NTXFPNAP.js → chunk-YQZ736IQ.js} +1 -1
  204. package/dist/{chunk-FPVGA6XT.js → chunk-YVVFXBT5.js} +1 -1
  205. package/dist/{chunk-JT6WLJSV.js → chunk-YWWVF5OU.js} +1 -1
  206. package/dist/{chunk-RLOJH5O6.js → chunk-Z24SD2EJ.js} +1 -1
  207. package/dist/{chunk-ENG2UTMX.js → chunk-Z36KVIRR.js} +1 -1
  208. package/dist/{chunk-JFBEHCJN.js → chunk-Z47ZEFH7.js} +1 -1
  209. package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
  210. package/dist/{chunk-GGV336P5.js → chunk-ZCBOHWN3.js} +1 -1
  211. package/dist/{chunk-AIGQCMGY.js → chunk-ZCL7XIVS.js} +1 -1
  212. package/dist/{chunk-ORNVIEUA.js → chunk-ZDCXWEQG.js} +1 -1
  213. package/dist/{chunk-6TNLITJO.js → chunk-ZHAMVLQZ.js} +1 -1
  214. package/dist/{chunk-FLOQ5NZL.js → chunk-ZIHQ5JGB.js} +4 -4
  215. package/dist/{chunk-PTISAIZW.js → chunk-ZMIKNNO6.js} +1 -1
  216. package/dist/{chunk-H4KPNGY4.js → chunk-ZMWTRXFH.js} +1 -1
  217. package/dist/{chunk-ONZ2CSTZ.js → chunk-ZPU3WAC4.js} +1 -1
  218. package/dist/commands-JBFLLT7A.js +2 -0
  219. package/dist/{committer-26UZDYSA.js → committer-UO3B3S5Y.js} +1 -1
  220. package/dist/{config-B472DZSR.js → config-7WTZPMAH.js} +1 -1
  221. package/dist/cover-cmd-DU6ZYJFL.js +2 -0
  222. package/dist/{credentials-TLT3RQOO.js → credentials-5WIFF5DG.js} +1 -1
  223. package/dist/{deps-bundle-CMTIWBS5.js → deps-bundle-BLLJ2BQ4.js} +1 -1
  224. package/dist/{deps-resolve-XLFZK74A.js → deps-resolve-WQ6J6RLI.js} +1 -1
  225. package/dist/{design-chat-I7X3QDDY.js → design-chat-ZICGVYIH.js} +1 -1
  226. package/dist/design-committer-7YIPFKMO.js +2 -0
  227. package/dist/design-headless-HYWZIIDS.js +2 -0
  228. package/dist/{design-remote-UDC5FP45.js → design-remote-HPX4VZ63.js} +2 -2
  229. package/dist/device-env-4P4GUVBW.js +2 -0
  230. package/dist/dispatch-BV6XMCN3.js +2 -0
  231. package/dist/{doctor-UHFCIM4B.js → doctor-Z2YQ2DBX.js} +1 -1
  232. package/dist/{docx-convert-N4KMLLKO.js → docx-convert-DO5AQYD3.js} +1 -1
  233. package/dist/{dossier-6KMKEIXV.js → dossier-5XKNAK6Q.js} +1 -1
  234. package/dist/evidence-BJIID6VT.js +2 -0
  235. package/dist/evidence-presentation-LSFOZGLH.js +2 -0
  236. package/dist/evolve-cmd-GZCUSCEK.js +2 -0
  237. package/dist/evolve-remote-LILOAHYH.js +2 -0
  238. package/dist/{explain-cmd-R67B4YR3.js → explain-cmd-KNDORU2D.js} +1 -1
  239. package/dist/{explain-cmd-235TY7QX.js → explain-cmd-LXIVHGN7.js} +1 -1
  240. package/dist/explore-SA2P3SGX.js +2 -0
  241. package/dist/{explore-context-tty-YXEFT32U.js → explore-context-tty-PERKIWXD.js} +1 -1
  242. package/dist/{explore-entry-V6L5FSP4.js → explore-entry-E6EY3VV3.js} +4 -4
  243. package/dist/{explore-live-N5VBLBUI.js → explore-live-XIWWUV52.js} +1 -1
  244. package/dist/{explore-run-tty-ZZQ33GNA.js → explore-run-tty-M56I23IF.js} +2 -2
  245. package/dist/{extract-bind-BTINHHE5.js → extract-bind-LZ22VFKB.js} +3 -3
  246. package/dist/extract-chat-Z64LEAJ5.js +2 -0
  247. package/dist/{extract-cmd-45OZETCM.js → extract-cmd-46E2XDWZ.js} +2 -2
  248. package/dist/extract-headless-XLS56LMN.js +2 -0
  249. package/dist/{feeder-L55TH2NC.js → feeder-NGWIPZ26.js} +1 -1
  250. package/dist/folder-flags-ZIDJVDKX.js +2 -0
  251. package/dist/gaps-cmd-XYOBJVTO.js +3 -0
  252. package/dist/gate-AK44VDHC.js +2 -0
  253. package/dist/gate-NB5CJMTN.js +2 -0
  254. package/dist/{generate-headless-DAH3HHRQ.js → generate-headless-HXAVEAEZ.js} +2 -2
  255. package/dist/hold-passthrough-JGHWMYDM.js +2 -0
  256. package/dist/{impact-cmd-3VFJAKYK.js → impact-cmd-TJTUFAFO.js} +2 -2
  257. package/dist/index.js +4159 -190
  258. package/dist/ingest-ZHHHBUXR.js +2 -0
  259. package/dist/{ingest-cmd-YSEH5EPU.js → ingest-cmd-OJSKTSQK.js} +3 -3
  260. package/dist/ingest-remote-2WM6PYUW.js +2 -0
  261. package/dist/install-JBWBF3WX.js +2 -0
  262. package/dist/{interactive-bind-P3GTFIZM.js → interactive-bind-SOD7VTAY.js} +4 -4
  263. package/dist/{interactive-remote-PBRQHTAF.js → interactive-remote-7ZSTI66T.js} +1 -1
  264. package/dist/lane-CNGO7LH5.js +2 -0
  265. package/dist/lattice-auth-UQPFQSG7.js +2 -0
  266. package/dist/{lifecycle-cmd-PUNFWKV5.js → lifecycle-cmd-DGIO3VAO.js} +1 -1
  267. package/dist/{list-cmd-RD7YBF4S.js → list-cmd-HQIN3HX4.js} +1 -1
  268. package/dist/{list-commands-UZELZAB3.js → list-commands-OFRRBU3D.js} +1 -1
  269. package/dist/{list-remote-KGKXPCQA.js → list-remote-EFCET42K.js} +1 -1
  270. package/dist/{locks-cmd-LXZ6I4QG.js → locks-cmd-AZKCSGHI.js} +1 -1
  271. package/dist/{logical-ids-D5PFYY4C.js → logical-ids-74PLU3VR.js} +1 -1
  272. package/dist/login-flow-SYKXXDLH.js +2 -0
  273. package/dist/{maintenance-cmd-WRWBCP3R.js → maintenance-cmd-X5247RSJ.js} +1 -1
  274. package/dist/{mobile-prompts-Z7NQHRGP.js → mobile-prompts-I66ENBDW.js} +1 -1
  275. package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
  276. package/dist/{onboarding-ZP4XDYEO.js → onboarding-6HIP3KW6.js} +1 -1
  277. package/dist/open-provider-XDJKT3W3.js +2 -0
  278. package/dist/pdf-convert-YB6PJFMI.js +2 -0
  279. package/dist/persist-recorded-session-RSSMTVF3.js +3 -0
  280. package/dist/phase-seed-ZZSJME7M.js +2 -0
  281. package/dist/pipeline-NTJDH5TC.js +2 -0
  282. package/dist/{policy-commands-TY6WOR73.js → policy-commands-4PUGESCW.js} +1 -1
  283. package/dist/{prepare-target-EVL2QSXA.js → prepare-target-AI3GGZF6.js} +1 -1
  284. package/dist/{pull-cmd-QJQANBAW.js → pull-cmd-NRVB5ZN7.js} +1 -1
  285. package/dist/{pull-route-AIOTLA3D.js → pull-route-FWCZW76M.js} +1 -1
  286. package/dist/readmodel-TRV4E3MW.js +2 -0
  287. package/dist/real-device-run-NQ7RNH7C.js +2 -0
  288. package/dist/{reconcile-cmd-IJTQAJZX.js → reconcile-cmd-7B7THAFJ.js} +4 -4
  289. package/dist/reconcile-deps-UDQBWSLE.js +2 -0
  290. package/dist/{reconcile-remote-23D6SXXT.js → reconcile-remote-3W6ZTO3G.js} +2 -2
  291. package/dist/{recording-banner-MNRMMEX4.js → recording-banner-WVDTWTSE.js} +1 -1
  292. package/dist/registry-PFOSXOIH.js +2 -0
  293. package/dist/remote-entry-BZU4NFNS.js +2 -0
  294. package/dist/{remote-mode-AFNCN6EE.js → remote-mode-NXUKDUXG.js} +1 -1
  295. package/dist/{remote-words-RCNFI2TQ.js → remote-words-JRDDNOZ6.js} +1 -1
  296. package/dist/{require-project-folder-7UH43GHI.js → require-project-folder-3DTI2CVB.js} +1 -1
  297. package/dist/{resolve-run-intent-XEWFYMGN.js → resolve-run-intent-QCL7QXIB.js} +1 -1
  298. package/dist/{resolver-QMPX6RBR.js → resolver-CDF7QKVD.js} +1 -1
  299. package/dist/revert-QKHPCRT6.js +2 -0
  300. package/dist/{review-cmd-2OECKNL5.js → review-cmd-XBK3TGRE.js} +1 -1
  301. package/dist/run-CSYGVV3D.js +2 -0
  302. package/dist/run-YUHHD54J.js +2 -0
  303. package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
  304. package/dist/run-remote-SFR3F2T5.js +2 -0
  305. package/dist/{run-startup-gate-USQFSW47.js → run-startup-gate-QSFJRYUY.js} +1 -1
  306. package/dist/run-test-md-ZSREINDQ.js +20 -0
  307. package/dist/session-worker.js +2 -2
  308. package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
  309. package/dist/{sessions-cmd-LQ2LZQOC.js → sessions-cmd-TLUITRG5.js} +2 -2
  310. package/dist/{sessions-remote-H7CQST42.js → sessions-remote-INO7AWKB.js} +1 -1
  311. package/dist/{skill-installer-LKYY6XFJ.js → skill-installer-7JH5QCJF.js} +1 -1
  312. package/dist/spawner-MQ4XEHIX.js +2 -0
  313. package/dist/{store-KM5MG3XB.js → store-X4UK4AP7.js} +1 -1
  314. package/dist/store-choice-27HDIFTU.js +2 -0
  315. package/dist/{store-guard-34GG2TW2.js → store-guard-ZXKB5DQH.js} +1 -1
  316. package/dist/{store-site-ZSFINU6C.js → store-site-K5NHLI7D.js} +1 -1
  317. package/dist/stream-warnings-GM7YEOVG.js +2 -0
  318. package/dist/sync-cmd-2PCO7LZA.js +2 -0
  319. package/dist/{sync-setup-QQXYO6R4.js → sync-setup-5WQO73Y5.js} +1 -1
  320. package/dist/tcg-generate-DGJD5KSM.js +2 -0
  321. package/dist/testmd-actions-XE2JPQHB.js +2 -0
  322. package/dist/{testmd-sync-PQ4GFKHB.js → testmd-sync-LYHEXWCT.js} +1 -1
  323. package/dist/{tms-client-XWCR7O7J.js → tms-client-J4OCD3EP.js} +1 -1
  324. package/dist/token-refresh-E4FTJVHY.js +2 -0
  325. package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
  326. package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
  327. package/dist/{use-case-ref-NA3IXGQW.js → use-case-ref-44BPIP4N.js} +1 -1
  328. package/dist/{validate-basic-3DX3MMC7.js → validate-basic-66XDPA3S.js} +1 -1
  329. package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
  330. package/dist/verdicts-PVB7TV5S.js +2 -0
  331. package/dist/{version-check-OV6AOVED.js → version-check-SHNVYTMU.js} +1 -1
  332. package/dist/{view-cmd-QDKBBNIU.js → view-cmd-QOB3O6YW.js} +1 -1
  333. package/dist/{walk-session-BAYYPIKN.js → walk-session-WIEROYOT.js} +1 -1
  334. package/dist/with-telemetry-T2PWI5CY.js +2 -0
  335. package/package.json +16 -16
  336. package/dist/ChatSurface-XUV3EQPZ.js +0 -2
  337. package/dist/EvidenceViewOffer-EIANIYN7.js +0 -2
  338. package/dist/FolderPicker-XOA7FTHF.js +0 -2
  339. package/dist/InfoBox-OBH7SUGC.js +0 -2
  340. package/dist/ProjectPicker-6KRLKV4U.js +0 -2
  341. package/dist/SaveSessionPrompt-J2OPDEOO.js +0 -2
  342. package/dist/SingleShotApp-QI4B2TSL.js +0 -2
  343. package/dist/TestMdRunView-I4MV54FB.js +0 -2
  344. package/dist/TestrunEvidenceTable-WEIUSW3E.js +0 -2
  345. package/dist/bridge-SDEP7Y33.js +0 -2
  346. package/dist/chat-committer-FM5NG46O.js +0 -2
  347. package/dist/chat-controller-FWFQVZTB.js +0 -2
  348. package/dist/child-H2YSDFCG.js +0 -2
  349. package/dist/chunk-2EVP636F.js +0 -26
  350. package/dist/chunk-34R7BNZ2.js +0 -2
  351. package/dist/chunk-5T6II7VN.js +0 -7
  352. package/dist/chunk-6K5BEEAJ.js +0 -2
  353. package/dist/chunk-HMQ5M4JJ.js +0 -34
  354. package/dist/chunk-KF4DKXSS.js +0 -2
  355. package/dist/chunk-NOFJXCYP.js +0 -5
  356. package/dist/chunk-SB6P5EQH.js +0 -2
  357. package/dist/chunk-Y6Y6RAY4.js +0 -2
  358. package/dist/commands-QOORPTSI.js +0 -2
  359. package/dist/cover-cmd-3VO6QC5Y.js +0 -2
  360. package/dist/design-committer-Y7R56RFZ.js +0 -2
  361. package/dist/design-headless-HUQOXLZB.js +0 -2
  362. package/dist/device-env-MMGISNHN.js +0 -2
  363. package/dist/dispatch-P2445PUU.js +0 -2
  364. package/dist/evidence-M3JTOJNL.js +0 -2
  365. package/dist/evidence-presentation-DV3DRB4S.js +0 -2
  366. package/dist/evolve-cmd-K3JXACMN.js +0 -2
  367. package/dist/evolve-remote-CUDVV2O2.js +0 -2
  368. package/dist/explore-UDD5FHXW.js +0 -2
  369. package/dist/extract-chat-ABZ5S7UU.js +0 -2
  370. package/dist/extract-headless-ALEFAMVS.js +0 -2
  371. package/dist/folder-flags-HTKJCXKB.js +0 -2
  372. package/dist/gaps-cmd-ROGQWK5X.js +0 -3
  373. package/dist/gate-QA5J7UZA.js +0 -2
  374. package/dist/gate-XFFFX5ZF.js +0 -2
  375. package/dist/hold-passthrough-K5PP26CP.js +0 -2
  376. package/dist/ingest-S5R736ZV.js +0 -2
  377. package/dist/ingest-remote-C6AP2Q7E.js +0 -2
  378. package/dist/install-B26Y2NU4.js +0 -2
  379. package/dist/lane-7IEAE6AC.js +0 -2
  380. package/dist/lattice-auth-7EL4ET3P.js +0 -2
  381. package/dist/login-flow-CHLGQGHK.js +0 -2
  382. package/dist/open-provider-U26BBVUE.js +0 -2
  383. package/dist/pdf-convert-LMKOKLXT.js +0 -2
  384. package/dist/persist-recorded-session-4IRYG5CJ.js +0 -3
  385. package/dist/phase-seed-2H6OXZXT.js +0 -2
  386. package/dist/pipeline-U7D25NST.js +0 -2
  387. package/dist/readmodel-KXCFPL2M.js +0 -2
  388. package/dist/real-device-run-QODMDUXF.js +0 -2
  389. package/dist/reconcile-deps-2CTIFXDR.js +0 -2
  390. package/dist/registry-MZYBLEW2.js +0 -2
  391. package/dist/remote-entry-DW2J56N4.js +0 -2
  392. package/dist/revert-37346WLE.js +0 -2
  393. package/dist/run-JWOHNWA3.js +0 -2
  394. package/dist/run-QFJ6ZRVD.js +0 -2
  395. package/dist/run-remote-66QTUQ2M.js +0 -2
  396. package/dist/run-test-md-7DRWCSQE.js +0 -19
  397. package/dist/spawner-C7NLLM4F.js +0 -2
  398. package/dist/store-choice-4J2NN6OQ.js +0 -2
  399. package/dist/stream-warnings-N4KVVWXV.js +0 -2
  400. package/dist/sync-cmd-3CHSWWWW.js +0 -2
  401. package/dist/tcg-generate-IPD5FQUW.js +0 -2
  402. package/dist/testmd-actions-V7P7BMKE.js +0 -2
  403. package/dist/token-refresh-LR33BKAB.js +0 -2
  404. package/dist/verdicts-7GKZEDHV.js +0 -2
  405. package/dist/with-telemetry-62LW4VFI.js +0 -2
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as rt,c as st}from"./chunk-W3USRQX6.js";import{R as nt}from"./chunk-CB2BWDHG.js";import{a as tt}from"./chunk-JQ64X2TO.js";import{a as Ct}from"./chunk-JIRNI5TB.js";import{a as k}from"./chunk-UTM7D4PI.js";import{b as et}from"./chunk-Z36KVIRR.js";import{b as Z,e as Q}from"./chunk-SB26HQO7.js";import{a as X}from"./chunk-FCD3NYOM.js";import{a as W}from"./chunk-4QTH7VYE.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as jt}from"./chunk-UR6MHSHU.js";import{readFileSync as L,existsSync as H,readdirSync as Ae,mkdirSync as J,writeFileSync as S}from"fs";import{readFile as Lt,unlink as ke}from"fs/promises";import{join as y}from"path";import{existsSync as le,mkdirSync as de,readdirSync as kt,writeFileSync as _e}from"fs";import{join as w}from"path";import{randomUUID as A}from"crypto";var ot=["children","instructions","branches","module_content","true_branch","false_branch"];function D(e){let t=new Map,n=r=>{if(!r||typeof r!="object")return;let i=r;if(Array.isArray(i.operations))for(let s of i.operations){let o=s.operation_id;if(typeof o!="string"||!o)continue;let a=t.get(o)??[];a.includes(i)||a.push(i),t.set(o,a)}for(let s of ot){let o=i[s];Array.isArray(o)?o.forEach(n):o&&typeof o=="object"&&n(o)}};return e.forEach(n),t}function Dt(e,t){if(!t||t.length===0)return;if(t.length===1)return t[0];let n=e.action_params?.script;if(typeof n=="string"&&n.trim()){let r=n.trim(),i=t.find(s=>Ft(s)?.trim()===r);if(i)return i}return t[0]}function Ft(e){let t=e,n=t.script_content??t.js_snippet;return typeof n=="string"?n:void 0}function F(e,t){let n=new Map;for(let r of e){let i=Dt(r,r.action_id?t.get(r.action_id):void 0);if(!i)continue;let s=n.get(i)??[];s.push(r),n.set(i,s)}return n.size===0?null:[...n].map(([r,i])=>$t(r,i))}function at(e,t){let n=D(t.authoredInstructions),r=[];for(let i of e){if(i.flatIndex===void 0||!t.replayOnlyFlatIndices.has(i.flatIndex))continue;let s=F(i.records,n);s&&r.push(...s)}return r}function ct(e,t){let n=new Map(t.map(a=>[a.instruction_id,a])),r=[],i=a=>{if(!a||typeof a!="object")return;let c=a.instruction_id,u=typeof c=="string"?n.get(c):void 0;return u&&r.push(c),u},s=a=>{if(!a||typeof a!="object")return;let c=a;for(let u of ot){let l=c[u];if(Array.isArray(l))o(l);else if(l&&typeof l=="object"){let _=i(l);_&&(c[u]=_),s(_??l)}}},o=a=>{for(let c=0;c<a.length;c++){let u=i(a[c]);u&&(a[c]=u),s(u??a[c])}};return o(e),r}function Bt(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function j(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function Ut(e){return typeof e=="string"?"string":typeof e=="boolean"?"bool":typeof e=="number"?Number.isInteger(e)?"int":"float":Array.isArray(e)?"list":e==null?"NoneType":"JSON"}function C(e,t,n){let r=e.user_variables,i=typeof r=="string",s;try{s=i?JSON.parse(r):r??[]}catch{return}if(!Array.isArray(s)||s.length===0)return;let o=s.find(a=>t&&a.name===t)??(s.length===1?s[0]:void 0);o&&(o.value=n,o.value_type=Ut(n),e.user_variables=i?JSON.stringify(s):s)}function it(e){e.user_variables!==void 0&&(e.user_variables=typeof e.user_variables=="string"?"[]":[])}function Mt(e,t){let n=e.operations??[],r=new Set(t.map(s=>s.action_id).filter(Boolean)),i=n.filter(s=>r.has(s.operation_id));return i.length>0?i:n.length===1?n:[]}function zt(e){let t=e.error??"Script execution failed";return{error:t,error_code:"SCRIPT_EXECUTION_ERROR",error_message:t,reason:t}}function $t(e,t){let n=structuredClone(e),r=t[0],i=t[t.length-1];n.status=t.find(o=>o.status!=="success")?.status??r.status,n.start_timestamp=r.timestamp??n.start_timestamp,n.end_timestamp=Bt(i)||n.end_timestamp;let s=Mt(n,t);for(let o of s)o.status=n.status,o.operation_start=n.start_timestamp,o.operation_end=n.end_timestamp;switch(n.content_type){case"api":{let o=i.action_params?.api_data?.response;if(o&&typeof o=="object")for(let a of[n,...s])a.api_data={...a.api_data??{},response:o},C(a,i.output_variable,o);break}case"script":{let o=i.output_variable??n.output_variable_name;if(n.status!=="success"){let a=zt(i);n.code_error=a,it(n);for(let c of s)c.execution_result=a,c.code_error=a,it(c)}else if(i.output_value!=null){let a=j(i.output_value);C(n,o,a);for(let c of s)c.execution_result={value:a},C(c,o,a)}break}case"db_query":{i.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:j(i.output_value)});break}case"screenshot_command":{let o=j(i.output_value);o&&typeof o=="object"&&(n.smartui_results=o);break}case"network_assertion":case"network_query":break;default:break}return n}var Vt="/home/kaneai/Downloads";function O(e){return`${Vt}/${e}`}function dt(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}function z(e){return"file."+e}function N(e){let t=e?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc",...t.alias?{alias:t.alias}:{}}}function _t(e){return e?e.includes(`
3
+ `)?e.split(`
4
+ `).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function B(e){return typeof e=="string"&&e.includes("{{secrets.")}var qt={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",clear:"CLEAR",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",js_dialog:"JS_DIALOG",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD",device_control:"DEVICE_CONTROL",device_control_query:"DEVICE_CONTROL_QUERY"},pt={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},Gt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function U(e,t){return e!=="fill"&&!(e==="type"&&t.delay_requested===!0)?0:typeof t.delay_ms=="number"&&t.delay_ms>0?t.delay_ms:0}function gt(e,t){if(U(e,t?.action_params??{})&&(e==="fill"||(t?.selectors?.length??0)>0))return"FILL";if(e==="analyze"){let r=t?.action_params?.analyzer_type??"";return pt[r]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=qt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function ft(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function mt(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function Kt(e){let t=e.output_variable??"";if(!t)return"[]";let r={...mt(e)};return delete r.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||A().replace(/-/g,"").slice(0,8),value:r,variable_description:"API Response"}])}function Ht(e,t,n){let r=e.action_params??{},i=Gt.has(t)?"Vision Agent":"Operation Agent",s={operation_type:t};t==="OPEN"&&(s.url=r.url??""),t==="SET_VARIABLE"&&(s.variable_name=e.output_variable??r.key??"",s.variable_value=e.output_value??"");let o=t==="UPLOAD_FILE"?N(r):null;o&&(s.value=O(o.name));let a={},c={},u=e.action_instruction??"",l=r.text??"",_=r.url??"",p=[["intent",u],["value",l],["url",_]];for(let[h,v]of Object.entries(n)){let I=String(v);if(h.startsWith("secrets."))for(let[b,E]of p)E.includes(I)&&(c[b]=h);for(let[b,E]of p)E.includes(I)&&!(b in a)&&(a[b]=E)}o?.alias&&(a.value=`{{${z(o.alias)}}}`);let d=e.action_type,g={operation:e.action_instruction??"",agent:i,operation_dict:s,reasoning:d==="analyze"?r.query??"":e.intent??e.action_instruction??"",variable:a,secrets:c,params:{}};d==="analyze"&&typeof r.code=="string"&&r.code&&(g.code=r.code),d==="analyze"&&typeof r.code_js=="string"&&r.code_js&&(g.code_js=r.code_js),d==="analyze"&&typeof r.condition_expression=="string"&&r.condition_expression&&(g.condition_expression=r.condition_expression),r.uses_websocket===!0&&(g.uses_websocket=!0),r.uses_sse===!0&&(g.uses_sse=!0),d==="analyze"&&r.analyzer_type==="textual_visual"&&(typeof r.wrapped_js=="string"&&(g.wrapped_js=r.wrapped_js),Array.isArray(r.locators)&&(g.locators=r.locators),typeof r.operator=="string"&&(g.operator=r.operator),Array.isArray(r.transforms)&&(g.transforms=r.transforms),typeof r.query=="string"&&(g.query=r.query),typeof r.expected_value=="string"&&(g.expected_value=r.expected_value),typeof r.needs_unit_conversion=="boolean"&&(g.needs_unit_conversion=r.needs_unit_conversion),typeof r.condition=="string"&&(g.condition=r.condition));let m={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[d];return m&&r[m]!==void 0&&(g[m]=r[m]),d==="set_clipboard"&&typeof r.html=="string"&&r.html&&(g.html=r.html),g}function T(e){let t=e.assertion_tree;return t&&typeof t=="object"&&Object.keys(t).length>0?t:Array.isArray(e.sub_results)?e:{}}function Jt(e){let t=T(e);if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(i=>i.passed===!0):n.every(i=>i.passed===!0)}function ht(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Yt(e){let t=T(e),n=t.sub_results??[],r=ht(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:r,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Wt(e){let t=e.action_params??{},n=T(t),r=n.sub_results??[],i=ht(r);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:r,sub_checks:i,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Xt(e,t,n,r){let i=e.visual_data;if(!i||i.x==null||i.y==null)return null;let s=t?`${t}/test_screenshots`:"";return{x:i.x,y:i.y,confidence:0,bbox:i.bbox??null,bbox_source:i.bbox?"accessibility_tree":"fallback",viewport_width:i.viewport_width??1280,viewport_height:i.viewport_height??800,scale_factor:null,raw_image_url:s?`${s}/untagged_screenshot/${n}.${r?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Zt(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function Qt(e){return/^(android|ios)_native$/i.test(e.platform??"")}function bt(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function te(e,t,n){let r={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return r;let i=t.target_selectors,s={};typeof t.direction=="string"&&t.direction&&(s.direction=t.direction,typeof t.fraction=="number"&&(s.fraction=t.fraction));let o=a=>typeof t[a]=="number"?Math.trunc(t[a]):null;return{selector_target:Array.isArray(i)&&i.length>0?bt(i,n):"",drag_displacement:s,hold_duration_ms:o("hold_duration_ms"),move_duration_ms:o("move_duration_ms"),hold_at_destination_ms:o("hold_at_destination_ms")}}function ut(e,t="",n){let r=e.action_type,i=gt(r,e),s=e.action_params??{},o=e.coordinates??null,a=e.selectors??null,c=!!(a&&a.length>0),u=Qt(e),l=te(r,s,u),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??A(),f=A(),m=ft(_,p),h="",v="";if(r==="navigate")v=s.url??"",h=v;else if(r==="type"||r==="fill")h=s.text??"";else if(r==="press_key")h=s.key??"";else if(r==="wait")h=String(s.ms??s.timeout_ms??"");else if(r==="evaluate_js")h=s.script??"";else if(r==="js_dialog")h=s.prompt_text??"";else if(r==="upload_files"){let Y=N(s);Y&&(h=O(Y.name))}else r==="analyze"&&i==="SET_VARIABLE"&&(h=e.output_value??"");let I="";r==="go_back"?I="back":r==="go_forward"&&(I="forward");let b=e.action_instruction??"",E=B(h)||B(v)||B(b),x=Ht(e,i,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:i,name:"",target:"",value:h,message:"",operation_dict:"",frame:Zt(e.frame_info),surface:typeof s.surface=="string"?s.surface:"",...U(r,s)?{delay_ms:U(r,s)}:{},frame_path:typeof s.frame_path=="string"?s.frame_path:"",grounded_by:typeof s.grounded_by=="string"?s.grounded_by:"",error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t&&r!=="js_dialog"?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:v,navigation_direction:I,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:i==="ASSERTION"?Jt(s):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(s.tab_index??""),tab_identifier:String(s.tab_identifier??""),scroll_value:s.amount??1,scroll_direction:s.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:r==="evaluate_js"?s.script??"":"",code_error:"",hide:E,dismiss_dialog:!1,use_v2_mobile_tagging:u,multiple_inputs:!1,dialog_action:r==="js_dialog"?s.action??"":"",dialog_type:r==="js_dialog"?s.dialog_type??"":"",is_coordinates_used_for_interaction:o!==null&&!c,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:c?null:o?.x??null,y_coord:c?null:o?.y??null,target_x_coord:s.target_x??null,target_y_coord:s.target_y??null,source_description:s.source_description??null,target_description:s.target_description??null,use_coordinates:o!==null&&!c,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:c?bt(a,u):"",selector_target:l.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:i==="ASSERTION"?Yt(s):s.expression_tree??{},assertion_tree:i==="ASSERTION"?T(s):s.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(s.click_count??1)>=2?{kind:"multi_click",frequency:s.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:i==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:l.drag_displacement,hold_duration_ms:l.hold_duration_ms,move_duration_ms:l.move_duration_ms,hold_at_destination_ms:l.hold_at_destination_ms,start_coordinates:s.source_coordinates?{x:s.source_coordinates[0],y:s.source_coordinates[1]}:{},end_coordinates:s.target_coordinates?{x:s.target_coordinates[0],y:s.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:r==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:r==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Xt(e,t,g,n),reasoning:r==="analyze"?s.query??"":e.intent??e.action_instruction??""}}function lt(e,t){let n=e.action_type,r=gt(n,e),i=e.timestamp??"",s=e.duration_ms??0,o=ft(i,s),a=r==="ASSERTION"||r==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:r,error:null,parent_instruction_id:"",classification_layer_resp:r==="ASSERTION"?Wt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:i,end_timestamp:o,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?Kt(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:mt(e)}:{},params_used:!1,hard_assertion:r==="ASSERTION"?e.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function ee(e,t=[]){let n=e.action_params??{},r=n.branches??[],i=n.winning_index??-1,s=n.sub_results??[],o={};for(let c of s){let u=c.sub_results;if(u)for(let l of u){let _=l.store_key;_&&(o[_]=l)}}let a=r.map((c,u)=>{let l=u===i,_=(c.sub_checks??[]).map(p=>{let d=o[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&c.condition&&s.length>0){let d=s.find(g=>g.branch_index===u)?.sub_results??[];d.length>0&&(_=d.map(g=>({description:g.description??c.condition,store_key:g.store_key??"",expected_value:g.expected??"true",stored_value:g.extracted_value??void 0,operator:g.operator??"equals",transforms:g.transforms??[]})))}return{branch_index:u,condition:c.condition??null,branch_type:c.branch_type??"sub_objective",passed:l,sub_objective:null,custom_event:c.custom_event??null,children:l?t:[],sub_checks:c.condition?_:[],composite_operator:c.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${A().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:i,branches:a,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function yt(e,t,n){for(let r of e)r.content_type==="instruction"&&"generative_id"in r&&(r.generative_id=t,r.generative_objective=n)}function M(e,t="",n,r){let i=[],s=0;for(;s<e.length;){let o=e[s],a=o.action_type;if(!r?.keepFailedActions&&o.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&a!=="js_dialog"&&!(o.until_condition&&!o.error)){s+=1;continue}if(a==="analyze"&&(!pt[o.action_params?.analyzer_type??""]||o.action_params?.analyzer_type==="textual_visual"&&o.action_params?.code)){s+=1;continue}if(a==="child_agent_start"){let c=o.action_params?.child_id??"",u=o.action_params?.objective??"",l=[];s+=1;let _=1,p="error",d;for(;s<e.length&&_>0;){let E=e[s],x=E.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=E.status??"success",d=E,s+=1;break}_>0&&l.push(E),s+=1}let g=M(l,t,n);yt(g,c,u);let f=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,v=d?.action_params?.summary??null,I=d?.action_params?.one_liner??null,b=p==="error";i.push({content_type:"generative_block",instruction_id:`generative_block_${c}`,generative_id:c,objective:u,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:_t(v),one_liner:I??null});continue}else if(a==="child_agent_end"){s+=1;continue}else if(a==="if_else"){s+=1;let c=[];for(;s<e.length&&e[s].action_type==="child_agent_start";){let u=e[s],l=u.action_params?.child_id??"",_=u.action_params?.objective??"",p=[];s+=1;let d=1,g="error";for(;s<e.length&&d>0;){let m=e[s];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){g=m.status??"success",s+=1;break}d>0&&p.push(m),s+=1}let f=M(p,t,n);c.push(...f)}i.push(ee(o,c));continue}else if(a==="query_tool"){s+=1;continue}else if(o.until_condition){let c=ut(o,t,n),u=lt(o,c),l=typeof o.until_condition_met=="boolean"?o.until_condition_met:o.status==="success";i.push({content_type:"until_block",instruction_id:`until_${A().slice(0,8)}`,condition:o.until_condition,max_retries:o.until_max_retries??10,settle_ms:o.until_settle_ms??500,current_count:0,condition_met:l,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:o.status??"success"})}else{let c=ut(o,t,n),u=lt(o,c);i.push(u)}s+=1}return i}function P(e,t="",n,r){let i=[],s=[],o=r?.passthrough,a=o?D(o.authoredInstructions):null;for(let d of e){if(o&&a&&d.flatIndex!==void 0&&o.replayOnlyFlatIndices.has(d.flatIndex)){let b=F(d.records,a);if(b){for(let E of b)i.push(E),s.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let g=M(d.records,t,n,r);if(g.length===0)continue;let f=A().replace(/-/g,"");yt(g,f,d.objective);let m=g.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,v=h!==null&&!isNaN(h)&&h>=200,I=m||v?"error":"success";i.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:I,children:g,error_message:I==="error"?d.errorMessage??null:null,error_code:I==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:_t(d.summary),one_liner:d.oneLiner??null}),s.push(d.flatIndex)}let c=i.map((d,g)=>({block:d,flat:s[g]})),u=r?.moduleSpans??[],l=r?.blockSpans??[],_=r?.authoredBlocks??[];u.length>0&&(c=Et(c,u,l,_));let p=At(l,u);return p.length>0&&(c=$(c,p,_)),{instructions:c.map(d=>d.block)}}function Et(e,t,n,r){let i=[],s=a=>a===void 0?void 0:t.find(c=>a>=c.flatFrom&&a<=c.flatTo),o=0;for(;o<e.length;){let a=s(e[o].flat);if(!a){i.push(e[o]),o++;continue}let c=[];for(;o<e.length&&s(e[o].flat)===a;)c.push(e[o++]);let u=Et(c,a.children,n,r),l=At(vt(n,a),a.children);l.length>0&&(u=$(u,l,r)),i.push({block:ue(a,u.map(_=>_.block)),flat:c[0].flat})}return i}function It(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function vt(e,t){let n=[];for(let r of e)It(r,t)?n.push(r):n.push(...vt(r.children,t));return n}function At(e,t){let n=[],r=s=>{for(let o of s)n.push(o),r(o.children)};r(t);let i=s=>s.filter(o=>!n.some(a=>It(o,a))).map(o=>({...o,children:i(o.children)}));return n.length>0?i(e):e}function $(e,t,n){let r=[...t].sort((u,l)=>u.flatFrom-l.flatFrom),i=[],s=(u,l)=>{i.push({block:oe(u,l,n),flat:u.flatFrom})},o=(u,l)=>u!==void 0&&u>=l.flatFrom&&u<=l.flatTo,a=0,c=0;for(;c<e.length;){let u=e[c].flat;for(;a<r.length&&u!==void 0&&r[a].flatTo<u;)s(r[a++],[]);let l=a<r.length&&o(u,r[a])?r[a]:void 0;if(!l){i.push(e[c]),c++;continue}let _=[];for(;c<e.length&&o(e[c].flat,l);)_.push(e[c++]);s(l,_),a++}for(;a<r.length;)s(r[a++],[]);return i}function ne(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var re=["children","instructions","branches","module_content","true_branch","false_branch"];function se(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let r=n.pop();if(!r||typeof r!="object")continue;let i=r;if(i.instruction_id===t&&(i.content_type==="conditional_block"||i.content_type==="until_block"))return i;for(let s of re){let o=i[s];Array.isArray(o)?n.push(...o):o&&typeof o=="object"&&n.push(o)}}}function ie(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let i=(Array.isArray(e.branches)?e.branches:[])[n];return i&&Array.isArray(i.children)?i.children:[]}function oe(e,t,n){let r=se(n,e.blockId),i=e.branches.map((s,o)=>{let a=t.filter(l=>l.flat!==void 0&&l.flat>=s.flatFrom&&l.flat<=s.flatTo);e.kind==="while"&&(a=ne(a));let c=$(a,e.children,n).map(l=>l.block);if(c.length>0)return c;let u=ie(r,e.kind,o);return u.length===0&&!s.taken&&console.warn(`[migrator] control-flow: branch ${o} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),u});return e.kind==="if"?ae(e,i,r):ce(e,i[0]??[],r)}function ae(e,t,n){let r=Array.isArray(n?.branches)?n.branches:[],i=V(t.flat()),s=e.branches.map((o,a)=>{let c=r[a];return{branch_index:a,condition:o.branch_type==="else"?null:o.condition,branch_type:o.branch_type,passed:o.taken,sub_objective:null,custom_event:c?.custom_event??null,children:t[a],sub_checks:Array.isArray(c?.sub_checks)?c.sub_checks:[],composite_operator:c?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${A().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:i?"error":"success",resolved_branch_index:e.branches.findIndex(o=>o.taken),branches:s,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:i?.message??"",error_code:i?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function ce(e,t,n){let r=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},i=V(t),s=(o,a)=>n&&n[o]!==void 0?n[o]:a;return{content_type:"until_block",instruction_id:e.blockId||`until_${A().slice(0,8)}`,condition:e.instruction,max_retries:r.max_retries,settle_ms:r.settle_ms,current_count:r.iterations,condition_met:r.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:i?"error":"success",on_exhaust:s("on_exhaust",r.on_exhaust),mode:s("mode",""),check:s("check",""),conditions:s("conditions",[]),connectors:s("connectors",[]),sub_checks:s("sub_checks",[]),composite_operator:s("composite_operator","and")}}function V(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let r="error_message"in t?t.error_message:void 0,i="error_code"in t?t.error_code:void 0;return{message:r??null,code:i??null}}}return null}function ue(e,t){let n=e.meta,r=(u,l="")=>typeof n[u]=="string"?n[u]:l,i=(u,l=!1)=>typeof n[u]=="boolean"?n[u]:l,s=u=>Array.isArray(n[u])?n[u]:[],o=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,a=r("module_id"),c=V(t);return{content_type:nt,instruction_id:`module_block_${a}`,module_id:a,module_version:o,module_instance_id:A(),module_name:r("module_name"),module_description:r("module_description"),module_platform:r("module_platform"),creation_mode:r("creation_mode","Agent"),tms_status:r("tms_status","active"),is_validated:i("is_validated"),is_dirty:e.dirty,enrichment_id:r("enrichment_id"),tags:s("tags"),project_ids:s("project_ids"),link_to_all:i("link_to_all"),status:c?"error":"success",children:t,error_message:c?.message??null,error_code:c?.code??null,update_available:!1,update_info:{}}}function Rt(e,t){let n;try{n=kt(e)}catch{return 0}let r=0,i=n.filter(s=>/^\d+$/.test(s)).sort((s,o)=>Number(s)-Number(o));for(let s of i){let o=w(e,s),a=w(o,"logs");if(!le(a))continue;let c;try{c=kt(a)}catch{continue}let u=c.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),l=[];for(let p of u){let d=t.readActions(w(a,p));d.length&&l.push({objective:t.objective??"",records:d})}if(l.length===0)continue;let{instructions:_}=P(l,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=w(o,"auteur");de(p,{recursive:!0}),_e(w(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),r++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:s,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:s,error:p instanceof Error?p.message:String(p)})}}return r}import{existsSync as pe,readFileSync as ge}from"fs";function Pt(e){try{return pe(e)?JSON.parse(ge(e,"utf-8")):void 0}catch{return}}function q(e,t){if(!e||typeof e!="object")return;let n=e,r=n.project_token;if(typeof r!="string"||!r)return;let i={project_token:r},s=n[t];typeof s=="string"&&s&&(i.project_name=s);let o=n.project_id;return typeof o=="string"&&o&&(i.project_id=o),i}function G(e){if(Array.isArray(e)){for(let r of e){let i=G(r);if(i)return i}return}if(!e||typeof e!="object")return;let t=e,n=t.smartui_results;if(n&&typeof n=="object"){let r=q(n.project,"name");if(r)return r}for(let r of Object.values(t)){let i=G(r);if(i)return i}}function wt(e){for(let t of e.runMetaPaths){let n=Pt(t),r=q(n?.smartui,"project_name");if(r)return r}if(e.authoredBlobPath){let t=Pt(e.authoredBlobPath),n=q(t?.smartui,"project_name");if(n)return n}return G(e.instructions)??{}}var St=jt(Ct(),1);import{createWriteStream as fe}from"fs";import{readFile as me}from"fs/promises";import{join as he,basename as be}from"path";import{tmpdir as ye}from"os";var Ee=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function xt(e){let t=he(ye(),`${be(e)}_artifacts.zip`);return new Promise((n,r)=>{let i=fe(t),s=(0,St.default)("zip",{zlib:{level:6}});i.on("close",()=>n(t)),s.on("error",r),s.pipe(i),s.glob("**/*",{cwd:e,ignore:Ee}),s.finalize()})}async function Ot(e){return me(e)}function Ie(e){if(!e||typeof e!="object")return;let t=e,n=typeof t.message=="string"?t.message:t.error?.message;return typeof n=="string"&&n.trim()?n.trim():void 0}function ve(e){if(!(e instanceof Error)||e.name!=="TmsHttpError")return null;let t=e.status;return typeof t=="number"?{status:t,body:e.body}:null}function qe(e){let t=ve(e);return t?{kind:"tms_refused",status:t.status,message:Ie(t.body)}:{kind:"tms_unreachable",detail:e instanceof Error?e.message:String(e)}}function K(e){if(!e)return"no Test Manager test was created for this session";switch(e.kind){case"tms_refused":return e.message?`${e.message} (HTTP ${e.status})`:e.status===401?"Test Manager didn't accept your login (HTTP 401) \u2014 run `kane-cli login` and try again":e.status>=500?`Test Manager had an error (HTTP ${e.status}) \u2014 try again later`:`Test Manager refused to create the test (HTTP ${e.status})`;case"tms_unreachable":return`Test Manager couldn't be reached${e.detail?` (${e.detail})`:""} \u2014 try again later`;case"no_cloud_app":return"the app under test wasn't uploaded to LambdaTest, so Test Manager has no build to file this test under";case"signed_out":return"you're not signed in \u2014 run `kane-cli login` to save runs to Test Manager"}}function Ge(e){return`This run won't be saved to Test Manager: ${K(e)}.`}function Nt(e,t){let n=t?.trim()?` (${t.trim()})`:"";switch(e){case"expired":return`Not saved to Test Manager: this test's edit session expired before the save${n}. Run it again to save.`;case"base_mismatch":return`Not saved to Test Manager: someone saved a newer version of this test while this run was going${n}. Pull the latest version and run it again.`;case"lock_mismatch":return`Not saved to Test Manager: another session holds this test for editing${n}.`;case"not_found":return`Not saved to Test Manager: the version this run was saving was not found${n}. Run it again to save.`;case"auth":return`Not saved to Test Manager: your account isn't allowed to save this test${n}. Check your login and your KaneAI access in this organization.`;case"network":return`Not saved to Test Manager: Test Manager couldn't be reached${n}. Try again later.`;case"bundle_sync_failed":return`Not saved to Test Manager: the test files couldn't be uploaded before saving${n}, so no new version was committed. The local recording is kept \u2014 run again with --push once fixed.`;default:return`Not saved to Test Manager: committing the new version failed (${e??"unknown"}${t?.trim()?`: ${t.trim()}`:""}).`}}async function Re(e,t){return Lt(et(e,t))}function Pe(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var we=[1e3,2e3,4e3],Tt=class{config;controller;testId;constructor(t){this.config=t,this.controller=new X(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,r,i){this.config.log?.(t,n,r,i)}async execute(){let{onProgress:t}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available",{save_blocker:this.config.saveBlocker?.kind??null}),{success:!1,testId:null,error:`Not saved to Test Manager: ${K(this.config.saveBlocker)}.`};let n=this.config.evidence,r=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let a=this.collectNdjsonPerRun(),c=a.reduce((f,m)=>f+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:c,run_groups:a.length});let u=this.loadReplayOnlyPassthrough(),{instructions:l}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...u?{passthrough:u}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:l.length});let _=this.buildExecutionEnvelope(l),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=y(this.config.sessionDir,"execution.json");S(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=y(g,"auteur");J(f,{recursive:!0}),S(y(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:y(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)r=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await xt(this.config.sessionDir),m=await Ot(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await ke(f).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let a=this.collectNdjsonPerRun(),c=this.loadReplayOnlyPassthrough(),{instructions:u}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...c?{passthrough:c}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},l=this.buildExecutionEnvelope(u),_=y(this.config.sessionDir,"execution.json");S(_,JSON.stringify(l,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=y(p,"auteur");J(d,{recursive:!0});let g=this.readAuthoredExecution(),f=g?this.refreshReplayOnlyInPack(g,a,c):null;S(y(d,"execution.json"),f?.raw??JSON.stringify(l,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:y(d,"execution.json"),source:f?f.refreshed.length>0?"authored+replay_results":"authored":"run_envelope",...f&&f.refreshed.length>0?{refreshed_instruction_ids:f.refreshed}:{}}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(a){let c=a instanceof Error?a.message:String(a);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:c}),t("atomic_replace","failed",c),a}}else t("atomic_replace","skipped");let i,s;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let a=await this.config.onCommitLock();if(a.ok)i=a.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:i??"none",trigger:a.trigger??null,test_instance_id:a.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:a.reason,message:a.message}),t("commit_lock","failed",`${a.reason??"unknown"}: ${a.message??""}`),{success:!1,testId:this.testId,error:Nt(a.reason,a.message)}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let a=new Q(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),c=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective],u={commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:c,...this.config.assuranceStamp?{assurance:this.config.assuranceStamp}:{}},l;try{l=await this.stop(a,u)}catch(_){if(!this.config.attachedStop)throw _;let p=_ instanceof Error?_.message:String(_);this.log("error","PIPELINE_FINALIZE_NOT_SAVED","Attached test's stop did not finalize after its retries",{test_id:this.testId,error:p}),t("finalize","failed",p);try{await this.config.onFinalizeGaveUp?.()}catch(d){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after a stop that did not finalize failed",{error:String(d)})}return{success:!1,testId:this.testId,error:`finalize failed: ${p}`,notSaved:!0}}if(i=l.testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:i??"none",commit_id:l.commit_id??null}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(i,l.commit_id)}catch(_){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(_)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(i&&this.config.shareApiBaseUrl)try{s=await this.generateShareLink(i),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:s})}catch(a){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(a)})}if(n&&r){let a=null;t("zip","running");try{await n.sealFn({testcaseId:i,shareId:s}),a=n.sealedPackPath?await Lt(n.sealedPackPath):await Re(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(a.length/1024/1024).toFixed(1)})}catch(c){let u=c instanceof Error?c.message:String(c);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:u})}if(a){t("zip","done",`${(a.length/1024/1024).toFixed(1)}MB`),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[Pe(n.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:c.urls.artifacts?.blob_url,blob_url:c.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(a.length/1024/1024).toFixed(1),blob_size_kb:+(r.length/1024).toFixed(1)}),await Promise.all([k(c.urls.artifacts.upload_url,a,"application/zip"),k(c.urls.blob.upload_url,r,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(r.length/1024).toFixed(1)}),await k(c.urls.blob.upload_url,r,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let o;if(this.config.codeExport?.enabled&&i){let a=!1;try{await this.triggerCodeExport(i),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),a=!0}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),t("code_export","failed",`trigger failed: ${u}`)}if(a){t("code_export","running","Waiting for code generation\u2026");try{o=await this.pollAndDownloadCode(i,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),t("code_export","done",o)}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),t("code_export","failed",u)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:i,shareId:s,codeExportDir:o}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async stop(t,n){let r=this.config.attachedStop?this.config.stopRetryDelaysMs??we:[];for(let i=0;;i++)try{return await t.endTest(this.testId,n)}catch(s){if(!(s instanceof Z&&(s.status===null||s.status>=500)&&i<r.length))throw s;this.log("warn","PIPELINE_FINALIZE_RETRY","Attached test's stop sent again",{attempt:i+1,status:s.status}),await new Promise(a=>setTimeout(a,r[i]))}}async runCodeExport(t,n){let r=n??this.config.onProgress,i=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),i=!0}catch(s){let o=s instanceof Error?s.message:String(s);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:o}),r("code_export","failed",`trigger failed: ${o}`)}if(i){r("code_export","running","Waiting for code generation\u2026");try{let s=await this.pollAndDownloadCode(t,r);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),r("code_export","done",s),s}catch(s){let o=s instanceof Error?s.message:String(s);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:o}),r("code_export","failed",o);return}}}deriveArchivedAttemptBlobs(t){try{let n=Rt(t,{readActions:r=>this.readNdjsonFromFile(r),buildBlob:r=>this.buildExecutionEnvelope(r),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(r,i,s,o)=>this.log(r,i,s,o)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],r=this.config.runMetadata??[],i=this.config.evidence??this.config.evidenceRead;for(let s=0;s<this.config.runDirs.length;s++){let o=this.config.runDirs[s],a=n[s]||this.config.firstObjective,c=r[s],u=i?this.readNdjsonFromFile(y(i.packTestDir,"logs",`${i.runIndices?.[s]??s}-actions.ndjson`)):this.readNdjsonFromDir(o);if(u.length>0){let l=i?.runIndices?.[s]??s,_=this.config.runFlatIndex?.[l];t.push({objective:a,records:u,..._!==void 0?{flatIndex:_}:{},resultCode:c?.resultCode,reasonCode:c?.reasonCode,errorMessage:c?.errorMessage,summary:c?.summary,oneLiner:c?.oneLiner})}}if(t.length===0){let s=y(this.config.sessionDir,"runs");if(H(s))try{let a=Ae(s,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name).sort();for(let c of a){let u=y(s,c),l=this.readNdjsonFromDir(u);l.length>0&&t.push({objective:this.config.firstObjective,records:l})}}catch{}}return t}readNdjsonFromDir(t){let n=[y(t,"run-test","actions.ndjson"),y(t,"actions.ndjson")];for(let r of n)if(H(r))return this.readNdjsonFromFile(r);return[]}readNdjsonFromFile(t){let n=[];if(!H(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let r=L(t,"utf-8");for(let i of r.split(`
5
+ `)){let s=i.trim();if(s)try{n.push(JSON.parse(s))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},i=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:i,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let s=i?await this.config.authResolver.fetch(n,r):await R(n,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!s.ok)throw new Error(`Share link API failed: ${s.status} ${await s.text()}`);let o=await s.json();if(!o.shareId)throw new Error("Share link API returned no shareId");return o.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:r}=rt({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(r)},s=this.config.authResolver?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!s.ok)throw new Error(`Code export failed: ${s.status} ${await s.text()}`)}async pollAndDownloadCode(t,n){let r=st({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),i=this.config.exitTimeoutMs??3e5,s=5e3,o=Date.now()+i;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:r,timeout_ms:i});let a=(c,u)=>this.config.authResolver?this.config.authResolver.fetch(c,u):R(c,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<o;){let c=await a(r,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok){let d=await c.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:c.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${c.status}`)}let l=(await c.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!l){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(s);continue}let _=l.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:l.status}),n("code_export","running","Generating code\u2026"),await this.sleep(s);continue}if(!l.url||l.url.length===0)throw new Error(`Code export status=${l.status} but no files returned`);let p=this.config.codeExportDir??y(this.config.sessionDir,"code-export");J(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:l.url.length,dir:p}),n("code_export","running",`Downloading ${l.url.length} files\u2026`);for(let d of l.url){let g=y(p,d.file_name),f=await R(d.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:f.status});continue}let m=await f.text();S(g,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:m.length})}return p}throw new Error("Code export timed out")}sleep(t){return new Promise(n=>setTimeout(n,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:W(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=L(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}refreshReplayOnlyInPack(t,n,r){if(!r)return{raw:t,refreshed:[]};let i=at(n,r);if(i.length===0)return{raw:t,refreshed:[]};let s=JSON.parse(t);if(!Array.isArray(s.instructions))return{raw:t,refreshed:[]};let o=ct(s.instructions,i);return o.length===0?{raw:t,refreshed:o}:{raw:JSON.stringify(s,null,2),refreshed:o}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(L(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(L(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}smartuiProject(t){let n=this.config.evidence??this.config.evidenceRead,r=this.config.runDirs.map((s,o)=>n?y(n.packTestDir,"logs",`${n.runIndices?.[o]??o}-run_meta.json`):y(s,"run_meta.json"));return{...wt({runMetaPaths:r,authoredBlobPath:this.config.replayOnlyPassthrough?.authoredExecutionPath??this.config.authoredExecutionPath,instructions:t})}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(u=>u==="passed")?"success":"error",r=this.config.variableIds??{},i=[];if(this.config.variables)for(let[u,l]of Object.entries(this.config.variables)){if(l.secret||tt(l))continue;let _=u.startsWith("global.")?u.slice(7):u;i.push({id:r[_]??0,name:_,value:l.value,session_value:l.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let s=[],o=u=>{let l=s.find(_=>_.name===u.name);l?l.value=u.value:s.push(u)},a=[],c=new Set;for(let u of this.collectNdjsonPerRun())for(let l of u.records)if(l.output_variable&&l.output_value!=null&&o({name:l.output_variable,value:String(l.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),l.action_type==="upload_files"){let _=N(l.action_params);if(_){let p=_.media_id||_.media_url;if(!c.has(p)){c.add(p),a.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type,..._.alias?{alias:_.alias}:{}});let d=O(_.name);_.alias?o({name:z(_.alias),type:"file",value:d,value_type:"string",scope:_.alias.startsWith("local.")?"local":"global",media_id:_.media_id}):o({name:dt(_.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:a,test_params:this.config.testParams??[],test_level_variables:JSON.stringify(s),test_global_variables:i,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:this.config.environmentId??0,environment:"",mobile_browser:!1,native_popups:[],smartui:this.smartuiProject(t),module_index:0}}};export{qe as a,Ge as b,Re as c,Pe as d,we as e,Tt as f};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S}from"./chunk-FPVGA6XT.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as b,b as c,j as x}from"./chunk-33DWJV67.js";import{a as $}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-QMOGBKJM.js";import{e as y}from"./chunk-UR6MHSHU.js";var T=y($(),1);var n=y(R(),1);function k(e){return e.caseTc!==void 0&&!e.anyAuthorStepRan&&!e.degradedReadonly&&!e.lockHeld}function A(e){let t=e.decisions.filter(a=>a.kind==="replay").length,l=e.decisions.filter(a=>a.kind==="author").length,p=e.outcomes.filter(a=>a.status==="passed").length,f=e.outcomes.filter(a=>a.status==="failed").length,h=e.outcomes.filter(a=>a.status==="skipped").length,s=o.green,u;e.cancelled||e.overallStatus==="interrupted"?(s=o.orange,u="CANCELLED"):e.overallStatus==="failed"?(s=o.red,u="FAILED"):u="PASSED";let r=`${u} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${f} failed, ${h} skipped)`,C=`${t} replay \xB7 ${l} author`,v=e.retryTriggered,_="yes \u2014 healed after a replay miss",i,m=o.dim;if(e.cancelled)i="\u2013 not committed (cancellation)";else if(e.uploadResult?.notSaved)i=e.caseTc?`\u2717 not pushed to ${e.caseTc}`:"\u2717 not pushed",m=o.red;else if(e.overallStatus==="failed")i="\u2013 not committed (run failed)",m=o.red;else if(!e.shouldCommit)e.isFirstRun?i="\u2013 not committed (first run skipped commit)":k(e)?i=`\u2013 ${e.caseTc} unchanged: every step replayed`:e.lockHeld?i="\u2013 not committed":i="\u2013 not committed (readonly fallback / no lock)";else if(e.committed===!1&&!e.uploadResult?.testcaseId)i="\u2013 not committed (commit did not land)",m=o.red;else{let a=e.uploadResult?.testcaseId;i=e.caseTc?`\u2713 pushed to ${e.caseTc}`:a?`\u2713 pushed (testcase=${a})`:"\u2713 pushed",m=o.green}let D=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",d,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success||e.uploadResult?.notSaved?(d="\u2713 TMS",g=o.green):e.uploadResult?(d=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):d="\u2013 not run":d="\u2013 skipped (--local or no auth)",{resultLine:{color:s,text:r},breakdown:C,showRetries:v,retriesText:_,commitText:i,commitColor:m,artifactsText:D,uploadText:d,uploadColor:g}}function O(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,f=e.outcomes.filter(r=>r.status==="failed").length,h=e.outcomes.filter(r=>r.status==="skipped").length,s,u=!1;return e.cancelled?s="cancellation":e.overallStatus==="failed"?s="run_failed":e.shouldCommit&&(e.committed===!0||e.uploadResult?.testcaseId)?(s="ok",u=!0):!e.shouldCommit&&!e.isFirstRun&&k(e)?s="unchanged":!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?s="readonly_fallback":s="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:f,skipped:h,replay_decisions:t,author_decisions:l},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:u,reason:s,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function B({data:e}){let t=A(e),l=[{label:"result",value:(0,n.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,n.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"adaptive heal",value:(0,n.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,n.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,n.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,n.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,n.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function U({data:e}){let{exit:t}=x();return(0,T.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,n.jsx)(b,{flexDirection:"column",children:(0,n.jsx)(B,{data:e})})}export{A as a,O as b,B as c,U as d};
2
+ import{a as S}from"./chunk-YVVFXBT5.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as b,b as c,j as x}from"./chunk-33DWJV67.js";import{a as $}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-J4FIESTB.js";import{e as y}from"./chunk-UR6MHSHU.js";var T=y($(),1);var n=y(R(),1);function k(e){return e.caseTc!==void 0&&!e.anyAuthorStepRan&&!e.degradedReadonly&&!e.lockHeld}function A(e){let t=e.decisions.filter(a=>a.kind==="replay").length,l=e.decisions.filter(a=>a.kind==="author").length,p=e.outcomes.filter(a=>a.status==="passed").length,f=e.outcomes.filter(a=>a.status==="failed").length,h=e.outcomes.filter(a=>a.status==="skipped").length,s=o.green,u;e.cancelled||e.overallStatus==="interrupted"?(s=o.orange,u="CANCELLED"):e.overallStatus==="failed"?(s=o.red,u="FAILED"):u="PASSED";let r=`${u} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${f} failed, ${h} skipped)`,C=`${t} replay \xB7 ${l} author`,v=e.retryTriggered,_="yes \u2014 healed after a replay miss",i,m=o.dim;if(e.cancelled)i="\u2013 not committed (cancellation)";else if(e.uploadResult?.notSaved)i=e.caseTc?`\u2717 not pushed to ${e.caseTc}`:"\u2717 not pushed",m=o.red;else if(e.overallStatus==="failed")i="\u2013 not committed (run failed)",m=o.red;else if(!e.shouldCommit)e.isFirstRun?i="\u2013 not committed (first run skipped commit)":k(e)?i=`\u2013 ${e.caseTc} unchanged: every step replayed`:e.lockHeld?i="\u2013 not committed":i="\u2013 not committed (readonly fallback / no lock)";else if(e.committed===!1&&!e.uploadResult?.testcaseId)i="\u2013 not committed (commit did not land)",m=o.red;else{let a=e.uploadResult?.testcaseId;i=e.caseTc?`\u2713 pushed to ${e.caseTc}`:a?`\u2713 pushed (testcase=${a})`:"\u2713 pushed",m=o.green}let D=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",d,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success||e.uploadResult?.notSaved?(d="\u2713 TMS",g=o.green):e.uploadResult?(d=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):d="\u2013 not run":d="\u2013 skipped (--local or no auth)",{resultLine:{color:s,text:r},breakdown:C,showRetries:v,retriesText:_,commitText:i,commitColor:m,artifactsText:D,uploadText:d,uploadColor:g}}function O(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,f=e.outcomes.filter(r=>r.status==="failed").length,h=e.outcomes.filter(r=>r.status==="skipped").length,s,u=!1;return e.cancelled?s="cancellation":e.overallStatus==="failed"?s="run_failed":e.shouldCommit&&(e.committed===!0||e.uploadResult?.testcaseId)?(s="ok",u=!0):!e.shouldCommit&&!e.isFirstRun&&k(e)?s="unchanged":!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?s="readonly_fallback":s="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:f,skipped:h,replay_decisions:t,author_decisions:l},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:u,reason:s,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function B({data:e}){let t=A(e),l=[{label:"result",value:(0,n.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,n.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"adaptive heal",value:(0,n.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,n.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,n.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,n.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,n.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function U({data:e}){let{exit:t}=x();return(0,T.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,n.jsx)(b,{flexDirection:"column",children:(0,n.jsx)(B,{data:e})})}export{A as a,O as b,B as c,U as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as A}from"./chunk-SMXABALN.js";import{a as _}from"./chunk-X3J4CC27.js";import{e as B}from"./chunk-6K5BEEAJ.js";import{a as R}from"./chunk-A3TCFSCK.js";import{a as k}from"./chunk-GGV336P5.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as c}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{z as l}from"./chunk-QMOGBKJM.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,s,y,m){return{id:n,label:`${s} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:s,currentFolderId:y,env:m,onSelect:w,onCancel:x}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,h]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),b=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let i=await T.listFolders(s);yield{page:1,folders:i,totalLoaded:i.length,done:!0}})();for await(let i of F){if(d(!1),i.totalLoaded===0){b.current=!0,h("naming"),g(!1);return}M(i.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),i.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,s,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!s){f("No project selected \u2014 pick a project first");return}f(null),h("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),i=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(s,r);w(i.id,i.name)}catch(a){f(a instanceof Error?a.message:String(a)),h("naming")}})()},[n,s,m,w]),H=(0,t.useCallback)(()=>{v(""),f(null),b.current?x():h("list")},[x]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(c,{color:l.orange,bold:!0,children:"Create new folder"}),b.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(c,{color:l.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(c,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{b.current=!1,h("naming")},extraHint:"new",onSelect:o=>{let r=o.label.split(" (")[0];w(o.id,r)},onCancel:x})}export{X as a,W as b};
2
+ import{c as A}from"./chunk-SMXABALN.js";import{a as _}from"./chunk-LXK4B2FE.js";import{e as B}from"./chunk-SB26HQO7.js";import{a as R}from"./chunk-YCVEI7BT.js";import{a as k}from"./chunk-ZCBOHWN3.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as c}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{z as l}from"./chunk-J4FIESTB.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,s,y,m){return{id:n,label:`${s} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:s,currentFolderId:y,env:m,onSelect:w,onCancel:x}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,h]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),b=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let i=await T.listFolders(s);yield{page:1,folders:i,totalLoaded:i.length,done:!0}})();for await(let i of F){if(d(!1),i.totalLoaded===0){b.current=!0,h("naming"),g(!1);return}M(i.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),i.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,s,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!s){f("No project selected \u2014 pick a project first");return}f(null),h("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),i=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(s,r);w(i.id,i.name)}catch(a){f(a instanceof Error?a.message:String(a)),h("naming")}})()},[n,s,m,w]),H=(0,t.useCallback)(()=>{v(""),f(null),b.current?x():h("list")},[x]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(c,{color:l.orange,bold:!0,children:"Create new folder"}),b.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(c,{color:l.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(c,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{b.current=!1,h("naming")},extraHint:"new",onSelect:o=>{let r=o.label.split(" (")[0];w(o.id,r)},onCancel:x})}export{X as a,W as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as ne}from"./chunk-WMGKUERB.js";import{a as y,b as ie,c as oe,d as le,e as ae}from"./chunk-LNHBZEDC.js";import{a as F,b as x,c as D,d as ee,f as re,h as de,i as pe}from"./chunk-PL3SG3M2.js";import{a as se,d as te}from"./chunk-ZCIWQHCO.js";import{a as X,c as Y,d as Z}from"./chunk-CJE7PKRV.js";import{Ba as B,Ea as v,Ja as Q,Pa as w,Va as U,Xa as $,Ya as O,Za as b,_a as G,ab as J,fb as H,i as _,jb as z,kb as W,mb as R,nb as K,ob as T,t as I}from"./chunk-Z777GGHB.js";import{a as C}from"./chunk-7DFBOVUB.js";import{existsSync as Se,readFileSync as Ee}from"fs";import{join as Me}from"path";import{mkdirSync as be,readFileSync as Re,renameSync as Fe,writeFileSync as Ae}from"fs";import{dirname as A,join as M}from"path";function E(r,o){be(A(r),{recursive:!0});let s=M(A(r),`.${process.pid}.tmp`);Ae(s,o),Fe(s,r)}function ue(r){try{return JSON.parse(Re(r,"utf8"))}catch{return null}}function ce(r){let o=s=>M(A(y(r,s)),"verdicts.json");return{read:s=>ue(y(r,s)),write:(s,i)=>E(y(r,s),JSON.stringify(i,null,2)+`
2
+ import{b as ne}from"./chunk-WMGKUERB.js";import{a as y,b as ie,c as oe,d as le,e as ae}from"./chunk-UWPG5MWM.js";import{a as F,b as x,c as D,d as ee,f as re,h as de,i as pe}from"./chunk-GJXO6FF7.js";import{a as se,d as te}from"./chunk-ZCIWQHCO.js";import{a as X,c as Y,d as Z}from"./chunk-CQDCNP7V.js";import{Ba as B,Ea as v,Ja as Q,Pa as w,Va as U,Xa as $,Ya as O,Za as b,_a as G,ab as J,fb as H,i as _,jb as z,kb as W,mb as R,nb as K,ob as T,t as I}from"./chunk-PI7OXS62.js";import{a as C}from"./chunk-YJAQZMJT.js";import{existsSync as Se,readFileSync as Ee}from"fs";import{join as Me}from"path";import{mkdirSync as be,readFileSync as Re,renameSync as Fe,writeFileSync as Ae}from"fs";import{dirname as A,join as M}from"path";function E(r,o){be(A(r),{recursive:!0});let s=M(A(r),`.${process.pid}.tmp`);Ae(s,o),Fe(s,r)}function ue(r){try{return JSON.parse(Re(r,"utf8"))}catch{return null}}function ce(r){let o=s=>M(A(y(r,s)),"verdicts.json");return{read:s=>ue(y(r,s)),write:(s,i)=>E(y(r,s),JSON.stringify(i,null,2)+`
3
3
  `),writeReview:(s,i)=>E(M(A(y(r,s)),"review.json"),JSON.stringify(i,null,2)+`
4
4
  `),verdicts:s=>ue(o(s))??{verdicts:{}},saveVerdicts:(s,i)=>E(o(s),JSON.stringify(i,null,2)+`
5
5
  `)}}import{appendFileSync as fe,closeSync as qe,existsSync as V,openSync as Pe,readdirSync as Oe,readFileSync as ge,renameSync as Te,writeFileSync as he}from"fs";import{join as q}from"path";var me=".pending-facts.bad";function ye(r){let o=q(r,ie);return{quarantinePath:q(r,me),park:(s,i)=>{let l=null;try{l=w(r,{deadlineMs:i.deadlineMs})}catch{l=null}try{if(l)return fe(o,s+`
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- function l(e){return{command:(t,n)=>e.commands[t](n),text:(t,n)=>e.texts[t](n)}}function $(e,t,n){let s=n?(i,a)=>n[i](a):e.header;return{command:e.command,text:(i,a)=>{let u=t[i];return u?u(a):e.text(i,a)},...s?{header:s}:{}}}function w(e,t){let n=e.command("next.resume_session",t),s=e.command("next.resume_with_message",t);return{...n!==null?{resume:n}:{},...s!==null?{resumeMessage:s}:{}}}function x(e,t,n,s){let i=e.command(t,n);return i!==null?{cmd:i,...s}:{code:t,facts:n,...s}}import{getEnvironmentData as v,setEnvironmentData as f}from"worker_threads";var d=(e,t)=>e?`${e} ${t}${e>1?"s":""}`:null,p={"chat.added_use_cases":({minted:e,matched:t})=>e===0&&t>0?`all ${t} matched existing \u2014 nothing new to save`:`saved ${e} use-case${e===1?"":"s"} as drafts`+(t>0?` \xB7 ${t} matched existing`:""),"chat.added_design":({acs:e,scenarios:t,tests:n,gaps:s})=>`saved ${[d(e,"AC"),d(t,"scenario"),d(n,"test"),d(s,"gap")].filter(Boolean).join(" \xB7 ")||"judgements/wiring"} as drafts`,"chat.proposal_refused":()=>"proposal failed validation \u2014 nothing landed","chat.commit_failed":()=>"commit failed \u2014 nothing landed","chat.approved":({count:e})=>`${e} change${e===1?"":"s"} applied`,"chat.stales":({count:e})=>`stales ${e}`,"chat.held_degraded":({held:e})=>`held ${e} item(s) for review \u2014 semantic dedup ran degraded (embeddings unavailable); nothing saved this turn`,"chat.child_back":({drafts:e})=>`${e} draft${e===1?"":"s"} saved`,"chat.refine_hint":()=>'chat to refine ("looks good" approves; /done finishes)',"chat.repair_sent":()=>"that couldn't be saved as it was \u2014 the agent is fixing it","chat.updates_held":({count:e})=>`${e} update(s) held for review`,"note.dedup_reduced":()=>"note: duplicate detection is running in a reduced mode this run \u2014 new items will be held for your review instead of committed","note.chain_recovered":({sid:e})=>`session ${e}: checkpoint chain present with no pointer \u2014 recovering from the chain`,"note.chain_truncated":({sid:e,at:t,lost:n})=>`session ${e}: chain truncated to checkpoint ${t} \u2014 ${n} turn(s) lost to a corrupt record`,"note.turns_unrecorded":({detail:e})=>`this chat's turns are not being saved to its conversation (${e}) \u2014 your messages still reach the agent, but a resume cannot send them again`,"note.receipt_unbuilt":({detail:e})=>`a saved change's receipt for the agent could not be built (${e}) \u2014 the change is saved, but the agent is not told what it saved`,"note.tests_await_approval":({tests:e,criteria:t,criterion:n})=>{let s=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${s} a criterion not approved yet \u2014 say "approve ${n}"`:`note: ${s} criteria not approved yet \u2014 say "approve the criteria"`},"note.phase_unchanged":()=>"this phase matched what's already there \u2014 nothing new added","warning.variables_unwritten":({message:e})=>`warning: the design was saved, but its variable stubs could not be written (${e})`};var r=()=>null,c=e=>`resume session ${e}, which holds it`,h="review the current version again",g="retire it first, or add this under another id",m=l({commands:{"next.resume_session":r,"next.resume_with_message":r,"next.resume_child":r,"next.design_use_case":r,"next.review_use_case":r,"next.design_unreviewed":r,"next.view_design":r,"next.evolve_design":r,"next.redesign":r,"next.design_phase":r,"next.answer_evolve":r,"next.abandon_session":r,"next.review_held_changeset":r,"next.show_session":r,"next.review_source":r},texts:{...p,"note.paused":({sid:e})=>`paused: session ${e} saved and can be resumed`,"note.crashed":({sid:e,seq:t})=>`agent crashed \u2014 session ${e} can be resumed from its checkpoint ${t} (at most the in-flight turn lost)`,"note.model_unavailable_kept":({sid:e,detail:t})=>`the model service did not answer (${t}) \u2014 session ${e} is kept and can be resumed once it answers`,"note.model_retry":({seconds:e})=>`the model service is not answering; trying again in ${e}s`,"note.held_for_review":({sid:e,held:t})=>`paused: ${t} held item(s) await review in session ${e}`,"note.already_extracted":({source_id:e})=>`${e} already extracted \u2014 skipped`,"note.conversation_source_skipped":({source_id:e})=>`skipped ${e} \u2014 a conversation source is extracted only when it is named`,"note.reconcile_plan_pending":({source_id:e,pending:t})=>`note: a reconcile plan for ${e} is pending (${t} item(s))`,"note.nothing_to_extract":({sources:e,count:t})=>`extract: nothing to do \u2014 ${e} ${t===1?"is":"are all"} already extracted at the current snapshot`,"note.only_conversation_sources":()=>"extract: nothing to do \u2014 only conversation sources here, and each is extracted only when it is named","note.all_extracted":()=>"extract: nothing to do \u2014 every ingested source is already extracted","note.changeset_held_for_review":({sid:e,held:t})=>`paused: ${t} held change(s) await your verdicts in session ${e}`,"note.session_kept":({sid:e,seq:t,ts:n})=>`session ${e} kept its last checkpoint (seq ${t}, ${n}) and can be resumed`,"note.assumed_defaults":({sid:e,count:t})=>`note: ${t} default(s) were assumed while you were away \u2014 session ${e} lists them`,"note.landed_changed":({source_id:e})=>`note: ${e} changed after it was added \u2014 skipping its extraction this run; extract it again to pick up the newer version`,"note.landed_older_queued":({source_id:e})=>`note: an older version of ${e} is already queued this run \u2014 the newly landed version is not extracted; extract it again to pick it up`,"note.reingest_binary":({source_id:e,kind:t})=>`skipping ${e}: binary ${t} ingested before image support \u2014 add it again to extract from it`,"note.schedule_refused":()=>"this run holds items for review, so its extraction is not scheduled \u2014 it runs after the review","note.not_reached":()=>"run ended before its turn \u2014 extracting again runs it","note.nothing_committed":({source_id:e,remaining:t})=>`done \u2014 nothing committed for ${e} (no finalize before the session ended)`+(t>0?`; stopping here \u2014 ${t} remaining source(s) not extracted (extract them again to continue)`:""),"note.landed_not_extracted":({count:e,sources:t})=>`note: ${e} source(s) landed this session (${t}) were not extracted \u2014 the session ended first; extracting again runs them`,"note.evidence_not_attached":({count:e})=>`note: ${e} unchanged match(es) target unreviewed (or no-longer-resolving) item(s) \u2014 evidence not attached (review them; a later reconcile attaches)`,"note.sources_failed":({failed:e,total:t,sources:n})=>`${e} of ${t} source(s) failed \u2014 extract them again to retry (${n})`,"note.already_designed":({use_case:e,version:t})=>`'${e}' is already designed @ v${t} \u2014 current; redesign it to replace that design`,"note.design_stale":({use_case:e,designed:t,current:n})=>`'${e}' was designed @ ${t} \u2014 the use-case is now @ v${n} (STALE); evolve or redesign it`,"note.view_design":({use_case:e})=>`view the existing design of ${e}`,"note.evolve_first":({use_case:e})=>`refresh it first: evolve ${e}`,"note.nothing_executed":()=>"nothing executed","note.tests_await_approval_command":({tests:e,criteria:t,criterion:n})=>{let s=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${s} a criterion not approved yet; approve ${n}`:`note: ${s} criteria not approved yet; approve them`},"note.links_await_approval":({count:e})=>`warning: ${e} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items`,"note.no_design_skipped":({use_case:e})=>`note: ${e} has no design output \u2014 nothing to evolve; design it first`,"note.no_design":({use_case:e})=>`nothing to evolve \u2014 design ${e} first (no design output)`,"note.design_paused":({use_case:e})=>`design session for ${e} paused \u2014 resume it, then evolve again for the diff`,"note.nothing_changed":({ref:e})=>`nothing changed underneath ${e} \u2014 its sources and requirements are current; give a reason to re-design anyway`,"note.source_changed_skipped":({use_case:e})=>`${e} is left out: it's out of date because its source changed \u2014 review its source's change first`,"note.source_changed":({use_case:e})=>`${e} is out of date because its source changed, and an update can't change that \u2014 review its source's change first`,"note.source_changed_after":({use_case:e})=>`${e} is still out of date because its source changed \u2014 review its source's change`,"note.checkpoint_not_saved":({error:e,chain_unverified:t})=>`warning: couldn't save the session checkpoint \u2014 ${e}; asking the agent to pause`+(t?". The store's record chain fails verification.":""),"note.held_no_event_id":({sid:e})=>`this held row has no durable event id \u2014 ${c(e)}, to drop it`,"note.held_no_provenance":({sid:e})=>`this held row carries no committable provenance \u2014 ${c(e)}, to apply it`,"note.held_no_citable_text":({sid:e,source_id:t,source_cid:n})=>`the pinned source ${t} (${n.slice(0,19)}) has no citable text to verify this held row against \u2014 ${c(e)}`,"note.held_unverified":({sid:e,errors:t})=>`held provenance does not verify against the pinned source (${t}) \u2014 ${c(e)}`,"note.controller_unreachable":({base:e,error:t})=>`error: cannot reach the controller at ${e} (${t})
3
- hint: check the network connection and the sign-in`,"note.assurance_unsupported":()=>"error: this environment does not support assurance sessions yet (404) \u2014 contact support if the problem persists","note.credentials_rejected":({env:e})=>`error: your credentials were rejected (401) \u2014 sign in again (active environment: ${e})`,"note.key_recycled":({source_id:e,what:t})=>`source '${e}' was ingested from a different ${t} that used this key \u2014 the key was recycled; ${g}`,"note.kind_taken":({source_id:e,backing:t,kind:n})=>`source '${e}' is already backed by ${t}, not ${n} \u2014 ${g}`,"note.site_moved":({source_id:e,previous:t,site:n})=>`source '${e}' was ingested from ${t}, but this read serves ${n} \u2014 ${g}`,"note.web_url_changed":({source_id:e,previous:t})=>`source '${e}' was ingested from ${t} \u2014 adopt the new URL as its next version, or add it under another id`,"note.web_id_taken":({url:e})=>`skipped ${e} \u2014 add it under another id to keep both pages`,"note.web_login":()=>"your credentials were rejected \u2014 sign in again and retry","note.web_projection_unknown":({kind:e})=>`unknown web projection kind '${e}' \u2014 this source needs a newer engine to read it`,LIS_AUTH:()=>"credentials rejected \u2014 sign in again and retry",MULTI_SOURCE_RESUME:({sid:e,sources:t})=>`error: session ${e} spans ${t} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (extract anything remaining again)`,CHANGE_BASIS_MOVED:({source_id:e,sid:t})=>`error: ${e} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; review the current version instead (session ${t} is defunct and can be ignored)`,PROPOSAL_UNREADABLE:({proposal:e})=>`proposal ${e} is unreadable \u2014 review the source's changes again`,SOURCE_UNRESOLVED:({source_id:e})=>`the source ${e} no longer resolves \u2014 cannot verify this changeset is current; review the source's changes again`,SOURCE_MOVED:({source_id:e})=>`the source ${e} moved again while this review was open \u2014 review its changes again to refresh the changeset`,ARCHIVE_UNRESOLVED:({use_case:e})=>`its archive op no longer resolves to ${e} \u2014 review the source's changes again`,POSTURE_IN_CHAT:({sid:e})=>`error: session ${e} is a held reconcile review \u2014 resumed in the chat its changes would commit without verdicts; give its cards their verdicts in the review`,SOURCE_MISSING:({sid:e,sources:t})=>`error: resumed session's paused source (${t}) is no longer in the corpus \u2014 add it again and resume session ${e}, or abandon that session`,BLOB_MISSING:({source_id:e})=>`error: ${e}: its stored content is missing \u2014 add the file again [BLOB_MISSING]`,"AGENT_FAILED.invalid_proposal":({source_id:e})=>`error: the agent could not produce a valid proposal for ${e} \u2014 extract it again to retry`,UC_UNREVIEWED:({use_case:e})=>`${e} is unreviewed \u2014 approve it first, or design it unreviewed`,"UC_UNREVIEWED.merge_target":({temp_ref:e,target:t})=>`${e}: merge target ${t} is unreviewed (derived) \u2014 approve it first and re-propose the merge`,UC_HELD:({use_case:e,owner_sid:t,stopped:n})=>`design: ${e} is being designed by another session`+(n?` \u2014 that session looks stopped; resume session ${t??"<session>"}`:"")+" \u2014 pick another use-case or wait for it to finish",GENERATION_LIVE:({use_case:e,gen:t})=>`${e} already has a live design generation (gen ${t}) \u2014 redesign it, with a reason, to supersede it`,MESSAGE_TOO_LARGE:({bytes:e,max:t})=>`error: the opening statement is ${e} bytes and the agent takes at most ${t} per message (it would drop it silently) \u2014 give a shorter reason (it replaces the generated stale reason)`,REASON_TOO_LARGE:()=>"nothing was started: that reason is too long; run it again with a sentence or two",SESSION_V1:({sid:e})=>`session ${e} predates durable checkpoints \u2014 this build cannot resume it; abandon it and start a fresh run (committed work is untouched)`,WRONG_VERB:({sid:e,verb:t})=>`error: session ${e} is a ${t} session \u2014 resume it as one`,"HELD_CITES_STALE.moved":()=>`the source moved after this plan staged \u2014 its quotes no longer verify against the current head; ${h}`,"HELD_CITES_STALE.predates_images":({where:e,anchor:t})=>`${e}: this plan predates image-part staging \u2014 ${t} cannot be verified against the version it staged under; ${h}`,"HELD_CITES_STALE.no_image":({where:e,anchor:t})=>`${e}: ${t} names no decodable image of the staged version \u2014 ${h}`,"HELD_CITES_STALE.image_moved":({where:e,anchor:t,gone:n})=>`${e}: the image behind ${t} is ${n?"no longer in":"ambiguous in"} the current head \u2014 ${h}`}});var _="kane-context:flushToDisk",o=null;function U(e){o=e,e.flushToDisk!==void 0&&f(_,e.flushToDisk)}function A(){if(!o)throw new Error("engine config not set; the host must call setEngineConfig before any engine call");return o}function I(){return o?.writersFenced===!0}function L(){return(o?.flushToDisk??v(_))!==!1}function O(){return o?.warn}function W(){return o?.userSessionId?.()??null}function H(){return o?.version??null}function D(){return o?.wording??m}export{l as a,$ as b,w as c,x as d,p as e,U as f,A as g,I as h,L as i,O as j,W as k,H as l,D as m};
2
+ function l(e){return{command:(t,n)=>e.commands[t](n),text:(t,n)=>e.texts[t](n)}}function w(e,t,n){let s=n?(i,a)=>n[i](a):e.header;return{command:e.command,text:(i,a)=>{let u=t[i];return u?u(a):e.text(i,a)},...s?{header:s}:{}}}function x(e,t){let n=e.command("next.resume_session",t),s=e.command("next.resume_with_message",t);return{...n!==null?{resume:n}:{},...s!==null?{resumeMessage:s}:{}}}function y(e,t,n,s){let i=e.command(t,n);return i!==null?{cmd:i,...s}:{code:t,facts:n,...s}}import{getEnvironmentData as _,setEnvironmentData as v}from"worker_threads";var d=(e,t)=>e?`${e} ${t}${e>1?"s":""}`:null,p={"chat.added_use_cases":({minted:e,matched:t})=>e===0&&t>0?`all ${t} matched existing \u2014 nothing new to save`:`saved ${e} use-case${e===1?"":"s"} as drafts`+(t>0?` \xB7 ${t} matched existing`:""),"chat.added_design":({acs:e,scenarios:t,tests:n,gaps:s})=>`saved ${[d(e,"AC"),d(t,"scenario"),d(n,"test"),d(s,"gap")].filter(Boolean).join(" \xB7 ")||"judgements/wiring"} as drafts`,"chat.proposal_refused":()=>"proposal failed validation \u2014 nothing landed","chat.commit_failed":()=>"commit failed \u2014 nothing landed","chat.approved":({count:e})=>`${e} change${e===1?"":"s"} applied`,"chat.stales":({count:e})=>`stales ${e}`,"chat.held_degraded":({held:e})=>`held ${e} item(s) for review \u2014 semantic dedup ran degraded (embeddings unavailable); nothing saved this turn`,"chat.child_back":({drafts:e})=>`${e} draft${e===1?"":"s"} saved`,"chat.refine_hint":()=>'chat to refine ("looks good" approves; /done finishes)',"chat.repair_sent":()=>"that couldn't be saved as it was \u2014 the agent is fixing it","chat.updates_held":({count:e})=>`${e} update(s) held for review`,"note.dedup_reduced":()=>"note: duplicate detection is running in a reduced mode this run \u2014 new items will be held for your review instead of committed","note.chain_recovered":({sid:e})=>`session ${e}: checkpoint chain present with no pointer \u2014 recovering from the chain`,"note.chain_truncated":({sid:e,at:t,lost:n})=>`session ${e}: chain truncated to checkpoint ${t} \u2014 ${n} turn(s) lost to a corrupt record`,"note.turns_unrecorded":({detail:e})=>`this chat's turns are not being saved to its conversation (${e}) \u2014 your messages still reach the agent, but a resume cannot send them again`,"note.receipt_unbuilt":({detail:e})=>`a saved change's receipt for the agent could not be built (${e}) \u2014 the change is saved, but the agent is not told what it saved`,"note.tests_await_approval":({tests:e,criteria:t,criterion:n})=>{let s=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${s} a criterion not approved yet \u2014 say "approve ${n}"`:`note: ${s} criteria not approved yet \u2014 say "approve the criteria"`},"note.phase_unchanged":()=>"this phase matched what's already there \u2014 nothing new added","warning.variables_unwritten":({message:e})=>`warning: the design was saved, but its variable stubs could not be written (${e})`};var r=()=>null,c=e=>`resume session ${e}, which holds it`,h="review the current version again",g="retire it first, or add this under another id",m=l({commands:{"next.resume_session":r,"next.resume_with_message":r,"next.resume_child":r,"next.design_use_case":r,"next.review_use_case":r,"next.design_unreviewed":r,"next.view_design":r,"next.evolve_design":r,"next.redesign":r,"next.design_phase":r,"next.answer_evolve":r,"next.abandon_session":r,"next.review_held_changeset":r,"next.show_session":r,"next.review_source":r},texts:{...p,"note.paused":({sid:e})=>`paused: session ${e} saved and can be resumed`,"note.crashed":({sid:e,seq:t})=>`agent crashed \u2014 session ${e} can be resumed from its checkpoint ${t} (at most the in-flight turn lost)`,"note.model_unavailable_kept":({sid:e,detail:t})=>`the model service did not answer (${t}) \u2014 session ${e} is kept and can be resumed once it answers`,"note.model_retry":({seconds:e})=>`the model service is not answering; trying again in ${e}s`,"note.held_for_review":({sid:e,held:t})=>`paused: ${t} held item(s) await review in session ${e}`,"note.already_extracted":({source_id:e})=>`${e} already extracted \u2014 skipped`,"note.conversation_source_skipped":({source_id:e})=>`skipped ${e} \u2014 a conversation source is extracted only when it is named`,"note.reconcile_plan_pending":({source_id:e,pending:t})=>`note: a reconcile plan for ${e} is pending (${t} item(s))`,"note.nothing_to_extract":({sources:e,count:t})=>`extract: nothing to do \u2014 ${e} ${t===1?"is":"are all"} already extracted at the current snapshot`,"note.only_conversation_sources":()=>"extract: nothing to do \u2014 only conversation sources here, and each is extracted only when it is named","note.all_extracted":()=>"extract: nothing to do \u2014 every ingested source is already extracted","note.changeset_held_for_review":({sid:e,held:t})=>`paused: ${t} held change(s) await your verdicts in session ${e}`,"note.session_kept":({sid:e,seq:t,ts:n})=>`session ${e} kept its last checkpoint (seq ${t}, ${n}) and can be resumed`,"note.assumed_defaults":({sid:e,count:t})=>`note: ${t} default(s) were assumed while you were away \u2014 session ${e} lists them`,"note.landed_changed":({source_id:e})=>`note: ${e} changed after it was added \u2014 skipping its extraction this run; extract it again to pick up the newer version`,"note.landed_older_queued":({source_id:e})=>`note: an older version of ${e} is already queued this run \u2014 the newly landed version is not extracted; extract it again to pick it up`,"note.reingest_binary":({source_id:e,kind:t})=>`skipping ${e}: binary ${t} ingested before image support \u2014 add it again to extract from it`,"note.schedule_refused":()=>"this run holds items for review, so its extraction is not scheduled \u2014 it runs after the review","note.not_reached":()=>"run ended before its turn \u2014 extracting again runs it","note.nothing_committed":({source_id:e,remaining:t})=>`done \u2014 nothing committed for ${e} (no finalize before the session ended)`+(t>0?`; stopping here \u2014 ${t} remaining source(s) not extracted (extract them again to continue)`:""),"note.landed_not_extracted":({count:e,sources:t})=>`note: ${e} source(s) landed this session (${t}) were not extracted \u2014 the session ended first; extracting again runs them`,"note.evidence_not_attached":({count:e})=>`note: ${e} unchanged match(es) target unreviewed (or no-longer-resolving) item(s) \u2014 evidence not attached (review them; a later reconcile attaches)`,"note.sources_failed":({failed:e,total:t,sources:n})=>`${e} of ${t} source(s) failed \u2014 extract them again to retry (${n})`,"note.already_designed":({use_case:e,version:t})=>`'${e}' is already designed @ v${t} \u2014 current; redesign it to replace that design`,"note.design_stale":({use_case:e,designed:t,current:n})=>`'${e}' was designed @ ${t} \u2014 the use-case is now @ v${n} (STALE); evolve or redesign it`,"note.view_design":({use_case:e})=>`view the existing design of ${e}`,"note.evolve_first":({use_case:e})=>`refresh it first: evolve ${e}`,"note.nothing_executed":()=>"nothing executed","note.tests_await_approval_command":({tests:e,criteria:t,criterion:n})=>{let s=e===1?"1 test checks":`${e} tests check`;return t===1&&n!==null?`note: ${s} a criterion not approved yet; approve ${n}`:`note: ${s} criteria not approved yet; approve them`},"note.links_await_approval":({count:e})=>`warning: ${e} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items`,"note.no_design_skipped":({use_case:e})=>`note: ${e} has no design output \u2014 nothing to evolve; design it first`,"note.no_design":({use_case:e})=>`nothing to evolve \u2014 design ${e} first (no design output)`,"note.design_paused":({use_case:e})=>`design session for ${e} paused \u2014 resume it, then evolve again for the diff`,"note.nothing_changed":({ref:e})=>`nothing changed underneath ${e} \u2014 its sources and requirements are current; give a reason to re-design anyway`,"note.source_changed_skipped":({use_case:e})=>`${e} is left out: it's out of date because its source changed \u2014 review its source's change first`,"note.source_changed":({use_case:e})=>`${e} is out of date because its source changed, and an update can't change that \u2014 review its source's change first`,"note.source_changed_after":({use_case:e})=>`${e} is still out of date because its source changed \u2014 review its source's change`,"note.checkpoint_not_saved":({error:e,chain_unverified:t})=>`warning: couldn't save the session checkpoint \u2014 ${e}; asking the agent to pause`+(t?". The store's record chain fails verification.":""),"note.held_no_event_id":({sid:e})=>`this held row has no durable event id \u2014 ${c(e)}, to drop it`,"note.held_no_provenance":({sid:e})=>`this held row carries no committable provenance \u2014 ${c(e)}, to apply it`,"note.held_no_citable_text":({sid:e,source_id:t,source_cid:n})=>`the pinned source ${t} (${n.slice(0,19)}) has no citable text to verify this held row against \u2014 ${c(e)}`,"note.held_unverified":({sid:e,errors:t})=>`held provenance does not verify against the pinned source (${t}) \u2014 ${c(e)}`,"note.controller_unreachable":({base:e,error:t})=>`error: cannot reach the controller at ${e} (${t})
3
+ hint: check the network connection and the sign-in`,"note.assurance_unsupported":()=>"error: this environment does not support assurance sessions yet (404) \u2014 contact support if the problem persists","note.credentials_rejected":({env:e})=>`error: your credentials were rejected (401) \u2014 sign in again (active environment: ${e})`,"note.key_recycled":({source_id:e,what:t})=>`source '${e}' was ingested from a different ${t} that used this key \u2014 the key was recycled; ${g}`,"note.kind_taken":({source_id:e,backing:t,kind:n})=>`source '${e}' is already backed by ${t}, not ${n} \u2014 ${g}`,"note.site_moved":({source_id:e,previous:t,site:n})=>`source '${e}' was ingested from ${t}, but this read serves ${n} \u2014 ${g}`,"note.web_url_changed":({source_id:e,previous:t})=>`source '${e}' was ingested from ${t} \u2014 adopt the new URL as its next version, or add it under another id`,"note.web_id_taken":({url:e})=>`skipped ${e} \u2014 add it under another id to keep both pages`,"note.web_login":()=>"your credentials were rejected \u2014 sign in again and retry","note.web_projection_unknown":({kind:e})=>`unknown web projection kind '${e}' \u2014 this source needs a newer engine to read it`,LIS_AUTH:()=>"credentials rejected \u2014 sign in again and retry",MULTI_SOURCE_RESUME:({sid:e,sources:t})=>`error: session ${e} spans ${t} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (extract anything remaining again)`,CHANGE_BASIS_MOVED:({source_id:e,sid:t})=>`error: ${e} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; review the current version instead (session ${t} is defunct and can be ignored)`,PROPOSAL_UNREADABLE:({proposal:e})=>`proposal ${e} is unreadable \u2014 review the source's changes again`,SOURCE_UNRESOLVED:({source_id:e})=>`the source ${e} no longer resolves \u2014 cannot verify this changeset is current; review the source's changes again`,SOURCE_MOVED:({source_id:e})=>`the source ${e} moved again while this review was open \u2014 review its changes again to refresh the changeset`,ARCHIVE_UNRESOLVED:({use_case:e})=>`its archive op no longer resolves to ${e} \u2014 review the source's changes again`,POSTURE_IN_CHAT:({sid:e})=>`error: session ${e} is a held reconcile review \u2014 resumed in the chat its changes would commit without verdicts; give its cards their verdicts in the review`,SOURCE_MISSING:({sid:e,sources:t})=>`error: resumed session's paused source (${t}) is no longer in the corpus \u2014 add it again and resume session ${e}, or abandon that session`,BLOB_MISSING:({source_id:e})=>`error: ${e}: its stored content is missing \u2014 add the file again [BLOB_MISSING]`,"AGENT_FAILED.invalid_proposal":({source_id:e})=>`error: the agent could not produce a valid proposal for ${e} \u2014 extract it again to retry`,UC_UNREVIEWED:({use_case:e})=>`${e} is unreviewed \u2014 approve it first, or design it unreviewed`,"UC_UNREVIEWED.merge_target":({temp_ref:e,target:t})=>`${e}: merge target ${t} is unreviewed (derived) \u2014 approve it first and re-propose the merge`,UC_HELD:({use_case:e,owner_sid:t,stopped:n})=>`design: ${e} is being designed by another session`+(n?` \u2014 that session looks stopped; resume session ${t??"<session>"}`:"")+" \u2014 pick another use-case or wait for it to finish",GENERATION_LIVE:({use_case:e,gen:t})=>`${e} already has a live design generation (gen ${t}) \u2014 redesign it, with a reason, to supersede it`,MESSAGE_TOO_LARGE:({bytes:e,max:t})=>`error: the opening statement is ${e} bytes and the agent takes at most ${t} per message (it would drop it silently) \u2014 give a shorter reason (it replaces the generated stale reason)`,REASON_TOO_LARGE:()=>"nothing was started: that reason is too long; run it again with a sentence or two",SESSION_V1:({sid:e})=>`session ${e} predates durable checkpoints \u2014 this build cannot resume it; abandon it and start a fresh run (committed work is untouched)`,WRONG_VERB:({sid:e,verb:t})=>`error: session ${e} is a ${t} session \u2014 resume it as one`,"HELD_CITES_STALE.moved":()=>`the source moved after this plan staged \u2014 its quotes no longer verify against the current head; ${h}`,"HELD_CITES_STALE.predates_images":({where:e,anchor:t})=>`${e}: this plan predates image-part staging \u2014 ${t} cannot be verified against the version it staged under; ${h}`,"HELD_CITES_STALE.no_image":({where:e,anchor:t})=>`${e}: ${t} names no decodable image of the staged version \u2014 ${h}`,"HELD_CITES_STALE.image_moved":({where:e,anchor:t,gone:n})=>`${e}: the image behind ${t} is ${n?"no longer in":"ambiguous in"} the current head \u2014 ${h}`}});var f="kane-context:flushToDisk",o=null;function A(e){o=e,e.flushToDisk!==void 0&&v(f,e.flushToDisk)}function I(){if(!o)throw new Error("engine config not set; the host must call setEngineConfig before any engine call");return o}function O(){return o?.writersFenced===!0}function L(){return(o?.flushToDisk??_(f))!==!1}function H(){return o?.warn}function W(){return o?.userSessionId?.()??null}var $="kane-context:pythonTrustFile";function R(e){v($,e??void 0)}function D(){let e=_($);return typeof e=="string"?e:null}function F(){return o?.version??null}function N(){return o?.wording??m}export{l as a,w as b,x as c,y as d,p as e,A as f,I as g,O as h,L as i,H as j,W as k,R as l,D as m,F as n,N as o};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as w,b as C}from"./chunk-KRRZCY7U.js";import{a as j,b as I,e as x}from"./chunk-QQI6N3FO.js";import{e as y}from"./chunk-ZKPY3AXW.js";import{i as k}from"./chunk-XMPTFXPW.js";import{o as g}from"./chunk-7V34ZMMS.js";import{Ha as i,f as h}from"./chunk-TLOYTGVT.js";import{a as l}from"./chunk-I2MC6VVX.js";import{c as m}from"./chunk-GGV336P5.js";import{readFileSync as A}from"fs";import{basename as T,dirname as p,join as N}from"path";var S=5e3,O=w("assurance-case");function _(e,t={}){let s=p(e);if(T(s)!=="tests"||T(p(s))!==".testmuai")return null;let n=p(p(s)),a;try{a=g(A(e,"utf8"))}catch{return null}if(!a?.id)return null;let r=(c,u,d)=>({root:n,latticeUrl:c,projectId:u,projectName:d,test:a.id,base:a.base??null});if(t.grid){let c=x(N(n,j));return c===null?null:r("",c.projectId,c.projectName)}let o=I(n,t.address??m());return o.kind==="remote"?r(o.latticeUrl,o.projectId,o.projectName):null}function K(e,t={}){let s={};for(let n of e){let a=_(n,t);a?.base&&(s[n]={test:a.test,definitionId:a.base})}return s}async function V(e){let t=_(e.testFile,{address:e.address,grid:e.gridCase!==void 0});if(t===null)return{kind:"unlinked"};let s=t.base===null?null:{test:t.test,definitionId:t.base},n=e.metaCaseId===null;if(e.gridCase)return R(t,s,e.metaCaseId,{caseId:e.gridCase.caseId,internalId:e.gridCase.tc,canAttach:!0});if(s===null)return{kind:"stop",stop:{why:"not_in_project",useCase:null},projectName:t.projectName};let a;try{let r=e.auth??await y(),o=e.lookup??((c,u,d)=>h({url:t.latticeUrl,basicAuth:r}).testCase(c,u,d));a=await L(o(t.projectId,t.test,s.definitionId),e.budgetMs??S)}catch(r){return r instanceof l&&r.code==="NO_CONTEXT"?{kind:"stop",stop:{why:"no_work"},projectName:t.projectName}:(O(`the test case of ${t.test} wasn't checked: ${r instanceof f?r.message:C(r)}`),n?{kind:"stop",stop:{why:"lookup",refusal:v(r,t.projectName)},projectName:t.projectName}:{kind:"run",projectId:t.projectId,tc:null,stamp:s})}return"refused"in a?{kind:"stop",stop:E(a.refused),projectName:t.projectName}:R(t,s,e.metaCaseId,a.linked)}function R(e,t,s,n){return s===n.caseId?{kind:"run",projectId:e.projectId,tc:n.internalId,stamp:t}:n.canAttach?{kind:"attach",projectId:e.projectId,caseId:n.caseId,tc:n.internalId,stamp:t,rehome:s!==null}:{kind:"stop",stop:{why:"outdated"},projectName:e.projectName}}function X(e,t){switch(e.why){case"missing":return{refusal:i.testCaseMissing(e.session),exit:2};case"gone":return{refusal:i.testCaseGone(e.session),exit:2};case"archived":return{refusal:i.testCaseArchived(),exit:2};case"not_in_project":return{refusal:i.testNotInProject(t,e.useCase),exit:2};case"no_work":return{refusal:i.testProjectHasNoWork(t),exit:2};case"outdated":return{refusal:i.testManagerOutdated(),exit:1};case"lookup":return{refusal:e.refusal,exit:2}}}function b(e){switch(e.why){case"missing":return e.session?{reason:"it isn't in Test Manager yet; save the session that designed it:",cmd:`kane-cli context sessions save ${e.session}`}:{reason:"it isn't in Test Manager yet; find its session, then save it:",cmd:"kane-cli context sessions"};case"gone":return e.session?{reason:"its test case was deleted or moved; saving its session makes a new one:",cmd:`kane-cli context sessions save ${e.session}`}:{reason:"its test case was deleted or moved; find its session, then save it:",cmd:"kane-cli context sessions"};case"archived":return{reason:"its test case is archived in Test Manager; restore it there"};case"not_in_project":return{reason:"the session that designed it can't be saved anymore; design it again:",cmd:`kane-cli design tests --use-case ${e.useCase??"<use-case>"}`}}}function q(e){if(e.some(r=>r.stop.why==="outdated"))return{pair:i.dispatchTestManagerOutdated()};let t=e.find(r=>r.stop.why==="lookup")?.stop;if(t?.why==="lookup")return{pair:t.refusal};let s=e.find(r=>r.stop.why==="no_work");if(s)return{pair:i.dispatchProjectHasNoWork(s.projectName)};let n=[{text:i.dispatchStopped(e.length)}],a=new Set;for(let{relPath:r,stop:o}of e){if(o.why==="outdated"||o.why==="lookup"||o.why==="no_work")continue;let{reason:c,cmd:u}=b(o),d=u!==void 0&&a.has(u);n.push({text:` ${r}`,dim:!0},{text:` ${d?`${c.replace(/:$/,"")}, as above`:c}`,dim:!0}),u&&!d&&(a.add(u),n.push({text:` ${u}`}))}return n.push({text:i.dispatchNext(e.length)}),{lines:n}}function z(e){return{refusal:e.reason==="outdated"?i.testManagerMadeItsOwn():i.testCaseAttachFailed(),exit:1}}function E(e){switch(e.code){case"NO_CASE":return{why:"missing",session:e.session};case"CASE_BROKEN":return{why:"gone",session:e.session};case"CASE_ARCHIVED":return{why:"archived",internalId:e.internalId};case"TEST_FILE_STALE":return{why:"not_in_project",useCase:e.useCase}}}function v(e,t){return e instanceof k?{code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}}:e instanceof l&&e.status===401?i.credentialsRejected():e instanceof l&&e.code==="NOT_FOUND"?i.noAccess(t):e instanceof l&&e.code==="PROJECT_NOT_MARKED"?i.assuranceOff(t):i.noConnection()}var f=class extends Error{};async function L(e,t){let s,n=new Promise((a,r)=>{s=setTimeout(()=>r(new f(`Lattice took over ${t} ms`)),t)});try{return await Promise.race([e,n])}finally{clearTimeout(s)}}export{S as a,_ as b,K as c,V as d,X as e,q as f,z as g,f as h,L as i};
2
+ import{a as w,b as C}from"./chunk-TAY7J5VS.js";import{a as j,b as I,e as x}from"./chunk-3RO2YGKH.js";import{e as y}from"./chunk-NI3TIAD7.js";import{i as k}from"./chunk-XMPTFXPW.js";import{o as g}from"./chunk-7V34ZMMS.js";import{Ha as i,f as h}from"./chunk-WE7HRAGO.js";import{a as l}from"./chunk-4C7WVQOD.js";import{c as m}from"./chunk-ZCBOHWN3.js";import{readFileSync as A}from"fs";import{basename as T,dirname as p,join as N}from"path";var S=5e3,O=w("assurance-case");function _(e,t={}){let s=p(e);if(T(s)!=="tests"||T(p(s))!==".testmuai")return null;let n=p(p(s)),a;try{a=g(A(e,"utf8"))}catch{return null}if(!a?.id)return null;let r=(c,u,d)=>({root:n,latticeUrl:c,projectId:u,projectName:d,test:a.id,base:a.base??null});if(t.grid){let c=x(N(n,j));return c===null?null:r("",c.projectId,c.projectName)}let o=I(n,t.address??m());return o.kind==="remote"?r(o.latticeUrl,o.projectId,o.projectName):null}function K(e,t={}){let s={};for(let n of e){let a=_(n,t);a?.base&&(s[n]={test:a.test,definitionId:a.base})}return s}async function V(e){let t=_(e.testFile,{address:e.address,grid:e.gridCase!==void 0});if(t===null)return{kind:"unlinked"};let s=t.base===null?null:{test:t.test,definitionId:t.base},n=e.metaCaseId===null;if(e.gridCase)return R(t,s,e.metaCaseId,{caseId:e.gridCase.caseId,internalId:e.gridCase.tc,canAttach:!0});if(s===null)return{kind:"stop",stop:{why:"not_in_project",useCase:null},projectName:t.projectName};let a;try{let r=e.auth??await y(),o=e.lookup??((c,u,d)=>h({url:t.latticeUrl,basicAuth:r}).testCase(c,u,d));a=await L(o(t.projectId,t.test,s.definitionId),e.budgetMs??S)}catch(r){return r instanceof l&&r.code==="NO_CONTEXT"?{kind:"stop",stop:{why:"no_work"},projectName:t.projectName}:(O(`the test case of ${t.test} wasn't checked: ${r instanceof f?r.message:C(r)}`),n?{kind:"stop",stop:{why:"lookup",refusal:v(r,t.projectName)},projectName:t.projectName}:{kind:"run",projectId:t.projectId,tc:null,stamp:s})}return"refused"in a?{kind:"stop",stop:E(a.refused),projectName:t.projectName}:R(t,s,e.metaCaseId,a.linked)}function R(e,t,s,n){return s===n.caseId?{kind:"run",projectId:e.projectId,tc:n.internalId,stamp:t}:n.canAttach?{kind:"attach",projectId:e.projectId,caseId:n.caseId,tc:n.internalId,stamp:t,rehome:s!==null}:{kind:"stop",stop:{why:"outdated"},projectName:e.projectName}}function X(e,t){switch(e.why){case"missing":return{refusal:i.testCaseMissing(e.session),exit:2};case"gone":return{refusal:i.testCaseGone(e.session),exit:2};case"archived":return{refusal:i.testCaseArchived(),exit:2};case"not_in_project":return{refusal:i.testNotInProject(t,e.useCase),exit:2};case"no_work":return{refusal:i.testProjectHasNoWork(t),exit:2};case"outdated":return{refusal:i.testManagerOutdated(),exit:1};case"lookup":return{refusal:e.refusal,exit:2}}}function b(e){switch(e.why){case"missing":return e.session?{reason:"it isn't in Test Manager yet; save the session that designed it:",cmd:`kane-cli context sessions save ${e.session}`}:{reason:"it isn't in Test Manager yet; find its session, then save it:",cmd:"kane-cli context sessions"};case"gone":return e.session?{reason:"its test case was deleted or moved; saving its session makes a new one:",cmd:`kane-cli context sessions save ${e.session}`}:{reason:"its test case was deleted or moved; find its session, then save it:",cmd:"kane-cli context sessions"};case"archived":return{reason:"its test case is archived in Test Manager; restore it there"};case"not_in_project":return{reason:"the session that designed it can't be saved anymore; design it again:",cmd:`kane-cli design tests --use-case ${e.useCase??"<use-case>"}`}}}function q(e){if(e.some(r=>r.stop.why==="outdated"))return{pair:i.dispatchTestManagerOutdated()};let t=e.find(r=>r.stop.why==="lookup")?.stop;if(t?.why==="lookup")return{pair:t.refusal};let s=e.find(r=>r.stop.why==="no_work");if(s)return{pair:i.dispatchProjectHasNoWork(s.projectName)};let n=[{text:i.dispatchStopped(e.length)}],a=new Set;for(let{relPath:r,stop:o}of e){if(o.why==="outdated"||o.why==="lookup"||o.why==="no_work")continue;let{reason:c,cmd:u}=b(o),d=u!==void 0&&a.has(u);n.push({text:` ${r}`,dim:!0},{text:` ${d?`${c.replace(/:$/,"")}, as above`:c}`,dim:!0}),u&&!d&&(a.add(u),n.push({text:` ${u}`}))}return n.push({text:i.dispatchNext(e.length)}),{lines:n}}function z(e){return{refusal:e.reason==="outdated"?i.testManagerMadeItsOwn():i.testCaseAttachFailed(),exit:1}}function E(e){switch(e.code){case"NO_CASE":return{why:"missing",session:e.session};case"CASE_BROKEN":return{why:"gone",session:e.session};case"CASE_ARCHIVED":return{why:"archived",internalId:e.internalId};case"TEST_FILE_STALE":return{why:"not_in_project",useCase:e.useCase}}}function v(e,t){return e instanceof k?{code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}}:e instanceof l&&e.status===401?i.credentialsRejected():e instanceof l&&e.code==="NOT_FOUND"?i.noAccess(t):e instanceof l&&e.code==="PROJECT_NOT_MARKED"?i.assuranceOff(t):i.noConnection()}var f=class extends Error{};async function L(e,t){let s,n=new Promise((a,r)=>{s=setTimeout(()=>r(new f(`Lattice took over ${t} ms`)),t)});try{return await Promise.race([e,n])}finally{clearTimeout(s)}}export{S as a,_ as b,K as c,V as d,X as e,q as f,z as g,f as h,L as i};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{L as N,a as k,pa as S,r as w}from"./chunk-Z777GGHB.js";import{f as _,h as $}from"./chunk-KU3YHPWZ.js";var T=3,F={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function P(m){let{store:u,graph:s,watermark:v,by:f}=m,{signals:b}=u.signals().snapshot(v),E=b.filter(e=>e.event_id===void 0||s.appliedEvents.has(e.event_id)),n=new Map;for(let e of E){let t=e.event_id??`${e.ts}|${e.id}|${e.verdict}|${e.polarity}`;n.has(`${t}|${e.polarity}|${e.verdict}`)||n.set(`${t}|${e.polarity}|${e.verdict}`,e)}let j=[...n.values()].sort((e,t)=>(e.event_id??e.ts)<(t.event_id??t.ts)?-1:1),i=new Map;for(let e of j){let t=`${e.verdict}|${e.tag??""}`,r=i.get(t)??{verdict:e.verdict,tag:e.tag,events:new Set};r.events.add(e.event_id??e.ts),i.set(t,r)}let d=[],a=[],g=new Set,c=[],y=0;for(let[,e]of[...i.entries()].sort(([t],[r])=>t<r?-1:1)){if(e.events.size<T)continue;let r={derived:!0,statement:`${e.verdict}${e.tag?`/${e.tag}`:""} recurs (${e.events.size} distinct events) \u2014 bias future proposals ${e.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:F[e.verdict]??"usage",learned_from:[...e.events].sort()},h=$("stylenote",r);if(h.length>0)return{record:null,errors:h.map(o=>({code:o.code,detail:o.detail})),minted:0};let p=k("stylenote",r);if(s.hasNode(p))continue;d.push({cid:p,label:_.STYLENOTE,content:r});for(let o of r.learned_from)c.includes(o)||c.push(o);let l=S("stylenote",o=>g.has(o),s.names.keys());l!==null&&(g.add(l),a.push({cid:p,slug:l,by:f})),y+=1}return d.length===0?{record:null,errors:null,minted:0}:{record:N(u,{ts:new Date().toISOString(),proposal_id:null,nodes:d,edges:[],review:[],supersessions:[],source_head_moves:{},...a.length>0?{names:a}:{}},{graph:s,expectPrev:s.latestHash,intent:{v:1,verb:"distill",args:w({watermark:v,by:f}),pins:{events:c}},provenance:m.provenance}).record,errors:null,minted:y}}export{P as a};
2
+ import{L as N,a as k,pa as S,r as w}from"./chunk-PI7OXS62.js";import{f as _,h as $}from"./chunk-KU3YHPWZ.js";var T=3,F={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function P(m){let{store:u,graph:s,watermark:v,by:f}=m,{signals:b}=u.signals().snapshot(v),E=b.filter(e=>e.event_id===void 0||s.appliedEvents.has(e.event_id)),n=new Map;for(let e of E){let t=e.event_id??`${e.ts}|${e.id}|${e.verdict}|${e.polarity}`;n.has(`${t}|${e.polarity}|${e.verdict}`)||n.set(`${t}|${e.polarity}|${e.verdict}`,e)}let j=[...n.values()].sort((e,t)=>(e.event_id??e.ts)<(t.event_id??t.ts)?-1:1),i=new Map;for(let e of j){let t=`${e.verdict}|${e.tag??""}`,r=i.get(t)??{verdict:e.verdict,tag:e.tag,events:new Set};r.events.add(e.event_id??e.ts),i.set(t,r)}let d=[],a=[],g=new Set,c=[],y=0;for(let[,e]of[...i.entries()].sort(([t],[r])=>t<r?-1:1)){if(e.events.size<T)continue;let r={derived:!0,statement:`${e.verdict}${e.tag?`/${e.tag}`:""} recurs (${e.events.size} distinct events) \u2014 bias future proposals ${e.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:F[e.verdict]??"usage",learned_from:[...e.events].sort()},h=$("stylenote",r);if(h.length>0)return{record:null,errors:h.map(o=>({code:o.code,detail:o.detail})),minted:0};let p=k("stylenote",r);if(s.hasNode(p))continue;d.push({cid:p,label:_.STYLENOTE,content:r});for(let o of r.learned_from)c.includes(o)||c.push(o);let l=S("stylenote",o=>g.has(o),s.names.keys());l!==null&&(g.add(l),a.push({cid:p,slug:l,by:f})),y+=1}return d.length===0?{record:null,errors:null,minted:0}:{record:N(u,{ts:new Date().toISOString(),proposal_id:null,nodes:d,edges:[],review:[],supersessions:[],source_head_moves:{},...a.length>0?{names:a}:{}},{graph:s,expectPrev:s.latestHash,intent:{v:1,verb:"distill",args:w({watermark:v,by:f}),pins:{events:c}},provenance:m.provenance}).record,errors:null,minted:y}}export{P as a};
@@ -1,2 +1,2 @@
1
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 g="0.10.0";var a=t(s(),".testmuai","kaneai"),h=t(a,"profiles"),u=t(a,"tui-config.json"),U=t(a,"media"),_="https://registry.npmjs.org/@testmuai/kane-cli",x="https://api.github.com/repos/LambdaTest/kane-cli/releases",i="@testmuai/kane-cli-skill",A=`https://registry.npmjs.org/${i}`,r="kane-cli",L=[{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"}],I="https://dd-proxy.lambdatest.com/intake/kane-cli",R="https://kaneai-playground.lambdatest.io",E=9222,C=9230,v=t(a,"chrome-profiles"),o=t(a,"hints"),f=t(o,"state.json");function B(e){return t(o,`catalog-${e}.json`)}var l=t(a,"evidence");function S(e){return t(l,`catalog-kane-cli-${e}.json`)}var c=t(a,"mobile");function T(e,n="android"){return t(c,n==="ios"?`device-catalog-ios-${e}.json`:`device-catalog-${e}.json`)}var m="127.0.0.1",N=18392,k=18400,p="/callback";function O(e){return`http://${m}:${e}${p}`}var P="KANE CLI",D="*",H={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",latticeBaseUrl:"https://kaneai-api.lambdatest.com/v16-lattice",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",latticeBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-lattice",deviceStreamUrl:"https://stage-stream-microfrontend.lambdatestinternal.com"}},M={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{g as a,a as b,u as c,U as d,_ as e,x as f,i as g,L as h,I as i,R as j,E as k,C as l,v as m,f as n,B as o,S as p,T as q,m as r,N as s,k as t,p as u,O as v,P as w,D as x,H as y,M as z};
2
+ import{homedir as s}from"os";import{join as t}from"path";var g="0.10.3";var a=t(s(),".testmuai","kaneai"),h=t(a,"profiles"),u=t(a,"tui-config.json"),U=t(a,"media"),_="https://registry.npmjs.org/@testmuai/kane-cli",x="https://api.github.com/repos/LambdaTest/kane-cli/releases",i="@testmuai/kane-cli-skill",A=`https://registry.npmjs.org/${i}`,r="kane-cli",L=[{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"}],I="https://dd-proxy.lambdatest.com/intake/kane-cli",R="https://kaneai-playground.lambdatest.io",E=9222,C=9230,v=t(a,"chrome-profiles"),o=t(a,"hints"),f=t(o,"state.json");function B(e){return t(o,`catalog-${e}.json`)}var l=t(a,"evidence");function S(e){return t(l,`catalog-kane-cli-${e}.json`)}var c=t(a,"mobile");function T(e,n="android"){return t(c,n==="ios"?`device-catalog-ios-${e}.json`:`device-catalog-${e}.json`)}var m="127.0.0.1",N=18392,k=18400,p="/callback";function O(e){return`http://${m}:${e}${p}`}var P="KANE CLI",D="*",H={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",latticeBaseUrl:"https://kaneai-api.lambdatest.com/v16-lattice",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",latticeBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-lattice",deviceStreamUrl:"https://stage-stream-microfrontend.lambdatestinternal.com"}},M={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{g as a,a as b,u as c,U as d,_ as e,x as f,i as g,L as h,I as i,R as j,E as k,C as l,v as m,f as n,B as o,S as p,T as q,m as r,N as s,k as t,p as u,O as v,P as w,D as x,H as y,M as z};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R,b as C,f as T,h as N,i as _,j as $,k,l as x,m as j,p as A,q as W}from"./chunk-TLOYTGVT.js";import{a as p,e as E}from"./chunk-I2MC6VVX.js";var H=500;async function U(t,e){let l=e.now??(()=>new Date),u=e.sleep??(o=>new Promise(m=>setTimeout(m,o))),i=(await t.eventsAfter(0)).map(({seq:o,kind:m,at:S,body:y})=>({seq:o,kind:m,at:S,payload:y})),n=i.length,c=!1,s=null,h=[],d=()=>{for(let o of[...h]){if(s)o.reject(s);else if(n>=o.through)o.resolve();else continue;h.splice(h.indexOf(o),1)}},w=o=>{s=o,d(),e.onStopped(o)};async function r(){if(c||s)return;c=!0;let o=e.retryDeadlineMs??12e4,m=E(o,u,()=>l().getTime());for(;!s&&n<i.length;){let S=i.slice(n,n+H);try{await t.appendEvents(e.generation,S.map(({seq:y,kind:f,at:a,payload:g})=>({seq:y,kind:f,at:a,body:g}))),n+=S.length,m.reset(),e.imports?.answered(),d()}catch(y){let f=y instanceof p?y:new p(0,"UNREACHABLE",String(y));if(k(f)&&e.imports){if(await e.imports.wait())continue;w(x());break}if(!f.retryable){w(f);break}if(!await m.again()){w(new p(f.status,f.code,`the session's events were not stored within ${o/1e3} s: ${f.message}`,null,null,{},f.requestId));break}}}c=!1}return{append(o,m){let S={seq:i.length+1,kind:o,at:l().toISOString(),payload:m};return i.push(S),r(),S},since(o){return i.slice(Math.max(0,o))},lastSeq(){return i.length},halt(o){s||(s=o,d())},flush(){if(s)return Promise.reject(s);let o=i.length;return n>=o?Promise.resolve():new Promise((m,S)=>h.push({through:o,resolve:m,reject:S}))}}}function B(t,e){let l=e.now??(()=>new Date),u=e.sleep??(i=>new Promise(n=>setTimeout(n,i)));return{async save(i,n){if(i!==e.sessionId)throw new Error(`this host holds the token of session ${e.sessionId}; it cannot save session ${i}`);let{status:c,lastActivityAt:s}=n;await t.save({generation:e.generation,...s===void 0?{}:{lastActivityAt:s},...c===void 0?{}:{status:q(c)}})},async end(i,n){if(i!==e.sessionId)throw new Error(`this host holds the token of session ${e.sessionId}; it cannot end session ${i}`);let c=n.state==="complete"||n.state==="failed"?n.state:null;if(c===null)throw new Error(`session ${i}: ${n.state} is not an ending`);let s=e.endDeadlineMs??12e4,h=E(s,u,()=>l().getTime());for(;;)try{await t.save({generation:e.generation,status:q(n),ended:c,lastActivityAt:l().toISOString()});return}catch(d){let w=d instanceof p&&d.retryable&&!await h.again();if(!(d instanceof p)||!d.retryable||w){let r=w?new p(d.status,d.code,`the ending was not stored within ${s/1e3} s: ${d.message}`,null,null,{},d.requestId):d;throw r instanceof p&&e.onStopped?.(r),r}}}}}function q(t){let e=t.checkIn?{checkIn:"phase",...t.phase?{phase:t.phase}:{}}:{};return{state:t.state,panel:t.panel,error:t.error,...e}}var O=class extends Error{constructor(l,u){super(u);this.side=l;this.name="EngineFormsMismatch"}},Y=3e4,G=["main/history","save-state","session-side","ended"];async function Se(t){let e=t.testing??{},l={url:t.url,basicAuth:t.basicAuth,...e.fetch?{fetch:e.fetch}:{},...e.requestDeadlineMs?{requestDeadlineMs:e.requestDeadlineMs}:{}},u=T(l),i=async a=>{let g=E(e.retryDeadlineMs??12e4);for(;;)try{return await a()}catch(v){if(!(v instanceof p)||!v.retryable)throw v;let L=D=>t.onProgress({kind:"retry",attempt:g.attempt,nextInS:Math.ceil(D/1e3),giveUpAt:new Date(g.endsAt()??Date.now()).toISOString(),cause:A(v)});if(!await g.again(L))throw v}};t.onProgress({kind:"connect",step:"service"});let n=t.start.kind==="new"?await i(()=>u.createSession(t.start.body)):await i(()=>u.getSession(t.start.sessionId));if(n.ended!==null)throw new p(409,"SESSION_ENDED",`session ${n.sessionId} has ended (${n.ended}); start a new one`,null,null,{ended:n.ended});let c=$({...l,sessionId:n.sessionId,onBody:K(t.onProgress)});t.onProgress({kind:"connect",step:"session",sid:n.sessionId,...t.projectName!==void 0?{project:t.projectName}:{}});let s=await i(()=>c.claim()),h=G.filter(a=>!s.features?.includes(a));if(h.length>0)throw new O("service_older",`Lattice at ${t.url} does not serve ${h.join(", ")}; it is older than this kane-cli`);let d=s.engine;if(!d||1>d.forms||1<d.oldestRead){let a=d&&1<d.oldestRead?"cli_older":"service_older";throw new O(a,`Lattice at ${t.url} serves engine forms ${d?.oldestRead??"none"} to ${d?.forms??"none"}, and this kane-cli writes ${1}`)}let w=!1,r=null,o=a=>{if(w)return;w=!0,clearInterval(f);let g=a.code===_&&r!==null;t.onStopped(g?new p(a.status,V,`the lease lapsed while Lattice could not be reached: ${a.message}`,null,null,{},a.requestId):a)},m=e.leaseRenewMs??Y,S=e.retryDeadlineMs??12e4,y=0,f=setInterval(()=>{c.renewLease(s.generation).then(()=>{r=null,y=0},a=>{if(!(a instanceof p))return;if(J.has(a.code))return o(a);if(!a.retryable)return;let g=Date.now();r??=g;let v=r+S;if(g>=v)return o(new p(a.status,a.code,`Lattice did not take the lease for ${S/1e3} s: ${a.message}`,null,null,{},a.requestId));y+=1,t.onProgress({kind:"retry",attempt:y,nextInS:Math.ceil(m/1e3),giveUpAt:new Date(v).toISOString(),cause:A(a)})})},m);f.unref();try{let a=j(),g=e.retryDeadlineMs!==void 0?{retryDeadlineMs:e.retryDeadlineMs}:{},v=await U(c,{generation:s.generation,onStopped:o,imports:a,...g}),L=B(c,{sessionId:n.sessionId,generation:s.generation,onStopped:o}),D=W(c,{generation:s.generation,historyForms:d.forms,children:s.children,onStopped:o,log:v,imports:a,onRetry:P=>t.onProgress({kind:"retry",attempt:P.attempt,nextInS:Math.ceil(P.nextInMs/1e3),giveUpAt:new Date(P.giveUpAt).toISOString(),cause:P.cause}),...g}),M=await u.getSession(n.sessionId);return t.start.kind==="new"&&ee(u,M,t.onProgress,t.log??(()=>{})),{record:M,claim:s,client:c,person:u,storeCalls:D,log:v,state:L,release:()=>clearInterval(f)}}catch(a){throw clearInterval(f),a}}var V="CONNECTION_LOST",J=new Set([_,N,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function K(t){let e=new Map;return(l,u,i)=>{let n=/\/main\/history/.test(l)?"history":/\/embeddings\?/.test(l)?"search":/\/scope\/drafts/.test(l)?"session":null;if(n===null)return;let c=i===null?0:Math.min(10,Math.floor(u*10/Math.max(i,1)));e.has(l)&&e.get(l)>=c||(e.set(l,c),t({kind:"load",part:n,done:u,total:i,unit:"bytes"}))}}var F=3e3,Q=4;async function z(t,e,l,u){if(!l.sourceId&&!l.useCase)return[];let i=await t.listSessions(e,l),n=i.find(c=>c.sessionId===u)?.userId??null;return Z(t,e,i.filter(c=>c.sessionId!==u),n)}function X(t,e){return t.mine!==void 0?t.mine?"you":"someone_else":e===null?null:t.userId===e?"you":"someone_else"}async function Z(t,e,l,u,i=Q){let n=l.filter(r=>R(r)!=="saved"&&R(r)!=="discarded"),c=async r=>{let o=(await t.counts(e,r.sessionId)).proposes,m=r.verb==="design"?C(o):o.useCases??0;return{sid:r.sessionId,owner:X(r,u),verb:r.verb,subject:r.useCase??r.sourceId,state:R(r),added:m,lastActivityAt:r.lastActivityAt??r.createdAt}},s=new Array(n.length),h=0,d=async()=>{for(let r=h++;r<n.length;r=h++)s[r]=await c(n[r])};await Promise.all(Array.from({length:Math.min(i,n.length)},d));let w=r=>Date.parse(r.lastActivityAt??"")||0;return s.sort((r,o)=>+(o.owner==="you")-+(r.owner==="you")||w(o)-w(r))}function ee(t,e,l,u){let i=!1,n=setTimeout(()=>i=!0,F);n.unref();let c={...e.sourceId?{sourceId:e.sourceId}:{},...e.useCase?{useCase:e.useCase}:{}};z(t,e.projectId,c,e.sessionId).then(s=>{clearTimeout(n),i?u(`the other open sessions on this subject answered after ${F/1e3} s, too late to show (${s.length} open)`):s.length>0&&l({kind:"overlap",sessions:s})},s=>{clearTimeout(n),u(`the other open sessions on this subject couldn't be read: ${s instanceof p?`${s.code}: ${s.message}`:s instanceof Error?s.message:String(s)}`)})}export{O as a,Se as b,X as c,Z as d};
2
+ import{a as R,b as C,f as T,h as N,i as _,j as $,k,l as x,m as j,p as A,q as W}from"./chunk-WE7HRAGO.js";import{a as p,e as E}from"./chunk-4C7WVQOD.js";var H=500;async function U(t,e){let l=e.now??(()=>new Date),u=e.sleep??(o=>new Promise(m=>setTimeout(m,o))),i=(await t.eventsAfter(0)).map(({seq:o,kind:m,at:S,body:y})=>({seq:o,kind:m,at:S,payload:y})),n=i.length,c=!1,s=null,h=[],d=()=>{for(let o of[...h]){if(s)o.reject(s);else if(n>=o.through)o.resolve();else continue;h.splice(h.indexOf(o),1)}},w=o=>{s=o,d(),e.onStopped(o)};async function r(){if(c||s)return;c=!0;let o=e.retryDeadlineMs??12e4,m=E(o,u,()=>l().getTime());for(;!s&&n<i.length;){let S=i.slice(n,n+H);try{await t.appendEvents(e.generation,S.map(({seq:y,kind:f,at:a,payload:g})=>({seq:y,kind:f,at:a,body:g}))),n+=S.length,m.reset(),e.imports?.answered(),d()}catch(y){let f=y instanceof p?y:new p(0,"UNREACHABLE",String(y));if(k(f)&&e.imports){if(await e.imports.wait())continue;w(x());break}if(!f.retryable){w(f);break}if(!await m.again()){w(new p(f.status,f.code,`the session's events were not stored within ${o/1e3} s: ${f.message}`,null,null,{},f.requestId));break}}}c=!1}return{append(o,m){let S={seq:i.length+1,kind:o,at:l().toISOString(),payload:m};return i.push(S),r(),S},since(o){return i.slice(Math.max(0,o))},lastSeq(){return i.length},halt(o){s||(s=o,d())},flush(){if(s)return Promise.reject(s);let o=i.length;return n>=o?Promise.resolve():new Promise((m,S)=>h.push({through:o,resolve:m,reject:S}))}}}function B(t,e){let l=e.now??(()=>new Date),u=e.sleep??(i=>new Promise(n=>setTimeout(n,i)));return{async save(i,n){if(i!==e.sessionId)throw new Error(`this host holds the token of session ${e.sessionId}; it cannot save session ${i}`);let{status:c,lastActivityAt:s}=n;await t.save({generation:e.generation,...s===void 0?{}:{lastActivityAt:s},...c===void 0?{}:{status:q(c)}})},async end(i,n){if(i!==e.sessionId)throw new Error(`this host holds the token of session ${e.sessionId}; it cannot end session ${i}`);let c=n.state==="complete"||n.state==="failed"?n.state:null;if(c===null)throw new Error(`session ${i}: ${n.state} is not an ending`);let s=e.endDeadlineMs??12e4,h=E(s,u,()=>l().getTime());for(;;)try{await t.save({generation:e.generation,status:q(n),ended:c,lastActivityAt:l().toISOString()});return}catch(d){let w=d instanceof p&&d.retryable&&!await h.again();if(!(d instanceof p)||!d.retryable||w){let r=w?new p(d.status,d.code,`the ending was not stored within ${s/1e3} s: ${d.message}`,null,null,{},d.requestId):d;throw r instanceof p&&e.onStopped?.(r),r}}}}}function q(t){let e=t.checkIn?{checkIn:"phase",...t.phase?{phase:t.phase}:{}}:{};return{state:t.state,panel:t.panel,error:t.error,...e}}var O=class extends Error{constructor(l,u){super(u);this.side=l;this.name="EngineFormsMismatch"}},Y=3e4,G=["main/history","save-state","session-side","ended"];async function Se(t){let e=t.testing??{},l={url:t.url,basicAuth:t.basicAuth,...e.fetch?{fetch:e.fetch}:{},...e.requestDeadlineMs?{requestDeadlineMs:e.requestDeadlineMs}:{}},u=T(l),i=async a=>{let g=E(e.retryDeadlineMs??12e4);for(;;)try{return await a()}catch(v){if(!(v instanceof p)||!v.retryable)throw v;let L=D=>t.onProgress({kind:"retry",attempt:g.attempt,nextInS:Math.ceil(D/1e3),giveUpAt:new Date(g.endsAt()??Date.now()).toISOString(),cause:A(v)});if(!await g.again(L))throw v}};t.onProgress({kind:"connect",step:"service"});let n=t.start.kind==="new"?await i(()=>u.createSession(t.start.body)):await i(()=>u.getSession(t.start.sessionId));if(n.ended!==null)throw new p(409,"SESSION_ENDED",`session ${n.sessionId} has ended (${n.ended}); start a new one`,null,null,{ended:n.ended});let c=$({...l,sessionId:n.sessionId,onBody:K(t.onProgress)});t.onProgress({kind:"connect",step:"session",sid:n.sessionId,...t.projectName!==void 0?{project:t.projectName}:{}});let s=await i(()=>c.claim()),h=G.filter(a=>!s.features?.includes(a));if(h.length>0)throw new O("service_older",`Lattice at ${t.url} does not serve ${h.join(", ")}; it is older than this kane-cli`);let d=s.engine;if(!d||1>d.forms||1<d.oldestRead){let a=d&&1<d.oldestRead?"cli_older":"service_older";throw new O(a,`Lattice at ${t.url} serves engine forms ${d?.oldestRead??"none"} to ${d?.forms??"none"}, and this kane-cli writes ${1}`)}let w=!1,r=null,o=a=>{if(w)return;w=!0,clearInterval(f);let g=a.code===_&&r!==null;t.onStopped(g?new p(a.status,V,`the lease lapsed while Lattice could not be reached: ${a.message}`,null,null,{},a.requestId):a)},m=e.leaseRenewMs??Y,S=e.retryDeadlineMs??12e4,y=0,f=setInterval(()=>{c.renewLease(s.generation).then(()=>{r=null,y=0},a=>{if(!(a instanceof p))return;if(J.has(a.code))return o(a);if(!a.retryable)return;let g=Date.now();r??=g;let v=r+S;if(g>=v)return o(new p(a.status,a.code,`Lattice did not take the lease for ${S/1e3} s: ${a.message}`,null,null,{},a.requestId));y+=1,t.onProgress({kind:"retry",attempt:y,nextInS:Math.ceil(m/1e3),giveUpAt:new Date(v).toISOString(),cause:A(a)})})},m);f.unref();try{let a=j(),g=e.retryDeadlineMs!==void 0?{retryDeadlineMs:e.retryDeadlineMs}:{},v=await U(c,{generation:s.generation,onStopped:o,imports:a,...g}),L=B(c,{sessionId:n.sessionId,generation:s.generation,onStopped:o}),D=W(c,{generation:s.generation,historyForms:d.forms,children:s.children,onStopped:o,log:v,imports:a,onRetry:P=>t.onProgress({kind:"retry",attempt:P.attempt,nextInS:Math.ceil(P.nextInMs/1e3),giveUpAt:new Date(P.giveUpAt).toISOString(),cause:P.cause}),...g}),M=await u.getSession(n.sessionId);return t.start.kind==="new"&&ee(u,M,t.onProgress,t.log??(()=>{})),{record:M,claim:s,client:c,person:u,storeCalls:D,log:v,state:L,release:()=>clearInterval(f)}}catch(a){throw clearInterval(f),a}}var V="CONNECTION_LOST",J=new Set([_,N,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function K(t){let e=new Map;return(l,u,i)=>{let n=/\/main\/history/.test(l)?"history":/\/embeddings\?/.test(l)?"search":/\/scope\/drafts/.test(l)?"session":null;if(n===null)return;let c=i===null?0:Math.min(10,Math.floor(u*10/Math.max(i,1)));e.has(l)&&e.get(l)>=c||(e.set(l,c),t({kind:"load",part:n,done:u,total:i,unit:"bytes"}))}}var F=3e3,Q=4;async function z(t,e,l,u){if(!l.sourceId&&!l.useCase)return[];let i=await t.listSessions(e,l),n=i.find(c=>c.sessionId===u)?.userId??null;return Z(t,e,i.filter(c=>c.sessionId!==u),n)}function X(t,e){return t.mine!==void 0?t.mine?"you":"someone_else":e===null?null:t.userId===e?"you":"someone_else"}async function Z(t,e,l,u,i=Q){let n=l.filter(r=>R(r)!=="saved"&&R(r)!=="discarded"),c=async r=>{let o=(await t.counts(e,r.sessionId)).proposes,m=r.verb==="design"?C(o):o.useCases??0;return{sid:r.sessionId,owner:X(r,u),verb:r.verb,subject:r.useCase??r.sourceId,state:R(r),added:m,lastActivityAt:r.lastActivityAt??r.createdAt}},s=new Array(n.length),h=0,d=async()=>{for(let r=h++;r<n.length;r=h++)s[r]=await c(n[r])};await Promise.all(Array.from({length:Math.min(i,n.length)},d));let w=r=>Date.parse(r.lastActivityAt??"")||0;return s.sort((r,o)=>+(o.owner==="you")-+(r.owner==="you")||w(o)-w(r))}function ee(t,e,l,u){let i=!1,n=setTimeout(()=>i=!0,F);n.unref();let c={...e.sourceId?{sourceId:e.sourceId}:{},...e.useCase?{useCase:e.useCase}:{}};z(t,e.projectId,c,e.sessionId).then(s=>{clearTimeout(n),i?u(`the other open sessions on this subject answered after ${F/1e3} s, too late to show (${s.length} open)`):s.length>0&&l({kind:"overlap",sessions:s})},s=>{clearTimeout(n),u(`the other open sessions on this subject couldn't be read: ${s instanceof p?`${s.code}: ${s.message}`:s instanceof Error?s.message:String(s)}`)})}export{O as a,Se as b,X as c,Z as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as g}from"./chunk-H4KPNGY4.js";import{g as d}from"./chunk-U7NRZBB5.js";import{a as c}from"./chunk-KDR662D2.js";var p=["grounding","acs","scenarios","wiring","tests"];function P(i){let t=p.filter(e=>e!=="grounding"),n=0;for(let e of i)n=Math.max(n,t.indexOf(e)+1);return n}var x={acs:"acceptance criteria",scenarios:"scenarios",wiring:"acceptance criteria + exercises",tests:"tests + gaps"};function l(i,t,n){let e=t.resolve(n);if(e===null)return[];let s=c(t,e.cid),a=d(i.recordsSince(null),s),r=a.reduce((o,m)=>Math.max(o,m.generation),0);return a.filter(o=>o.generation===r)}function S(i,t,n,e){let s=p;if(!s.includes(e))return{ok:!1,code:"UNKNOWN_PHASE",message:`--phase must be one of ${s.join(" | ")}, got '${e}'`,valid:[...s]};let a=new Set(l(i,t,n).map(o=>o.phase)),r=s.slice(0,s.indexOf(e)).filter(o=>o!=="grounding"&&!a.has(o));return r.length===0?{ok:!0,phase:e}:{ok:!1,code:"PHASE_ORDER",message:`--phase ${e} needs ${r.join(" + ")} committed first (nothing recorded for ${r.join(", ")})`,missing:r,earliest:r[0]}}function E(i,t,n,e){let s=l(i,t,n),a=t.resolve(n);if(a===null)return{priorDesign:void 0,phaseLadder:s};let r=g(t,a.tip);return{priorDesign:r.scenarios.length===0&&r.tests.length===0&&r.acs.length===0?void 0:r,phaseLadder:s}}export{p as a,P as b,x as c,l as d,S as e,E as f};
2
+ import{b as g}from"./chunk-ZMWTRXFH.js";import{g as d}from"./chunk-MINDIQET.js";import{a as c}from"./chunk-3KY7HHQU.js";var p=["grounding","acs","scenarios","wiring","tests"];function P(i){let t=p.filter(e=>e!=="grounding"),n=0;for(let e of i)n=Math.max(n,t.indexOf(e)+1);return n}var x={acs:"acceptance criteria",scenarios:"scenarios",wiring:"acceptance criteria + exercises",tests:"tests + gaps"};function l(i,t,n){let e=t.resolve(n);if(e===null)return[];let s=c(t,e.cid),a=d(i.recordsSince(null),s),r=a.reduce((o,m)=>Math.max(o,m.generation),0);return a.filter(o=>o.generation===r)}function S(i,t,n,e){let s=p;if(!s.includes(e))return{ok:!1,code:"UNKNOWN_PHASE",message:`--phase must be one of ${s.join(" | ")}, got '${e}'`,valid:[...s]};let a=new Set(l(i,t,n).map(o=>o.phase)),r=s.slice(0,s.indexOf(e)).filter(o=>o!=="grounding"&&!a.has(o));return r.length===0?{ok:!0,phase:e}:{ok:!1,code:"PHASE_ORDER",message:`--phase ${e} needs ${r.join(" + ")} committed first (nothing recorded for ${r.join(", ")})`,missing:r,earliest:r[0]}}function E(i,t,n,e){let s=l(i,t,n),a=t.resolve(n);if(a===null)return{priorDesign:void 0,phaseLadder:s};let r=g(t,a.tip);return{priorDesign:r.scenarios.length===0&&r.tests.length===0&&r.acs.length===0?void 0:r,phaseLadder:s}}export{p as a,P as b,x as c,l as d,S as e,E as f};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as Oe}from"./chunk-BWXLZS5O.js";import{a as De,b as Me}from"./chunk-63EKRZKI.js";import{a as qe,c as Ne}from"./chunk-3JLEDSG5.js";import{b as $e,f as de,i as Ee}from"./chunk-6TNLITJO.js";import{A as Ae,D as ae,na as Ie,z as Te}from"./chunk-Z777GGHB.js";import{d as Re}from"./chunk-KU3YHPWZ.js";import{m as $}from"./chunk-4I7YN6YY.js";var Qe=new Set(["approve","edit","reject"]),Le=new Set(["approve","edit","reject","add","enhance","retract"]);function Fe(i,t){return t?`chatop:${t}:${i}`:`chatop:${i}`}function Ue(i,t,y,w){let k=`${t}:${i.target??"new"}:${i.op}:${i.seq}`,l=i.payload;switch(i.op){case"approve":return{kind:"approve",target:i.target,expectedCid:i.expected_cid,eventId:k};case"edit":{let{reason:C,...a}=l;return{kind:"edit",target:i.target,expectedCid:i.expected_cid,edit:a,reason:C,eventId:k}}case"enhance":return{kind:"enhance",target:i.target,expectedCid:i.expected_cid,edges:l.edges??[],eventId:k};case"retract":{let C=typeof l.reason=="string"?l.reason.trim():"";if(!C)throw new Error("INVALID_RETRACT: a retract needs a non-empty reason");let a=l.edge_ecid!==void 0&&l.edge_ecid!==null,d=l.edge!==void 0&&l.edge!==null;if(a&&d)throw new Error("INVALID_RETRACT: both edge_ecid and edge were sent \u2014 give exactly one");if(!a&&!d)throw new Error("INVALID_RETRACT: neither edge {type, dst, src?} (display refs) nor edge_ecid was sent \u2014 give exactly one");let g={kind:"retract",target:i.target,expectedCid:i.expected_cid,reason:C};if(a){if(typeof l.edge_ecid!="string"||!l.edge_ecid)throw new Error("INVALID_RETRACT: edge_ecid must be a non-empty string");return{...g,edgeEcid:l.edge_ecid,eventId:`${t}:${i.target}:retract:e:${l.edge_ecid}:${i.seq}`}}let f=l.edge;if(typeof f!="object"||typeof f.type!="string"||!f.type||typeof f.dst!="string"||!f.dst)throw new Error("INVALID_RETRACT: edge needs {type, dst} (src optional), all display refs");if(f.src!==void 0&&f.src!==null&&(typeof f.src!="string"||!f.src))throw new Error("INVALID_RETRACT: edge.src, when given, must be a non-empty display ref");let v=typeof f.src=="string"?f.src:void 0;return{...g,edgeRef:{type:f.type,dst:f.dst,...v!==void 0?{src:v}:{}},eventId:`${t}:${i.target}:retract:t:${f.type}:${f.dst}:${v??"-"}:${i.seq}`}}case"reject":return{kind:"reject",target:i.target,expectedCid:i.expected_cid,reason:l.reason??"",redirectTo:l.redirect_to,eventId:k};case"add":{let C=l.proposal_item??{},a=String(C.label??"");if(!y.mint_gate.includes(a))throw new Error(`GATED_LABEL: cannot mint "${a}" (gate: ${y.mint_gate.join(", ")})`);let d=C.cite??{},g=C.conv_source_id??w;if(!g||typeof d.turn!="number"||!d.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");let f=C.content,v=f&&typeof f=="object"&&!Array.isArray(f)&&Object.keys(f).length>0?f:null,A=new Set(["label","cite","conv_source_id","content","rationale","edges"]),S=v??Object.fromEntries(Object.entries(C).filter(([N])=>!A.has(N)));return{kind:"add",label:a,content:S,cite:{turn:d.turn,quote:d.quote},convSourceId:g,rationale:C.rationale,eventId:k}}}}function je(i,t,y={}){let w=y.turn??0,k=[],l=[];for(let[d,g]of i.entries()){let f=Te(g,`ops[${d}]`);if(f!==null)throw new Error(`NUL_IN_TEXT: ${Ae(f)}`)}for(let d of i){if(!Le.has(d.op))throw new Error(`UNKNOWN_OP: "${d.op}" is not a chat op (accepted: ${[...Le].join(", ")})`);if(d.op!=="add"&&!d.target)throw new Error(`MISSING_TARGET: a ${d.op} op needs a target ref`)}for(let d of i)(d.op==="add"||d.op==="enhance"||d.op==="retract")&&l.push(d);let C=new Map;for(let d of i){if(!Qe.has(d.op)||!d.target)continue;let g=C.get(d.target)??[];g.push(d),C.set(d.target,g)}for(let[d,g]of C){let f=Math.max(...g.map(A=>A.seq)),v=g.filter(A=>A.seq===f);if(v.length>1){k.push({target:d,seq:f,kinds:v.map(A=>A.op)});continue}l.push(v[0])}return{chatOps:l.sort((d,g)=>d.seq-g.seq).map(d=>Ue(d,y.prefix??Fe(w,y.session),t,y.convSourceId)),ambiguous:k}}function Pe(i,t){return i.map(y=>{let w=y.data?.tip;if(y.code!=="EXPECTED_CID_MOVED"||typeof w!="string")return{code:y.code};let k=t?.getNode(w)?.content??{},l=typeof k.title=="string"?k.title:typeof k.text=="string"?k.text:void 0,C=t?.displayNameOf(w)??(typeof y.data?.target=="string"?y.data.target:void 0);return{code:y.code,moved:y.data?.moved===!0,...C?{ref:C}:{},...l?{title:l}:{}}})}function He(i){let t=[];return i.questions.forEach((y,w)=>{if(i.resolution[w])return;let k=y.recommended_index!=null?y.options[y.recommended_index]?.label:void 0;k!=null&&t.push(y.risk==="high"?`${B(k)} \u203C`:B(k))}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function B(i){return i.replace(/\s*\(recommended\)\s*$/i,"")}function Be(i){let t=i.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function ze(i,t){let y=new Set;for(let w=t;w&&!y.has(w);w=i.superseded.get(w)){if(i.trust.get(w)==="archived")return!0;y.add(w)}return!1}function Ve(i){return i.use_cases??[]}var Ke={acs:"acceptance criteria",scenarios:"scenarios",exercises:"exercises",tests:"tests",gaps:"gaps"};function Xe(i){let t=[],y=[],w=(a,d)=>{d.length!==0&&(y.push(a),t.push(...d))},k=a=>typeof a=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(a)?a:null,l=a=>{let d=k(a.automates)??"1 scenario",g=a.verifies??[],f=g.map(k).filter(S=>S!==null).slice(0,2),v=g.length-f.length,A=f.length?`${f.join(" ")}${v>0?` +${v}`:""}`:`${g.length} ACs`;return`covers ${d} \xB7 verifies ${A}`};w("acs",(i.acs??[]).map(a=>({temp_ref:a.temp_ref,title:a.text,kind:"ac",badge:String(a.kind),extra:{...a.expected_answer?{expects:`${String(a.expected_answer.operator??"")} \xB7 ${String(a.expected_answer.operand??"")}`}:{},"scoped to":a.scoped_to??"(use-case)"}}))),w("scenarios",(i.scenarios??[]).map(a=>({temp_ref:a.temp_ref,title:a.title,kind:"scenario",badge:a.case_type,why:a.intent,depends_on_hint:a.depends_on??[],extra:{technique:a.technique_notes}}))),w("exercises",(i.exercises??[]).map(a=>({temp_ref:k(a.scenario)??"wiring",title:`${k(a.scenario)??"scenario"} exercises ${k(a.ac)??"1 AC"}`,kind:"exercise",badge:"wires",why:a.rationale}))),w("tests",(i.tests??[]).map(a=>({temp_ref:a.temp_ref,title:a.title,kind:"test",why:l(a),depends_on_hint:a.reuses??[],extra:{automates:String(a.automates??"?"),verifies:(a.verifies??[]).join(", "),check:a.check?`${String(a.check.kind)} vs ${String(a.check.verified_against)}`:"?"}})));let C={high:"high",medium:"med",med:"med",low:"low"};return w("gaps",(i.gaps??[]).map(a=>{let d=a.question??{};return{temp_ref:a.temp_ref??a.ref??"?",title:String(d.header??a.kind),kind:"gap",badge:C[String(a.risk??"").trim().toLowerCase()]??"",why:d.prompt??d.text??"",question:String(d.prompt??d.text??d.header??""),rationale:String(a.risk_rationale??"")}})),{items:t,heading:y.join(" + ")||"design"}}function ut(i={}){let t={turns:[],thinking:De(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},y=e=>{let n=[],r=e.minted.map(u=>u.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let s=e.applied.length-e.minted.length;s>0&&n.push(`${s} change${s===1?"":"s"} applied`);let o=e.staleDelta.length?$().text("chat.stales",{count:e.staleDelta.length}):"";return o&&n.push(o),n.join(" \xB7 ")||"no changes"},w=(e,n)=>{let r=i.refreshGraph?.()??i.graph;return!r?.nodeLabel||n.applied.length===0||n.minted.length>0||n.staleDelta.length>0?!1:e.every(s=>{if(s.kind!=="approve"||!s.target)return!1;let o=r.resolve(s.target);return o!==null&&r.nodeLabel.get(r.tipOf(o.cid))==="usecase"})},k=[];i.onRender&&k.push(i.onRender);let l=0,C=new Map,a=e=>{let n=C.get(e);if(n===void 0){let r=`chatop:${e}:`;n=0;for(let s of(i.refreshGraph?.()??i.graph)?.appliedEvents??[]){if(!s.startsWith(r))continue;let o=Number(s.slice(r.length).split(":")[0]);Number.isInteger(o)&&o>n&&(n=o)}C.set(e,n)}return n},d=0,g=null,f=null,v=null,A=null,S=[],N=null,ee=!1,G=0,te=null,M=null,ne=0,ue=0,le=!1,ce=!1,ge=e=>(le||(le=!0,m({kind:"note",text:$().text("note.turns_unrecorded",{detail:e})}),p()),null),pe=(e,n)=>{if(!v||!i.store||!e.trim())return null;try{let r=i.refreshGraph?.()??i.graph;if(!r)return null;let s=Ee({store:i.store,graph:r,sourceId:v,text:e,speaker:n,by:i.by??{kind:"human",id:"owner"}});return s.errors?ge(s.errors.map(o=>o.detail).join("; ")):s.record!==null?$e(v,s.turn):null}catch(r){return ge(r instanceof Error?r.message:String(r))}},Ge=e=>{if(!v||!i.store)return;let n=i.refreshGraph?.()??i.graph,r=n?.heads.get(v),s=n?.convChains.get(v);if(!n||typeof r!="string"||!s)return;let o=n.getNode(r)?.content?.blob,u=typeof o=="string"?i.store.getBlob(o)?.toString("utf8")??"":"";if(u)for(let h of e){if(h.kind!=="add"||h.convSourceId!==v)continue;let _=de(u,h.cite.turn);if(!(_!==null&&ae(h.cite.quote,_)))for(let R=s.turns;R>=1;R--){let b=de(u,R);if(b!==null&&ae(h.cite.quote,b)){h.cite={...h.cite,turn:R};break}}}},T={startedAt:null,thinkMs:0,toolCalls:0,tools:new Map},W=()=>{T.startedAt??=Date.now()},D=()=>{if(T.toolCalls>0){let e=T.startedAt!=null?Math.max(1,Math.round((Date.now()-T.startedAt)/1e3)):Math.max(1,Math.round(T.thinkMs/1e3));m({kind:"worked",durS:e,toolCalls:T.toolCalls,tools:[...T.tools.entries()].map(([n,r])=>({name:n,n:r}))})}T.startedAt=null,T.thinkMs=0,T.toolCalls=0,T.tools.clear()},Q=null,re=new Map,fe=e=>JSON.stringify([e.id,e.text,e.options.map(n=>n.label)]),F=null,me=new Map,ie=new Map,U=new Map,he=null,p=()=>{H&&(clearTimeout(H),H=null),ke();for(let e of k)e()},ke=()=>{G>0&&g!=null&&g!==te?t.nestedAgent=!0:delete t.nestedAgent},H=null,be=()=>{H||(H=setTimeout(()=>{H=null,ke();for(let e of k)e()},80))},Y=0,m=e=>{e.kind==="childClose"&&Y>0&&(Y-=1),Y>0&&e.kind!=="childOpen"&&e.kind!=="childBack"&&(e.era=Y),e.kind==="childOpen"&&(Y+=1),t.ledger.push(e)},z=null,Z=!1,se=0,V=(e=!1)=>{if(z)m({kind:"agent",text:z});else if(e&&Z){let r=([...t.turns].reverse().find(s=>s.role==="agent")?.items??[]).filter(s=>!s.matches_existing).length;m({kind:"note",text:$().text("chat.refine_hint",{added:r,held:se})})}z=null,Z=!1,se=0,delete t.committing},We=()=>{z=null,Z=!1,delete t.committing},E=null,oe=(e,n=!1,r)=>{if(!E)return;if(e)for(let o of E.items){let u=e.get(o.temp_ref);u&&(o.logical_id=u)}if(r)for(let o of E.items)r.has(o.temp_ref)&&(o.sessionAdded=!0);let s=E.items.filter(o=>o.kind==="test");if(s.length>0){let o;try{o=i.refreshGraph?.()??i.graph}catch{o=i.graph}let u=h=>{if(Ie.test(h))return h;let _=e?.get(h);if(_)return _;let R=h.startsWith("sha256:")?h:U.get(h);return(R?o?.displayNameOf(R):null)??null};for(let h of s){let _=h.extra??{},R=_.verifies?_.verifies.split(", "):[];h.links={covers:_.automates&&_.automates!=="?"?u(_.automates):null,verifies:R.map(u).filter(b=>b!==null),verifiesTotal:R.length}}}if(n)for(let o of E.items)o.logical_id||(o.held=!0);m({kind:"turn",...E}),E=null},ye=()=>{let e=i.refreshGraph?.()??i.graph;if(!i.commitChatTurn||!e?.trust)return!0;let n=[];for(let{item:b}of Oe(t.turns).entries){if(!b.logical_id||b.turnedDown||b.matches_existing||(b.kind??"use-case")!=="use-case")continue;let I=e.names?.get(b.logical_id)??U.get(b.temp_ref);if(!I)continue;let c=e.tipOf(I);e.trust.get(c)==="derived"&&!n.includes(c)&&n.push(c)}let r=new Set(i.addedBefore?.()??[]);for(let b of r){let I=e.tipOf(b);r.has(I)&&e.trust.get(I)==="derived"&&!n.includes(I)&&n.push(I)}if(n.length===0)return!0;l+=1;let s=v||i.session?.state?.sid,o=l+(s?a(s):0),u=s?`chatop:${s}:${o}`:`chatop:${o}`,h=n.map((b,I)=>({kind:"approve",target:b,expectedCid:b,eventId:`${u}:${b}:approve:${I}`})),_;try{_=i.commitChatTurn({graph:e,ops:h,by:i.by??{kind:"human",id:"owner"},...i.descriptor?.mint_gate?{mintable:i.descriptor.mint_gate}:{},...i.session?.state?.sid?{sid:i.session.state.sid}:{}})}catch(b){_={record:null,errors:[{code:"COMMIT_THREW",detail:b instanceof Error?b.message:String(b)}]}}if(_.errors)return t.error=_.errors.map(b=>b.detail).join("; "),m({kind:"commit",ok:!1,line:$().text("chat.commit_failed",{}),warnings:_.errors.map(b=>`${b.code}: ${b.detail}`),refused:Pe(_.errors,e),person:!0}),p(),!1;_.applied.length>0&&i.session?.markApplied(_.applied),m({kind:"commit",ok:!0,line:$().text("chat.approved",{count:_.applied.length})});let R=i.refreshGraph?.();return R&&f&&f(R),xe(R??i.graph),!0},xe=e=>{if(!(!e?.trust||!e.superseded))for(let n of t.turns)for(let r of n.items??[]){let s=r.logical_id&&e.names?.get(r.logical_id)||U.get(r.temp_ref);s&&(ze(e,s)?r.turnedDown=!0:delete r.turnedDown)}},q=()=>{oe(),delete t.committing,t.activeTurn&&(t.activeTurn=null)},ve=(e,n)=>{let r=n.selected_index!=null?e.options[n.selected_index]?.label:void 0;return n.choice||(r!=null?B(r):"?")},K=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(s=>s===null);return}let n=e.questions.map((s,o)=>{let u=e.resolution[o];return u.form==="deferred"?{id:s.id,selected_index:null,free_text:null}:{id:s.id,selected_index:u.selected_index,free_text:u.free_text}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now());let r=Q;Q=null,r?.(n)},L=(e,n)=>{let r=t.pending,s=r.questions[e],o=r.resolution[e];r.resolution[e]=n;let u=Be(s);o?m({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:u,choice:ve(s,n),prev:o.choice}}):n.form==="deferred"?m({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:u}}):m({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:u,choice:ve(s,n)}})},we=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||L(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),K())},X=new Map,_e=e=>{X.clear();let n={high:0,med:1,low:2};return e=e.map((r,s)=>({q:r,i:s})).sort((r,s)=>(n[r.q.risk]??3)-(n[s.q.risk]??3)||r.i-s.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}},Ce=(e,n)=>{if(t.confirm&&(t.confirm=null),t.pending)return;let r=n==="kane"?{kind:"note",text:$().text("chat.repair_sent",{})}:{kind:"user",text:e};if(!g){t.turns.push({role:"user",text:e}),m(r),t.notice="the agent isn't running \u2014 nothing sent",p();return}t.notice=void 0,ee=!1,t.checkpoint=!1,delete t.resumedParked,V(),t.turns.push({role:"user",text:e}),m(r);let s=pe(e,n);for(t.status="streaming",t.busySince=Date.now(),W(),t.error=void 0,d+=1;S.length>0;)d+=1,g({type:"user_message",message_id:`u${d}-receipt`,text:S.shift()},{by:"kane",receipt:!0});g({type:"user_message",message_id:s??`u${d}`,text:e},{by:n}),p()};return{state:t,explainLines(e){if(!i.explain||!i.graph||!i.store)return null;let n=i.explain(i.store,i.graph,e);return n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(r=>` [${r.kind}] ${r.rationale??r.detail}`)]:null},explainRef(e){if(!i.explain||!i.graph||!i.store){m({kind:"note",text:"explain isn't available here"}),p();return}let n=i.explain(i.store,i.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(s=>` [${s.kind}] ${s.rationale??s.detail}`)].join(`
2
+ import{c as Oe}from"./chunk-BWXLZS5O.js";import{a as De,b as Me}from"./chunk-63EKRZKI.js";import{a as qe,c as Ne}from"./chunk-3JLEDSG5.js";import{b as $e,f as de,i as Ee}from"./chunk-ZHAMVLQZ.js";import{A as Ae,D as ae,na as Ie,z as Te}from"./chunk-PI7OXS62.js";import{d as Re}from"./chunk-KU3YHPWZ.js";import{o as $}from"./chunk-HYJVYYAZ.js";var Qe=new Set(["approve","edit","reject"]),Le=new Set(["approve","edit","reject","add","enhance","retract"]);function Fe(i,t){return t?`chatop:${t}:${i}`:`chatop:${i}`}function Ue(i,t,y,w){let k=`${t}:${i.target??"new"}:${i.op}:${i.seq}`,l=i.payload;switch(i.op){case"approve":return{kind:"approve",target:i.target,expectedCid:i.expected_cid,eventId:k};case"edit":{let{reason:C,...a}=l;return{kind:"edit",target:i.target,expectedCid:i.expected_cid,edit:a,reason:C,eventId:k}}case"enhance":return{kind:"enhance",target:i.target,expectedCid:i.expected_cid,edges:l.edges??[],eventId:k};case"retract":{let C=typeof l.reason=="string"?l.reason.trim():"";if(!C)throw new Error("INVALID_RETRACT: a retract needs a non-empty reason");let a=l.edge_ecid!==void 0&&l.edge_ecid!==null,d=l.edge!==void 0&&l.edge!==null;if(a&&d)throw new Error("INVALID_RETRACT: both edge_ecid and edge were sent \u2014 give exactly one");if(!a&&!d)throw new Error("INVALID_RETRACT: neither edge {type, dst, src?} (display refs) nor edge_ecid was sent \u2014 give exactly one");let g={kind:"retract",target:i.target,expectedCid:i.expected_cid,reason:C};if(a){if(typeof l.edge_ecid!="string"||!l.edge_ecid)throw new Error("INVALID_RETRACT: edge_ecid must be a non-empty string");return{...g,edgeEcid:l.edge_ecid,eventId:`${t}:${i.target}:retract:e:${l.edge_ecid}:${i.seq}`}}let f=l.edge;if(typeof f!="object"||typeof f.type!="string"||!f.type||typeof f.dst!="string"||!f.dst)throw new Error("INVALID_RETRACT: edge needs {type, dst} (src optional), all display refs");if(f.src!==void 0&&f.src!==null&&(typeof f.src!="string"||!f.src))throw new Error("INVALID_RETRACT: edge.src, when given, must be a non-empty display ref");let v=typeof f.src=="string"?f.src:void 0;return{...g,edgeRef:{type:f.type,dst:f.dst,...v!==void 0?{src:v}:{}},eventId:`${t}:${i.target}:retract:t:${f.type}:${f.dst}:${v??"-"}:${i.seq}`}}case"reject":return{kind:"reject",target:i.target,expectedCid:i.expected_cid,reason:l.reason??"",redirectTo:l.redirect_to,eventId:k};case"add":{let C=l.proposal_item??{},a=String(C.label??"");if(!y.mint_gate.includes(a))throw new Error(`GATED_LABEL: cannot mint "${a}" (gate: ${y.mint_gate.join(", ")})`);let d=C.cite??{},g=C.conv_source_id??w;if(!g||typeof d.turn!="number"||!d.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");let f=C.content,v=f&&typeof f=="object"&&!Array.isArray(f)&&Object.keys(f).length>0?f:null,A=new Set(["label","cite","conv_source_id","content","rationale","edges"]),S=v??Object.fromEntries(Object.entries(C).filter(([N])=>!A.has(N)));return{kind:"add",label:a,content:S,cite:{turn:d.turn,quote:d.quote},convSourceId:g,rationale:C.rationale,eventId:k}}}}function je(i,t,y={}){let w=y.turn??0,k=[],l=[];for(let[d,g]of i.entries()){let f=Te(g,`ops[${d}]`);if(f!==null)throw new Error(`NUL_IN_TEXT: ${Ae(f)}`)}for(let d of i){if(!Le.has(d.op))throw new Error(`UNKNOWN_OP: "${d.op}" is not a chat op (accepted: ${[...Le].join(", ")})`);if(d.op!=="add"&&!d.target)throw new Error(`MISSING_TARGET: a ${d.op} op needs a target ref`)}for(let d of i)(d.op==="add"||d.op==="enhance"||d.op==="retract")&&l.push(d);let C=new Map;for(let d of i){if(!Qe.has(d.op)||!d.target)continue;let g=C.get(d.target)??[];g.push(d),C.set(d.target,g)}for(let[d,g]of C){let f=Math.max(...g.map(A=>A.seq)),v=g.filter(A=>A.seq===f);if(v.length>1){k.push({target:d,seq:f,kinds:v.map(A=>A.op)});continue}l.push(v[0])}return{chatOps:l.sort((d,g)=>d.seq-g.seq).map(d=>Ue(d,y.prefix??Fe(w,y.session),t,y.convSourceId)),ambiguous:k}}function Pe(i,t){return i.map(y=>{let w=y.data?.tip;if(y.code!=="EXPECTED_CID_MOVED"||typeof w!="string")return{code:y.code};let k=t?.getNode(w)?.content??{},l=typeof k.title=="string"?k.title:typeof k.text=="string"?k.text:void 0,C=t?.displayNameOf(w)??(typeof y.data?.target=="string"?y.data.target:void 0);return{code:y.code,moved:y.data?.moved===!0,...C?{ref:C}:{},...l?{title:l}:{}}})}function He(i){let t=[];return i.questions.forEach((y,w)=>{if(i.resolution[w])return;let k=y.recommended_index!=null?y.options[y.recommended_index]?.label:void 0;k!=null&&t.push(y.risk==="high"?`${B(k)} \u203C`:B(k))}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function B(i){return i.replace(/\s*\(recommended\)\s*$/i,"")}function Be(i){let t=i.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function ze(i,t){let y=new Set;for(let w=t;w&&!y.has(w);w=i.superseded.get(w)){if(i.trust.get(w)==="archived")return!0;y.add(w)}return!1}function Ve(i){return i.use_cases??[]}var Ke={acs:"acceptance criteria",scenarios:"scenarios",exercises:"exercises",tests:"tests",gaps:"gaps"};function Xe(i){let t=[],y=[],w=(a,d)=>{d.length!==0&&(y.push(a),t.push(...d))},k=a=>typeof a=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(a)?a:null,l=a=>{let d=k(a.automates)??"1 scenario",g=a.verifies??[],f=g.map(k).filter(S=>S!==null).slice(0,2),v=g.length-f.length,A=f.length?`${f.join(" ")}${v>0?` +${v}`:""}`:`${g.length} ACs`;return`covers ${d} \xB7 verifies ${A}`};w("acs",(i.acs??[]).map(a=>({temp_ref:a.temp_ref,title:a.text,kind:"ac",badge:String(a.kind),extra:{...a.expected_answer?{expects:`${String(a.expected_answer.operator??"")} \xB7 ${String(a.expected_answer.operand??"")}`}:{},"scoped to":a.scoped_to??"(use-case)"}}))),w("scenarios",(i.scenarios??[]).map(a=>({temp_ref:a.temp_ref,title:a.title,kind:"scenario",badge:a.case_type,why:a.intent,depends_on_hint:a.depends_on??[],extra:{technique:a.technique_notes}}))),w("exercises",(i.exercises??[]).map(a=>({temp_ref:k(a.scenario)??"wiring",title:`${k(a.scenario)??"scenario"} exercises ${k(a.ac)??"1 AC"}`,kind:"exercise",badge:"wires",why:a.rationale}))),w("tests",(i.tests??[]).map(a=>({temp_ref:a.temp_ref,title:a.title,kind:"test",why:l(a),depends_on_hint:a.reuses??[],extra:{automates:String(a.automates??"?"),verifies:(a.verifies??[]).join(", "),check:a.check?`${String(a.check.kind)} vs ${String(a.check.verified_against)}`:"?"}})));let C={high:"high",medium:"med",med:"med",low:"low"};return w("gaps",(i.gaps??[]).map(a=>{let d=a.question??{};return{temp_ref:a.temp_ref??a.ref??"?",title:String(d.header??a.kind),kind:"gap",badge:C[String(a.risk??"").trim().toLowerCase()]??"",why:d.prompt??d.text??"",question:String(d.prompt??d.text??d.header??""),rationale:String(a.risk_rationale??"")}})),{items:t,heading:y.join(" + ")||"design"}}function ut(i={}){let t={turns:[],thinking:De(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},y=e=>{let n=[],r=e.minted.map(u=>u.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let s=e.applied.length-e.minted.length;s>0&&n.push(`${s} change${s===1?"":"s"} applied`);let o=e.staleDelta.length?$().text("chat.stales",{count:e.staleDelta.length}):"";return o&&n.push(o),n.join(" \xB7 ")||"no changes"},w=(e,n)=>{let r=i.refreshGraph?.()??i.graph;return!r?.nodeLabel||n.applied.length===0||n.minted.length>0||n.staleDelta.length>0?!1:e.every(s=>{if(s.kind!=="approve"||!s.target)return!1;let o=r.resolve(s.target);return o!==null&&r.nodeLabel.get(r.tipOf(o.cid))==="usecase"})},k=[];i.onRender&&k.push(i.onRender);let l=0,C=new Map,a=e=>{let n=C.get(e);if(n===void 0){let r=`chatop:${e}:`;n=0;for(let s of(i.refreshGraph?.()??i.graph)?.appliedEvents??[]){if(!s.startsWith(r))continue;let o=Number(s.slice(r.length).split(":")[0]);Number.isInteger(o)&&o>n&&(n=o)}C.set(e,n)}return n},d=0,g=null,f=null,v=null,A=null,S=[],N=null,ee=!1,G=0,te=null,M=null,ne=0,ue=0,le=!1,ce=!1,ge=e=>(le||(le=!0,m({kind:"note",text:$().text("note.turns_unrecorded",{detail:e})}),p()),null),pe=(e,n)=>{if(!v||!i.store||!e.trim())return null;try{let r=i.refreshGraph?.()??i.graph;if(!r)return null;let s=Ee({store:i.store,graph:r,sourceId:v,text:e,speaker:n,by:i.by??{kind:"human",id:"owner"}});return s.errors?ge(s.errors.map(o=>o.detail).join("; ")):s.record!==null?$e(v,s.turn):null}catch(r){return ge(r instanceof Error?r.message:String(r))}},Ge=e=>{if(!v||!i.store)return;let n=i.refreshGraph?.()??i.graph,r=n?.heads.get(v),s=n?.convChains.get(v);if(!n||typeof r!="string"||!s)return;let o=n.getNode(r)?.content?.blob,u=typeof o=="string"?i.store.getBlob(o)?.toString("utf8")??"":"";if(u)for(let h of e){if(h.kind!=="add"||h.convSourceId!==v)continue;let _=de(u,h.cite.turn);if(!(_!==null&&ae(h.cite.quote,_)))for(let R=s.turns;R>=1;R--){let b=de(u,R);if(b!==null&&ae(h.cite.quote,b)){h.cite={...h.cite,turn:R};break}}}},T={startedAt:null,thinkMs:0,toolCalls:0,tools:new Map},W=()=>{T.startedAt??=Date.now()},D=()=>{if(T.toolCalls>0){let e=T.startedAt!=null?Math.max(1,Math.round((Date.now()-T.startedAt)/1e3)):Math.max(1,Math.round(T.thinkMs/1e3));m({kind:"worked",durS:e,toolCalls:T.toolCalls,tools:[...T.tools.entries()].map(([n,r])=>({name:n,n:r}))})}T.startedAt=null,T.thinkMs=0,T.toolCalls=0,T.tools.clear()},Q=null,re=new Map,fe=e=>JSON.stringify([e.id,e.text,e.options.map(n=>n.label)]),F=null,me=new Map,ie=new Map,U=new Map,he=null,p=()=>{H&&(clearTimeout(H),H=null),ke();for(let e of k)e()},ke=()=>{G>0&&g!=null&&g!==te?t.nestedAgent=!0:delete t.nestedAgent},H=null,be=()=>{H||(H=setTimeout(()=>{H=null,ke();for(let e of k)e()},80))},Y=0,m=e=>{e.kind==="childClose"&&Y>0&&(Y-=1),Y>0&&e.kind!=="childOpen"&&e.kind!=="childBack"&&(e.era=Y),e.kind==="childOpen"&&(Y+=1),t.ledger.push(e)},z=null,Z=!1,se=0,V=(e=!1)=>{if(z)m({kind:"agent",text:z});else if(e&&Z){let r=([...t.turns].reverse().find(s=>s.role==="agent")?.items??[]).filter(s=>!s.matches_existing).length;m({kind:"note",text:$().text("chat.refine_hint",{added:r,held:se})})}z=null,Z=!1,se=0,delete t.committing},We=()=>{z=null,Z=!1,delete t.committing},E=null,oe=(e,n=!1,r)=>{if(!E)return;if(e)for(let o of E.items){let u=e.get(o.temp_ref);u&&(o.logical_id=u)}if(r)for(let o of E.items)r.has(o.temp_ref)&&(o.sessionAdded=!0);let s=E.items.filter(o=>o.kind==="test");if(s.length>0){let o;try{o=i.refreshGraph?.()??i.graph}catch{o=i.graph}let u=h=>{if(Ie.test(h))return h;let _=e?.get(h);if(_)return _;let R=h.startsWith("sha256:")?h:U.get(h);return(R?o?.displayNameOf(R):null)??null};for(let h of s){let _=h.extra??{},R=_.verifies?_.verifies.split(", "):[];h.links={covers:_.automates&&_.automates!=="?"?u(_.automates):null,verifies:R.map(u).filter(b=>b!==null),verifiesTotal:R.length}}}if(n)for(let o of E.items)o.logical_id||(o.held=!0);m({kind:"turn",...E}),E=null},ye=()=>{let e=i.refreshGraph?.()??i.graph;if(!i.commitChatTurn||!e?.trust)return!0;let n=[];for(let{item:b}of Oe(t.turns).entries){if(!b.logical_id||b.turnedDown||b.matches_existing||(b.kind??"use-case")!=="use-case")continue;let I=e.names?.get(b.logical_id)??U.get(b.temp_ref);if(!I)continue;let c=e.tipOf(I);e.trust.get(c)==="derived"&&!n.includes(c)&&n.push(c)}let r=new Set(i.addedBefore?.()??[]);for(let b of r){let I=e.tipOf(b);r.has(I)&&e.trust.get(I)==="derived"&&!n.includes(I)&&n.push(I)}if(n.length===0)return!0;l+=1;let s=v||i.session?.state?.sid,o=l+(s?a(s):0),u=s?`chatop:${s}:${o}`:`chatop:${o}`,h=n.map((b,I)=>({kind:"approve",target:b,expectedCid:b,eventId:`${u}:${b}:approve:${I}`})),_;try{_=i.commitChatTurn({graph:e,ops:h,by:i.by??{kind:"human",id:"owner"},...i.descriptor?.mint_gate?{mintable:i.descriptor.mint_gate}:{},...i.session?.state?.sid?{sid:i.session.state.sid}:{}})}catch(b){_={record:null,errors:[{code:"COMMIT_THREW",detail:b instanceof Error?b.message:String(b)}]}}if(_.errors)return t.error=_.errors.map(b=>b.detail).join("; "),m({kind:"commit",ok:!1,line:$().text("chat.commit_failed",{}),warnings:_.errors.map(b=>`${b.code}: ${b.detail}`),refused:Pe(_.errors,e),person:!0}),p(),!1;_.applied.length>0&&i.session?.markApplied(_.applied),m({kind:"commit",ok:!0,line:$().text("chat.approved",{count:_.applied.length})});let R=i.refreshGraph?.();return R&&f&&f(R),xe(R??i.graph),!0},xe=e=>{if(!(!e?.trust||!e.superseded))for(let n of t.turns)for(let r of n.items??[]){let s=r.logical_id&&e.names?.get(r.logical_id)||U.get(r.temp_ref);s&&(ze(e,s)?r.turnedDown=!0:delete r.turnedDown)}},q=()=>{oe(),delete t.committing,t.activeTurn&&(t.activeTurn=null)},ve=(e,n)=>{let r=n.selected_index!=null?e.options[n.selected_index]?.label:void 0;return n.choice||(r!=null?B(r):"?")},K=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(s=>s===null);return}let n=e.questions.map((s,o)=>{let u=e.resolution[o];return u.form==="deferred"?{id:s.id,selected_index:null,free_text:null}:{id:s.id,selected_index:u.selected_index,free_text:u.free_text}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now());let r=Q;Q=null,r?.(n)},L=(e,n)=>{let r=t.pending,s=r.questions[e],o=r.resolution[e];r.resolution[e]=n;let u=Be(s);o?m({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:u,choice:ve(s,n),prev:o.choice}}):n.form==="deferred"?m({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:u}}):m({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:u,choice:ve(s,n)}})},we=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||L(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),K())},X=new Map,_e=e=>{X.clear();let n={high:0,med:1,low:2};return e=e.map((r,s)=>({q:r,i:s})).sort((r,s)=>(n[r.q.risk]??3)-(n[s.q.risk]??3)||r.i-s.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}},Ce=(e,n)=>{if(t.confirm&&(t.confirm=null),t.pending)return;let r=n==="kane"?{kind:"note",text:$().text("chat.repair_sent",{})}:{kind:"user",text:e};if(!g){t.turns.push({role:"user",text:e}),m(r),t.notice="the agent isn't running \u2014 nothing sent",p();return}t.notice=void 0,ee=!1,t.checkpoint=!1,delete t.resumedParked,V(),t.turns.push({role:"user",text:e}),m(r);let s=pe(e,n);for(t.status="streaming",t.busySince=Date.now(),W(),t.error=void 0,d+=1;S.length>0;)d+=1,g({type:"user_message",message_id:`u${d}-receipt`,text:S.shift()},{by:"kane",receipt:!0});g({type:"user_message",message_id:s??`u${d}`,text:e},{by:n}),p()};return{state:t,explainLines(e){if(!i.explain||!i.graph||!i.store)return null;let n=i.explain(i.store,i.graph,e);return n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(r=>` [${r.kind}] ${r.rationale??r.detail}`)]:null},explainRef(e){if(!i.explain||!i.graph||!i.store){m({kind:"note",text:"explain isn't available here"}),p();return}let n=i.explain(i.store,i.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(s=>` [${s.kind}] ${s.rationale??s.detail}`)].join(`
3
3
  `):`unknown ref: ${e}`;m({kind:"note",text:r}),p()},subscribe(e){return k.push(e),()=>{let n=k.indexOf(e);n>=0&&k.splice(n,1)}},submit(e){Ce(e,"person")},repair(e){Ce(e,"kane")},attachSender(e){let n=g;return g=e,()=>{g=n}},attachOnCommitted(e){f=e},attachConversationSource(e){v=e},opIdPrefix(e){A=e},attachSession(e){i.session=e},enterNested(e){if(G+=1,G>1)return()=>{G-=1};let n={checkpoint:t.checkpoint,receipts:S.splice(0,S.length)};te=g,M=t.credits?.total??0,t.checkpoint=!1,t.status==="idle"&&(t.status="working",t.workingLabel=e,t.busySince=Date.now()),p();let r=!1;return()=>{r||(r=!0,G-=1,te=null,M!==null&&(ne+=Math.max(0,(t.credits?.total??M)-M)),M=null,S.splice(0,S.length,...n.receipts),t.checkpoint=n.checkpoint,t.status==="working"&&(t.status="idle",t.workingLabel=void 0,t.busySince=void 0),p())}},holdReceipt(e,n){S.push(e),n?.checkIn!==!1&&(t.checkpoint=!0),p()},drainHeldReceipts(){return S.splice(0,S.length)},peekHeldReceipts(){return[...S]},submitAnswer(e,n){let r=t.pending,s=r?.questions[e],o=s?.options[n]?.label;!r||!s||o==null||(L(e,{form:"answered",selected_index:n,free_text:null,choice:B(o)}),K(),p())},submitFreeText(e,n){let r=t.pending,s=r?.questions[e],o=n.trim();!r||!s||!o||(L(e,{form:"answered",selected_index:null,free_text:o,choice:o}),K(),p())},deferBatch(e){let n=t.pending;if(!n||!Q)return;n.questions.forEach((s,o)=>{let u=n.resolution[o];u&&u.form==="answered"&&re.set(fe(s),u)}),t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now()),m({kind:"note",text:`questions set aside \u2014 source ${e.source_id} landed; the agent reads it next`});let r=Q;Q=null,r({deferred:!0,ingested:e}),p()},submitAnswerWithText(e,n,r){let s=t.pending,o=s?.questions[e],u=o?.options[n]?.label;if(!s||!o||u==null)return;let h=r.trim();L(e,{form:"answered",selected_index:n,free_text:h||null,choice:h?`${B(u)} \u2014 ${h}`:B(u)}),K(),p()},toggleOption(e,n){let r=t.pending?.questions[e];if(!r||r.options[n]==null)return;let s=X.get(e)??new Set;s.has(n)?s.delete(n):s.add(n),X.set(e,s),p()},multiSelection(e){return[...X.get(e)??[]].sort((n,r)=>n-r)},confirmMulti(e){let n=t.pending,r=n?.questions[e];if(!n||!r)return;let s=[...X.get(e)??[]].sort((u,h)=>u-h).map(u=>r.options[u]?.label).filter(u=>u!=null);if(s.length===0)return;X.delete(e);let o=s.join(", ");L(e,{form:"answered",selected_index:null,free_text:o,choice:o}),K(),p()},goWithRecommendations(){let e=t.pending;if(!e)return{picks:""};let n=He(e),r=null;return e.questions.forEach((s,o)=>{if(e.resolution[o])return;let u=s.recommended_index,h=u!=null?s.options[u]?.label:void 0;if(h==null){r===null&&(r=o);return}L(o,{form:"assumed",selected_index:u,free_text:null,choice:B(h)})}),r!==null?(e.cursor=r,p(),{blocked:r}):(K(),p(),{picks:n})},reopenQuestion(){let e=t.pending;if(!e)return;let n=e.cursor<0?e.questions.length:e.cursor;for(let r=n-1;r>=0;r--)if(e.resolution[r]){e.cursor=r,p();return}},continueParked(){if(g&&!(G>0&&g===te)){for(t.checkpoint=!1,m({kind:"continued"});S.length>0;)d+=1,g({type:"user_message",message_id:`u${d}-receipt`,text:S.shift()},{by:"kane",receipt:!0});d+=1,g({type:"user_message",message_id:`u${d}`,text:"continue"},{by:"person",continued:!0}),t.status="streaming",t.busySince=Date.now(),W(),p()}},note(e){m({kind:"note",text:e}),p()},finalizeForExit(){q(),D(),V(),t.stream=null,p()},aliasOf(e){return U.get(e)},guardOps(e){return N=e,ee=!1,()=>{N===e&&(N=null)}},registerAliases(e,n){for(let r of e)U.set(r.ref,r.cid);if(n?.unchanged){E=null,p();return}oe(new Map(e.filter(r=>r.id).map(r=>[r.ref,r.id])),!1,new Set(e.filter(r=>r.own).map(r=>r.ref))),p()},endUnstartedTurn(){t.status!=="streaming"&&t.status!=="working"||(t.status="idle",t.workingLabel=void 0,t.busySince=void 0,p())},answersHeld(e){ie=new Map(e.map(n=>[n.id,n.digest]))},resumedParked(){t.status="idle",t.workingLabel=void 0,t.busySince=void 0,t.resumedParked=!0,p()},restoreCheckIn(){let e=i.resumedCheckIn?.()??null;e!==null&&(t.resumed=e,t.checkpoint=!0,p())},setWorking(e){if(e!=null){if(t.status!=="idle"&&t.status!=="working")return;t.status==="idle"&&(t.busySince=Date.now()),W(),t.status="working",t.workingLabel=e}else{if(t.status!=="working")return;t.status="idle",t.workingLabel=void 0,t.busySince=void 0}p()},narrated(e,n){q(),t.stream=null,t.busySince=void 0,D(),n&&m(n),e&&m({kind:"agent",text:e}),(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0,p()},ledger(e){if(e.kind==="commit"&&(oe(void 0,e.held===!0),se+=e.heldChanges??0),e.kind==="error"&&(q(),D(),V()),e.kind==="commit"&&(e.notes!==void 0||e.quiet)){let{notes:n,quiet:r,...s}=e;m(r?{kind:"note",text:s.line}:s);for(let o of n??[])m({kind:"note",text:o})}else m(e);e.kind==="commit"&&(e.ok?V(!0):We()),p()},senderAlive(){return g!=null},approveAdded(){let e=ye();return p(),e},completeSession(e){e?.approveAdded&&!ye()||(we(),g?.({type:"session_complete"}),t.status="idle",t.busySince=void 0,p())},requestPause(){we(),t.status="pausing",t.busySince=void 0;let e=g;Promise.resolve().then(()=>e?.({type:"pause"})),p()},ask(e){t.pending=_e(e),me=new Map(e.map((r,s)=>[r.id,s+1])),t.status="awaiting-input",t.busySince=void 0;let n=new Promise(r=>{Q=r});if(re.size>0){let r=0;e.forEach((s,o)=>{let u=fe(s),h=re.get(u);h&&(re.delete(u),L(o,{...h}),r+=1)}),r>0&&m({kind:"note",text:`your earlier answer${r>1?"s are":" is"} pre-filled \u2014 press enter to send, or pick a different answer`})}return p(),n},attachIngest(e){let n=F;return F=e,()=>{F===e&&(F=n)}},canIngest(){return F!==null},async ingestAttach(e){let n=F,r=e.trim();if(!n||!r)return;let s;try{s=await n(r)}catch(o){s={ok:!1,error:o instanceof Error?o.message:String(o)}}s.ok||(m({kind:"note",text:s.error??"the source could not be ingested"}),p())},noteCoercion(e,n){m({kind:"answer",receipt:{form:"assumed",qNum:me.get(e.id)??0,stub:Be(e),choice:n,note:"your typed answer couldn't be used here"}}),p()},nothingCommitted(){t.committing&&(delete t.committing,p())},creditsCarriedIn(e){e<=0||(t.credits={turn:t.credits?.turn??0,total:(t.credits?.total??0)+e},ne+=e,p())},creditsSoFar(e,n){if(!(e<=0)){if(M!==null){t.credits={turn:0,total:M+e},p();return}t.credits||(t.credits={turn:0,total:e},n!==void 0&&n>0&&(ne=n),p())}},onAgentEvent(e){switch(e.type){case"reasoning_delta":case"reasoning_done":case"tool_activity":case"decision_activity":{let n=t.thinking;if(t.thinking=Me(n,e),t.thinking!==n&&(e.type==="reasoning_done"&&e.present?(W(),T.thinkMs+=e.took_ms):e.type==="tool_activity"&&e.status!=="started"&&(W(),T.toolCalls+=1,T.tools.set(e.name,(T.tools.get(e.name)??0)+1))),e.type==="reasoning_delta"){be();return}break}case"usage":t.credits={turn:e.credits,total:(M??ne)+e.total_credits};break;case"text_delta":{let n=he;if(n&&(e.turn_id<n.turn_id||e.turn_id===n.turn_id&&e.attempt<n.attempt))return;(!n||n.turn_id!==e.turn_id||n.attempt!==e.attempt)&&(he={turn_id:e.turn_id,attempt:e.attempt},t.stream={text:""}),t.stream={text:(t.stream?.text??"")+e.text},be();return}case"progress":break;case"proposal":{l+=1,q(),t.stream=null,t.busySince=void 0,D();let n=Ve(e.proposal),r=i.dedupFlags?.(e.proposal);if(r)for(let o of n){let u=r.get(o.temp_ref);u&&(o.matches_existing=u)}let s=i.refreshGraph?.()??i.graph;if(s)for(let o of n){let u=o.matches_existing?.cid,h=typeof u=="string"?s.displayNameOf(u):null;h&&(o.matched_id=h)}t.turns.push({role:"agent",turnIndex:l,items:n,text:e.narrative}),z=e.narrative??null,Z=!0,t.committing=!0,t.activeTurn={turnIndex:l,heading:"use-cases",items:n},E={turnIndex:l,heading:"use-cases",items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"design":{l+=1,q(),t.stream=null,t.busySince=void 0,D();let{items:n,heading:r}=Xe(e.design),s=e.design.phase==="wiring"?"acceptance criteria + exercises":r.split(" + ").map(o=>Ke[o]??o).join(" + ");m({kind:"banner",text:`designing: ${s}`}),t.turns.push({role:"agent",turnIndex:l,items:n,itemsHeading:r,text:e.narrative}),z=e.narrative??null,Z=!0,t.committing=!0,t.activeTurn={turnIndex:l,heading:r,items:n},E={turnIndex:l,heading:r,items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"ask_user":if(D(),e.questions.length>0&&e.questions.every(n=>ie.get(n.id)===Ne(n))){for(let n of e.questions)ie.delete(n.id);break}t.pending=_e(e.questions),t.status="awaiting-input",t.busySince=void 0;break;case"chat_ops":{l+=1,q(),D(),t.stream=null,(t.status==="streaming"||t.status==="working")&&(t.status="idle",t.busySince=void 0,t.workingLabel=void 0);let n=e.chat_ops??e,r=Array.isArray(n.ops)?n.ops:[],s=n.text??e.text??"",o=i.refreshGraph?.()??i.graph,u=c=>U.get(c)??c,h=r.map(c=>{if(!c.target)return c;let x=u(c.target),O=c.expected_cid;if(O==null&&o){let Se=o.resolve(x);Se&&(O=o.tipOf(Se.cid))}let j=c.payload?.redirect_to,P=j&&u(j);return x===c.target&&O===c.expected_cid&&P===j?c:{...c,target:x,expected_cid:O,...P!==j?{payload:{...c.payload,redirect_to:P}}:{}}}),_;try{if(!Array.isArray(n.ops))throw new Error("the agent sent an unreadable change set (no ops array) \u2014 say it again in different words");let c=v||i.session?.state?.sid,x=A;A=null,_=je(h,i.descriptor??{mint_gate:[]},{turn:l+(c?a(c):0),...c?{session:c}:{},...x?{prefix:x}:{},...v?{convSourceId:v}:{}})}catch(c){t.error=c instanceof Error?c.message:String(c),t.turns.push({role:"agent",turnIndex:l,text:s,narration:t.error}),s&&m({kind:"agent",text:s}),m({kind:"error",title:t.error,detail:[]}),S.push(`OPS REJECTED (did not compile) \u2014 nothing landed; do not assume any of your last ops applied.
4
4
  - `+t.error);break}let{chatOps:R,ambiguous:b}=_;if(b.length>0){let c=b[0];t.confirm={kind:"ambiguity-confirm",prompt:`did you mean edit or ${c.kinds.filter(x=>x!=="edit").join("/")} on ${c.target}?`},t.turns.push({role:"agent",turnIndex:l,text:s}),s&&m({kind:"agent",text:s});break}Ge(R);let I=R.length>0&&N?N(R):null;if(I){if(t.turns.push({role:"agent",turnIndex:l,text:s}),S.push(I),g&&!ee)for(ee=!0,t.status="streaming",t.busySince=Date.now(),W();S.length>0;)d+=1,g({type:"user_message",message_id:`u${d}-receipt`,text:S.shift()},{by:"kane",receipt:!0});break}if(i.commitChatTurn&&R.length>0){let c;try{c=i.commitChatTurn({graph:i.refreshGraph?.()??i.graph,ops:R,by:i.by??{kind:"human",id:"owner"},...i.descriptor?.mint_gate?{mintable:i.descriptor.mint_gate}:{},...i.session?.state?.sid?{sid:i.session.state.sid}:{}})}catch(x){c={record:null,errors:[{code:"COMMIT_THREW",detail:x instanceof Error?x.message:String(x)}]}}if(c.errors)t.error=c.errors.map(x=>x.detail).join("; "),t.turns.push({role:"agent",turnIndex:l,text:s}),m({kind:"commit",ok:!1,line:$().text("chat.commit_failed",{}),warnings:c.errors.map(x=>`${x.code}: ${x.detail}`),refused:Pe(c.errors,o)}),S.push(["COMMIT FAILED (chat turn) \u2014 nothing landed; do not assume any of your last ops applied.",...c.errors.map(x=>`- ${x.code}: ${x.detail}${x.code==="EXPECTED_CID_MOVED"&&typeof x.data?.tip=="string"?`; its current cid is ${x.data.tip}`:""}`),...c.errors.some(x=>x.code==="UNKNOWN_FIELD")?["If you were changing citations or matched-existing content, that is proposal territory (approve/re-propose) \u2014 a chat edit can only replace a node's own schema fields."]:[]].join(`
5
5
  `)),s&&m({kind:"agent",text:s});else{c.applied.length>0&&i.session?.markApplied(c.applied);let x=w(R,c)?$().text("chat.approved",{count:c.applied.length}):y(c);t.turns.push({role:"agent",turnIndex:l,text:s,narration:x}),m({kind:"commit",ok:!0,line:x});let O=i.refreshGraph?.();if(O&&f&&f(O),xe(O??i.graph),O)try{ue+=1;let J=i.descriptor?.mint_gate?.includes("usecase")?"extract":"design",j=qe({verb:J,commitN:ue,phase:"chat",committed:c.minted.map(P=>({cid:P.cid,...P.slug?{logical_id:P.slug}:{}})),...Re(i.templateVersion?.()??null)>=8?{typedBlockers:!0,...i.ucRef?{ucRef:i.ucRef}:{}}:{},...(i.pendingForceScope?.()??[]).length?{ignoreGaps:new Set(i.pendingForceScope())}:{}},O);S.push(j.text)}catch(J){ce||(ce=!0,m({kind:"note",text:$().text("note.receipt_unbuilt",{detail:J instanceof Error?J.message:String(J)})}))}s&&m({kind:"agent",text:s})}}else t.turns.push({role:"agent",turnIndex:l,text:s}),s&&m({kind:"agent",text:s});pe(s,"agent");break}case"done":case"session_complete":q(),D(),V(),t.status="idle",t.busySince=void 0,g=null;break;case"error":q(),D(),V(),t.stream=null,t.status="idle",t.busySince=void 0,t.error=e.message,g=null,m({kind:"error",title:e.message,detail:[]});break;case"session_paused":break;case"turn_retry":m({kind:"note",text:$().text("note.model_retry",{seconds:Math.round(e.wait_s)})});break;default:break}p()}}}export{He as a,B as b,Be as c,ut as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as o,h as a}from"./chunk-2SY2NCOP.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
2
+ import{g as o,h as a}from"./chunk-PTLOOVV4.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as t}from"./chunk-TZVPDGJD.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
2
+ import{a as t}from"./chunk-PCQK62MP.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};